Dixie is capped (max_inflight 2, queue_depth 8, queue_wait 20s) and never queued on llama-server. Streaming chat, thinking off, 45s fallback to clean. Digest and chunk-embedding caches are content-addressed SQLite (Honcho context is not cached). Recover uses the guarded Fetcher. guardian-star is refused in code.
9137 lines
290 KiB
Go
9137 lines
290 KiB
Go
// Code generated by modernc.org/undup from the per-target sqlite_*.go files; DO NOT EDIT.
|
|
|
|
//go:build (linux && 386) || (linux && amd64) || (linux && arm) || (linux && arm64) || (linux && loong64) || (linux && ppc64le) || (linux && riscv64) || (linux && s390x)
|
|
|
|
package sqlite3
|
|
|
|
import (
|
|
"unsafe"
|
|
|
|
"modernc.org/libc"
|
|
)
|
|
|
|
const AT_EACCESS = 512
|
|
|
|
const AT_EMPTY_PATH = 4096
|
|
|
|
const AT_NO_AUTOMOUNT = 2048
|
|
|
|
const AT_RECURSIVE = 32768
|
|
|
|
const AT_REMOVEDIR = 512
|
|
|
|
const AT_STATX_DONT_SYNC = 16384
|
|
|
|
const AT_STATX_FORCE_SYNC = 8192
|
|
|
|
const AT_STATX_SYNC_AS_STAT = 0
|
|
|
|
const AT_STATX_SYNC_TYPE = 24576
|
|
|
|
const AT_SYMLINK_NOFOLLOW = 256
|
|
|
|
const CLOCKS_PER_SEC = 1000000
|
|
|
|
const CLOCK_BOOTTIME = 7
|
|
|
|
const CLOCK_BOOTTIME_ALARM = 9
|
|
|
|
const CLOCK_MONOTONIC_COARSE = 6
|
|
|
|
const CLOCK_MONOTONIC_RAW = 4
|
|
|
|
const CLOCK_REALTIME_ALARM = 8
|
|
|
|
const CLOCK_REALTIME_COARSE = 5
|
|
|
|
const CLOCK_SGI_CYCLE = 10
|
|
|
|
const CLOCK_TAI = 11
|
|
|
|
const CLONE_CHILD_CLEARTID = 2097152
|
|
|
|
const CLONE_CHILD_SETTID = 16777216
|
|
|
|
const CLONE_DETACHED = 4194304
|
|
|
|
const CLONE_FILES = 1024
|
|
|
|
const CLONE_FS = 512
|
|
|
|
const CLONE_IO = 2147483648
|
|
|
|
const CLONE_NEWCGROUP = 33554432
|
|
|
|
const CLONE_NEWIPC = 134217728
|
|
|
|
const CLONE_NEWNET = 1073741824
|
|
|
|
const CLONE_NEWNS = 131072
|
|
|
|
const CLONE_NEWPID = 536870912
|
|
|
|
const CLONE_NEWTIME = 128
|
|
|
|
const CLONE_NEWUSER = 268435456
|
|
|
|
const CLONE_NEWUTS = 67108864
|
|
|
|
const CLONE_PARENT = 32768
|
|
|
|
const CLONE_PARENT_SETTID = 1048576
|
|
|
|
const CLONE_PIDFD = 4096
|
|
|
|
const CLONE_PTRACE = 8192
|
|
|
|
const CLONE_SETTLS = 524288
|
|
|
|
const CLONE_SIGHAND = 2048
|
|
|
|
const CLONE_SYSVSEM = 262144
|
|
|
|
const CLONE_THREAD = 65536
|
|
|
|
const CLONE_UNTRACED = 8388608
|
|
|
|
const CLONE_VFORK = 16384
|
|
|
|
const CLONE_VM = 256
|
|
|
|
const CPU_SETSIZE = 1024
|
|
|
|
const CSIGNAL = 255
|
|
|
|
const DN_ACCESS = 1
|
|
|
|
const DN_ATTRIB = 32
|
|
|
|
const DN_CREATE = 4
|
|
|
|
const DN_DELETE = 8
|
|
|
|
const DN_MODIFY = 2
|
|
|
|
const DN_MULTISHOT = 2147483648
|
|
|
|
const DN_RENAME = 16
|
|
|
|
const EADDRINUSE = 98
|
|
|
|
const EADDRNOTAVAIL = 99
|
|
|
|
const EADV = 68
|
|
|
|
const EAFNOSUPPORT = 97
|
|
|
|
const EALREADY = 114
|
|
|
|
const EBADE = 52
|
|
|
|
const EBADFD = 77
|
|
|
|
const EBADMSG = 74
|
|
|
|
const EBADR = 53
|
|
|
|
const EBADRQC = 56
|
|
|
|
const EBADSLT = 57
|
|
|
|
const EBFONT = 59
|
|
|
|
const ECANCELED = 125
|
|
|
|
const ECHRNG = 44
|
|
|
|
const ECOMM = 70
|
|
|
|
const ECONNABORTED = 103
|
|
|
|
const ECONNREFUSED = 111
|
|
|
|
const ECONNRESET = 104
|
|
|
|
const EDEADLK = 35
|
|
|
|
const EDESTADDRREQ = 89
|
|
|
|
const EDOTDOT = 73
|
|
|
|
const EDQUOT = 122
|
|
|
|
const EHOSTDOWN = 112
|
|
|
|
const EHOSTUNREACH = 113
|
|
|
|
const EHWPOISON = 133
|
|
|
|
const EIDRM = 43
|
|
|
|
const EINPROGRESS = 115
|
|
|
|
const EISCONN = 106
|
|
|
|
const EISNAM = 120
|
|
|
|
const EKEYEXPIRED = 127
|
|
|
|
const EKEYREJECTED = 129
|
|
|
|
const EKEYREVOKED = 128
|
|
|
|
const EL2HLT = 51
|
|
|
|
const EL2NSYNC = 45
|
|
|
|
const EL3HLT = 46
|
|
|
|
const EL3RST = 47
|
|
|
|
const ELIBACC = 79
|
|
|
|
const ELIBBAD = 80
|
|
|
|
const ELIBEXEC = 83
|
|
|
|
const ELIBMAX = 82
|
|
|
|
const ELIBSCN = 81
|
|
|
|
const ELNRNG = 48
|
|
|
|
const ELOOP = 40
|
|
|
|
const EMEDIUMTYPE = 124
|
|
|
|
const EMSGSIZE = 90
|
|
|
|
const EMULTIHOP = 72
|
|
|
|
const ENAMETOOLONG = 36
|
|
|
|
const ENAVAIL = 119
|
|
|
|
const ENETDOWN = 100
|
|
|
|
const ENETRESET = 102
|
|
|
|
const ENETUNREACH = 101
|
|
|
|
const ENOANO = 55
|
|
|
|
const ENOBUFS = 105
|
|
|
|
const ENOCSI = 50
|
|
|
|
const ENODATA = 61
|
|
|
|
const ENOKEY = 126
|
|
|
|
const ENOLCK = 37
|
|
|
|
const ENOLINK = 67
|
|
|
|
const ENOMEDIUM = 123
|
|
|
|
const ENOMSG = 42
|
|
|
|
const ENONET = 64
|
|
|
|
const ENOPKG = 65
|
|
|
|
const ENOPROTOOPT = 92
|
|
|
|
const ENOSR = 63
|
|
|
|
const ENOSTR = 60
|
|
|
|
const ENOSYS = 38
|
|
|
|
const ENOTCONN = 107
|
|
|
|
const ENOTEMPTY = 39
|
|
|
|
const ENOTNAM = 118
|
|
|
|
const ENOTRECOVERABLE = 131
|
|
|
|
const ENOTSOCK = 88
|
|
|
|
const ENOTSUP = 95
|
|
|
|
const ENOTUNIQ = 76
|
|
|
|
const EOPNOTSUPP = 95
|
|
|
|
const EOVERFLOW = 75
|
|
|
|
const EOWNERDEAD = 130
|
|
|
|
const EPFNOSUPPORT = 96
|
|
|
|
const EPROTO = 71
|
|
|
|
const EPROTONOSUPPORT = 93
|
|
|
|
const EPROTOTYPE = 91
|
|
|
|
const EREMCHG = 78
|
|
|
|
const EREMOTE = 66
|
|
|
|
const EREMOTEIO = 121
|
|
|
|
const ERESTART = 85
|
|
|
|
const ERFKILL = 132
|
|
|
|
const ESHUTDOWN = 108
|
|
|
|
const ESOCKTNOSUPPORT = 94
|
|
|
|
const ESRMNT = 69
|
|
|
|
const ESTALE = 116
|
|
|
|
const ESTRPIPE = 86
|
|
|
|
const ETIME = 62
|
|
|
|
const ETIMEDOUT = 110
|
|
|
|
const ETOOMANYREFS = 109
|
|
|
|
const EUCLEAN = 117
|
|
|
|
const EUNATCH = 49
|
|
|
|
const EUSERS = 87
|
|
|
|
const EWOULDBLOCK = 11
|
|
|
|
const EXFULL = 54
|
|
|
|
const F2FS_FEATURE_ATOMIC_WRITE = 4
|
|
|
|
const F2FS_IOCTL_MAGIC = 245
|
|
|
|
const FALLOC_FL_KEEP_SIZE = 1
|
|
|
|
const FALLOC_FL_PUNCH_HOLE = 2
|
|
|
|
const FAPPEND = 1024
|
|
|
|
const FASYNC = 8192
|
|
|
|
const FFSYNC = 1052672
|
|
|
|
const FILENAME_MAX = 4096
|
|
|
|
const FIOGETOWN = 35075
|
|
|
|
const FIOSETOWN = 35073
|
|
|
|
const FNDELAY = 2048
|
|
|
|
const FNONBLOCK = 2048
|
|
|
|
const FOPEN_MAX = 1000
|
|
|
|
const FP_NAN = 0
|
|
|
|
const FP_ZERO = 2
|
|
|
|
const F_ADD_SEALS = 1033
|
|
|
|
const F_CANCELLK = 1029
|
|
|
|
const F_DUPFD_CLOEXEC = 1030
|
|
|
|
const F_GETLEASE = 1025
|
|
|
|
const F_GETOWN = 9
|
|
|
|
const F_GETOWNER_UIDS = 17
|
|
|
|
const F_GETOWN_EX = 16
|
|
|
|
const F_GETPIPE_SZ = 1032
|
|
|
|
const F_GETSIG = 11
|
|
|
|
const F_GET_FILE_RW_HINT = 1037
|
|
|
|
const F_GET_RW_HINT = 1035
|
|
|
|
const F_GET_SEALS = 1034
|
|
|
|
const F_NOTIFY = 1026
|
|
|
|
const F_OFD_GETLK = 36
|
|
|
|
const F_OFD_SETLK = 37
|
|
|
|
const F_OFD_SETLKW = 38
|
|
|
|
const F_OWNER_GID = 2
|
|
|
|
const F_OWNER_PGRP = 2
|
|
|
|
const F_OWNER_PID = 1
|
|
|
|
const F_OWNER_TID = 0
|
|
|
|
const F_RDLCK = 0
|
|
|
|
const F_SEAL_FUTURE_WRITE = 16
|
|
|
|
const F_SETLEASE = 1024
|
|
|
|
const F_SETOWN = 8
|
|
|
|
const F_SETOWN_EX = 15
|
|
|
|
const F_SETPIPE_SZ = 1031
|
|
|
|
const F_SETSIG = 10
|
|
|
|
const F_SET_FILE_RW_HINT = 1038
|
|
|
|
const F_SET_RW_HINT = 1036
|
|
|
|
const F_WRLCK = 1
|
|
|
|
const HAVE_MREMAP = 1
|
|
|
|
const L_ctermid = 20
|
|
|
|
const L_cuserid = 20
|
|
|
|
const L_tmpnam = 20
|
|
|
|
const MADV_COLD = 20
|
|
|
|
const MADV_DODUMP = 17
|
|
|
|
const MADV_DOFORK = 11
|
|
|
|
const MADV_DONTDUMP = 16
|
|
|
|
const MADV_DONTFORK = 10
|
|
|
|
const MADV_FREE = 8
|
|
|
|
const MADV_HUGEPAGE = 14
|
|
|
|
const MADV_HWPOISON = 100
|
|
|
|
const MADV_KEEPONFORK = 19
|
|
|
|
const MADV_MERGEABLE = 12
|
|
|
|
const MADV_NOHUGEPAGE = 15
|
|
|
|
const MADV_PAGEOUT = 21
|
|
|
|
const MADV_REMOVE = 9
|
|
|
|
const MADV_SOFT_OFFLINE = 101
|
|
|
|
const MADV_UNMERGEABLE = 13
|
|
|
|
const MADV_WIPEONFORK = 18
|
|
|
|
const MAP_ANON = 32
|
|
|
|
const MAP_ANONYMOUS = 32
|
|
|
|
const MAP_DENYWRITE = 2048
|
|
|
|
const MAP_EXECUTABLE = 4096
|
|
|
|
const MAP_FIXED_NOREPLACE = 1048576
|
|
|
|
const MAP_GROWSDOWN = 256
|
|
|
|
const MAP_HUGETLB = 262144
|
|
|
|
const MAP_HUGE_16GB = 2281701376
|
|
|
|
const MAP_HUGE_16KB = 939524096
|
|
|
|
const MAP_HUGE_16MB = 1610612736
|
|
|
|
const MAP_HUGE_1GB = 2013265920
|
|
|
|
const MAP_HUGE_1MB = 1342177280
|
|
|
|
const MAP_HUGE_256MB = 1879048192
|
|
|
|
const MAP_HUGE_2GB = 2080374784
|
|
|
|
const MAP_HUGE_2MB = 1409286144
|
|
|
|
const MAP_HUGE_32MB = 1677721600
|
|
|
|
const MAP_HUGE_512KB = 1275068416
|
|
|
|
const MAP_HUGE_512MB = 1946157056
|
|
|
|
const MAP_HUGE_64KB = 1073741824
|
|
|
|
const MAP_HUGE_8MB = 1543503872
|
|
|
|
const MAP_HUGE_MASK = 63
|
|
|
|
const MAP_HUGE_SHIFT = 26
|
|
|
|
const MAP_NONBLOCK = 65536
|
|
|
|
const MAP_POPULATE = 32768
|
|
|
|
const MAP_SHARED_VALIDATE = 3
|
|
|
|
const MAP_STACK = 131072
|
|
|
|
const MAP_SYNC = 524288
|
|
|
|
const MAP_TYPE = 15
|
|
|
|
const MAX_HANDLE_SZ = 128
|
|
|
|
const MLOCK_ONFAULT = 1
|
|
|
|
const MREMAP_DONTUNMAP = 4
|
|
|
|
const MREMAP_FIXED = 2
|
|
|
|
const MREMAP_MAYMOVE = 1
|
|
|
|
const N_6PACK = 7
|
|
|
|
const N_AX25 = 5
|
|
|
|
const N_CAIF = 20
|
|
|
|
const N_GIGASET_M101 = 16
|
|
|
|
const N_GSM0710 = 21
|
|
|
|
const N_HCI = 15
|
|
|
|
const N_HDLC = 13
|
|
|
|
const N_IRDA = 11
|
|
|
|
const N_MASC = 8
|
|
|
|
const N_MOUSE = 2
|
|
|
|
const N_NCI = 25
|
|
|
|
const N_NULL = 27
|
|
|
|
const N_PPP = 3
|
|
|
|
const N_PPS = 18
|
|
|
|
const N_PROFIBUS_FDL = 10
|
|
|
|
const N_R3964 = 9
|
|
|
|
const N_SLCAN = 17
|
|
|
|
const N_SLIP = 1
|
|
|
|
const N_SMSBLOCK = 12
|
|
|
|
const N_SPEAKUP = 26
|
|
|
|
const N_STRIP = 4
|
|
|
|
const N_SYNC_PPP = 14
|
|
|
|
const N_TI_WL = 22
|
|
|
|
const N_TRACEROUTER = 24
|
|
|
|
const N_TRACESINK = 23
|
|
|
|
const N_TTY = 0
|
|
|
|
const N_V253 = 19
|
|
|
|
const N_X25 = 6
|
|
|
|
const O_ACCMODE = 2097155
|
|
|
|
const O_APPEND = 1024
|
|
|
|
const O_ASYNC = 8192
|
|
|
|
const O_CLOEXEC = 524288
|
|
|
|
const O_CREAT = 64
|
|
|
|
const O_DSYNC = 4096
|
|
|
|
const O_EXCL = 128
|
|
|
|
const O_EXEC = 2097152
|
|
|
|
const O_NDELAY = 2048
|
|
|
|
const O_NOATIME = 262144
|
|
|
|
const O_NOCTTY = 256
|
|
|
|
const O_NONBLOCK = 2048
|
|
|
|
const O_PATH = 2097152
|
|
|
|
const O_RSYNC = 1052672
|
|
|
|
const O_SEARCH = 2097152
|
|
|
|
const O_SYNC = 1052672
|
|
|
|
const O_TRUNC = 512
|
|
|
|
const O_TTY_INIT = 0
|
|
|
|
const POSIX_CLOSE_RESTART = 0
|
|
|
|
const PROT_GROWSDOWN = 16777216
|
|
|
|
const PROT_GROWSUP = 33554432
|
|
|
|
const PTHREAD_BARRIER_SERIAL_THREAD = -1
|
|
|
|
const PTHREAD_CANCELED = -1
|
|
|
|
const PTHREAD_CANCEL_ASYNCHRONOUS = 1
|
|
|
|
const PTHREAD_CANCEL_DEFERRED = 0
|
|
|
|
const PTHREAD_CANCEL_DISABLE = 1
|
|
|
|
const PTHREAD_CANCEL_ENABLE = 0
|
|
|
|
const PTHREAD_CANCEL_MASKED = 2
|
|
|
|
const PTHREAD_CREATE_DETACHED = 1
|
|
|
|
const PTHREAD_CREATE_JOINABLE = 0
|
|
|
|
const PTHREAD_EXPLICIT_SCHED = 1
|
|
|
|
const PTHREAD_INHERIT_SCHED = 0
|
|
|
|
const PTHREAD_MUTEX_DEFAULT = 0
|
|
|
|
const PTHREAD_MUTEX_ERRORCHECK = 2
|
|
|
|
const PTHREAD_MUTEX_NORMAL = 0
|
|
|
|
const PTHREAD_MUTEX_RECURSIVE = 1
|
|
|
|
const PTHREAD_MUTEX_ROBUST = 1
|
|
|
|
const PTHREAD_MUTEX_STALLED = 0
|
|
|
|
const PTHREAD_ONCE_INIT = 0
|
|
|
|
const PTHREAD_PRIO_INHERIT = 1
|
|
|
|
const PTHREAD_PRIO_NONE = 0
|
|
|
|
const PTHREAD_PRIO_PROTECT = 2
|
|
|
|
const PTHREAD_PROCESS_PRIVATE = 0
|
|
|
|
const PTHREAD_PROCESS_SHARED = 1
|
|
|
|
const PTHREAD_SCOPE_PROCESS = 1
|
|
|
|
const PTHREAD_SCOPE_SYSTEM = 0
|
|
|
|
const P_tmpdir = "/tmp"
|
|
|
|
const RTLD_NOLOAD = 4
|
|
|
|
const RWF_WRITE_LIFE_NOT_SET = 0
|
|
|
|
const RWH_WRITE_LIFE_EXTREME = 5
|
|
|
|
const RWH_WRITE_LIFE_LONG = 4
|
|
|
|
const RWH_WRITE_LIFE_MEDIUM = 3
|
|
|
|
const RWH_WRITE_LIFE_NONE = 1
|
|
|
|
const RWH_WRITE_LIFE_SHORT = 2
|
|
|
|
const SCHED_BATCH = 3
|
|
|
|
const SCHED_DEADLINE = 6
|
|
|
|
const SCHED_FIFO = 1
|
|
|
|
const SCHED_IDLE = 5
|
|
|
|
const SCHED_OTHER = 0
|
|
|
|
const SCHED_RESET_ON_FORK = 1073741824
|
|
|
|
const SCHED_RR = 2
|
|
|
|
const SIOCADDDLCI = 35200
|
|
|
|
const SIOCADDMULTI = 35121
|
|
|
|
const SIOCADDRT = 35083
|
|
|
|
const SIOCATMARK = 35077
|
|
|
|
const SIOCDARP = 35155
|
|
|
|
const SIOCDELDLCI = 35201
|
|
|
|
const SIOCDELMULTI = 35122
|
|
|
|
const SIOCDELRT = 35084
|
|
|
|
const SIOCDEVPRIVATE = 35312
|
|
|
|
const SIOCDIFADDR = 35126
|
|
|
|
const SIOCDRARP = 35168
|
|
|
|
const SIOCGARP = 35156
|
|
|
|
const SIOCGIFADDR = 35093
|
|
|
|
const SIOCGIFBR = 35136
|
|
|
|
const SIOCGIFBRDADDR = 35097
|
|
|
|
const SIOCGIFCONF = 35090
|
|
|
|
const SIOCGIFCOUNT = 35128
|
|
|
|
const SIOCGIFDSTADDR = 35095
|
|
|
|
const SIOCGIFENCAP = 35109
|
|
|
|
const SIOCGIFFLAGS = 35091
|
|
|
|
const SIOCGIFHWADDR = 35111
|
|
|
|
const SIOCGIFINDEX = 35123
|
|
|
|
const SIOCGIFMAP = 35184
|
|
|
|
const SIOCGIFMEM = 35103
|
|
|
|
const SIOCGIFMETRIC = 35101
|
|
|
|
const SIOCGIFMTU = 35105
|
|
|
|
const SIOCGIFNAME = 35088
|
|
|
|
const SIOCGIFNETMASK = 35099
|
|
|
|
const SIOCGIFPFLAGS = 35125
|
|
|
|
const SIOCGIFSLAVE = 35113
|
|
|
|
const SIOCGIFTXQLEN = 35138
|
|
|
|
const SIOCGPGRP = 35076
|
|
|
|
const SIOCGRARP = 35169
|
|
|
|
const SIOCPROTOPRIVATE = 35296
|
|
|
|
const SIOCRTMSG = 35085
|
|
|
|
const SIOCSARP = 35157
|
|
|
|
const SIOCSIFADDR = 35094
|
|
|
|
const SIOCSIFBR = 35137
|
|
|
|
const SIOCSIFBRDADDR = 35098
|
|
|
|
const SIOCSIFDSTADDR = 35096
|
|
|
|
const SIOCSIFENCAP = 35110
|
|
|
|
const SIOCSIFFLAGS = 35092
|
|
|
|
const SIOCSIFHWADDR = 35108
|
|
|
|
const SIOCSIFHWBROADCAST = 35127
|
|
|
|
const SIOCSIFLINK = 35089
|
|
|
|
const SIOCSIFMAP = 35185
|
|
|
|
const SIOCSIFMEM = 35104
|
|
|
|
const SIOCSIFMETRIC = 35102
|
|
|
|
const SIOCSIFMTU = 35106
|
|
|
|
const SIOCSIFNAME = 35107
|
|
|
|
const SIOCSIFNETMASK = 35100
|
|
|
|
const SIOCSIFPFLAGS = 35124
|
|
|
|
const SIOCSIFSLAVE = 35120
|
|
|
|
const SIOCSIFTXQLEN = 35139
|
|
|
|
const SIOCSPGRP = 35074
|
|
|
|
const SIOCSRARP = 35170
|
|
|
|
const SIOGIFINDEX = 35123
|
|
|
|
const SPLICE_F_GIFT = 8
|
|
|
|
const SPLICE_F_MORE = 4
|
|
|
|
const SPLICE_F_MOVE = 1
|
|
|
|
const SPLICE_F_NONBLOCK = 2
|
|
|
|
const SQLITE_MAX_PATHLEN = 4096
|
|
|
|
const SQLITE_MUTEX_NREF = 0
|
|
|
|
const STATX_ALL = 4095
|
|
|
|
const STATX_ATIME = 32
|
|
|
|
const STATX_BASIC_STATS = 2047
|
|
|
|
const STATX_BLOCKS = 1024
|
|
|
|
const STATX_BTIME = 2048
|
|
|
|
const STATX_CTIME = 128
|
|
|
|
const STATX_GID = 16
|
|
|
|
const STATX_INO = 256
|
|
|
|
const STATX_MODE = 2
|
|
|
|
const STATX_MTIME = 64
|
|
|
|
const STATX_NLINK = 4
|
|
|
|
const STATX_SIZE = 512
|
|
|
|
const STATX_TYPE = 1
|
|
|
|
const STATX_UID = 8
|
|
|
|
const SYNC_FILE_RANGE_WAIT_AFTER = 4
|
|
|
|
const SYNC_FILE_RANGE_WAIT_BEFORE = 1
|
|
|
|
const SYNC_FILE_RANGE_WRITE = 2
|
|
|
|
const TCSBRKP = 21541
|
|
|
|
const TIOCCBRK = 21544
|
|
|
|
const TIOCCONS = 21533
|
|
|
|
const TIOCEXCL = 21516
|
|
|
|
const TIOCGETD = 21540
|
|
|
|
const TIOCGICOUNT = 21597
|
|
|
|
const TIOCGLCKTRMIOS = 21590
|
|
|
|
const TIOCGRS485 = 21550
|
|
|
|
const TIOCGSERIAL = 21534
|
|
|
|
const TIOCGSID = 21545
|
|
|
|
const TIOCGSOFTCAR = 21529
|
|
|
|
const TIOCLINUX = 21532
|
|
|
|
const TIOCMBIC = 21527
|
|
|
|
const TIOCMBIS = 21526
|
|
|
|
const TIOCMGET = 21525
|
|
|
|
const TIOCMIWAIT = 21596
|
|
|
|
const TIOCMSET = 21528
|
|
|
|
const TIOCM_LOOP = 32768
|
|
|
|
const TIOCM_OUT1 = 8192
|
|
|
|
const TIOCM_OUT2 = 16384
|
|
|
|
const TIOCNOTTY = 21538
|
|
|
|
const TIOCNXCL = 21517
|
|
|
|
const TIOCPKT = 21536
|
|
|
|
const TIOCSBRK = 21543
|
|
|
|
const TIOCSCTTY = 21518
|
|
|
|
const TIOCSERCONFIG = 21587
|
|
|
|
const TIOCSERGETLSR = 21593
|
|
|
|
const TIOCSERGETMULTI = 21594
|
|
|
|
const TIOCSERGSTRUCT = 21592
|
|
|
|
const TIOCSERGWILD = 21588
|
|
|
|
const TIOCSERSETMULTI = 21595
|
|
|
|
const TIOCSERSWILD = 21589
|
|
|
|
const TIOCSER_TEMT = 1
|
|
|
|
const TIOCSETD = 21539
|
|
|
|
const TIOCSLCKTRMIOS = 21591
|
|
|
|
const TIOCSRS485 = 21551
|
|
|
|
const TIOCSSERIAL = 21535
|
|
|
|
const TIOCSSOFTCAR = 21530
|
|
|
|
const TIOCSTI = 21522
|
|
|
|
const TIOCVHANGUP = 21559
|
|
|
|
const TMP_MAX = 10000
|
|
|
|
type TSQLiteThread = struct {
|
|
Ftid Tpthread_t
|
|
Fdone int32
|
|
FpOut uintptr
|
|
FxTask uintptr
|
|
FpIn uintptr
|
|
}
|
|
|
|
type T_G_fpos64_t = Tfpos_t
|
|
|
|
type T_IO_cookie_io_functions_t = Tcookie_io_functions_t
|
|
|
|
type Tf_owner_ex = struct {
|
|
Ftype1 int32
|
|
Fpid Tpid_t
|
|
}
|
|
|
|
type Tfile_handle = struct {
|
|
Fhandle_bytes uint32
|
|
Fhandle_type int32
|
|
}
|
|
|
|
type Tpthread_barrierattr_t = struct {
|
|
F__attr uint32
|
|
}
|
|
|
|
type Tpthread_condattr_t = struct {
|
|
F__attr uint32
|
|
}
|
|
|
|
type Tpthread_key_t = uint32
|
|
|
|
type Tpthread_mutexattr_t = struct {
|
|
F__attr uint32
|
|
}
|
|
|
|
type Tpthread_once_t = int32
|
|
|
|
type Tpthread_rwlockattr_t = struct {
|
|
F__attr [2]uint32
|
|
}
|
|
|
|
type Tpthread_spinlock_t = int32
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** CAPI3REF: Mutex Handle
|
|
// **
|
|
// ** The mutex module within SQLite defines [sqlite3_mutex] to be an
|
|
// ** abstract type for a mutex object. The SQLite core never looks
|
|
// ** at the internal representation of an [sqlite3_mutex]. It only
|
|
// ** deals with pointers to the [sqlite3_mutex] object.
|
|
// **
|
|
// ** Mutexes are created using [sqlite3_mutex_alloc()].
|
|
// */
|
|
type Tsqlite3_mutex = struct {
|
|
Fmutex Tpthread_mutex_t
|
|
}
|
|
|
|
const WINT_MAX = 4294967295
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Switch OFD locking on (onoff>0) or off (onoff==0), or query it (onoff<0).
|
|
// ** Returns the previous setting; -1 where OFD locks are not available: on
|
|
// ** every unix target but Linux, and on Linux once the kernel has rejected
|
|
// ** them; -2 when the setting can no longer be changed because a lock has
|
|
// ** already been attempted in this process (it can again after
|
|
// ** sqlite3_shutdown()). Overrides MODERNC_SQLITE_OFD_LOCK. Meant to be
|
|
// ** called before the first database file is opened; querying, and setting
|
|
// ** the value already in effect, always work.
|
|
// */
|
|
func Xmodernc_ofd_locking(tls *libc.TLS, onoff int32) (r int32) {
|
|
var prev int32
|
|
_ = prev
|
|
_ofdInitOnce(tls)
|
|
if !(libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_ofdSupported))) != 0) {
|
|
return -int32(1)
|
|
}
|
|
prev = libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_ofdEnabled)))
|
|
if onoff < 0 || libc.BoolInt32(onoff != 0) == prev {
|
|
return prev
|
|
}
|
|
if libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_ofdFrozen))) != 0 {
|
|
return -int32(2)
|
|
}
|
|
libc.AtomicStorePInt32(uintptr(unsafe.Pointer(&_ofdEnabled)), libc.BoolInt32(onoff != libc.Int32FromInt32(0)))
|
|
return prev
|
|
}
|
|
|
|
/*
|
|
** The descriptor through which the kernel locks on pFile's inode are held.
|
|
** With OFD locks every lock of the inode must go through one open file
|
|
** description (pInode->hLock); with POSIX locks the fd does not matter,
|
|
** so use pFile->h as upstream does.
|
|
*/
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Move an existing blob handle to point to a different row of the same
|
|
// ** database table.
|
|
// **
|
|
// ** If an error occurs, or if the specified row does not exist or does not
|
|
// ** contain a blob or text value, then an error code is returned and the
|
|
// ** database handle error code and message set. If this happens, then all
|
|
// ** subsequent calls to sqlite3_blob_xxx() functions (except blob_close())
|
|
// ** immediately return SQLITE_ABORT.
|
|
// */
|
|
func Xsqlite3_blob_reopen(tls *libc.TLS, pBlob uintptr, iRow Tsqlite3_int64) (r int32) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var db, p, v1 uintptr
|
|
var rc int32
|
|
var _ /* zErr at bp+0 */ uintptr
|
|
_, _, _, _ = db, p, rc, v1
|
|
p = pBlob
|
|
if p == uintptr(0) {
|
|
return _sqlite3MisuseError(tls, int32(106649))
|
|
}
|
|
db = (*TIncrblob)(unsafe.Pointer(p)).Fdb
|
|
Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
|
|
if (*TIncrblob)(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 = int32(SQLITE_ABORT)
|
|
} else {
|
|
(*TVdbe)(unsafe.Pointer((*TIncrblob)(unsafe.Pointer(p)).FpStmt)).Frc = SQLITE_OK
|
|
rc = _blobSeekToRow(tls, p, iRow, bp)
|
|
if rc != SQLITE_OK {
|
|
if **(**uintptr)(__ccgo_up(bp)) != 0 {
|
|
v1 = __ccgo_ts + 3968
|
|
} else {
|
|
v1 = libc.UintptrFromInt32(0)
|
|
}
|
|
_sqlite3ErrorWithMsg(tls, db, rc, v1, libc.VaList(bp+16, **(**uintptr)(__ccgo_up(bp))))
|
|
_sqlite3DbFree(tls, db, **(**uintptr)(__ccgo_up(bp)))
|
|
}
|
|
}
|
|
rc = _sqlite3ApiExit(tls, db, rc)
|
|
Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
|
|
return rc
|
|
}
|
|
|
|
/************** End of vdbeblob.c ********************************************/
|
|
/************** Begin file vdbesort.c ****************************************/
|
|
/*
|
|
** 2011-07-09
|
|
**
|
|
** The author disclaims copyright to this source code. In place of
|
|
** a legal notice, here is a blessing:
|
|
**
|
|
** May you do good and not evil.
|
|
** May you find forgiveness for yourself and forgive others.
|
|
** May you share freely, never taking more than you give.
|
|
**
|
|
*************************************************************************
|
|
** This file contains code for the VdbeSorter object, used in concert with
|
|
** a VdbeCursor to sort large numbers of keys for CREATE INDEX statements
|
|
** or by SELECT statements with ORDER BY clauses that cannot be satisfied
|
|
** using indexes and without LIMIT clauses.
|
|
**
|
|
** The VdbeSorter object implements a multi-threaded external merge sort
|
|
** algorithm that is efficient even if the number of elements being sorted
|
|
** exceeds the available memory.
|
|
**
|
|
** Here is the (internal, non-API) interface between this module and the
|
|
** rest of the SQLite system:
|
|
**
|
|
** sqlite3VdbeSorterInit() Create a new VdbeSorter object.
|
|
**
|
|
** sqlite3VdbeSorterWrite() Add a single new row to the VdbeSorter
|
|
** object. The row is a binary blob in the
|
|
** OP_MakeRecord format that contains both
|
|
** the ORDER BY key columns and result columns
|
|
** in the case of a SELECT w/ ORDER BY, or
|
|
** the complete record for an index entry
|
|
** in the case of a CREATE INDEX.
|
|
**
|
|
** sqlite3VdbeSorterRewind() Sort all content previously added.
|
|
** Position the read cursor on the
|
|
** first sorted element.
|
|
**
|
|
** sqlite3VdbeSorterNext() Advance the read cursor to the next sorted
|
|
** element.
|
|
**
|
|
** sqlite3VdbeSorterRowkey() Return the complete binary blob for the
|
|
** row currently under the read cursor.
|
|
**
|
|
** sqlite3VdbeSorterCompare() Compare the binary blob for the row
|
|
** currently under the read cursor against
|
|
** another binary blob X and report if
|
|
** X is strictly less than the read cursor.
|
|
** Used to enforce uniqueness in a
|
|
** CREATE UNIQUE INDEX statement.
|
|
**
|
|
** sqlite3VdbeSorterClose() Close the VdbeSorter object and reclaim
|
|
** all resources.
|
|
**
|
|
** sqlite3VdbeSorterReset() Refurbish the VdbeSorter for reuse. This
|
|
** is like Close() followed by Init() only
|
|
** much faster.
|
|
**
|
|
** The interfaces above must be called in a particular order. Write() can
|
|
** only occur in between Init()/Reset() and Rewind(). Next(), Rowkey(), and
|
|
** Compare() can only occur in between Rewind() and Close()/Reset(). i.e.
|
|
**
|
|
** Init()
|
|
** for each record: Write()
|
|
** Rewind()
|
|
** Rowkey()/Compare()
|
|
** Next()
|
|
** Close()
|
|
**
|
|
** Algorithm:
|
|
**
|
|
** Records passed to the sorter via calls to Write() are initially held
|
|
** unsorted in main memory. Assuming the amount of memory used never exceeds
|
|
** a threshold, when Rewind() is called the set of records is sorted using
|
|
** an in-memory merge sort. In this case, no temporary files are required
|
|
** and subsequent calls to Rowkey(), Next() and Compare() read records
|
|
** directly from main memory.
|
|
**
|
|
** If the amount of space used to store records in main memory exceeds the
|
|
** threshold, then the set of records currently in memory are sorted and
|
|
** written to a temporary file in "Packed Memory Array" (PMA) format.
|
|
** A PMA created at this point is known as a "level-0 PMA". Higher levels
|
|
** of PMAs may be created by merging existing PMAs together - for example
|
|
** merging two or more level-0 PMAs together creates a level-1 PMA.
|
|
**
|
|
** The threshold for the amount of main memory to use before flushing
|
|
** records to a PMA is roughly the same as the limit configured for the
|
|
** page-cache of the main database. Specifically, the threshold is set to
|
|
** the value returned by "PRAGMA main.page_size" multiplied by
|
|
** that returned by "PRAGMA main.cache_size", in bytes.
|
|
**
|
|
** If the sorter is running in single-threaded mode, then all PMAs generated
|
|
** are appended to a single temporary file. Or, if the sorter is running in
|
|
** multi-threaded mode then up to (N+1) temporary files may be opened, where
|
|
** N is the configured number of worker threads. In this case, instead of
|
|
** sorting the records and writing the PMA to a temporary file itself, the
|
|
** calling thread usually launches a worker thread to do so. Except, if
|
|
** there are already N worker threads running, the main thread does the work
|
|
** itself.
|
|
**
|
|
** The sorter is running in multi-threaded mode if (a) the library was built
|
|
** with pre-processor symbol SQLITE_MAX_WORKER_THREADS set to a value greater
|
|
** than zero, and (b) worker threads have been enabled at runtime by calling
|
|
** "PRAGMA threads=N" with some value of N greater than 0.
|
|
**
|
|
** When Rewind() is called, any data remaining in memory is flushed to a
|
|
** final PMA. So at this point the data is stored in some number of sorted
|
|
** PMAs within temporary files on disk.
|
|
**
|
|
** If there are fewer than SORTER_MAX_MERGE_COUNT PMAs in total and the
|
|
** sorter is running in single-threaded mode, then these PMAs are merged
|
|
** incrementally as keys are retrieved from the sorter by the VDBE. The
|
|
** MergeEngine object, described in further detail below, performs this
|
|
** merge.
|
|
**
|
|
** Or, if running in multi-threaded mode, then a background thread is
|
|
** launched to merge the existing PMAs. Once the background thread has
|
|
** merged T bytes of data into a single sorted PMA, the main thread
|
|
** begins reading keys from that PMA while the background thread proceeds
|
|
** with merging the next T bytes of data. And so on.
|
|
**
|
|
** Parameter T is set to half the value of the memory threshold used
|
|
** by Write() above to determine when to create a new PMA.
|
|
**
|
|
** If there are more than SORTER_MAX_MERGE_COUNT PMAs in total when
|
|
** Rewind() is called, then a hierarchy of incremental-merges is used.
|
|
** First, T bytes of data from the first SORTER_MAX_MERGE_COUNT PMAs on
|
|
** disk are merged together. Then T bytes of data from the second set, and
|
|
** so on, such that no operation ever merges more than SORTER_MAX_MERGE_COUNT
|
|
** PMAs at a time. This done is to improve locality.
|
|
**
|
|
** If running in multi-threaded mode and there are more than
|
|
** SORTER_MAX_MERGE_COUNT PMAs on disk when Rewind() is called, then more
|
|
** than one background thread may be created. Specifically, there may be
|
|
** one background thread for each temporary file on disk, and one background
|
|
** thread to merge the output of each of the others to a single PMA for
|
|
** the main thread to read from.
|
|
*/
|
|
/* #include "sqliteInt.h" */
|
|
/* #include "vdbeInt.h" */
|
|
|
|
/*
|
|
** If SQLITE_DEBUG_SORTER_THREADS is defined, this module outputs various
|
|
** messages to stderr that may be helpful in understanding the performance
|
|
** characteristics of the sorter in multi-threaded mode.
|
|
*/
|
|
|
|
/*
|
|
** Hard-coded maximum amount of data to accumulate in memory before flushing
|
|
** to a level 0 PMA. The purpose of this limit is to prevent various integer
|
|
** overflows. 512MiB.
|
|
*/
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Shutdown the operating system interface.
|
|
// **
|
|
// ** Some operating systems might need to do some cleanup in this routine,
|
|
// ** to release dynamically allocated objects. But not on unix.
|
|
// ** This routine is a no-op for unix.
|
|
// */
|
|
func Xsqlite3_os_end(tls *libc.TLS) (r int32) {
|
|
_unixBigLock = uintptr(0)
|
|
libc.AtomicStorePInt32(uintptr(unsafe.Pointer(&_ofdFrozen)), 0)
|
|
return SQLITE_OK
|
|
}
|
|
|
|
/************** End of os_unix.c *********************************************/
|
|
/************** Begin file os_win.c ******************************************/
|
|
/*
|
|
** 2004 May 22
|
|
**
|
|
** The author disclaims copyright to this source code. In place of
|
|
** a legal notice, here is a blessing:
|
|
**
|
|
** May you do good and not evil.
|
|
** May you find forgiveness for yourself and forgive others.
|
|
** May you share freely, never taking more than you give.
|
|
**
|
|
******************************************************************************
|
|
**
|
|
** This file contains code that is specific to Windows.
|
|
*/
|
|
/* #include "sqliteInt.h" */
|
|
|
|
/************** End of os_win.c **********************************************/
|
|
/************** Begin file memdb.c *******************************************/
|
|
/*
|
|
** 2016-09-07
|
|
**
|
|
** The author disclaims copyright to this source code. In place of
|
|
** a legal notice, here is a blessing:
|
|
**
|
|
** May you do good and not evil.
|
|
** May you find forgiveness for yourself and forgive others.
|
|
** May you share freely, never taking more than you give.
|
|
**
|
|
******************************************************************************
|
|
**
|
|
** This file implements an in-memory VFS. A database is held as a contiguous
|
|
** block of memory.
|
|
**
|
|
** This file also implements interface sqlite3_serialize() and
|
|
** sqlite3_deserialize().
|
|
*/
|
|
/* #include "sqliteInt.h" */
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Declare that a function has been overloaded by a virtual table.
|
|
// **
|
|
// ** If the function already exists as a regular global function, then
|
|
// ** this routine is a no-op. If the function does not exist, then create
|
|
// ** a new one that always throws a run-time error.
|
|
// **
|
|
// ** When virtual tables intend to provide an overloaded function, they
|
|
// ** should call this routine to make sure the global function exists.
|
|
// ** A global function must exist in order for name resolution to work
|
|
// ** properly.
|
|
// */
|
|
func Xsqlite3_overload_function(tls *libc.TLS, db uintptr, zName uintptr, nArg int32) (r int32) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var rc int32
|
|
var zCopy uintptr
|
|
_, _ = rc, zCopy
|
|
Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
|
|
rc = libc.BoolInt32(_sqlite3FindFunction(tls, db, zName, nArg, uint8(SQLITE_UTF8), uint8(0)) != uintptr(0))
|
|
Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
|
|
if rc != 0 {
|
|
return SQLITE_OK
|
|
}
|
|
zCopy = Xsqlite3_mprintf(tls, __ccgo_ts+3968, libc.VaList(bp+8, zName))
|
|
if zCopy == uintptr(0) {
|
|
return int32(SQLITE_NOMEM)
|
|
}
|
|
return Xsqlite3_create_function_v2(tls, db, zName, nArg, int32(SQLITE_UTF8), zCopy, __ccgo_fp(_sqlite3InvalidFunction), uintptr(0), uintptr(0), __ccgo_fp(Xsqlite3_free))
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /* Force an SQLITE_TOOBIG error. */
|
|
func Xsqlite3_result_error_toobig(tls *libc.TLS, pCtx uintptr) {
|
|
(*Tsqlite3_context)(unsafe.Pointer(pCtx)).FisError = int32(SQLITE_TOOBIG)
|
|
_sqlite3VdbeMemSetStr(tls, (*Tsqlite3_context)(unsafe.Pointer(pCtx)).FpOut, __ccgo_ts+5618, int64(-int32(1)), uint8(SQLITE_UTF8), libc.UintptrFromInt32(0))
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Set the error code and error message associated with the database handle.
|
|
// **
|
|
// ** This routine is intended to be called by outside extensions (ex: the
|
|
// ** Session extension). Internal logic should invoke sqlite3Error() or
|
|
// ** sqlite3ErrorWithMsg() directly.
|
|
// */
|
|
func Xsqlite3_set_errmsg(tls *libc.TLS, db uintptr, errcode int32, zMsg uintptr) (r int32) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var rc int32
|
|
_ = rc
|
|
rc = SQLITE_OK
|
|
if !(_sqlite3SafetyCheckOk(tls, db) != 0) {
|
|
return _sqlite3MisuseError(tls, int32(190279))
|
|
}
|
|
Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
|
|
if zMsg != 0 {
|
|
_sqlite3ErrorWithMsg(tls, db, errcode, __ccgo_ts+3968, libc.VaList(bp+8, zMsg))
|
|
} else {
|
|
_sqlite3Error(tls, db, errcode)
|
|
}
|
|
rc = _sqlite3ApiExit(tls, db, rc)
|
|
Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /************** End of stmt.c ************************************************/
|
|
// /* Return the source-id for this library */
|
|
func Xsqlite3_sourceid(tls *libc.TLS) (r uintptr) {
|
|
return __ccgo_ts + 42563
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Register an unlock-notify callback.
|
|
// **
|
|
// ** This is called after connection "db" has attempted some operation
|
|
// ** but has received an SQLITE_LOCKED error because another connection
|
|
// ** (call it pOther) in the same process was busy using the same shared
|
|
// ** cache. pOther is found by looking at db->pBlockingConnection.
|
|
// **
|
|
// ** If there is no blocking connection, the callback is invoked immediately,
|
|
// ** before this routine returns.
|
|
// **
|
|
// ** If pOther is already blocked on db, then report SQLITE_LOCKED, to indicate
|
|
// ** a deadlock.
|
|
// **
|
|
// ** Otherwise, make arrangements to invoke xNotify when pOther drops
|
|
// ** its locks.
|
|
// **
|
|
// ** Each call to this routine overrides any prior callbacks registered
|
|
// ** on the same "db". If xNotify==0 then any prior callbacks are immediately
|
|
// ** cancelled.
|
|
// */
|
|
func Xsqlite3_unlock_notify(tls *libc.TLS, db uintptr, __ccgo_fp_xNotify uintptr, _pArg uintptr) (r int32) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
*(*uintptr)(unsafe.Pointer(bp)) = _pArg
|
|
var p, v2 uintptr
|
|
var rc int32
|
|
_, _, _ = p, rc, v2
|
|
rc = SQLITE_OK
|
|
Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
|
|
_enterMutex(tls)
|
|
if __ccgo_fp_xNotify == uintptr(0) {
|
|
_removeFromBlockedList(tls, db)
|
|
(*Tsqlite3)(unsafe.Pointer(db)).FpBlockingConnection = uintptr(0)
|
|
(*Tsqlite3)(unsafe.Pointer(db)).FpUnlockConnection = uintptr(0)
|
|
(*Tsqlite3)(unsafe.Pointer(db)).FxUnlockNotify = uintptr(0)
|
|
(*Tsqlite3)(unsafe.Pointer(db)).FpUnlockArg = uintptr(0)
|
|
} else {
|
|
if uintptr(0) == (*Tsqlite3)(unsafe.Pointer(db)).FpBlockingConnection {
|
|
/* The blocking transaction has been concluded. Or there never was a
|
|
** blocking transaction. In either case, invoke the notify callback
|
|
** immediately.
|
|
*/
|
|
(*(*func(*libc.TLS, uintptr, int32))(unsafe.Pointer(&struct{ uintptr }{__ccgo_fp_xNotify})))(tls, bp, int32(1))
|
|
} else {
|
|
p = (*Tsqlite3)(unsafe.Pointer(db)).FpBlockingConnection
|
|
for {
|
|
if !(p != 0 && p != db) {
|
|
break
|
|
}
|
|
goto _1
|
|
_1:
|
|
;
|
|
p = (*Tsqlite3)(unsafe.Pointer(p)).FpUnlockConnection
|
|
}
|
|
if p != 0 {
|
|
rc = int32(SQLITE_LOCKED) /* Deadlock detected. */
|
|
} else {
|
|
(*Tsqlite3)(unsafe.Pointer(db)).FpUnlockConnection = (*Tsqlite3)(unsafe.Pointer(db)).FpBlockingConnection
|
|
(*Tsqlite3)(unsafe.Pointer(db)).FxUnlockNotify = __ccgo_fp_xNotify
|
|
(*Tsqlite3)(unsafe.Pointer(db)).FpUnlockArg = **(**uintptr)(__ccgo_up(bp))
|
|
_removeFromBlockedList(tls, db)
|
|
_addToBlockedList(tls, db)
|
|
}
|
|
}
|
|
}
|
|
_leaveMutex(tls)
|
|
if rc != 0 {
|
|
v2 = __ccgo_ts + 26400
|
|
} else {
|
|
v2 = uintptr(0)
|
|
}
|
|
_sqlite3ErrorWithMsg(tls, db, rc, v2, 0)
|
|
Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Provide a database schema to the changegroup object.
|
|
// */
|
|
func Xsqlite3changegroup_schema(tls *libc.TLS, pGrp uintptr, db uintptr, zDb uintptr) (r int32) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var rc int32
|
|
_ = rc
|
|
rc = SQLITE_OK
|
|
if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FpList != 0 || (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fdb != 0 {
|
|
/* Cannot add a schema after one or more calls to sqlite3changegroup_add(),
|
|
** or after sqlite3changegroup_schema() has already been called. */
|
|
rc = int32(SQLITE_MISUSE)
|
|
} else {
|
|
(*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FzDb = Xsqlite3_mprintf(tls, __ccgo_ts+3968, libc.VaList(bp+8, zDb))
|
|
if (*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).FzDb == uintptr(0) {
|
|
rc = int32(SQLITE_NOMEM)
|
|
} else {
|
|
(*Tsqlite3_changegroup)(unsafe.Pointer(pGrp)).Fdb = db
|
|
}
|
|
}
|
|
return rc
|
|
}
|
|
|
|
func Xsqlite3rbu_savestate(tls *libc.TLS, p uintptr) (r int32) {
|
|
var pDb, zBegin, v1 uintptr
|
|
var rc int32
|
|
_, _, _, _ = pDb, rc, zBegin, v1
|
|
rc = (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc
|
|
if rc == int32(SQLITE_DONE) {
|
|
return SQLITE_OK
|
|
}
|
|
if (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_OAL) {
|
|
if rc == SQLITE_OK {
|
|
rc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+16146, uintptr(0), uintptr(0), uintptr(0))
|
|
}
|
|
}
|
|
/* Sync the db file */
|
|
if rc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_CKPT) {
|
|
pDb = (*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal
|
|
rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pDb)).FpMethods)).FxSync})))(tls, pDb, int32(SQLITE_SYNC_NORMAL))
|
|
}
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc
|
|
_rbuSaveState(tls, p, (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage)
|
|
rc = (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc
|
|
if (*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage == int32(RBU_STAGE_OAL) {
|
|
if rc == SQLITE_OK {
|
|
rc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, __ccgo_ts+16146, uintptr(0), uintptr(0), uintptr(0))
|
|
}
|
|
if rc == SQLITE_OK {
|
|
if (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget == uintptr(0) {
|
|
v1 = __ccgo_ts + 16131
|
|
} else {
|
|
v1 = __ccgo_ts + 34660
|
|
}
|
|
zBegin = v1
|
|
rc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbRbu, zBegin, uintptr(0), uintptr(0), uintptr(0))
|
|
}
|
|
if rc == SQLITE_OK {
|
|
rc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+34660, uintptr(0), uintptr(0), uintptr(0))
|
|
}
|
|
}
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc
|
|
return rc
|
|
}
|
|
|
|
const _CS_GNU_LIBC_VERSION = 2
|
|
|
|
const _CS_GNU_LIBPTHREAD_VERSION = 3
|
|
|
|
const _CS_PATH = 0
|
|
|
|
const _CS_POSIX_V5_WIDTH_RESTRICTED_ENVS = 4
|
|
|
|
const _CS_POSIX_V6_ILP32_OFF32_CFLAGS = 1116
|
|
|
|
const _CS_POSIX_V6_ILP32_OFF32_LDFLAGS = 1117
|
|
|
|
const _CS_POSIX_V6_ILP32_OFF32_LIBS = 1118
|
|
|
|
const _CS_POSIX_V6_ILP32_OFF32_LINTFLAGS = 1119
|
|
|
|
const _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS = 1120
|
|
|
|
const _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS = 1121
|
|
|
|
const _CS_POSIX_V6_ILP32_OFFBIG_LIBS = 1122
|
|
|
|
const _CS_POSIX_V6_ILP32_OFFBIG_LINTFLAGS = 1123
|
|
|
|
const _CS_POSIX_V6_LP64_OFF64_CFLAGS = 1124
|
|
|
|
const _CS_POSIX_V6_LP64_OFF64_LDFLAGS = 1125
|
|
|
|
const _CS_POSIX_V6_LP64_OFF64_LIBS = 1126
|
|
|
|
const _CS_POSIX_V6_LP64_OFF64_LINTFLAGS = 1127
|
|
|
|
const _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS = 1128
|
|
|
|
const _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS = 1129
|
|
|
|
const _CS_POSIX_V6_LPBIG_OFFBIG_LIBS = 1130
|
|
|
|
const _CS_POSIX_V6_LPBIG_OFFBIG_LINTFLAGS = 1131
|
|
|
|
const _CS_POSIX_V6_WIDTH_RESTRICTED_ENVS = 1
|
|
|
|
const _CS_POSIX_V7_ILP32_OFF32_CFLAGS = 1132
|
|
|
|
const _CS_POSIX_V7_ILP32_OFF32_LDFLAGS = 1133
|
|
|
|
const _CS_POSIX_V7_ILP32_OFF32_LIBS = 1134
|
|
|
|
const _CS_POSIX_V7_ILP32_OFF32_LINTFLAGS = 1135
|
|
|
|
const _CS_POSIX_V7_ILP32_OFFBIG_CFLAGS = 1136
|
|
|
|
const _CS_POSIX_V7_ILP32_OFFBIG_LDFLAGS = 1137
|
|
|
|
const _CS_POSIX_V7_ILP32_OFFBIG_LIBS = 1138
|
|
|
|
const _CS_POSIX_V7_ILP32_OFFBIG_LINTFLAGS = 1139
|
|
|
|
const _CS_POSIX_V7_LP64_OFF64_CFLAGS = 1140
|
|
|
|
const _CS_POSIX_V7_LP64_OFF64_LDFLAGS = 1141
|
|
|
|
const _CS_POSIX_V7_LP64_OFF64_LIBS = 1142
|
|
|
|
const _CS_POSIX_V7_LP64_OFF64_LINTFLAGS = 1143
|
|
|
|
const _CS_POSIX_V7_LPBIG_OFFBIG_CFLAGS = 1144
|
|
|
|
const _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS = 1145
|
|
|
|
const _CS_POSIX_V7_LPBIG_OFFBIG_LIBS = 1146
|
|
|
|
const _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS = 1147
|
|
|
|
const _CS_POSIX_V7_THREADS_CFLAGS = 1150
|
|
|
|
const _CS_POSIX_V7_THREADS_LDFLAGS = 1151
|
|
|
|
const _CS_POSIX_V7_WIDTH_RESTRICTED_ENVS = 5
|
|
|
|
const _CS_V6_ENV = 1148
|
|
|
|
const _CS_V7_ENV = 1149
|
|
|
|
const _GNU_SOURCE = 1
|
|
|
|
type _G_fpos64_t = T_G_fpos64_t
|
|
|
|
const _IOC_READ = 2
|
|
|
|
type _IO_cookie_io_functions_t = T_IO_cookie_io_functions_t
|
|
|
|
const _PC_2_SYMLINKS = 20
|
|
|
|
const _PC_ALLOC_SIZE_MIN = 18
|
|
|
|
const _PC_ASYNC_IO = 10
|
|
|
|
const _PC_CHOWN_RESTRICTED = 6
|
|
|
|
const _PC_LINK_MAX = 0
|
|
|
|
const _PC_MAX_CANON = 1
|
|
|
|
const _PC_MAX_INPUT = 2
|
|
|
|
const _PC_NAME_MAX = 3
|
|
|
|
const _PC_NO_TRUNC = 7
|
|
|
|
const _PC_PATH_MAX = 4
|
|
|
|
const _PC_PIPE_BUF = 5
|
|
|
|
const _PC_PRIO_IO = 11
|
|
|
|
const _PC_SOCK_MAXBUF = 12
|
|
|
|
const _PC_SYNC_IO = 9
|
|
|
|
const _PC_VDISABLE = 8
|
|
|
|
const _POSIX2_C_BIND = 200809
|
|
|
|
const _POSIX_ADVISORY_INFO = 200809
|
|
|
|
const _POSIX_ASYNCHRONOUS_IO = 200809
|
|
|
|
const _POSIX_BARRIERS = 200809
|
|
|
|
const _POSIX_CLOCK_SELECTION = 200809
|
|
|
|
const _POSIX_FSYNC = 200809
|
|
|
|
const _POSIX_IPV6 = 200809
|
|
|
|
const _POSIX_MAPPED_FILES = 200809
|
|
|
|
const _POSIX_MEMLOCK = 200809
|
|
|
|
const _POSIX_MEMLOCK_RANGE = 200809
|
|
|
|
const _POSIX_MEMORY_PROTECTION = 200809
|
|
|
|
const _POSIX_MESSAGE_PASSING = 200809
|
|
|
|
const _POSIX_RAW_SOCKETS = 200809
|
|
|
|
const _POSIX_READER_WRITER_LOCKS = 200809
|
|
|
|
const _POSIX_REALTIME_SIGNALS = 200809
|
|
|
|
const _POSIX_SEMAPHORES = 200809
|
|
|
|
const _POSIX_SPIN_LOCKS = 200809
|
|
|
|
const _POSIX_THREADS = 200809
|
|
|
|
const _POSIX_THREAD_ATTR_STACKADDR = 200809
|
|
|
|
const _POSIX_THREAD_ATTR_STACKSIZE = 200809
|
|
|
|
const _POSIX_THREAD_PRIORITY_SCHEDULING = 200809
|
|
|
|
const _POSIX_THREAD_PROCESS_SHARED = 200809
|
|
|
|
const _POSIX_THREAD_SAFE_FUNCTIONS = 200809
|
|
|
|
const _POSIX_TIMEOUTS = 200809
|
|
|
|
const _POSIX_VDISABLE = 0
|
|
|
|
const _SC_2_CHAR_TERM = 95
|
|
|
|
const _SC_2_C_BIND = 47
|
|
|
|
const _SC_2_C_DEV = 48
|
|
|
|
const _SC_2_FORT_DEV = 49
|
|
|
|
const _SC_2_FORT_RUN = 50
|
|
|
|
const _SC_2_LOCALEDEF = 52
|
|
|
|
const _SC_2_PBS = 168
|
|
|
|
const _SC_2_PBS_ACCOUNTING = 169
|
|
|
|
const _SC_2_PBS_CHECKPOINT = 175
|
|
|
|
const _SC_2_PBS_LOCATE = 170
|
|
|
|
const _SC_2_PBS_MESSAGE = 171
|
|
|
|
const _SC_2_PBS_TRACK = 172
|
|
|
|
const _SC_2_SW_DEV = 51
|
|
|
|
const _SC_2_UPE = 97
|
|
|
|
const _SC_2_VERSION = 46
|
|
|
|
const _SC_ADVISORY_INFO = 132
|
|
|
|
const _SC_AIO_LISTIO_MAX = 23
|
|
|
|
const _SC_AIO_MAX = 24
|
|
|
|
const _SC_AIO_PRIO_DELTA_MAX = 25
|
|
|
|
const _SC_ARG_MAX = 0
|
|
|
|
const _SC_ASYNCHRONOUS_IO = 12
|
|
|
|
const _SC_ATEXIT_MAX = 87
|
|
|
|
const _SC_AVPHYS_PAGES = 86
|
|
|
|
const _SC_BARRIERS = 133
|
|
|
|
const _SC_BC_BASE_MAX = 36
|
|
|
|
const _SC_BC_DIM_MAX = 37
|
|
|
|
const _SC_BC_SCALE_MAX = 38
|
|
|
|
const _SC_BC_STRING_MAX = 39
|
|
|
|
const _SC_CHILD_MAX = 1
|
|
|
|
const _SC_CLK_TCK = 2
|
|
|
|
const _SC_CLOCK_SELECTION = 137
|
|
|
|
const _SC_COLL_WEIGHTS_MAX = 40
|
|
|
|
const _SC_CPUTIME = 138
|
|
|
|
const _SC_DELAYTIMER_MAX = 26
|
|
|
|
const _SC_EXPR_NEST_MAX = 42
|
|
|
|
const _SC_FSYNC = 15
|
|
|
|
const _SC_GETGR_R_SIZE_MAX = 69
|
|
|
|
const _SC_GETPW_R_SIZE_MAX = 70
|
|
|
|
const _SC_HOST_NAME_MAX = 180
|
|
|
|
const _SC_IOV_MAX = 60
|
|
|
|
const _SC_IPV6 = 235
|
|
|
|
const _SC_JOB_CONTROL = 7
|
|
|
|
const _SC_LINE_MAX = 43
|
|
|
|
const _SC_LOGIN_NAME_MAX = 71
|
|
|
|
const _SC_MAPPED_FILES = 16
|
|
|
|
const _SC_MEMLOCK = 17
|
|
|
|
const _SC_MEMLOCK_RANGE = 18
|
|
|
|
const _SC_MEMORY_PROTECTION = 19
|
|
|
|
const _SC_MESSAGE_PASSING = 20
|
|
|
|
const _SC_MINSIGSTKSZ = 249
|
|
|
|
const _SC_MONOTONIC_CLOCK = 149
|
|
|
|
const _SC_MQ_OPEN_MAX = 27
|
|
|
|
const _SC_MQ_PRIO_MAX = 28
|
|
|
|
const _SC_NGROUPS_MAX = 3
|
|
|
|
const _SC_NPROCESSORS_CONF = 83
|
|
|
|
const _SC_NPROCESSORS_ONLN = 84
|
|
|
|
const _SC_NZERO = 109
|
|
|
|
const _SC_OPEN_MAX = 4
|
|
|
|
const _SC_PAGESIZE = 30
|
|
|
|
const _SC_PAGE_SIZE = 30
|
|
|
|
const _SC_PASS_MAX = 88
|
|
|
|
const _SC_PHYS_PAGES = 85
|
|
|
|
const _SC_PRIORITIZED_IO = 13
|
|
|
|
const _SC_PRIORITY_SCHEDULING = 10
|
|
|
|
const _SC_RAW_SOCKETS = 236
|
|
|
|
const _SC_READER_WRITER_LOCKS = 153
|
|
|
|
const _SC_REALTIME_SIGNALS = 9
|
|
|
|
const _SC_REGEXP = 155
|
|
|
|
const _SC_RE_DUP_MAX = 44
|
|
|
|
const _SC_RTSIG_MAX = 31
|
|
|
|
const _SC_SAVED_IDS = 8
|
|
|
|
const _SC_SEMAPHORES = 21
|
|
|
|
const _SC_SEM_NSEMS_MAX = 32
|
|
|
|
const _SC_SEM_VALUE_MAX = 33
|
|
|
|
const _SC_SHARED_MEMORY_OBJECTS = 22
|
|
|
|
const _SC_SHELL = 157
|
|
|
|
const _SC_SIGQUEUE_MAX = 34
|
|
|
|
const _SC_SIGSTKSZ = 250
|
|
|
|
const _SC_SPAWN = 159
|
|
|
|
const _SC_SPIN_LOCKS = 154
|
|
|
|
const _SC_SPORADIC_SERVER = 160
|
|
|
|
const _SC_SS_REPL_MAX = 241
|
|
|
|
const _SC_STREAMS = 174
|
|
|
|
const _SC_STREAM_MAX = 5
|
|
|
|
const _SC_SYMLOOP_MAX = 173
|
|
|
|
const _SC_SYNCHRONIZED_IO = 14
|
|
|
|
const _SC_THREADS = 67
|
|
|
|
const _SC_THREAD_CPUTIME = 139
|
|
|
|
const _SC_THREAD_DESTRUCTOR_ITERATIONS = 73
|
|
|
|
const _SC_THREAD_KEYS_MAX = 74
|
|
|
|
const _SC_THREAD_PRIORITY_SCHEDULING = 79
|
|
|
|
const _SC_THREAD_PRIO_INHERIT = 80
|
|
|
|
const _SC_THREAD_PRIO_PROTECT = 81
|
|
|
|
const _SC_THREAD_PROCESS_SHARED = 82
|
|
|
|
const _SC_THREAD_ROBUST_PRIO_INHERIT = 247
|
|
|
|
const _SC_THREAD_ROBUST_PRIO_PROTECT = 248
|
|
|
|
const _SC_THREAD_SAFE_FUNCTIONS = 68
|
|
|
|
const _SC_THREAD_SPORADIC_SERVER = 161
|
|
|
|
const _SC_THREAD_STACK_MIN = 75
|
|
|
|
const _SC_THREAD_THREADS_MAX = 76
|
|
|
|
const _SC_TIMEOUTS = 164
|
|
|
|
const _SC_TIMERS = 11
|
|
|
|
const _SC_TIMER_MAX = 35
|
|
|
|
const _SC_TRACE = 181
|
|
|
|
const _SC_TRACE_EVENT_FILTER = 182
|
|
|
|
const _SC_TRACE_EVENT_NAME_MAX = 242
|
|
|
|
const _SC_TRACE_INHERIT = 183
|
|
|
|
const _SC_TRACE_LOG = 184
|
|
|
|
const _SC_TRACE_NAME_MAX = 243
|
|
|
|
const _SC_TRACE_SYS_MAX = 244
|
|
|
|
const _SC_TRACE_USER_EVENT_MAX = 245
|
|
|
|
const _SC_TTY_NAME_MAX = 72
|
|
|
|
const _SC_TYPED_MEMORY_OBJECTS = 165
|
|
|
|
const _SC_TZNAME_MAX = 6
|
|
|
|
const _SC_UIO_MAXIOV = 60
|
|
|
|
const _SC_V6_ILP32_OFF32 = 176
|
|
|
|
const _SC_V6_ILP32_OFFBIG = 177
|
|
|
|
const _SC_V6_LP64_OFF64 = 178
|
|
|
|
const _SC_V6_LPBIG_OFFBIG = 179
|
|
|
|
const _SC_V7_ILP32_OFF32 = 237
|
|
|
|
const _SC_V7_ILP32_OFFBIG = 238
|
|
|
|
const _SC_V7_LP64_OFF64 = 239
|
|
|
|
const _SC_V7_LPBIG_OFFBIG = 240
|
|
|
|
const _SC_VERSION = 29
|
|
|
|
const _SC_XBS5_ILP32_OFF32 = 125
|
|
|
|
const _SC_XBS5_ILP32_OFFBIG = 126
|
|
|
|
const _SC_XBS5_LP64_OFF64 = 127
|
|
|
|
const _SC_XBS5_LPBIG_OFFBIG = 128
|
|
|
|
const _SC_XOPEN_CRYPT = 92
|
|
|
|
const _SC_XOPEN_ENH_I18N = 93
|
|
|
|
const _SC_XOPEN_LEGACY = 129
|
|
|
|
const _SC_XOPEN_REALTIME = 130
|
|
|
|
const _SC_XOPEN_REALTIME_THREADS = 131
|
|
|
|
const _SC_XOPEN_SHM = 94
|
|
|
|
const _SC_XOPEN_STREAMS = 246
|
|
|
|
const _SC_XOPEN_UNIX = 91
|
|
|
|
const _SC_XOPEN_VERSION = 89
|
|
|
|
const _SC_XOPEN_XCU_VERSION = 90
|
|
|
|
const _SC_XOPEN_XPG2 = 98
|
|
|
|
const _SC_XOPEN_XPG3 = 99
|
|
|
|
const _SC_XOPEN_XPG4 = 100
|
|
|
|
const _STDC_PREDEF_H = 1
|
|
|
|
const _XOPEN_VERSION = 700
|
|
|
|
const __BIG_ENDIAN = 4321
|
|
|
|
const __LITTLE_ENDIAN = 1234
|
|
|
|
const __PDP_ENDIAN = 3412
|
|
|
|
const __STDC_IEC_559_COMPLEX__ = 1
|
|
|
|
const __STDC_IEC_559__ = 1
|
|
|
|
const __STDC_IEC_60559_BFP__ = 201404
|
|
|
|
const __STDC_IEC_60559_COMPLEX__ = 201404
|
|
|
|
const __STDC_ISO_10646__ = 201706
|
|
|
|
const __USE_TIME_BITS64 = 1
|
|
|
|
const __WINT_MAX__ = 4294967295
|
|
|
|
const __gnu_linux__ = 1
|
|
|
|
const __inline = 0
|
|
|
|
const __linux = 1
|
|
|
|
const __linux__ = 1
|
|
|
|
const __tm_gmtoff = 0
|
|
|
|
const __tm_zone = 0
|
|
|
|
var _aAgg = [1]struct {
|
|
FxStep uintptr
|
|
FxFinal uintptr
|
|
FzName uintptr
|
|
}{
|
|
0: {
|
|
FzName: __ccgo_ts + 30226,
|
|
},
|
|
}
|
|
|
|
var _aAlterTableFuncs = [9]TFuncDef{
|
|
0: {
|
|
FnArg: int16(9),
|
|
FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)),
|
|
FzName: __ccgo_ts + 12679,
|
|
},
|
|
1: {
|
|
FnArg: int16(7),
|
|
FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)),
|
|
FzName: __ccgo_ts + 12700,
|
|
},
|
|
2: {
|
|
FnArg: int16(7),
|
|
FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)),
|
|
FzName: __ccgo_ts + 12720,
|
|
},
|
|
3: {
|
|
FnArg: int16(3),
|
|
FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)),
|
|
FzName: __ccgo_ts + 12739,
|
|
},
|
|
4: {
|
|
FnArg: int16(2),
|
|
FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)),
|
|
FzName: __ccgo_ts + 12758,
|
|
},
|
|
5: {
|
|
FnArg: int16(2),
|
|
FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)),
|
|
FzName: __ccgo_ts + 12781,
|
|
},
|
|
6: {
|
|
FnArg: int16(2),
|
|
FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)),
|
|
FzName: __ccgo_ts + 12804,
|
|
},
|
|
7: {
|
|
FnArg: int16(3),
|
|
FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)),
|
|
FzName: __ccgo_ts + 12816,
|
|
},
|
|
8: {
|
|
FnArg: int16(2),
|
|
FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)),
|
|
FzName: __ccgo_ts + 12838,
|
|
},
|
|
}
|
|
|
|
var _aCacheMode = [3]struct {
|
|
Fz uintptr
|
|
Fmode int32
|
|
}{
|
|
0: {
|
|
Fz: __ccgo_ts + 26196,
|
|
Fmode: int32(SQLITE_OPEN_SHAREDCACHE),
|
|
},
|
|
1: {
|
|
Fz: __ccgo_ts + 26203,
|
|
Fmode: int32(SQLITE_OPEN_PRIVATECACHE),
|
|
},
|
|
2: {},
|
|
}
|
|
|
|
var _aDateTimeFuncs = [10]TFuncDef{
|
|
0: {
|
|
FnArg: int16(-int32(1)),
|
|
FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)),
|
|
FpUserData: uintptr(unsafe.Pointer(&_sqlite3Config)),
|
|
FzName: __ccgo_ts + 1291,
|
|
},
|
|
1: {
|
|
FnArg: int16(-int32(1)),
|
|
FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)),
|
|
FpUserData: uintptr(unsafe.Pointer(&_sqlite3Config)),
|
|
FzName: __ccgo_ts + 1311,
|
|
},
|
|
2: {
|
|
FnArg: int16(-int32(1)),
|
|
FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)),
|
|
FpUserData: uintptr(unsafe.Pointer(&_sqlite3Config)),
|
|
FzName: __ccgo_ts + 1519,
|
|
},
|
|
3: {
|
|
FnArg: int16(-int32(1)),
|
|
FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)),
|
|
FpUserData: uintptr(unsafe.Pointer(&_sqlite3Config)),
|
|
FzName: __ccgo_ts + 1524,
|
|
},
|
|
4: {
|
|
FnArg: int16(-int32(1)),
|
|
FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)),
|
|
FpUserData: uintptr(unsafe.Pointer(&_sqlite3Config)),
|
|
FzName: __ccgo_ts + 1529,
|
|
},
|
|
5: {
|
|
FnArg: int16(-int32(1)),
|
|
FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)),
|
|
FpUserData: uintptr(unsafe.Pointer(&_sqlite3Config)),
|
|
FzName: __ccgo_ts + 1538,
|
|
},
|
|
6: {
|
|
FnArg: int16(2),
|
|
FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8) | libc.Int32FromInt32(SQLITE_FUNC_CONSTANT)),
|
|
FpUserData: uintptr(unsafe.Pointer(&_sqlite3Config)),
|
|
FzName: __ccgo_ts + 1547,
|
|
},
|
|
7: {
|
|
FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8)),
|
|
FzName: __ccgo_ts + 1556,
|
|
},
|
|
8: {
|
|
FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8)),
|
|
FzName: __ccgo_ts + 1569,
|
|
},
|
|
9: {
|
|
FfuncFlags: libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_FUNC_BUILTIN) | libc.Int32FromInt32(SQLITE_FUNC_SLOCHNG) | libc.Int32FromInt32(SQLITE_UTF8)),
|
|
FzName: __ccgo_ts + 1587,
|
|
},
|
|
}
|
|
|
|
var _aFunc = [12]struct {
|
|
FxFunc uintptr
|
|
FnArg int8
|
|
FbPure uint8
|
|
FzName uintptr
|
|
}{
|
|
0: {
|
|
FnArg: int8(1),
|
|
FbPure: uint8(1),
|
|
FzName: __ccgo_ts + 30083,
|
|
},
|
|
1: {
|
|
FnArg: int8(1),
|
|
FbPure: uint8(1),
|
|
FzName: __ccgo_ts + 30096,
|
|
},
|
|
2: {
|
|
FnArg: int8(1),
|
|
FbPure: uint8(1),
|
|
FzName: __ccgo_ts + 30109,
|
|
},
|
|
3: {
|
|
FnArg: int8(-int32(1)),
|
|
FbPure: uint8(1),
|
|
FzName: __ccgo_ts + 30122,
|
|
},
|
|
4: {
|
|
FnArg: int8(2),
|
|
FbPure: uint8(1),
|
|
FzName: __ccgo_ts + 30068,
|
|
},
|
|
5: {
|
|
FnArg: int8(3),
|
|
FbPure: uint8(1),
|
|
FzName: __ccgo_ts + 30134,
|
|
},
|
|
6: {
|
|
FnArg: int8(2),
|
|
FbPure: uint8(1),
|
|
FzName: __ccgo_ts + 30052,
|
|
},
|
|
7: {
|
|
FnArg: int8(1),
|
|
FzName: __ccgo_ts + 30157,
|
|
},
|
|
8: {
|
|
FnArg: int8(1),
|
|
FbPure: uint8(1),
|
|
FzName: __ccgo_ts + 30171,
|
|
},
|
|
9: {
|
|
FnArg: int8(7),
|
|
FbPure: uint8(1),
|
|
FzName: __ccgo_ts + 30184,
|
|
},
|
|
10: {
|
|
FnArg: int8(4),
|
|
FbPure: uint8(1),
|
|
FzName: __ccgo_ts + 30198,
|
|
},
|
|
11: {
|
|
FnArg: int8(1),
|
|
FbPure: uint8(1),
|
|
FzName: __ccgo_ts + 30214,
|
|
},
|
|
}
|
|
|
|
var _aMsg = [29]uintptr{
|
|
0: __ccgo_ts + 25383,
|
|
1: __ccgo_ts + 25396,
|
|
3: __ccgo_ts + 25412,
|
|
4: __ccgo_ts + 25437,
|
|
5: __ccgo_ts + 25451,
|
|
6: __ccgo_ts + 25470,
|
|
7: __ccgo_ts + 1674,
|
|
8: __ccgo_ts + 25495,
|
|
9: __ccgo_ts + 25532,
|
|
10: __ccgo_ts + 25544,
|
|
11: __ccgo_ts + 25559,
|
|
12: __ccgo_ts + 25592,
|
|
13: __ccgo_ts + 25610,
|
|
14: __ccgo_ts + 25635,
|
|
15: __ccgo_ts + 25664,
|
|
17: __ccgo_ts + 6267,
|
|
18: __ccgo_ts + 5618,
|
|
19: __ccgo_ts + 25681,
|
|
20: __ccgo_ts + 25699,
|
|
21: __ccgo_ts + 25717,
|
|
23: __ccgo_ts + 25751,
|
|
25: __ccgo_ts + 25772,
|
|
26: __ccgo_ts + 25798,
|
|
27: __ccgo_ts + 25821,
|
|
28: __ccgo_ts + 25842,
|
|
}
|
|
|
|
var _aOp = [4]struct {
|
|
FzOp uintptr
|
|
FeOp uint8
|
|
}{
|
|
0: {
|
|
FzOp: __ccgo_ts + 17840,
|
|
FeOp: uint8(SQLITE_INDEX_CONSTRAINT_MATCH),
|
|
},
|
|
1: {
|
|
FzOp: __ccgo_ts + 17174,
|
|
FeOp: uint8(SQLITE_INDEX_CONSTRAINT_GLOB),
|
|
},
|
|
2: {
|
|
FzOp: __ccgo_ts + 16633,
|
|
FeOp: uint8(SQLITE_INDEX_CONSTRAINT_LIKE),
|
|
},
|
|
3: {
|
|
FzOp: __ccgo_ts + 23962,
|
|
FeOp: uint8(SQLITE_INDEX_CONSTRAINT_REGEXP),
|
|
},
|
|
}
|
|
|
|
var _aOpenMode = [5]struct {
|
|
Fz uintptr
|
|
Fmode int32
|
|
}{
|
|
0: {
|
|
Fz: __ccgo_ts + 26216,
|
|
Fmode: int32(SQLITE_OPEN_READONLY),
|
|
},
|
|
1: {
|
|
Fz: __ccgo_ts + 26219,
|
|
Fmode: int32(SQLITE_OPEN_READWRITE),
|
|
},
|
|
2: {
|
|
Fz: __ccgo_ts + 26222,
|
|
Fmode: libc.Int32FromInt32(SQLITE_OPEN_READWRITE) | libc.Int32FromInt32(SQLITE_OPEN_CREATE),
|
|
},
|
|
3: {
|
|
Fz: __ccgo_ts + 19061,
|
|
Fmode: int32(SQLITE_OPEN_MEMORY),
|
|
},
|
|
4: {},
|
|
}
|
|
|
|
var _aPragmaName = [66]TPragmaName{
|
|
0: {
|
|
FzName: __ccgo_ts + 18060,
|
|
FePragTyp: uint8(PragTyp_ANALYSIS_LIMIT),
|
|
FmPragFlg: uint8(PragFlg_Result0),
|
|
},
|
|
1: {
|
|
FzName: __ccgo_ts + 18075,
|
|
FePragTyp: uint8(PragTyp_HEADER_VALUE),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NoColumns1) | libc.Int32FromInt32(PragFlg_Result0)),
|
|
FiArg: uint64(BTREE_APPLICATION_ID),
|
|
},
|
|
2: {
|
|
FzName: __ccgo_ts + 18090,
|
|
FePragTyp: uint8(PragTyp_AUTO_VACUUM),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
},
|
|
3: {
|
|
FzName: __ccgo_ts + 18102,
|
|
FePragTyp: uint8(PragTyp_FLAG),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
FiArg: uint64(SQLITE_AutoIndex),
|
|
},
|
|
4: {
|
|
FzName: __ccgo_ts + 18118,
|
|
FePragTyp: uint8(PragTyp_BUSY_TIMEOUT),
|
|
FmPragFlg: uint8(PragFlg_Result0),
|
|
FiPragCName: uint8(56),
|
|
FnPragCName: uint8(1),
|
|
},
|
|
5: {
|
|
FzName: __ccgo_ts + 18041,
|
|
FePragTyp: uint8(PragTyp_CACHE_SIZE),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
},
|
|
6: {
|
|
FzName: __ccgo_ts + 18131,
|
|
FePragTyp: uint8(PragTyp_CACHE_SPILL),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
},
|
|
7: {
|
|
FzName: __ccgo_ts + 18143,
|
|
FePragTyp: uint8(PragTyp_CASE_SENSITIVE_LIKE),
|
|
FmPragFlg: uint8(PragFlg_NoColumns),
|
|
},
|
|
8: {
|
|
FzName: __ccgo_ts + 18163,
|
|
FePragTyp: uint8(PragTyp_FLAG),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
FiArg: uint64(SQLITE_CellSizeCk),
|
|
},
|
|
9: {
|
|
FzName: __ccgo_ts + 18179,
|
|
FePragTyp: uint8(PragTyp_FLAG),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
FiArg: uint64(SQLITE_CkptFullFSync),
|
|
},
|
|
10: {
|
|
FzName: __ccgo_ts + 18200,
|
|
FePragTyp: uint8(PragTyp_COLLATION_LIST),
|
|
FmPragFlg: uint8(PragFlg_Result0),
|
|
FiPragCName: uint8(33),
|
|
FnPragCName: uint8(2),
|
|
},
|
|
11: {
|
|
FzName: __ccgo_ts + 18215,
|
|
FePragTyp: uint8(PragTyp_COMPILE_OPTIONS),
|
|
FmPragFlg: uint8(PragFlg_Result0),
|
|
},
|
|
12: {
|
|
FzName: __ccgo_ts + 18231,
|
|
FePragTyp: uint8(PragTyp_FLAG),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
FiArg: libc.Uint64FromInt32(libc.Int32FromInt32(0x00001)) << libc.Int32FromInt32(32),
|
|
},
|
|
13: {
|
|
FzName: __ccgo_ts + 18245,
|
|
FePragTyp: uint8(PragTyp_HEADER_VALUE),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_ReadOnly) | libc.Int32FromInt32(PragFlg_Result0)),
|
|
FiArg: uint64(BTREE_DATA_VERSION),
|
|
},
|
|
14: {
|
|
FzName: __ccgo_ts + 18258,
|
|
FePragTyp: uint8(PragTyp_DATABASE_LIST),
|
|
FmPragFlg: uint8(PragFlg_Result0),
|
|
FiPragCName: uint8(50),
|
|
FnPragCName: uint8(3),
|
|
},
|
|
15: {
|
|
FzName: __ccgo_ts + 18272,
|
|
FePragTyp: uint8(PragTyp_DEFAULT_CACHE_SIZE),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
FiPragCName: uint8(55),
|
|
FnPragCName: uint8(1),
|
|
},
|
|
16: {
|
|
FzName: __ccgo_ts + 18291,
|
|
FePragTyp: uint8(PragTyp_FLAG),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
FiArg: uint64(SQLITE_DeferFKs),
|
|
},
|
|
17: {
|
|
FzName: __ccgo_ts + 18310,
|
|
FePragTyp: uint8(PragTyp_FLAG),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
FiArg: uint64(SQLITE_NullCallback),
|
|
},
|
|
18: {
|
|
FzName: __ccgo_ts + 18333,
|
|
FePragTyp: uint8(PragTyp_ENCODING),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
},
|
|
19: {
|
|
FzName: __ccgo_ts + 18342,
|
|
FePragTyp: uint8(PragTyp_FOREIGN_KEY_CHECK),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)),
|
|
FiPragCName: uint8(43),
|
|
FnPragCName: uint8(4),
|
|
},
|
|
20: {
|
|
FzName: __ccgo_ts + 18360,
|
|
FePragTyp: uint8(PragTyp_FOREIGN_KEY_LIST),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)),
|
|
FnPragCName: uint8(8),
|
|
},
|
|
21: {
|
|
FzName: __ccgo_ts + 18377,
|
|
FePragTyp: uint8(PragTyp_FLAG),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
FiArg: uint64(SQLITE_ForeignKeys),
|
|
},
|
|
22: {
|
|
FzName: __ccgo_ts + 18390,
|
|
FePragTyp: uint8(PragTyp_HEADER_VALUE),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_ReadOnly) | libc.Int32FromInt32(PragFlg_Result0)),
|
|
},
|
|
23: {
|
|
FzName: __ccgo_ts + 18405,
|
|
FePragTyp: uint8(PragTyp_FLAG),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
FiArg: uint64(SQLITE_FullColNames),
|
|
},
|
|
24: {
|
|
FzName: __ccgo_ts + 18423,
|
|
FePragTyp: uint8(PragTyp_FLAG),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
FiArg: uint64(SQLITE_FullFSync),
|
|
},
|
|
25: {
|
|
FzName: __ccgo_ts + 18433,
|
|
FePragTyp: uint8(PragTyp_FUNCTION_LIST),
|
|
FmPragFlg: uint8(PragFlg_Result0),
|
|
FiPragCName: uint8(15),
|
|
FnPragCName: uint8(6),
|
|
},
|
|
26: {
|
|
FzName: __ccgo_ts + 18447,
|
|
FePragTyp: uint8(PragTyp_HARD_HEAP_LIMIT),
|
|
FmPragFlg: uint8(PragFlg_Result0),
|
|
},
|
|
27: {
|
|
FzName: __ccgo_ts + 18463,
|
|
FePragTyp: uint8(PragTyp_FLAG),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
FiArg: uint64(SQLITE_IgnoreChecks),
|
|
},
|
|
28: {
|
|
FzName: __ccgo_ts + 18488,
|
|
FePragTyp: uint8(PragTyp_INCREMENTAL_VACUUM),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_NoColumns)),
|
|
},
|
|
29: {
|
|
FzName: __ccgo_ts + 18507,
|
|
FePragTyp: uint8(PragTyp_INDEX_INFO),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)),
|
|
FiPragCName: uint8(27),
|
|
FnPragCName: uint8(3),
|
|
},
|
|
30: {
|
|
FzName: __ccgo_ts + 18518,
|
|
FePragTyp: uint8(PragTyp_INDEX_LIST),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)),
|
|
FiPragCName: uint8(33),
|
|
FnPragCName: uint8(5),
|
|
},
|
|
31: {
|
|
FzName: __ccgo_ts + 18529,
|
|
FePragTyp: uint8(PragTyp_INDEX_INFO),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)),
|
|
FiPragCName: uint8(27),
|
|
FnPragCName: uint8(6),
|
|
FiArg: uint64(1),
|
|
},
|
|
32: {
|
|
FzName: __ccgo_ts + 18541,
|
|
FePragTyp: uint8(PragTyp_INTEGRITY_CHECK),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)),
|
|
},
|
|
33: {
|
|
FzName: __ccgo_ts + 18557,
|
|
FePragTyp: uint8(PragTyp_JOURNAL_MODE),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq)),
|
|
},
|
|
34: {
|
|
FzName: __ccgo_ts + 18570,
|
|
FePragTyp: uint8(PragTyp_JOURNAL_SIZE_LIMIT),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq)),
|
|
},
|
|
35: {
|
|
FzName: __ccgo_ts + 18589,
|
|
FePragTyp: uint8(PragTyp_FLAG),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
FiArg: uint64(SQLITE_LegacyAlter),
|
|
},
|
|
36: {
|
|
FzName: __ccgo_ts + 18608,
|
|
FePragTyp: uint8(PragTyp_LOCKING_MODE),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq)),
|
|
},
|
|
37: {
|
|
FzName: __ccgo_ts + 18621,
|
|
FePragTyp: uint8(PragTyp_PAGE_COUNT),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq)),
|
|
},
|
|
38: {
|
|
FzName: __ccgo_ts + 18636,
|
|
FePragTyp: uint8(PragTyp_MMAP_SIZE),
|
|
},
|
|
39: {
|
|
FzName: __ccgo_ts + 18646,
|
|
FePragTyp: uint8(PragTyp_MODULE_LIST),
|
|
FmPragFlg: uint8(PragFlg_Result0),
|
|
FiPragCName: uint8(9),
|
|
FnPragCName: uint8(1),
|
|
},
|
|
40: {
|
|
FzName: __ccgo_ts + 18658,
|
|
FePragTyp: uint8(PragTyp_OPTIMIZE),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_NeedSchema)),
|
|
},
|
|
41: {
|
|
FzName: __ccgo_ts + 18667,
|
|
FePragTyp: uint8(PragTyp_PAGE_COUNT),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq)),
|
|
},
|
|
42: {
|
|
FzName: __ccgo_ts + 18678,
|
|
FePragTyp: uint8(PragTyp_PAGE_SIZE),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
},
|
|
43: {
|
|
FzName: __ccgo_ts + 18688,
|
|
FePragTyp: uint8(PragTyp_PRAGMA_LIST),
|
|
FmPragFlg: uint8(PragFlg_Result0),
|
|
FiPragCName: uint8(9),
|
|
FnPragCName: uint8(1),
|
|
},
|
|
44: {
|
|
FzName: __ccgo_ts + 18700,
|
|
FePragTyp: uint8(PragTyp_FLAG),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
FiArg: uint64(SQLITE_QueryOnly),
|
|
},
|
|
45: {
|
|
FzName: __ccgo_ts + 18711,
|
|
FePragTyp: uint8(PragTyp_INTEGRITY_CHECK),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)),
|
|
},
|
|
46: {
|
|
FzName: __ccgo_ts + 18723,
|
|
FePragTyp: uint8(PragTyp_FLAG),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
FiArg: libc.Uint64FromInt32(libc.Int32FromInt32(0x00004)) << libc.Int32FromInt32(32),
|
|
},
|
|
47: {
|
|
FzName: __ccgo_ts + 18740,
|
|
FePragTyp: uint8(PragTyp_FLAG),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
FiArg: uint64(SQLITE_RecTriggers),
|
|
},
|
|
48: {
|
|
FzName: __ccgo_ts + 18759,
|
|
FePragTyp: uint8(PragTyp_FLAG),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
FiArg: uint64(SQLITE_ReverseOrder),
|
|
},
|
|
49: {
|
|
FzName: __ccgo_ts + 18785,
|
|
FePragTyp: uint8(PragTyp_HEADER_VALUE),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NoColumns1) | libc.Int32FromInt32(PragFlg_Result0)),
|
|
FiArg: uint64(BTREE_SCHEMA_VERSION),
|
|
},
|
|
50: {
|
|
FzName: __ccgo_ts + 18800,
|
|
FePragTyp: uint8(PragTyp_SECURE_DELETE),
|
|
FmPragFlg: uint8(PragFlg_Result0),
|
|
},
|
|
51: {
|
|
FzName: __ccgo_ts + 18814,
|
|
FePragTyp: uint8(PragTyp_FLAG),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
FiArg: uint64(SQLITE_ShortColNames),
|
|
},
|
|
52: {
|
|
FzName: __ccgo_ts + 18833,
|
|
FePragTyp: uint8(PragTyp_SHRINK_MEMORY),
|
|
FmPragFlg: uint8(PragFlg_NoColumns),
|
|
},
|
|
53: {
|
|
FzName: __ccgo_ts + 18847,
|
|
FePragTyp: uint8(PragTyp_SOFT_HEAP_LIMIT),
|
|
FmPragFlg: uint8(PragFlg_Result0),
|
|
},
|
|
54: {
|
|
FzName: __ccgo_ts + 18863,
|
|
FePragTyp: uint8(PragTyp_SYNCHRONOUS),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_SchemaReq) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
},
|
|
55: {
|
|
FzName: __ccgo_ts + 18875,
|
|
FePragTyp: uint8(PragTyp_TABLE_INFO),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)),
|
|
FiPragCName: uint8(8),
|
|
FnPragCName: uint8(6),
|
|
},
|
|
56: {
|
|
FzName: __ccgo_ts + 18886,
|
|
FePragTyp: uint8(PragTyp_TABLE_LIST),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result1)),
|
|
FiPragCName: uint8(21),
|
|
FnPragCName: uint8(6),
|
|
},
|
|
57: {
|
|
FzName: __ccgo_ts + 18897,
|
|
FePragTyp: uint8(PragTyp_TABLE_INFO),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NeedSchema) | libc.Int32FromInt32(PragFlg_Result1) | libc.Int32FromInt32(PragFlg_SchemaOpt)),
|
|
FiPragCName: uint8(8),
|
|
FnPragCName: uint8(7),
|
|
FiArg: uint64(1),
|
|
},
|
|
58: {
|
|
FzName: __ccgo_ts + 18909,
|
|
FePragTyp: uint8(PragTyp_TEMP_STORE),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
},
|
|
59: {
|
|
FzName: __ccgo_ts + 18920,
|
|
FePragTyp: uint8(PragTyp_TEMP_STORE_DIRECTORY),
|
|
FmPragFlg: uint8(PragFlg_NoColumns1),
|
|
},
|
|
60: {
|
|
FzName: __ccgo_ts + 18941,
|
|
FePragTyp: uint8(PragTyp_THREADS),
|
|
FmPragFlg: uint8(PragFlg_Result0),
|
|
},
|
|
61: {
|
|
FzName: __ccgo_ts + 18949,
|
|
FePragTyp: uint8(PragTyp_FLAG),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
FiArg: uint64(SQLITE_TrustedSchema),
|
|
},
|
|
62: {
|
|
FzName: __ccgo_ts + 18964,
|
|
FePragTyp: uint8(PragTyp_HEADER_VALUE),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_NoColumns1) | libc.Int32FromInt32(PragFlg_Result0)),
|
|
FiArg: uint64(BTREE_USER_VERSION),
|
|
},
|
|
63: {
|
|
FzName: __ccgo_ts + 18977,
|
|
FePragTyp: uint8(PragTyp_WAL_AUTOCHECKPOINT),
|
|
},
|
|
64: {
|
|
FzName: __ccgo_ts + 18996,
|
|
FePragTyp: uint8(PragTyp_WAL_CHECKPOINT),
|
|
FmPragFlg: uint8(PragFlg_NeedSchema),
|
|
FiPragCName: uint8(47),
|
|
FnPragCName: uint8(3),
|
|
},
|
|
65: {
|
|
FzName: __ccgo_ts + 19011,
|
|
FePragTyp: uint8(PragTyp_FLAG),
|
|
FmPragFlg: libc.Uint8FromInt32(libc.Int32FromInt32(PragFlg_Result0) | libc.Int32FromInt32(PragFlg_NoColumns1)),
|
|
FiArg: libc.Uint64FromInt32(libc.Int32FromInt32(SQLITE_WriteSchema) | libc.Int32FromInt32(SQLITE_NoSchemaError)),
|
|
},
|
|
}
|
|
|
|
/* Number of pragmas: 68 on by default, 78 total. */
|
|
|
|
/************** End of pragma.h **********************************************/
|
|
/************** Continuing where we left off in pragma.c *********************/
|
|
|
|
/*
|
|
** When the 0x10 bit of PRAGMA optimize is set, any ANALYZE commands
|
|
** will be run with an analysis_limit set to the lessor of the value of
|
|
** the following macro or to the actual analysis_limit if it is non-zero,
|
|
** in order to prevent PRAGMA optimize from running for too long.
|
|
**
|
|
** The value of 2000 is chosen empirically so that the worst-case run-time
|
|
** for PRAGMA optimize does not exceed 100 milliseconds against a variety
|
|
** of test databases on a RaspberryPI-4 compiled using -Os and without
|
|
** -DSQLITE_DEBUG. Of course, your mileage may vary. For the purpose of
|
|
** this paragraph, "worst-case" means that ANALYZE ends up being
|
|
** run on every table in the database. The worst case typically only
|
|
** happens if PRAGMA optimize is run on a database file for which ANALYZE
|
|
** has not been previously run and the 0x10000 flag is included so that
|
|
** all tables are analyzed. The usual case for PRAGMA optimize is that
|
|
** no ANALYZE commands will be run at all, or if any ANALYZE happens it
|
|
** will be against a single table, so that expected timing for PRAGMA
|
|
** optimize on a PI-4 is more like 1 millisecond or less with the 0x10000
|
|
** flag or less than 100 microseconds without the 0x10000 flag.
|
|
**
|
|
** An analysis limit of 2000 is almost always sufficient for the query
|
|
** planner to fully characterize an index. The additional accuracy from
|
|
** a larger analysis is not usually helpful.
|
|
*/
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Many system calls are accessed through pointer-to-functions so that
|
|
// ** they may be overridden at runtime to facilitate fault injection during
|
|
// ** testing and sandboxing. The following array holds the names and pointers
|
|
// ** to all overrideable system calls.
|
|
// */
|
|
var _aSyscall = [29]Tunix_syscall{
|
|
0: {
|
|
FzName: __ccgo_ts + 3542,
|
|
},
|
|
1: {
|
|
FzName: __ccgo_ts + 3547,
|
|
},
|
|
2: {
|
|
FzName: __ccgo_ts + 3553,
|
|
},
|
|
3: {
|
|
FzName: __ccgo_ts + 3560,
|
|
},
|
|
4: {
|
|
FzName: __ccgo_ts + 3567,
|
|
},
|
|
5: {
|
|
FzName: __ccgo_ts + 3572,
|
|
},
|
|
6: {
|
|
FzName: __ccgo_ts + 3578,
|
|
},
|
|
7: {
|
|
FzName: __ccgo_ts + 3588,
|
|
},
|
|
8: {
|
|
FzName: __ccgo_ts + 3594,
|
|
},
|
|
9: {
|
|
FzName: __ccgo_ts + 3599,
|
|
},
|
|
10: {
|
|
FzName: __ccgo_ts + 3605,
|
|
},
|
|
11: {
|
|
FzName: __ccgo_ts + 3613,
|
|
},
|
|
12: {
|
|
FzName: __ccgo_ts + 3619,
|
|
},
|
|
13: {
|
|
FzName: __ccgo_ts + 3626,
|
|
},
|
|
14: {
|
|
FzName: __ccgo_ts + 3635,
|
|
},
|
|
15: {
|
|
FzName: __ccgo_ts + 3642,
|
|
},
|
|
16: {
|
|
FzName: __ccgo_ts + 3652,
|
|
},
|
|
17: {
|
|
FzName: __ccgo_ts + 3659,
|
|
},
|
|
18: {
|
|
FzName: __ccgo_ts + 3673,
|
|
},
|
|
19: {
|
|
FzName: __ccgo_ts + 3679,
|
|
},
|
|
20: {
|
|
FzName: __ccgo_ts + 3685,
|
|
},
|
|
21: {
|
|
FzName: __ccgo_ts + 3692,
|
|
},
|
|
22: {
|
|
FzName: __ccgo_ts + 3700,
|
|
},
|
|
23: {
|
|
FzName: __ccgo_ts + 3705,
|
|
},
|
|
24: {
|
|
FzName: __ccgo_ts + 3712,
|
|
},
|
|
25: {
|
|
FzName: __ccgo_ts + 3719,
|
|
},
|
|
26: {
|
|
FzName: __ccgo_ts + 3731,
|
|
},
|
|
27: {
|
|
FzName: __ccgo_ts + 3740,
|
|
},
|
|
28: {
|
|
FzName: __ccgo_ts + 3746,
|
|
},
|
|
}
|
|
|
|
var _aTable = [3]struct {
|
|
FzName uintptr
|
|
FzCols uintptr
|
|
}{
|
|
0: {
|
|
FzName: __ccgo_ts + 12861,
|
|
FzCols: __ccgo_ts + 12874,
|
|
},
|
|
1: {
|
|
FzName: __ccgo_ts + 12887,
|
|
FzCols: __ccgo_ts + 12900,
|
|
},
|
|
2: {
|
|
FzName: __ccgo_ts + 12928,
|
|
},
|
|
}
|
|
|
|
/*
|
|
** Recommended number of samples for sqlite_stat4
|
|
*/
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Implementation of the abs() function.
|
|
// **
|
|
// ** IMP: R-23979-26855 The abs(X) function returns the absolute value of
|
|
// ** the numeric argument X.
|
|
// */
|
|
func _absFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
|
|
var iVal Ti64
|
|
var rVal float64
|
|
_, _ = iVal, rVal
|
|
_ = argc
|
|
switch Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(argv))) {
|
|
case int32(SQLITE_INTEGER):
|
|
iVal = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(argv)))
|
|
if iVal < 0 {
|
|
if iVal == int64(-libc.Int32FromInt32(1))-(libc.Int64FromUint32(0xffffffff)|libc.Int64FromInt32(0x7fffffff)<<libc.Int32FromInt32(32)) {
|
|
/* IMP: R-31676-45509 If X is the integer -9223372036854775808
|
|
** then abs(X) throws an integer overflow error since there is no
|
|
** equivalent positive 64-bit two complement value. */
|
|
Xsqlite3_result_error(tls, context, __ccgo_ts+16486, -int32(1))
|
|
return
|
|
}
|
|
iVal = -iVal
|
|
}
|
|
Xsqlite3_result_int64(tls, context, iVal)
|
|
case int32(SQLITE_NULL):
|
|
/* IMP: R-37434-19929 Abs(X) returns NULL if X is NULL. */
|
|
Xsqlite3_result_null(tls, context)
|
|
default:
|
|
/* Because sqlite3_value_double() returns 0.0 if the argument is not
|
|
** 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.
|
|
*/
|
|
rVal = Xsqlite3_value_double(tls, **(**uintptr)(__ccgo_up(argv)))
|
|
if rVal < libc.Float64FromInt32(0) {
|
|
rVal = -rVal
|
|
}
|
|
Xsqlite3_result_double(tls, context, rVal)
|
|
break
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Return a human-readable name for a constraint resolution action.
|
|
// */
|
|
func _actionName(tls *libc.TLS, action Tu8) (r uintptr) {
|
|
var zName uintptr
|
|
_ = zName
|
|
switch libc.Int32FromUint8(action) {
|
|
case int32(OE_SetNull):
|
|
zName = __ccgo_ts + 19130
|
|
case int32(OE_SetDflt):
|
|
zName = __ccgo_ts + 19139
|
|
case int32(OE_Cascade):
|
|
zName = __ccgo_ts + 19151
|
|
case int32(OE_Restrict):
|
|
zName = __ccgo_ts + 19159
|
|
default:
|
|
zName = __ccgo_ts + 19168
|
|
break
|
|
}
|
|
return zName
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Buffer pCons, which is nCons bytes in size, contains the text of a
|
|
// ** NOT NULL or CHECK constraint that will be inserted into a CREATE TABLE
|
|
// ** statement. If successful, this function returns the size of the buffer in
|
|
// ** bytes not including any trailing whitespace or "--" style comments. Or,
|
|
// ** if an OOM occurs, it returns 0 and sets db->mallocFailed to true.
|
|
// **
|
|
// ** C-style comments at the end are preserved. "--" style comments are
|
|
// ** removed because the comment terminator might be \000, and we are about
|
|
// ** to insert the pCons[] text into the middle of a larger string, and that
|
|
// ** will have the effect of removing the comment terminator and messing up
|
|
// ** the syntax.
|
|
// */
|
|
func _alterRtrimConstraint(tls *libc.TLS, db uintptr, pCons uintptr, nCons int32) (r int32) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var iEnd, iOff, nToken int32
|
|
var zTmp uintptr
|
|
var _ /* t at bp+0 */ int32
|
|
_, _, _, _ = iEnd, iOff, nToken, zTmp
|
|
zTmp = _sqlite3MPrintf(tls, db, __ccgo_ts+12074, libc.VaList(bp+16, nCons, pCons))
|
|
iOff = 0
|
|
iEnd = 0
|
|
if zTmp == uintptr(0) {
|
|
return 0
|
|
}
|
|
for int32(1) != 0 {
|
|
**(**int32)(__ccgo_up(bp)) = 0
|
|
nToken = int32(_sqlite3GetToken(tls, zTmp+uintptr(iOff), bp))
|
|
if **(**int32)(__ccgo_up(bp)) == int32(TK_ILLEGAL) {
|
|
break
|
|
}
|
|
if **(**int32)(__ccgo_up(bp)) != int32(TK_SPACE) && (**(**int32)(__ccgo_up(bp)) != int32(TK_COMMENT) || libc.Int32FromUint8(**(**Tu8)(__ccgo_up(zTmp + uintptr(iOff)))) != int32('-')) {
|
|
iEnd = iOff + nToken
|
|
}
|
|
iOff = iOff + nToken
|
|
}
|
|
_sqlite3DbFree(tls, db, zTmp)
|
|
return iEnd
|
|
}
|
|
|
|
var _attach_func = TFuncDef{
|
|
FnArg: int16(3),
|
|
FfuncFlags: uint32(SQLITE_UTF8),
|
|
FzName: __ccgo_ts + 13553,
|
|
}
|
|
|
|
var _az = [3]uintptr{
|
|
0: __ccgo_ts + 16131,
|
|
1: __ccgo_ts + 16153,
|
|
2: __ccgo_ts + 16137,
|
|
}
|
|
|
|
var _azAlterType = [4]uintptr{
|
|
0: __ccgo_ts + 20005,
|
|
1: __ccgo_ts + 20012,
|
|
2: __ccgo_ts + 20024,
|
|
3: __ccgo_ts + 20035,
|
|
}
|
|
|
|
var _azEnc = [4]uintptr{
|
|
1: __ccgo_ts + 19210,
|
|
2: __ccgo_ts + 19215,
|
|
3: __ccgo_ts + 19223,
|
|
}
|
|
|
|
/* Shared library endings to try if zFile cannot be loaded as written */
|
|
var _azEndings = [1]uintptr{
|
|
0: __ccgo_ts + 17612,
|
|
}
|
|
|
|
var _azErr = [5]uintptr{
|
|
0: __ccgo_ts + 24648,
|
|
1: __ccgo_ts + 24701,
|
|
2: __ccgo_ts + 24203,
|
|
3: __ccgo_ts + 24752,
|
|
4: __ccgo_ts + 24804,
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Column names appropriate for EXPLAIN or EXPLAIN QUERY PLAN.
|
|
// */
|
|
var _azExplainColNames8 = [12]uintptr{
|
|
0: __ccgo_ts + 5641,
|
|
1: __ccgo_ts + 5646,
|
|
2: __ccgo_ts + 5653,
|
|
3: __ccgo_ts + 5656,
|
|
4: __ccgo_ts + 5659,
|
|
5: __ccgo_ts + 5662,
|
|
6: __ccgo_ts + 5665,
|
|
7: __ccgo_ts + 5668,
|
|
8: __ccgo_ts + 5676,
|
|
9: __ccgo_ts + 5679,
|
|
10: __ccgo_ts + 5686,
|
|
11: __ccgo_ts + 5694,
|
|
}
|
|
|
|
var _azFormat = [2]uintptr{
|
|
0: __ccgo_ts + 29012,
|
|
1: __ccgo_ts + 29023,
|
|
}
|
|
|
|
var _azInsType = [3]uintptr{
|
|
0: __ccgo_ts + 26792,
|
|
1: __ccgo_ts + 26799,
|
|
2: __ccgo_ts + 26803,
|
|
}
|
|
|
|
var _azModeName = [6]uintptr{
|
|
0: __ccgo_ts + 19178,
|
|
1: __ccgo_ts + 19185,
|
|
2: __ccgo_ts + 19193,
|
|
3: __ccgo_ts + 19197,
|
|
4: __ccgo_ts + 19061,
|
|
5: __ccgo_ts + 19206,
|
|
}
|
|
|
|
var _azModule = [4]uintptr{
|
|
0: __ccgo_ts + 27390,
|
|
1: __ccgo_ts + 27400,
|
|
2: __ccgo_ts + 27410,
|
|
3: __ccgo_ts + 27421,
|
|
}
|
|
|
|
/* In SQLite core */
|
|
|
|
/* #include <stddef.h> */
|
|
|
|
/*
|
|
** If building separately, we will need some setup that is normally
|
|
** found in sqliteInt.h
|
|
*/
|
|
|
|
/* Macro to check for 4-byte alignment. Only used inside of assert() */
|
|
|
|
/* #include <string.h> */
|
|
/* #include <stdio.h> */
|
|
/* #include <assert.h> */
|
|
/* #include <stdlib.h> */
|
|
|
|
/* The following macro is used to suppress compiler warnings.
|
|
*/
|
|
|
|
var _azName = [192]uintptr{
|
|
0: __ccgo_ts + 1914,
|
|
1: __ccgo_ts + 1924,
|
|
2: __ccgo_ts + 1935,
|
|
3: __ccgo_ts + 1947,
|
|
4: __ccgo_ts + 1958,
|
|
5: __ccgo_ts + 1970,
|
|
6: __ccgo_ts + 1977,
|
|
7: __ccgo_ts + 1985,
|
|
8: __ccgo_ts + 1993,
|
|
9: __ccgo_ts + 1998,
|
|
10: __ccgo_ts + 2003,
|
|
11: __ccgo_ts + 2009,
|
|
12: __ccgo_ts + 2023,
|
|
13: __ccgo_ts + 2029,
|
|
14: __ccgo_ts + 2039,
|
|
15: __ccgo_ts + 2044,
|
|
16: __ccgo_ts + 2049,
|
|
17: __ccgo_ts + 2052,
|
|
18: __ccgo_ts + 2058,
|
|
19: __ccgo_ts + 2065,
|
|
20: __ccgo_ts + 2069,
|
|
21: __ccgo_ts + 2079,
|
|
22: __ccgo_ts + 2086,
|
|
23: __ccgo_ts + 2093,
|
|
24: __ccgo_ts + 2100,
|
|
25: __ccgo_ts + 2107,
|
|
26: __ccgo_ts + 2117,
|
|
27: __ccgo_ts + 2126,
|
|
28: __ccgo_ts + 2137,
|
|
29: __ccgo_ts + 2146,
|
|
30: __ccgo_ts + 2152,
|
|
31: __ccgo_ts + 2162,
|
|
32: __ccgo_ts + 2172,
|
|
33: __ccgo_ts + 2177,
|
|
34: __ccgo_ts + 2191,
|
|
35: __ccgo_ts + 2202,
|
|
36: __ccgo_ts + 2207,
|
|
37: __ccgo_ts + 2214,
|
|
38: __ccgo_ts + 2222,
|
|
39: __ccgo_ts + 2233,
|
|
40: __ccgo_ts + 2238,
|
|
41: __ccgo_ts + 2243,
|
|
42: __ccgo_ts + 2249,
|
|
43: __ccgo_ts + 2255,
|
|
44: __ccgo_ts + 2258,
|
|
45: __ccgo_ts + 2262,
|
|
46: __ccgo_ts + 2268,
|
|
47: __ccgo_ts + 2274,
|
|
48: __ccgo_ts + 2283,
|
|
49: __ccgo_ts + 2294,
|
|
50: __ccgo_ts + 2305,
|
|
51: __ccgo_ts + 2313,
|
|
52: __ccgo_ts + 2320,
|
|
53: __ccgo_ts + 2328,
|
|
54: __ccgo_ts + 2331,
|
|
55: __ccgo_ts + 2334,
|
|
56: __ccgo_ts + 2337,
|
|
57: __ccgo_ts + 2340,
|
|
58: __ccgo_ts + 2343,
|
|
59: __ccgo_ts + 2346,
|
|
60: __ccgo_ts + 2353,
|
|
61: __ccgo_ts + 2362,
|
|
62: __ccgo_ts + 2368,
|
|
63: __ccgo_ts + 2378,
|
|
64: __ccgo_ts + 2391,
|
|
65: __ccgo_ts + 2402,
|
|
66: __ccgo_ts + 2408,
|
|
67: __ccgo_ts + 2415,
|
|
68: __ccgo_ts + 2424,
|
|
69: __ccgo_ts + 2433,
|
|
70: __ccgo_ts + 2440,
|
|
71: __ccgo_ts + 2453,
|
|
72: __ccgo_ts + 2464,
|
|
73: __ccgo_ts + 2469,
|
|
74: __ccgo_ts + 2477,
|
|
75: __ccgo_ts + 2483,
|
|
76: __ccgo_ts + 2490,
|
|
77: __ccgo_ts + 2502,
|
|
78: __ccgo_ts + 2507,
|
|
79: __ccgo_ts + 2516,
|
|
80: __ccgo_ts + 2521,
|
|
81: __ccgo_ts + 2530,
|
|
82: __ccgo_ts + 2535,
|
|
83: __ccgo_ts + 2540,
|
|
84: __ccgo_ts + 2546,
|
|
85: __ccgo_ts + 2554,
|
|
86: __ccgo_ts + 2562,
|
|
87: __ccgo_ts + 2572,
|
|
88: __ccgo_ts + 2580,
|
|
89: __ccgo_ts + 2587,
|
|
90: __ccgo_ts + 2600,
|
|
91: __ccgo_ts + 2605,
|
|
92: __ccgo_ts + 2617,
|
|
93: __ccgo_ts + 2625,
|
|
94: __ccgo_ts + 2632,
|
|
95: __ccgo_ts + 2643,
|
|
96: __ccgo_ts + 2650,
|
|
97: __ccgo_ts + 2657,
|
|
98: __ccgo_ts + 2667,
|
|
99: __ccgo_ts + 2676,
|
|
100: __ccgo_ts + 2687,
|
|
101: __ccgo_ts + 2693,
|
|
102: __ccgo_ts + 2704,
|
|
103: __ccgo_ts + 2714,
|
|
104: __ccgo_ts + 2721,
|
|
105: __ccgo_ts + 2727,
|
|
106: __ccgo_ts + 2737,
|
|
107: __ccgo_ts + 2748,
|
|
108: __ccgo_ts + 2752,
|
|
109: __ccgo_ts + 2761,
|
|
110: __ccgo_ts + 2770,
|
|
111: __ccgo_ts + 2777,
|
|
112: __ccgo_ts + 2787,
|
|
113: __ccgo_ts + 2794,
|
|
114: __ccgo_ts + 2804,
|
|
115: __ccgo_ts + 2813,
|
|
116: __ccgo_ts + 2820,
|
|
117: __ccgo_ts + 2830,
|
|
118: __ccgo_ts + 2838,
|
|
119: __ccgo_ts + 2846,
|
|
120: __ccgo_ts + 2860,
|
|
121: __ccgo_ts + 2874,
|
|
122: __ccgo_ts + 2885,
|
|
123: __ccgo_ts + 2898,
|
|
124: __ccgo_ts + 2909,
|
|
125: __ccgo_ts + 2915,
|
|
126: __ccgo_ts + 2927,
|
|
127: __ccgo_ts + 2936,
|
|
128: __ccgo_ts + 2944,
|
|
129: __ccgo_ts + 2953,
|
|
130: __ccgo_ts + 2962,
|
|
131: __ccgo_ts + 2969,
|
|
132: __ccgo_ts + 2977,
|
|
133: __ccgo_ts + 2984,
|
|
134: __ccgo_ts + 2995,
|
|
135: __ccgo_ts + 3009,
|
|
136: __ccgo_ts + 3020,
|
|
137: __ccgo_ts + 3028,
|
|
138: __ccgo_ts + 3034,
|
|
139: __ccgo_ts + 3042,
|
|
140: __ccgo_ts + 3050,
|
|
141: __ccgo_ts + 3060,
|
|
142: __ccgo_ts + 3073,
|
|
143: __ccgo_ts + 3083,
|
|
144: __ccgo_ts + 3096,
|
|
145: __ccgo_ts + 3105,
|
|
146: __ccgo_ts + 3116,
|
|
147: __ccgo_ts + 3124,
|
|
148: __ccgo_ts + 3130,
|
|
149: __ccgo_ts + 3142,
|
|
150: __ccgo_ts + 3154,
|
|
151: __ccgo_ts + 3162,
|
|
152: __ccgo_ts + 3174,
|
|
153: __ccgo_ts + 3187,
|
|
154: __ccgo_ts + 3197,
|
|
155: __ccgo_ts + 3202,
|
|
156: __ccgo_ts + 3212,
|
|
157: __ccgo_ts + 3224,
|
|
158: __ccgo_ts + 3236,
|
|
159: __ccgo_ts + 3246,
|
|
160: __ccgo_ts + 3252,
|
|
161: __ccgo_ts + 3262,
|
|
162: __ccgo_ts + 3269,
|
|
163: __ccgo_ts + 3281,
|
|
164: __ccgo_ts + 3292,
|
|
165: __ccgo_ts + 3300,
|
|
166: __ccgo_ts + 3309,
|
|
167: __ccgo_ts + 3318,
|
|
168: __ccgo_ts + 3327,
|
|
169: __ccgo_ts + 3334,
|
|
170: __ccgo_ts + 3345,
|
|
171: __ccgo_ts + 3358,
|
|
172: __ccgo_ts + 3368,
|
|
173: __ccgo_ts + 3375,
|
|
174: __ccgo_ts + 3383,
|
|
175: __ccgo_ts + 3392,
|
|
176: __ccgo_ts + 3398,
|
|
177: __ccgo_ts + 3405,
|
|
178: __ccgo_ts + 3413,
|
|
179: __ccgo_ts + 3421,
|
|
180: __ccgo_ts + 3429,
|
|
181: __ccgo_ts + 3439,
|
|
182: __ccgo_ts + 3448,
|
|
183: __ccgo_ts + 3459,
|
|
184: __ccgo_ts + 3470,
|
|
185: __ccgo_ts + 3481,
|
|
186: __ccgo_ts + 3491,
|
|
187: __ccgo_ts + 3497,
|
|
188: __ccgo_ts + 3508,
|
|
189: __ccgo_ts + 3519,
|
|
190: __ccgo_ts + 3524,
|
|
191: __ccgo_ts + 3532,
|
|
}
|
|
|
|
var _azName1 = [3]uintptr{
|
|
0: __ccgo_ts + 27823,
|
|
1: __ccgo_ts + 5679,
|
|
2: __ccgo_ts + 17991,
|
|
}
|
|
|
|
var _azName2 = [5]uintptr{
|
|
0: __ccgo_ts + 40624,
|
|
1: __ccgo_ts + 37615,
|
|
2: __ccgo_ts + 27432,
|
|
3: __ccgo_ts + 38310,
|
|
4: __ccgo_ts + 13072,
|
|
}
|
|
|
|
var _azOne = [1]uintptr{
|
|
0: __ccgo_ts + 11569,
|
|
}
|
|
|
|
var _azSql = [8]uintptr{
|
|
0: __ccgo_ts + 27828,
|
|
1: __ccgo_ts + 27881,
|
|
2: __ccgo_ts + 27926,
|
|
3: __ccgo_ts + 27978,
|
|
4: __ccgo_ts + 28032,
|
|
5: __ccgo_ts + 28077,
|
|
6: __ccgo_ts + 28135,
|
|
7: __ccgo_ts + 28190,
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Directories to consider for temp files.
|
|
// */
|
|
var _azTempDirs = [6]uintptr{
|
|
2: __ccgo_ts + 4025,
|
|
3: __ccgo_ts + 4034,
|
|
4: __ccgo_ts + 4043,
|
|
5: __ccgo_ts + 1743,
|
|
}
|
|
|
|
var _azType = [4]uintptr{
|
|
0: __ccgo_ts + 5850,
|
|
1: __ccgo_ts + 5859,
|
|
2: __ccgo_ts + 5866,
|
|
3: __ccgo_ts + 5872,
|
|
}
|
|
|
|
var _azType1 = [6]uintptr{
|
|
0: __ccgo_ts + 1704,
|
|
1: __ccgo_ts + 14402,
|
|
2: __ccgo_ts + 14408,
|
|
3: __ccgo_ts + 14413,
|
|
4: __ccgo_ts + 14418,
|
|
5: __ccgo_ts + 14408,
|
|
}
|
|
|
|
var _azType2 = [5]uintptr{
|
|
0: __ccgo_ts + 6520,
|
|
1: __ccgo_ts + 6515,
|
|
2: __ccgo_ts + 8515,
|
|
3: __ccgo_ts + 8510,
|
|
4: __ccgo_ts + 1690,
|
|
}
|
|
|
|
var _azTypes = [5]uintptr{
|
|
0: __ccgo_ts + 1174,
|
|
1: __ccgo_ts + 1186,
|
|
2: __ccgo_ts + 1191,
|
|
3: __ccgo_ts + 1169,
|
|
4: __ccgo_ts + 1705,
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Check the integrity of the freelist or of an overflow page list.
|
|
// ** Verify that the number of pages on the list is N.
|
|
// */
|
|
func _checkList(tls *libc.TLS, pCheck uintptr, isFreeList int32, iPage TPgno, N Tu32) {
|
|
bp := tls.Alloc(48)
|
|
defer tls.Free(48)
|
|
var expected, n Tu32
|
|
var i, nErrAtStart int32
|
|
var iFreePage TPgno
|
|
var pOvflData, v2 uintptr
|
|
var _ /* pOvflPage at bp+0 */ uintptr
|
|
_, _, _, _, _, _, _ = expected, i, iFreePage, n, nErrAtStart, pOvflData, v2
|
|
expected = N
|
|
nErrAtStart = (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnErr
|
|
for iPage != uint32(0) && (*TIntegrityCk)(unsafe.Pointer(pCheck)).FmxErr != 0 {
|
|
if _checkRef(tls, pCheck, iPage) != 0 {
|
|
break
|
|
}
|
|
N = N - 1
|
|
if _sqlite3PagerGet(tls, (*TIntegrityCk)(unsafe.Pointer(pCheck)).FpPager, iPage, bp, 0) != 0 {
|
|
_checkAppendMsg(tls, pCheck, __ccgo_ts+4513, libc.VaList(bp+16, iPage))
|
|
break
|
|
}
|
|
pOvflData = _sqlite3PagerGetData(tls, **(**uintptr)(__ccgo_up(bp)))
|
|
if isFreeList != 0 {
|
|
n = _sqlite3Get4byte(tls, pOvflData+4)
|
|
if (*TBtShared)(unsafe.Pointer((*TIntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FautoVacuum != 0 {
|
|
_checkPtrmap(tls, pCheck, iPage, uint8(PTRMAP_FREEPAGE), uint32(0))
|
|
}
|
|
if n > (*TBtShared)(unsafe.Pointer((*TIntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FusableSize/uint32(4)-uint32(2) {
|
|
_checkAppendMsg(tls, pCheck, __ccgo_ts+4535, libc.VaList(bp+16, iPage))
|
|
N = N - 1
|
|
} else {
|
|
i = 0
|
|
for {
|
|
if !(i < libc.Int32FromUint32(n)) {
|
|
break
|
|
}
|
|
iFreePage = _sqlite3Get4byte(tls, pOvflData+uintptr(int32(8)+i*int32(4)))
|
|
if (*TBtShared)(unsafe.Pointer((*TIntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FautoVacuum != 0 {
|
|
_checkPtrmap(tls, pCheck, iFreePage, uint8(PTRMAP_FREEPAGE), uint32(0))
|
|
}
|
|
_checkRef(tls, pCheck, iFreePage)
|
|
goto _1
|
|
_1:
|
|
;
|
|
i = i + 1
|
|
}
|
|
N = N - n
|
|
}
|
|
} else {
|
|
/* If this database supports auto-vacuum and iPage is not the last
|
|
** page in this overflow list, check that the pointer-map entry for
|
|
** the following page matches iPage.
|
|
*/
|
|
if (*TBtShared)(unsafe.Pointer((*TIntegrityCk)(unsafe.Pointer(pCheck)).FpBt)).FautoVacuum != 0 && N > uint32(0) {
|
|
i = libc.Int32FromUint32(_sqlite3Get4byte(tls, pOvflData))
|
|
_checkPtrmap(tls, pCheck, libc.Uint32FromInt32(i), uint8(PTRMAP_OVERFLOW2), iPage)
|
|
}
|
|
}
|
|
iPage = _sqlite3Get4byte(tls, pOvflData)
|
|
_sqlite3PagerUnref(tls, **(**uintptr)(__ccgo_up(bp)))
|
|
}
|
|
if N != 0 && nErrAtStart == (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnErr {
|
|
if isFreeList != 0 {
|
|
v2 = __ccgo_ts + 4574
|
|
} else {
|
|
v2 = __ccgo_ts + 4579
|
|
}
|
|
_checkAppendMsg(tls, pCheck, __ccgo_ts+4600, libc.VaList(bp+16, v2, expected-N, expected))
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Check that the entry in the pointer-map for page iChild maps to
|
|
// ** page iParent, pointer type ptrType. If not, append an error message
|
|
// ** to pCheck.
|
|
// */
|
|
func _checkPtrmap(tls *libc.TLS, pCheck uintptr, iChild TPgno, eType Tu8, iParent TPgno) {
|
|
bp := tls.Alloc(64)
|
|
defer tls.Free(64)
|
|
var rc int32
|
|
var _ /* ePtrmapType at bp+0 */ Tu8
|
|
var _ /* iPtrmapParent at bp+4 */ TPgno
|
|
_ = rc
|
|
rc = _ptrmapGet(tls, (*TIntegrityCk)(unsafe.Pointer(pCheck)).FpBt, iChild, bp, bp+4)
|
|
if rc != SQLITE_OK {
|
|
if rc == int32(SQLITE_NOMEM) || rc == libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(12)<<libc.Int32FromInt32(8) {
|
|
_checkOom(tls, pCheck)
|
|
}
|
|
_checkAppendMsg(tls, pCheck, __ccgo_ts+4430, libc.VaList(bp+16, iChild))
|
|
return
|
|
}
|
|
if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(bp))) != libc.Int32FromUint8(eType) || **(**TPgno)(__ccgo_up(bp + 4)) != iParent {
|
|
_checkAppendMsg(tls, pCheck, __ccgo_ts+4459, libc.VaList(bp+16, iChild, libc.Int32FromUint8(eType), iParent, libc.Int32FromUint8(**(**Tu8)(__ccgo_up(bp))), **(**TPgno)(__ccgo_up(bp + 4))))
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Check that there is no open read-transaction on the b-tree passed as the
|
|
// ** second argument. If there is not, return SQLITE_OK. Otherwise, if there
|
|
// ** is an open read-transaction, return SQLITE_ERROR and leave an error
|
|
// ** message in database handle db.
|
|
// */
|
|
func _checkReadTransaction(tls *libc.TLS, db uintptr, p uintptr) (r int32) {
|
|
if _sqlite3BtreeTxnState(tls, p) != SQLITE_TXN_NONE {
|
|
_sqlite3ErrorWithMsg(tls, db, int32(SQLITE_ERROR), __ccgo_ts+5173, 0)
|
|
return int32(SQLITE_ERROR)
|
|
}
|
|
return SQLITE_OK
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Add 1 to the reference count for page iPage. If this is the second
|
|
// ** reference to the page, add an error message to pCheck->zErrMsg.
|
|
// ** Return 1 if there are 2 or more references to the page and 0 if
|
|
// ** if this is the first reference to the page.
|
|
// **
|
|
// ** Also check that the page number is in bounds.
|
|
// */
|
|
func _checkRef(tls *libc.TLS, pCheck uintptr, iPage TPgno) (r int32) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
if iPage > (*TIntegrityCk)(unsafe.Pointer(pCheck)).FnCkPage || iPage == uint32(0) {
|
|
_checkAppendMsg(tls, pCheck, __ccgo_ts+4382, libc.VaList(bp+8, iPage))
|
|
return int32(1)
|
|
}
|
|
if _getPageReferenced(tls, pCheck, iPage) != 0 {
|
|
_checkAppendMsg(tls, pCheck, __ccgo_ts+4405, libc.VaList(bp+8, iPage))
|
|
return int32(1)
|
|
}
|
|
_setPageReferenced(tls, pCheck, iPage)
|
|
return 0
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** The CONCAT(...) function. Generate a string result that is the
|
|
// ** concatentation of all non-null arguments.
|
|
// */
|
|
func _concatFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
|
|
_concatFuncCore(tls, context, argc, argv, 0, __ccgo_ts+1704)
|
|
}
|
|
|
|
var _detach_func = TFuncDef{
|
|
FnArg: int16(1),
|
|
FfuncFlags: uint32(SQLITE_UTF8),
|
|
FzName: __ccgo_ts + 13539,
|
|
}
|
|
|
|
func _disallowAggregatesInOrderByCb(tls *libc.TLS, pWalker uintptr, pExpr uintptr) (r int32) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pExpr)).Fop) == int32(TK_AGG_FUNCTION) && (*TExpr)(unsafe.Pointer(pExpr)).FpAggInfo == uintptr(0) {
|
|
_sqlite3ErrorMsg(tls, (*TWalker)(unsafe.Pointer(pWalker)).FpParse, __ccgo_ts+24457, libc.VaList(bp+8, *(*uintptr)(unsafe.Pointer(pExpr + 8))))
|
|
}
|
|
return WRC_Continue
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Lock the file with the lock specified by parameter eFileLock - one
|
|
// ** of the following:
|
|
// **
|
|
// ** (1) SHARED_LOCK
|
|
// ** (2) RESERVED_LOCK
|
|
// ** (3) PENDING_LOCK
|
|
// ** (4) EXCLUSIVE_LOCK
|
|
// **
|
|
// ** Sometimes when requesting one lock state, additional lock states
|
|
// ** are inserted in between. The locking might fail on one of the later
|
|
// ** transitions leaving the lock state different from what it started but
|
|
// ** still short of its goal. The following chart shows the allowed
|
|
// ** transitions and the inserted intermediate states:
|
|
// **
|
|
// ** UNLOCKED -> SHARED
|
|
// ** SHARED -> RESERVED
|
|
// ** SHARED -> (PENDING) -> EXCLUSIVE
|
|
// ** RESERVED -> (PENDING) -> EXCLUSIVE
|
|
// ** PENDING -> EXCLUSIVE
|
|
// **
|
|
// ** This routine will only increase a lock. Use the sqlite3OsUnlock()
|
|
// ** routine to lower a locking level.
|
|
// **
|
|
// ** With dotfile locking, we really only support state (4): EXCLUSIVE.
|
|
// ** But we track the other locking levels internally.
|
|
// */
|
|
func _dotlockLock(tls *libc.TLS, id uintptr, eFileLock int32) (r int32) {
|
|
var pFile, zLockFile uintptr
|
|
var rc, tErrno int32
|
|
_, _, _, _ = pFile, rc, tErrno, zLockFile
|
|
pFile = id
|
|
zLockFile = (*TunixFile)(unsafe.Pointer(pFile)).FlockingContext
|
|
rc = 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 libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) > NO_LOCK {
|
|
(*TunixFile)(unsafe.Pointer(pFile)).FeFileLock = libc.Uint8FromInt32(eFileLock)
|
|
/* Always update the timestamp on the old file */
|
|
libc.Xutimes(tls, zLockFile, libc.UintptrFromInt32(0))
|
|
return SQLITE_OK
|
|
}
|
|
/* grab an exclusive lock */
|
|
rc = (*(*func(*libc.TLS, uintptr, Tmode_t) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(18)].FpCurrent})))(tls, zLockFile, uint32(0777))
|
|
if rc < 0 {
|
|
/* failed to open/create the lock directory */
|
|
tErrno = **(**int32)(__ccgo_up(libc.X__errno_location(tls)))
|
|
if int32(EEXIST) == tErrno {
|
|
rc = int32(SQLITE_BUSY)
|
|
} else {
|
|
rc = _sqliteErrorFromPosixError(tls, tErrno, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(15)<<libc.Int32FromInt32(8))
|
|
if rc != int32(SQLITE_BUSY) {
|
|
_storeLastErrno(tls, pFile, tErrno)
|
|
}
|
|
}
|
|
return rc
|
|
}
|
|
/* got it, set the type and return ok */
|
|
(*TunixFile)(unsafe.Pointer(pFile)).FeFileLock = libc.Uint8FromInt32(eFileLock)
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Lower the locking level on file descriptor pFile to eFileLock. eFileLock
|
|
// ** must be either NO_LOCK or SHARED_LOCK.
|
|
// **
|
|
// ** If the locking level of the file descriptor is already at or below
|
|
// ** the requested locking level, this routine is a no-op.
|
|
// **
|
|
// ** When the locking level reaches NO_LOCK, delete the lock file.
|
|
// */
|
|
func _dotlockUnlock(tls *libc.TLS, id uintptr, eFileLock int32) (r int32) {
|
|
var pFile, zLockFile uintptr
|
|
var rc, tErrno int32
|
|
_, _, _, _ = pFile, rc, tErrno, zLockFile
|
|
pFile = id
|
|
zLockFile = (*TunixFile)(unsafe.Pointer(pFile)).FlockingContext
|
|
/* no-op if possible */
|
|
if libc.Int32FromUint8((*TunixFile)(unsafe.Pointer(pFile)).FeFileLock) == eFileLock {
|
|
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 == int32(SHARED_LOCK) {
|
|
(*TunixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(SHARED_LOCK)
|
|
return SQLITE_OK
|
|
}
|
|
/* To fully unlock the database, delete the lock file */
|
|
rc = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(19)].FpCurrent})))(tls, zLockFile)
|
|
if rc < 0 {
|
|
tErrno = **(**int32)(__ccgo_up(libc.X__errno_location(tls)))
|
|
if tErrno == int32(ENOENT) {
|
|
rc = SQLITE_OK
|
|
} else {
|
|
rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(8)<<libc.Int32FromInt32(8)
|
|
_storeLastErrno(tls, pFile, tErrno)
|
|
}
|
|
return rc
|
|
}
|
|
(*TunixFile)(unsafe.Pointer(pFile)).FeFileLock = uint8(NO_LOCK)
|
|
return SQLITE_OK
|
|
}
|
|
|
|
var _encnames = [4]uintptr{
|
|
0: __ccgo_ts + 5287,
|
|
1: __ccgo_ts + 5289,
|
|
2: __ccgo_ts + 5291,
|
|
3: __ccgo_ts + 5296,
|
|
}
|
|
|
|
var _encnames1 = [9]struct {
|
|
FzName uintptr
|
|
Fenc Tu8
|
|
}{
|
|
0: {
|
|
FzName: __ccgo_ts + 19820,
|
|
Fenc: uint8(SQLITE_UTF8),
|
|
},
|
|
1: {
|
|
FzName: __ccgo_ts + 19825,
|
|
Fenc: uint8(SQLITE_UTF8),
|
|
},
|
|
2: {
|
|
FzName: __ccgo_ts + 19831,
|
|
Fenc: uint8(SQLITE_UTF16LE),
|
|
},
|
|
3: {
|
|
FzName: __ccgo_ts + 19840,
|
|
Fenc: uint8(SQLITE_UTF16BE),
|
|
},
|
|
4: {
|
|
FzName: __ccgo_ts + 19849,
|
|
Fenc: uint8(SQLITE_UTF16LE),
|
|
},
|
|
5: {
|
|
FzName: __ccgo_ts + 19857,
|
|
Fenc: uint8(SQLITE_UTF16BE),
|
|
},
|
|
6: {
|
|
FzName: __ccgo_ts + 19865,
|
|
},
|
|
7: {
|
|
FzName: __ccgo_ts + 19872,
|
|
},
|
|
8: {},
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** This routine is a helper for explainIndexRange() below
|
|
// **
|
|
// ** pStr holds the text of an expression that we are building up one term
|
|
// ** at a time. This routine adds a new term to the end of the expression.
|
|
// ** Terms are separated by AND so add the "AND" text for second and subsequent
|
|
// ** terms only.
|
|
// */
|
|
func _explainAppendTerm(tls *libc.TLS, pStr uintptr, pIdx uintptr, nTerm int32, iTerm int32, bAnd int32, zOp uintptr) {
|
|
var i int32
|
|
_ = i
|
|
if bAnd != 0 {
|
|
Xsqlite3_str_append(tls, pStr, __ccgo_ts+23653, int32(5))
|
|
}
|
|
if nTerm > int32(1) {
|
|
Xsqlite3_str_append(tls, pStr, __ccgo_ts+23659, int32(1))
|
|
}
|
|
i = 0
|
|
for {
|
|
if !(i < nTerm) {
|
|
break
|
|
}
|
|
if i != 0 {
|
|
Xsqlite3_str_append(tls, pStr, __ccgo_ts+14374, int32(1))
|
|
}
|
|
Xsqlite3_str_appendall(tls, pStr, _explainIndexColumnName(tls, pIdx, iTerm+i))
|
|
goto _1
|
|
_1:
|
|
;
|
|
i = i + 1
|
|
}
|
|
if nTerm > int32(1) {
|
|
Xsqlite3_str_append(tls, pStr, __ccgo_ts+5285, int32(1))
|
|
}
|
|
Xsqlite3_str_append(tls, pStr, zOp, int32(1))
|
|
if nTerm > int32(1) {
|
|
Xsqlite3_str_append(tls, pStr, __ccgo_ts+23659, int32(1))
|
|
}
|
|
i = 0
|
|
for {
|
|
if !(i < nTerm) {
|
|
break
|
|
}
|
|
if i != 0 {
|
|
Xsqlite3_str_append(tls, pStr, __ccgo_ts+14374, int32(1))
|
|
}
|
|
Xsqlite3_str_append(tls, pStr, __ccgo_ts+5287, int32(1))
|
|
goto _2
|
|
_2:
|
|
;
|
|
i = i + 1
|
|
}
|
|
if nTerm > int32(1) {
|
|
Xsqlite3_str_append(tls, pStr, __ccgo_ts+5285, int32(1))
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Argument pLevel describes a strategy for scanning table pTab. This
|
|
// ** function appends text to pStr that describes the subset of table
|
|
// ** rows scanned by the strategy in the form of an SQL expression.
|
|
// **
|
|
// ** For example, if the query:
|
|
// **
|
|
// ** SELECT * FROM t1 WHERE a=1 AND b>2;
|
|
// **
|
|
// ** is run and there is an index on (a, b), then this function returns a
|
|
// ** string similar to:
|
|
// **
|
|
// ** "a=? AND b>?"
|
|
// */
|
|
func _explainIndexRange(tls *libc.TLS, pStr uintptr, pLoop uintptr) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var i, j int32
|
|
var nEq, nSkip Tu16
|
|
var pIndex, z, v2 uintptr
|
|
_, _, _, _, _, _, _ = i, j, nEq, nSkip, pIndex, z, v2
|
|
pIndex = (*(*struct {
|
|
FnEq Tu16
|
|
FnBtm Tu16
|
|
FnTop Tu16
|
|
FnDistinctCol Tu16
|
|
FpIndex uintptr
|
|
FpOrderBy uintptr
|
|
})(unsafe.Pointer(pLoop + 24))).FpIndex
|
|
nEq = (*(*struct {
|
|
FnEq Tu16
|
|
FnBtm Tu16
|
|
FnTop Tu16
|
|
FnDistinctCol Tu16
|
|
FpIndex uintptr
|
|
FpOrderBy uintptr
|
|
})(unsafe.Pointer(pLoop + 24))).FnEq
|
|
nSkip = (*TWhereLoop)(unsafe.Pointer(pLoop)).FnSkip
|
|
if libc.Int32FromUint16(nEq) == 0 && (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&libc.Uint32FromInt32(libc.Int32FromInt32(WHERE_BTM_LIMIT)|libc.Int32FromInt32(WHERE_TOP_LIMIT)) == uint32(0) {
|
|
return
|
|
}
|
|
Xsqlite3_str_append(tls, pStr, __ccgo_ts+23661, int32(2))
|
|
i = 0
|
|
for {
|
|
if !(i < libc.Int32FromUint16(nEq)) {
|
|
break
|
|
}
|
|
z = _explainIndexColumnName(tls, pIndex, i)
|
|
if i != 0 {
|
|
Xsqlite3_str_append(tls, pStr, __ccgo_ts+23653, int32(5))
|
|
}
|
|
if i >= libc.Int32FromUint16(nSkip) {
|
|
v2 = __ccgo_ts + 23664
|
|
} else {
|
|
v2 = __ccgo_ts + 23669
|
|
}
|
|
Xsqlite3_str_appendf(tls, pStr, v2, libc.VaList(bp+8, z))
|
|
goto _1
|
|
_1:
|
|
;
|
|
i = i + 1
|
|
}
|
|
j = i
|
|
if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_BTM_LIMIT) != 0 {
|
|
_explainAppendTerm(tls, pStr, pIndex, libc.Int32FromUint16((*(*struct {
|
|
FnEq Tu16
|
|
FnBtm Tu16
|
|
FnTop Tu16
|
|
FnDistinctCol Tu16
|
|
FpIndex uintptr
|
|
FpOrderBy uintptr
|
|
})(unsafe.Pointer(pLoop + 24))).FnBtm), j, i, __ccgo_ts+23677)
|
|
i = int32(1)
|
|
}
|
|
if (*TWhereLoop)(unsafe.Pointer(pLoop)).FwsFlags&uint32(WHERE_TOP_LIMIT) != 0 {
|
|
_explainAppendTerm(tls, pStr, pIndex, libc.Int32FromUint16((*(*struct {
|
|
FnEq Tu16
|
|
FnBtm Tu16
|
|
FnTop Tu16
|
|
FnDistinctCol Tu16
|
|
FpIndex uintptr
|
|
FpOrderBy uintptr
|
|
})(unsafe.Pointer(pLoop + 24))).FnTop), j, i, __ccgo_ts+23679)
|
|
}
|
|
Xsqlite3_str_append(tls, pStr, __ccgo_ts+5285, int32(1))
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Unless an "EXPLAIN QUERY PLAN" command is being processed, this function
|
|
// ** is a no-op. Otherwise, it adds a single row of output to the EQP result,
|
|
// ** where the caption is of the form:
|
|
// **
|
|
// ** "USE TEMP B-TREE FOR xxx"
|
|
// **
|
|
// ** where xxx is one of "DISTINCT", "ORDER BY" or "GROUP BY". Exactly which
|
|
// ** is determined by the zUsage argument.
|
|
// */
|
|
func _explainTempTable(tls *libc.TLS, pParse uintptr, zUsage uintptr) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
_sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+20546, libc.VaList(bp+8, zUsage))
|
|
}
|
|
|
|
/*
|
|
** Assign expression b to lvalue a. A second, no-op, version of this macro
|
|
** is provided when SQLITE_OMIT_EXPLAIN is defined. This allows the code
|
|
** in sqlite3Select() to assign values to structure member variables that
|
|
** only exist if SQLITE_OMIT_EXPLAIN is not defined without polluting the
|
|
** code with #ifndef directives.
|
|
*/
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Implementation of the fts5() function used by clients to obtain the
|
|
// ** API pointer.
|
|
// */
|
|
func _fts5Fts5Func(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
|
|
var pGlobal, ppApi uintptr
|
|
_, _ = pGlobal, ppApi
|
|
pGlobal = Xsqlite3_user_data(tls, pCtx)
|
|
_ = nArg
|
|
ppApi = Xsqlite3_value_pointer(tls, **(**uintptr)(__ccgo_up(apArg)), __ccgo_ts+40520)
|
|
if ppApi != 0 {
|
|
**(**uintptr)(__ccgo_up(ppApi)) = pGlobal
|
|
}
|
|
}
|
|
|
|
func _fts5IndexCorruptIdx(tls *libc.TLS, pIdx uintptr) (r int32) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
(*TFts5Index)(unsafe.Pointer(pIdx)).Frc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<<libc.Int32FromInt32(8)
|
|
_sqlite3Fts5ConfigErrmsg(tls, (*TFts5Index)(unsafe.Pointer(pIdx)).FpConfig, __ccgo_ts+38935, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(pIdx)).FpConfig)).FzName))
|
|
return libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<<libc.Int32FromInt32(8)
|
|
}
|
|
|
|
/* Size (in bytes) of an Fts5DlidxIter object with up to N levels */
|
|
|
|
func _fts5IndexCorruptIter(tls *libc.TLS, pIdx uintptr, pIter uintptr) (r int32) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
(*TFts5Index)(unsafe.Pointer(pIdx)).Frc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<<libc.Int32FromInt32(8)
|
|
_sqlite3Fts5ConfigErrmsg(tls, (*TFts5Index)(unsafe.Pointer(pIdx)).FpConfig, __ccgo_ts+38883, libc.VaList(bp+8, (*TFts5SegIter)(unsafe.Pointer(pIter)).FiLeafPgno, (*TFts5StructureSegment)(unsafe.Pointer((*TFts5SegIter)(unsafe.Pointer(pIter)).FpSeg)).FiSegid, (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(pIdx)).FpConfig)).FzName))
|
|
return libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<<libc.Int32FromInt32(8)
|
|
}
|
|
|
|
func _fts5IndexCorruptRowid(tls *libc.TLS, pIdx uintptr, iRowid Ti64) (r int32) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
(*TFts5Index)(unsafe.Pointer(pIdx)).Frc = libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<<libc.Int32FromInt32(8)
|
|
_sqlite3Fts5ConfigErrmsg(tls, (*TFts5Index)(unsafe.Pointer(pIdx)).FpConfig, __ccgo_ts+38826, libc.VaList(bp+8, iRowid, (*TFts5Config)(unsafe.Pointer((*TFts5Index)(unsafe.Pointer(pIdx)).FpConfig)).FzName))
|
|
return libc.Int32FromInt32(SQLITE_CORRUPT) | libc.Int32FromInt32(1)<<libc.Int32FromInt32(8)
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Run an integrity check on the FTS5 data structures. Return a string
|
|
// ** if anything is found amiss. Return a NULL pointer if everything is
|
|
// ** OK.
|
|
// */
|
|
func _fts5IntegrityMethod(tls *libc.TLS, pVtab uintptr, zSchema uintptr, zTabname uintptr, isQuick int32, pzErr uintptr) (r int32) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var pTab uintptr
|
|
var rc, v1 int32
|
|
_, _, _ = pTab, rc, v1
|
|
pTab = pVtab
|
|
_ = isQuick
|
|
(*TFts5Config)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FpzErrmsg = pzErr
|
|
rc = _sqlite3Fts5StorageIntegrity(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, 0)
|
|
if **(**uintptr)(__ccgo_up(pzErr)) == uintptr(0) && rc != SQLITE_OK {
|
|
if rc&int32(0xff) == int32(SQLITE_CORRUPT) {
|
|
**(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+40631, libc.VaList(bp+8, zSchema, zTabname))
|
|
if **(**uintptr)(__ccgo_up(pzErr)) != 0 {
|
|
v1 = SQLITE_OK
|
|
} else {
|
|
v1 = int32(SQLITE_NOMEM)
|
|
}
|
|
rc = v1
|
|
} else {
|
|
**(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+40677, libc.VaList(bp+8, zSchema, zTabname, Xsqlite3_errstr(tls, rc)))
|
|
}
|
|
} else {
|
|
if rc&int32(0xff) == int32(SQLITE_CORRUPT) {
|
|
rc = SQLITE_OK
|
|
}
|
|
}
|
|
_sqlite3Fts5IndexCloseReader(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex)
|
|
(*TFts5Config)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FpzErrmsg = uintptr(0)
|
|
return rc
|
|
}
|
|
|
|
func _fts5PrepareStatement(tls *libc.TLS, ppStmt uintptr, pConfig uintptr, zFmt uintptr, va uintptr) (r int32) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var ap Tva_list
|
|
var rc int32
|
|
var zSql uintptr
|
|
var _ /* pRet at bp+0 */ uintptr
|
|
_, _, _ = ap, rc, zSql
|
|
**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
|
|
ap = va
|
|
zSql = Xsqlite3_vmprintf(tls, zFmt, ap)
|
|
if zSql == uintptr(0) {
|
|
rc = int32(SQLITE_NOMEM)
|
|
} else {
|
|
rc = Xsqlite3_prepare_v3(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, zSql, -int32(1), uint32(SQLITE_PREPARE_PERSISTENT), bp, uintptr(0))
|
|
if rc != SQLITE_OK {
|
|
_sqlite3Fts5ConfigErrmsg(tls, pConfig, __ccgo_ts+3968, libc.VaList(bp+16, Xsqlite3_errmsg(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb)))
|
|
}
|
|
Xsqlite3_free(tls, zSql)
|
|
}
|
|
_ = ap
|
|
**(**uintptr)(__ccgo_up(ppStmt)) = **(**uintptr)(__ccgo_up(bp))
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Implementation of fts5_source_id() function.
|
|
// */
|
|
func _fts5SourceIdFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apUnused uintptr) {
|
|
_ = nArg
|
|
_ = apUnused
|
|
Xsqlite3_result_text(tls, pCtx, __ccgo_ts+40533, -int32(1), uintptr(-libc.Int32FromInt32(1)))
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** This function is called to handle an FTS INSERT command. In other words,
|
|
// ** an INSERT statement of the form:
|
|
// **
|
|
// ** INSERT INTO fts(fts) VALUES($pCmd)
|
|
// ** INSERT INTO fts(fts, rank) VALUES($pCmd, $pVal)
|
|
// **
|
|
// ** Argument pVal is the value assigned to column "fts" by the INSERT
|
|
// ** statement. This function returns SQLITE_OK if successful, or an SQLite
|
|
// ** error code if an error occurs.
|
|
// **
|
|
// ** The commands implemented by this function are documented in the "Special
|
|
// ** INSERT Directives" section of the documentation. It should be updated if
|
|
// ** more commands are added to this function.
|
|
// */
|
|
func _fts5SpecialInsert(tls *libc.TLS, pTab uintptr, zCmd uintptr, pVal uintptr) (r int32) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var bLoadConfig, iArg, nMerge, rc int32
|
|
var pConfig uintptr
|
|
var _ /* bError at bp+0 */ int32
|
|
_, _, _, _, _ = bLoadConfig, iArg, nMerge, pConfig, rc
|
|
pConfig = (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig
|
|
rc = SQLITE_OK
|
|
**(**int32)(__ccgo_up(bp)) = 0
|
|
bLoadConfig = 0
|
|
if 0 == Xsqlite3_stricmp(tls, __ccgo_ts+40022, zCmd) {
|
|
if (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL {
|
|
_fts5SetVtabError(tls, pTab, __ccgo_ts+40033, 0)
|
|
rc = int32(SQLITE_ERROR)
|
|
} else {
|
|
rc = _sqlite3Fts5StorageDeleteAll(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage)
|
|
}
|
|
bLoadConfig = int32(1)
|
|
} else {
|
|
if 0 == Xsqlite3_stricmp(tls, __ccgo_ts+40113, zCmd) {
|
|
if _fts5IsContentless(tls, pTab, int32(1)) != 0 {
|
|
_fts5SetVtabError(tls, pTab, __ccgo_ts+40121, 0)
|
|
rc = int32(SQLITE_ERROR)
|
|
} else {
|
|
rc = _sqlite3Fts5StorageRebuild(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage)
|
|
}
|
|
bLoadConfig = int32(1)
|
|
} else {
|
|
if 0 == Xsqlite3_stricmp(tls, __ccgo_ts+18658, zCmd) {
|
|
rc = _sqlite3Fts5StorageOptimize(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage)
|
|
} else {
|
|
if 0 == Xsqlite3_stricmp(tls, __ccgo_ts+40177, zCmd) {
|
|
nMerge = Xsqlite3_value_int(tls, pVal)
|
|
rc = _sqlite3Fts5StorageMerge(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, nMerge)
|
|
} else {
|
|
if 0 == Xsqlite3_stricmp(tls, __ccgo_ts+40183, zCmd) {
|
|
iArg = Xsqlite3_value_int(tls, pVal)
|
|
rc = _sqlite3Fts5StorageIntegrity(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, iArg)
|
|
} else {
|
|
if 0 == Xsqlite3_stricmp(tls, __ccgo_ts+40199, zCmd) {
|
|
rc = _sqlite3Fts5FlushToDisk(tls, pTab)
|
|
} else {
|
|
rc = _sqlite3Fts5FlushToDisk(tls, pTab)
|
|
if rc == SQLITE_OK {
|
|
rc = _sqlite3Fts5IndexLoadConfig(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex)
|
|
}
|
|
if rc == SQLITE_OK {
|
|
rc = _sqlite3Fts5ConfigSetValue(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig, zCmd, pVal, bp)
|
|
}
|
|
if rc == SQLITE_OK {
|
|
if **(**int32)(__ccgo_up(bp)) != 0 {
|
|
rc = int32(SQLITE_ERROR)
|
|
} else {
|
|
rc = _sqlite3Fts5StorageConfigValue(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).FpStorage, zCmd, pVal, 0)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if rc == SQLITE_OK && bLoadConfig != 0 {
|
|
(*TFts5Config)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FiCookie = (*TFts5Config)(unsafe.Pointer((*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpConfig)).FiCookie - 1
|
|
rc = _sqlite3Fts5IndexLoadConfig(tls, (*TFts5FullTable)(unsafe.Pointer(pTab)).Fp.FpIndex)
|
|
}
|
|
return rc
|
|
}
|
|
|
|
func _fts5StorageCount(tls *libc.TLS, p uintptr, zSuffix uintptr, pnRow uintptr) (r int32) {
|
|
bp := tls.Alloc(48)
|
|
defer tls.Free(48)
|
|
var pConfig, zSql uintptr
|
|
var rc int32
|
|
var _ /* pCnt at bp+0 */ uintptr
|
|
_, _, _ = pConfig, rc, zSql
|
|
pConfig = (*TFts5Storage)(unsafe.Pointer(p)).FpConfig
|
|
zSql = Xsqlite3_mprintf(tls, __ccgo_ts+41826, libc.VaList(bp+16, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, zSuffix))
|
|
if zSql == uintptr(0) {
|
|
rc = int32(SQLITE_NOMEM)
|
|
} else {
|
|
**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
|
|
rc = Xsqlite3_prepare_v2(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, zSql, -int32(1), bp, uintptr(0))
|
|
if rc == SQLITE_OK {
|
|
if int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) {
|
|
**(**Ti64)(__ccgo_up(pnRow)) = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), 0)
|
|
}
|
|
rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp)))
|
|
}
|
|
}
|
|
Xsqlite3_free(tls, zSql)
|
|
return rc
|
|
}
|
|
|
|
func _fts5StorageRenameOne(tls *libc.TLS, pConfig uintptr, pRc uintptr, zTail uintptr, zName uintptr) {
|
|
bp := tls.Alloc(48)
|
|
defer tls.Free(48)
|
|
if **(**int32)(__ccgo_up(pRc)) == SQLITE_OK {
|
|
**(**int32)(__ccgo_up(pRc)) = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), __ccgo_ts+41470, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, zTail, zName, zTail))
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Return the value in pVal interpreted as utf-8 text. Except, if pVal
|
|
// ** contains a NULL value, return a pointer to a static string zero
|
|
// ** bytes in length instead of a NULL pointer.
|
|
// */
|
|
func _fts5ValueToText(tls *libc.TLS, pVal uintptr) (r uintptr) {
|
|
var zRet, v1 uintptr
|
|
_, _ = zRet, v1
|
|
zRet = Xsqlite3_value_text(tls, pVal)
|
|
if zRet != 0 {
|
|
v1 = zRet
|
|
} else {
|
|
v1 = __ccgo_ts + 1704
|
|
}
|
|
return v1
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Translate a string containing an fts5vocab table type to an
|
|
// ** FTS5_VOCAB_XXX constant. If successful, set *peType to the output
|
|
// ** value and return SQLITE_OK. Otherwise, set *pzErr to an error message
|
|
// ** and return SQLITE_ERROR.
|
|
// */
|
|
func _fts5VocabTableType(tls *libc.TLS, zType uintptr, pzErr uintptr, peType uintptr) (r int32) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var zCopy uintptr
|
|
var _ /* rc at bp+0 */ int32
|
|
_ = zCopy
|
|
**(**int32)(__ccgo_up(bp)) = SQLITE_OK
|
|
zCopy = _sqlite3Fts5Strndup(tls, bp, zType, -int32(1))
|
|
if **(**int32)(__ccgo_up(bp)) == SQLITE_OK {
|
|
_sqlite3Fts5Dequote(tls, zCopy)
|
|
if Xsqlite3_stricmp(tls, zCopy, __ccgo_ts+42243) == 0 {
|
|
**(**int32)(__ccgo_up(peType)) = FTS5_VOCAB_COL
|
|
} else {
|
|
if Xsqlite3_stricmp(tls, zCopy, __ccgo_ts+42247) == 0 {
|
|
**(**int32)(__ccgo_up(peType)) = int32(FTS5_VOCAB_ROW)
|
|
} else {
|
|
if Xsqlite3_stricmp(tls, zCopy, __ccgo_ts+42251) == 0 {
|
|
**(**int32)(__ccgo_up(peType)) = int32(FTS5_VOCAB_INSTANCE)
|
|
} else {
|
|
**(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+42260, libc.VaList(bp+16, zCopy))
|
|
**(**int32)(__ccgo_up(bp)) = int32(SQLITE_ERROR)
|
|
}
|
|
}
|
|
}
|
|
Xsqlite3_free(tls, zCopy)
|
|
}
|
|
return **(**int32)(__ccgo_up(bp))
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** This function is called whenever processing of the doclist for the
|
|
// ** last term on leaf page (pWriter->iBtPage) is completed.
|
|
// **
|
|
// ** The doclist-index for that term is currently stored in-memory within the
|
|
// ** Fts5SegWriter.aDlidx[] array. If it is large enough, this function
|
|
// ** writes it out to disk. Or, if it is too small to bother with, discards
|
|
// ** it.
|
|
// **
|
|
// ** Fts5SegWriter.btterm currently contains the first term on page iBtPage.
|
|
// */
|
|
func _fts5WriteFlushBtree(tls *libc.TLS, p uintptr, pWriter uintptr) {
|
|
var bFlag int32
|
|
var z, v1 uintptr
|
|
_, _, _ = bFlag, z, v1
|
|
if (*TFts5SegWriter)(unsafe.Pointer(pWriter)).FiBtPage == 0 {
|
|
return
|
|
}
|
|
bFlag = _fts5WriteFlushDlidx(tls, p, pWriter)
|
|
if (*TFts5Index)(unsafe.Pointer(p)).Frc == SQLITE_OK {
|
|
if (*TFts5SegWriter)(unsafe.Pointer(pWriter)).Fbtterm.Fn > 0 {
|
|
v1 = (*TFts5SegWriter)(unsafe.Pointer(pWriter)).Fbtterm.Fp
|
|
} else {
|
|
v1 = __ccgo_ts + 1704
|
|
}
|
|
z = v1
|
|
/* The following was already done in fts5WriteInit(): */
|
|
/* sqlite3_bind_int(p->pIdxWriter, 1, pWriter->iSegid); */
|
|
Xsqlite3_bind_blob(tls, (*TFts5Index)(unsafe.Pointer(p)).FpIdxWriter, int32(2), z, (*TFts5SegWriter)(unsafe.Pointer(pWriter)).Fbtterm.Fn, libc.UintptrFromInt32(0))
|
|
Xsqlite3_bind_int64(tls, (*TFts5Index)(unsafe.Pointer(p)).FpIdxWriter, int32(3), int64(bFlag)+int64((*TFts5SegWriter)(unsafe.Pointer(pWriter)).FiBtPage)<<libc.Int32FromInt32(1))
|
|
Xsqlite3_step(tls, (*TFts5Index)(unsafe.Pointer(p)).FpIdxWriter)
|
|
(*TFts5Index)(unsafe.Pointer(p)).Frc = Xsqlite3_reset(tls, (*TFts5Index)(unsafe.Pointer(p)).FpIdxWriter)
|
|
Xsqlite3_bind_null(tls, (*TFts5Index)(unsafe.Pointer(p)).FpIdxWriter, int32(2))
|
|
}
|
|
(*TFts5SegWriter)(unsafe.Pointer(pWriter)).FiBtPage = 0
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** The following routine is called if the stack overflows.
|
|
// */
|
|
func _fts5yyStackOverflow(tls *libc.TLS, fts5yypParser uintptr) {
|
|
var pParse uintptr
|
|
_ = pParse
|
|
pParse = (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse
|
|
for (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yytos > (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).Ffts5yystack {
|
|
_fts5yy_pop_parser_stack(tls, fts5yypParser)
|
|
}
|
|
/* Here code is inserted which will execute if the parser
|
|
** stack every overflows */
|
|
/******** Begin %stack_overflow code ******************************************/
|
|
_sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+37114, 0)
|
|
/******** End %stack_overflow code ********************************************/
|
|
(*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse = pParse /* Suppress warning about unused %extra_argument var */
|
|
}
|
|
|
|
/*
|
|
** Print tracing information for a SHIFT action
|
|
*/
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** The following code executes when a syntax error first occurs.
|
|
// */
|
|
func _fts5yy_syntax_error(tls *libc.TLS, fts5yypParser uintptr, fts5yymajor int32, fts5yyminor TFts5Token) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var pParse uintptr
|
|
_ = pParse
|
|
pParse = (*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse
|
|
/************ Begin %syntax_error code ****************************************/
|
|
_ = fts5yymajor /* Silence a compiler warning */
|
|
_sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+37142, libc.VaList(bp+8, fts5yyminor.Fn, fts5yyminor.Fp))
|
|
/************ End %syntax_error code ******************************************/
|
|
(*Tfts5yyParser)(unsafe.Pointer(fts5yypParser)).FpParse = pParse /* Suppress warning about unused %extra_argument variable */
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Rtree virtual table module xBestIndex method. There are three
|
|
// ** table scan strategies to choose from (in order from most to
|
|
// ** least desirable):
|
|
// **
|
|
// ** idxNum idxStr Strategy
|
|
// ** ------------------------------------------------
|
|
// ** 1 "rowid" Direct lookup by rowid.
|
|
// ** 2 "rtree" R-tree overlap query using geopoly_overlap()
|
|
// ** 3 "rtree" R-tree within query using geopoly_within()
|
|
// ** 4 "fullscan" full-table scan.
|
|
// ** ------------------------------------------------
|
|
// */
|
|
func _geopolyBestIndex(tls *libc.TLS, tab uintptr, pIdxInfo uintptr) (r int32) {
|
|
var iFuncTerm, iRowidTerm, idxNum, ii int32
|
|
var p uintptr
|
|
_, _, _, _, _ = iFuncTerm, iRowidTerm, idxNum, ii, p
|
|
iRowidTerm = -int32(1)
|
|
iFuncTerm = -int32(1)
|
|
idxNum = 0
|
|
_ = tab
|
|
ii = 0
|
|
for {
|
|
if !(ii < (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FnConstraint) {
|
|
break
|
|
}
|
|
p = (*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraint + uintptr(ii)*12
|
|
if !((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fusable != 0) {
|
|
goto _1
|
|
}
|
|
if (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn < 0 && libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) == int32(SQLITE_INDEX_CONSTRAINT_EQ) {
|
|
iRowidTerm = ii
|
|
break
|
|
}
|
|
if (*Tsqlite3_index_constraint)(unsafe.Pointer(p)).FiColumn == 0 && libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) >= int32(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 = libc.Int32FromUint8((*Tsqlite3_index_constraint)(unsafe.Pointer(p)).Fop) - int32(SQLITE_INDEX_CONSTRAINT_FUNCTION) + int32(2)
|
|
}
|
|
goto _1
|
|
_1:
|
|
;
|
|
ii = ii + 1
|
|
}
|
|
if iRowidTerm >= 0 {
|
|
(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = int32(1)
|
|
(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = __ccgo_ts + 17991
|
|
(**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iRowidTerm)*8))).FargvIndex = int32(1)
|
|
(**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iRowidTerm)*8))).Fomit = uint8(1)
|
|
(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(30)
|
|
(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(1)
|
|
(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxFlags = int32(SQLITE_INDEX_SCAN_UNIQUE)
|
|
return SQLITE_OK
|
|
}
|
|
if iFuncTerm >= 0 {
|
|
(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = idxNum
|
|
(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = __ccgo_ts + 29997
|
|
(**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iFuncTerm)*8))).FargvIndex = int32(1)
|
|
(**(**Tsqlite3_index_constraint_usage)(__ccgo_up((*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FaConstraintUsage + uintptr(iFuncTerm)*8))).Fomit = uint8(0)
|
|
(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(300)
|
|
(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(10)
|
|
return SQLITE_OK
|
|
}
|
|
(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxNum = int32(4)
|
|
(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FidxStr = __ccgo_ts + 30003
|
|
(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedCost = float64(3e+06)
|
|
(*Tsqlite3_index_info)(unsafe.Pointer(pIdxInfo)).FestimatedRows = int64(100000)
|
|
return SQLITE_OK
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Report that geopoly_overlap() is an overloaded function suitable
|
|
// ** for use in xBestIndex.
|
|
// */
|
|
func _geopolyFindFunction(tls *libc.TLS, pVtab uintptr, nArg int32, zName uintptr, __ccgo_fp_pxFunc uintptr, ppArg uintptr) (r int32) {
|
|
_ = pVtab
|
|
_ = nArg
|
|
if Xsqlite3_stricmp(tls, zName, __ccgo_ts+30052) == 0 {
|
|
**(**uintptr)(__ccgo_up(__ccgo_fp_pxFunc)) = __ccgo_fp(_geopolyOverlapFunc)
|
|
**(**uintptr)(__ccgo_up(ppArg)) = uintptr(0)
|
|
return int32(SQLITE_INDEX_CONSTRAINT_FUNCTION)
|
|
}
|
|
if Xsqlite3_stricmp(tls, zName, __ccgo_ts+30068) == 0 {
|
|
**(**uintptr)(__ccgo_up(__ccgo_fp_pxFunc)) = __ccgo_fp(_geopolyWithinFunc)
|
|
**(**uintptr)(__ccgo_up(ppArg)) = uintptr(0)
|
|
return libc.Int32FromInt32(SQLITE_INDEX_CONSTRAINT_FUNCTION) + libc.Int32FromInt32(1)
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** SQL function: geopoly_json(X)
|
|
// **
|
|
// ** Interpret X as a polygon and render it as a JSON array
|
|
// ** of coordinates. Or, if X is not a valid polygon, return NULL.
|
|
// */
|
|
func _geopolyJsonFunc(tls *libc.TLS, context uintptr, argc int32, argv uintptr) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var db, p, x uintptr
|
|
var i int32
|
|
_, _, _, _ = db, i, p, x
|
|
p = _geopolyFuncParam(tls, context, **(**uintptr)(__ccgo_up(argv)), uintptr(0))
|
|
_ = argc
|
|
if p != 0 {
|
|
db = Xsqlite3_context_db_handle(tls, context)
|
|
x = Xsqlite3_str_new(tls, db)
|
|
Xsqlite3_str_append(tls, x, __ccgo_ts+26698, int32(1))
|
|
i = 0
|
|
for {
|
|
if !(i < (*TGeoPoly)(unsafe.Pointer(p)).FnVertex) {
|
|
break
|
|
}
|
|
Xsqlite3_str_appendf(tls, x, __ccgo_ts+29861, libc.VaList(bp+8, float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(i*int32(2))*4))), float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(i*int32(2)+int32(1))*4)))))
|
|
goto _1
|
|
_1:
|
|
;
|
|
i = i + 1
|
|
}
|
|
Xsqlite3_str_appendf(tls, x, __ccgo_ts+29872, libc.VaList(bp+8, float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2))*4))), float64(**(**TGeoCoord)(__ccgo_up(p + 8 + uintptr(libc.Int32FromInt32(0)*libc.Int32FromInt32(2)+libc.Int32FromInt32(1))*4)))))
|
|
Xsqlite3_result_text(tls, context, Xsqlite3_str_finish(tls, x), -int32(1), __ccgo_fp(Xsqlite3_free))
|
|
Xsqlite3_free(tls, p)
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Interpret the given string as an auto-vacuum mode value.
|
|
// **
|
|
// ** The following strings, "none", "full" and "incremental" are
|
|
// ** acceptable, as are their numeric equivalents: 0, 1 and 2 respectively.
|
|
// */
|
|
func _getAutoVacuum(tls *libc.TLS, z uintptr) (r int32) {
|
|
var i, v1 int32
|
|
_, _ = i, v1
|
|
if 0 == _sqlite3StrICmp(tls, z, __ccgo_ts+8536) {
|
|
return BTREE_AUTOVACUUM_NONE
|
|
}
|
|
if 0 == _sqlite3StrICmp(tls, z, __ccgo_ts+19044) {
|
|
return int32(BTREE_AUTOVACUUM_FULL)
|
|
}
|
|
if 0 == _sqlite3StrICmp(tls, z, __ccgo_ts+19049) {
|
|
return int32(BTREE_AUTOVACUUM_INCR)
|
|
}
|
|
i = _sqlite3Atoi(tls, z)
|
|
if i >= 0 && i <= int32(2) {
|
|
v1 = i
|
|
} else {
|
|
v1 = 0
|
|
}
|
|
return libc.Int32FromUint8(libc.Uint8FromInt32(v1))
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Interpret the given string as a locking mode value.
|
|
// */
|
|
func _getLockingMode(tls *libc.TLS, z uintptr) (r int32) {
|
|
if z != 0 {
|
|
if 0 == _sqlite3StrICmp(tls, z, __ccgo_ts+19027) {
|
|
return int32(PAGER_LOCKINGMODE_EXCLUSIVE)
|
|
}
|
|
if 0 == _sqlite3StrICmp(tls, z, __ccgo_ts+19037) {
|
|
return PAGER_LOCKINGMODE_NORMAL
|
|
}
|
|
}
|
|
return -int32(1)
|
|
}
|
|
|
|
func _groupConcatValue(tls *libc.TLS, context uintptr) {
|
|
var pAccum, pGCC, zText uintptr
|
|
_, _, _ = pAccum, pGCC, zText
|
|
pGCC = Xsqlite3_aggregate_context(tls, context, 0)
|
|
if pGCC != 0 {
|
|
pAccum = pGCC
|
|
if libc.Int32FromUint8((*TStrAccum)(unsafe.Pointer(pAccum)).FaccError) == int32(SQLITE_TOOBIG) {
|
|
Xsqlite3_result_error_toobig(tls, context)
|
|
} else {
|
|
if libc.Int32FromUint8((*TStrAccum)(unsafe.Pointer(pAccum)).FaccError) == int32(SQLITE_NOMEM) {
|
|
Xsqlite3_result_error_nomem(tls, context)
|
|
} else {
|
|
if (*TGroupConcatCtx)(unsafe.Pointer(pGCC)).FnAccum > 0 && (*TStrAccum)(unsafe.Pointer(pAccum)).FnChar == uint32(0) {
|
|
Xsqlite3_result_text(tls, context, __ccgo_ts+1704, int32(1), libc.UintptrFromInt32(0))
|
|
} else {
|
|
zText = Xsqlite3_str_value(tls, pAccum)
|
|
Xsqlite3_result_text(tls, context, zText, libc.Int32FromUint32((*TStrAccum)(unsafe.Pointer(pAccum)).FnChar), uintptr(-libc.Int32FromInt32(1)))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Parameter zName is the name of a table that is about to be altered
|
|
// ** (either with ALTER TABLE ... RENAME TO or ALTER TABLE ... ADD COLUMN).
|
|
// ** If the table is a system table, this function leaves an error message
|
|
// ** in pParse->zErr (system tables may not be altered) and returns non-zero.
|
|
// **
|
|
// ** Or, if zName is not a system table, zero is returned.
|
|
// */
|
|
func _isAlterableTable(tls *libc.TLS, pParse uintptr, pTab uintptr) (r int32) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
if 0 == Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pTab)).FzName, __ccgo_ts+6784, int32(7)) || (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Eponymous) != uint32(0) || (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Shadow) != uint32(0) && _sqlite3ReadOnlyShadowTables(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb) != 0 {
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8671, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName))
|
|
return int32(1)
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Return true if the pExpr term from the RETURNING clause argument
|
|
// ** list is of the form "*". Raise an error if the terms if of the
|
|
// ** form "table.*".
|
|
// */
|
|
func _isAsteriskTerm(tls *libc.TLS, pParse uintptr, pTerm uintptr) (r int32) {
|
|
if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pTerm)).Fop) == int32(TK_ASTERISK) {
|
|
return int32(1)
|
|
}
|
|
if libc.Int32FromUint8((*TExpr)(unsafe.Pointer(pTerm)).Fop) != int32(TK_DOT) {
|
|
return 0
|
|
}
|
|
if libc.Int32FromUint8((*TExpr)(unsafe.Pointer((*TExpr)(unsafe.Pointer(pTerm)).FpRight)).Fop) != int32(TK_ASTERISK) {
|
|
return 0
|
|
}
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22550, 0)
|
|
return int32(1)
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Parameter pTab is the subject of an ALTER TABLE ... RENAME COLUMN
|
|
// ** command. This function checks if the table is a view or virtual
|
|
// ** table (columns of views or virtual tables may not be renamed). If so,
|
|
// ** it loads an error message into pParse and returns non-zero.
|
|
// **
|
|
// ** Or, if pTab is not a view or virtual table, zero is returned.
|
|
// */
|
|
func _isRealTable(tls *libc.TLS, pParse uintptr, pTab uintptr, iOp int32) (r int32) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var azMsg [3]uintptr
|
|
var zType uintptr
|
|
_, _ = azMsg, zType
|
|
zType = uintptr(0)
|
|
if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) {
|
|
zType = __ccgo_ts + 11143
|
|
}
|
|
if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) {
|
|
zType = __ccgo_ts + 11148
|
|
}
|
|
if zType != 0 {
|
|
azMsg = [3]uintptr{
|
|
0: __ccgo_ts + 11162,
|
|
1: __ccgo_ts + 11180,
|
|
2: __ccgo_ts + 11197,
|
|
}
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+11217, libc.VaList(bp+8, azMsg[iOp], zType, (*TTable)(unsafe.Pointer(pTab)).FzName))
|
|
return int32(1)
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Return TRUE (non-zero) if zTab is a valid name for the schema table pTab.
|
|
// */
|
|
func _isValidSchemaTableName(tls *libc.TLS, zTab uintptr, pTab uintptr, zDb uintptr) (r int32) {
|
|
var zLegacy uintptr
|
|
_ = zLegacy
|
|
if Xsqlite3_strnicmp(tls, zTab, __ccgo_ts+6784, int32(7)) != 0 {
|
|
return 0
|
|
}
|
|
zLegacy = (*TTable)(unsafe.Pointer(pTab)).FzName
|
|
if libc.Xstrcmp(tls, zLegacy+uintptr(7), __ccgo_ts+6792+7) == 0 {
|
|
if _sqlite3StrICmp(tls, zTab+uintptr(7), __ccgo_ts+6811+7) == 0 {
|
|
return int32(1)
|
|
}
|
|
if zDb == uintptr(0) {
|
|
return 0
|
|
}
|
|
if _sqlite3StrICmp(tls, zTab+uintptr(7), __ccgo_ts+6312+7) == 0 {
|
|
return int32(1)
|
|
}
|
|
if _sqlite3StrICmp(tls, zTab+uintptr(7), __ccgo_ts+6830+7) == 0 {
|
|
return int32(1)
|
|
}
|
|
} else {
|
|
if _sqlite3StrICmp(tls, zTab+uintptr(7), __ccgo_ts+6830+7) == 0 {
|
|
return int32(1)
|
|
}
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Generate a path error.
|
|
// **
|
|
// ** The specifics of the error are determined by the rc argument.
|
|
// **
|
|
// ** rc error
|
|
// ** ----------------- ----------------------
|
|
// ** JSON_LOOKUP_ARRAY "not an array"
|
|
// ** JSON_LOOKUP_TOODEEP "JSON nested too deep"
|
|
// ** JSON_LOOKUP_ERROR "malformed JSON"
|
|
// ** otherwise... "bad JSON path"
|
|
// **
|
|
// ** If ctx is not NULL then push the error message into ctx and return NULL.
|
|
// ** If ctx is NULL, then return the text of the error message.
|
|
// */
|
|
func _jsonBadPathError(tls *libc.TLS, ctx uintptr, zPath uintptr, rc int32) (r uintptr) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var zMsg uintptr
|
|
_ = zMsg
|
|
if rc == libc.Int32FromUint32(JSON_LOOKUP_NOTARRAY) {
|
|
zMsg = Xsqlite3_mprintf(tls, __ccgo_ts+26634, libc.VaList(bp+8, zPath))
|
|
} else {
|
|
if rc == libc.Int32FromUint32(JSON_LOOKUP_ERROR) {
|
|
zMsg = Xsqlite3_mprintf(tls, __ccgo_ts+26486, 0)
|
|
} else {
|
|
if rc == libc.Int32FromUint32(JSON_LOOKUP_TOODEEP) {
|
|
zMsg = Xsqlite3_mprintf(tls, __ccgo_ts+26659, 0)
|
|
} else {
|
|
zMsg = Xsqlite3_mprintf(tls, __ccgo_ts+26678, libc.VaList(bp+8, zPath))
|
|
}
|
|
}
|
|
}
|
|
if ctx == uintptr(0) {
|
|
return zMsg
|
|
}
|
|
if zMsg != 0 {
|
|
Xsqlite3_result_error(tls, ctx, zMsg, -int32(1))
|
|
Xsqlite3_free(tls, zMsg)
|
|
} else {
|
|
Xsqlite3_result_error_nomem(tls, ctx)
|
|
}
|
|
return uintptr(0)
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** json_replace(JSON, PATH, VALUE, ...)
|
|
// **
|
|
// ** Replace the value at PATH with VALUE. If PATH does not already exist,
|
|
// ** this routine is a no-op. If JSON or PATH is malformed, throw an error.
|
|
// */
|
|
func _jsonReplaceFunc(tls *libc.TLS, ctx uintptr, argc int32, argv uintptr) {
|
|
if argc < int32(1) {
|
|
return
|
|
}
|
|
if argc&int32(1) == 0 {
|
|
_jsonWrongNumArgs(tls, ctx, __ccgo_ts+17096)
|
|
return
|
|
}
|
|
_jsonInsertIntoBlob(tls, ctx, argc, argv, int32(JEDIT_REPL))
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Report the wrong number of arguments for json_insert(), json_replace()
|
|
// ** or json_set().
|
|
// */
|
|
func _jsonWrongNumArgs(tls *libc.TLS, pCtx uintptr, zFuncName uintptr) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var zMsg uintptr
|
|
_ = zMsg
|
|
zMsg = Xsqlite3_mprintf(tls, __ccgo_ts+26532, libc.VaList(bp+8, zFuncName))
|
|
Xsqlite3_result_error(tls, pCtx, zMsg, -int32(1))
|
|
Xsqlite3_free(tls, zMsg)
|
|
}
|
|
|
|
/****************************************************************************
|
|
** Utility routines for dealing with the binary BLOB representation of JSON
|
|
****************************************************************************/
|
|
|
|
// C documentation
|
|
//
|
|
// /* Human-readable names for the JSONB values. The index for each
|
|
// ** string must correspond to the JSONB_* integer above.
|
|
// */
|
|
var _jsonbType = [17]uintptr{
|
|
0: __ccgo_ts + 1690,
|
|
1: __ccgo_ts + 8206,
|
|
2: __ccgo_ts + 8211,
|
|
3: __ccgo_ts + 6520,
|
|
4: __ccgo_ts + 6520,
|
|
5: __ccgo_ts + 6515,
|
|
6: __ccgo_ts + 6515,
|
|
7: __ccgo_ts + 8515,
|
|
8: __ccgo_ts + 8515,
|
|
9: __ccgo_ts + 8515,
|
|
10: __ccgo_ts + 8515,
|
|
11: __ccgo_ts + 26423,
|
|
12: __ccgo_ts + 26429,
|
|
13: __ccgo_ts + 1704,
|
|
14: __ccgo_ts + 1704,
|
|
15: __ccgo_ts + 1704,
|
|
16: __ccgo_ts + 1704,
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Check a single element of the JSONB in pParse for validity.
|
|
// **
|
|
// ** The element to be checked starts at offset i and must end at on the
|
|
// ** last byte before iEnd.
|
|
// **
|
|
// ** Return 0 if everything is correct. Return the 1-based byte offset of the
|
|
// ** error if a problem is detected. (In other words, if the error is at offset
|
|
// ** 0, return 1).
|
|
// */
|
|
func _jsonbValidityCheck(tls *libc.TLS, pParse uintptr, i Tu32, iEnd Tu32, iDepth Tu32) (r Tu32) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var cnt, j, k, n, sub, sub1, szC Tu32
|
|
var seen, x Tu8
|
|
var z uintptr
|
|
var v1 uint32
|
|
var _ /* c at bp+4 */ Tu32
|
|
var _ /* sz at bp+0 */ Tu32
|
|
_, _, _, _, _, _, _, _, _, _, _ = cnt, j, k, n, seen, sub, sub1, szC, x, z, v1
|
|
if iDepth > uint32(JSON_MAX_DEPTH) {
|
|
return i + uint32(1)
|
|
}
|
|
**(**Tu32)(__ccgo_up(bp)) = uint32(0)
|
|
n = _jsonbPayloadSize(tls, pParse, i, bp)
|
|
if n == uint32(0) {
|
|
return i + uint32(1)
|
|
} /* Checked by caller */
|
|
if i+n+**(**Tu32)(__ccgo_up(bp)) != iEnd {
|
|
return i + uint32(1)
|
|
} /* Checked by caller */
|
|
z = (*TJsonParse)(unsafe.Pointer(pParse)).FaBlob
|
|
x = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(i)))) & int32(0x0f))
|
|
switch libc.Int32FromUint8(x) {
|
|
case JSONB_NULL:
|
|
fallthrough
|
|
case int32(JSONB_TRUE):
|
|
fallthrough
|
|
case int32(JSONB_FALSE):
|
|
if n+**(**Tu32)(__ccgo_up(bp)) == uint32(1) {
|
|
v1 = uint32(0)
|
|
} else {
|
|
v1 = i + uint32(1)
|
|
}
|
|
return v1
|
|
case int32(JSONB_INT):
|
|
if **(**Tu32)(__ccgo_up(bp)) < uint32(1) {
|
|
return i + uint32(1)
|
|
}
|
|
j = i + n
|
|
if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('-') {
|
|
j = j + 1
|
|
if **(**Tu32)(__ccgo_up(bp)) < uint32(2) {
|
|
return i + uint32(1)
|
|
}
|
|
}
|
|
k = i + n + **(**Tu32)(__ccgo_up(bp))
|
|
for j < k {
|
|
if libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(z + uintptr(j)))])&int32(0x04) != 0 {
|
|
j = j + 1
|
|
} else {
|
|
return j + uint32(1)
|
|
}
|
|
}
|
|
return uint32(0)
|
|
case int32(JSONB_INT5):
|
|
if **(**Tu32)(__ccgo_up(bp)) < uint32(3) {
|
|
return i + uint32(1)
|
|
}
|
|
j = i + n
|
|
if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('-') {
|
|
if **(**Tu32)(__ccgo_up(bp)) < uint32(4) {
|
|
return i + uint32(1)
|
|
}
|
|
j = j + 1
|
|
}
|
|
if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) != int32('0') {
|
|
return i + uint32(1)
|
|
}
|
|
if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) != int32('x') && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) != int32('X') {
|
|
return j + uint32(2)
|
|
}
|
|
j = j + uint32(2)
|
|
k = i + n + **(**Tu32)(__ccgo_up(bp))
|
|
for j < k {
|
|
if libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(z + uintptr(j)))])&int32(0x08) != 0 {
|
|
j = j + 1
|
|
} else {
|
|
return j + uint32(1)
|
|
}
|
|
}
|
|
return uint32(0)
|
|
case int32(JSONB_FLOAT):
|
|
fallthrough
|
|
case int32(JSONB_FLOAT5):
|
|
seen = uint8(0) /* 0: initial. 1: '.' seen 2: 'e' seen */
|
|
if **(**Tu32)(__ccgo_up(bp)) < uint32(2) {
|
|
return i + uint32(1)
|
|
}
|
|
j = i + n
|
|
k = j + **(**Tu32)(__ccgo_up(bp))
|
|
if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('-') {
|
|
j = j + 1
|
|
if **(**Tu32)(__ccgo_up(bp)) < uint32(3) {
|
|
return i + uint32(1)
|
|
}
|
|
}
|
|
if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('.') {
|
|
if libc.Int32FromUint8(x) == int32(JSONB_FLOAT) {
|
|
return j + uint32(1)
|
|
}
|
|
if !(libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))])&libc.Int32FromInt32(0x04) != 0) {
|
|
return j + uint32(1)
|
|
}
|
|
j = j + uint32(2)
|
|
seen = uint8(1)
|
|
} else {
|
|
if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('0') && libc.Int32FromUint8(x) == int32(JSONB_FLOAT) {
|
|
if j+uint32(3) > k {
|
|
return j + uint32(1)
|
|
}
|
|
if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) != int32('.') && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) != int32('e') && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) != int32('E') {
|
|
return j + uint32(1)
|
|
}
|
|
j = j + 1
|
|
}
|
|
}
|
|
for {
|
|
if !(j < k) {
|
|
break
|
|
}
|
|
if libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(z + uintptr(j)))])&int32(0x04) != 0 {
|
|
goto _2
|
|
}
|
|
if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('.') {
|
|
if libc.Int32FromUint8(seen) > 0 {
|
|
return j + uint32(1)
|
|
}
|
|
if libc.Int32FromUint8(x) == int32(JSONB_FLOAT) && (j == k-uint32(1) || !(libc.Int32FromUint8(_sqlite3CtypeMap[**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))])&libc.Int32FromInt32(0x04) != 0)) {
|
|
return j + uint32(1)
|
|
}
|
|
seen = uint8(1)
|
|
goto _2
|
|
}
|
|
if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('e') || libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('E') {
|
|
if libc.Int32FromUint8(seen) == int32(2) {
|
|
return j + uint32(1)
|
|
}
|
|
if j == k-uint32(1) {
|
|
return j + uint32(1)
|
|
}
|
|
if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) == int32('+') || libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) == int32('-') {
|
|
j = j + 1
|
|
if j == k-uint32(1) {
|
|
return j + uint32(1)
|
|
}
|
|
}
|
|
seen = uint8(2)
|
|
goto _2
|
|
}
|
|
return j + uint32(1)
|
|
goto _2
|
|
_2:
|
|
;
|
|
j = j + 1
|
|
}
|
|
if libc.Int32FromUint8(seen) == 0 {
|
|
return i + uint32(1)
|
|
}
|
|
return uint32(0)
|
|
case int32(JSONB_TEXT):
|
|
j = i + n
|
|
k = j + **(**Tu32)(__ccgo_up(bp))
|
|
for j < k {
|
|
if !(_jsonIsOk[**(**Tu8)(__ccgo_up(z + uintptr(j)))] != 0) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) != int32('\'') {
|
|
return j + uint32(1)
|
|
}
|
|
j = j + 1
|
|
}
|
|
return uint32(0)
|
|
case int32(JSONB_TEXTJ):
|
|
fallthrough
|
|
case int32(JSONB_TEXT5):
|
|
j = i + n
|
|
k = j + **(**Tu32)(__ccgo_up(bp))
|
|
for j < k {
|
|
if !(_jsonIsOk[**(**Tu8)(__ccgo_up(z + uintptr(j)))] != 0) && libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) != int32('\'') {
|
|
if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) == int32('"') {
|
|
if libc.Int32FromUint8(x) == int32(JSONB_TEXTJ) {
|
|
return j + uint32(1)
|
|
}
|
|
} else {
|
|
if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) <= int32(0x1f) {
|
|
/* Control characters in JSON5 string literals are ok */
|
|
if libc.Int32FromUint8(x) == int32(JSONB_TEXTJ) {
|
|
return j + uint32(1)
|
|
}
|
|
} else {
|
|
if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) != int32('\\') || j+uint32(1) >= k {
|
|
return j + uint32(1)
|
|
} else {
|
|
if libc.Xstrchr(tls, __ccgo_ts+26575, libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1)))))) != uintptr(0) {
|
|
j = j + 1
|
|
} else {
|
|
if libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j+uint32(1))))) == int32('u') {
|
|
if j+uint32(5) >= k {
|
|
return j + uint32(1)
|
|
}
|
|
if !(_jsonIs4Hex(tls, z+uintptr(j+uint32(2))) != 0) {
|
|
return j + uint32(1)
|
|
}
|
|
j = j + 1
|
|
} else {
|
|
if libc.Int32FromUint8(x) != int32(JSONB_TEXT5) {
|
|
return j + uint32(1)
|
|
} else {
|
|
**(**Tu32)(__ccgo_up(bp + 4)) = uint32(0)
|
|
szC = _jsonUnescapeOneChar(tls, z+uintptr(j), k-j, bp+4)
|
|
if **(**Tu32)(__ccgo_up(bp + 4)) == uint32(JSON_INVALID_CHAR) {
|
|
return j + uint32(1)
|
|
}
|
|
j = j + (szC - uint32(1))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
j = j + 1
|
|
}
|
|
return uint32(0)
|
|
case int32(JSONB_TEXTRAW):
|
|
return uint32(0)
|
|
case int32(JSONB_ARRAY):
|
|
j = i + n
|
|
k = j + **(**Tu32)(__ccgo_up(bp))
|
|
for j < k {
|
|
**(**Tu32)(__ccgo_up(bp)) = uint32(0)
|
|
n = _jsonbPayloadSize(tls, pParse, j, bp)
|
|
if n == uint32(0) {
|
|
return j + uint32(1)
|
|
}
|
|
if j+n+**(**Tu32)(__ccgo_up(bp)) > k {
|
|
return j + uint32(1)
|
|
}
|
|
sub = _jsonbValidityCheck(tls, pParse, j, j+n+**(**Tu32)(__ccgo_up(bp)), iDepth+uint32(1))
|
|
if sub != 0 {
|
|
return sub
|
|
}
|
|
j = j + (n + **(**Tu32)(__ccgo_up(bp)))
|
|
}
|
|
return uint32(0)
|
|
case int32(JSONB_OBJECT):
|
|
cnt = uint32(0)
|
|
j = i + n
|
|
k = j + **(**Tu32)(__ccgo_up(bp))
|
|
for j < k {
|
|
**(**Tu32)(__ccgo_up(bp)) = uint32(0)
|
|
n = _jsonbPayloadSize(tls, pParse, j, bp)
|
|
if n == uint32(0) {
|
|
return j + uint32(1)
|
|
}
|
|
if j+n+**(**Tu32)(__ccgo_up(bp)) > k {
|
|
return j + uint32(1)
|
|
}
|
|
if cnt&uint32(1) == uint32(0) {
|
|
x = libc.Uint8FromInt32(libc.Int32FromUint8(**(**Tu8)(__ccgo_up(z + uintptr(j)))) & int32(0x0f))
|
|
if libc.Int32FromUint8(x) < int32(JSONB_TEXT) || libc.Int32FromUint8(x) > int32(JSONB_TEXTRAW) {
|
|
return j + uint32(1)
|
|
}
|
|
}
|
|
sub1 = _jsonbValidityCheck(tls, pParse, j, j+n+**(**Tu32)(__ccgo_up(bp)), iDepth+uint32(1))
|
|
if sub1 != 0 {
|
|
return sub1
|
|
}
|
|
cnt = cnt + 1
|
|
j = j + (n + **(**Tu32)(__ccgo_up(bp)))
|
|
}
|
|
if cnt&uint32(1) != uint32(0) {
|
|
return j + uint32(1)
|
|
}
|
|
return uint32(0)
|
|
default:
|
|
return i + uint32(1)
|
|
}
|
|
return r
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Load content from the sqlite_stat4 table into
|
|
// ** the Index.aSample[] arrays of all indices.
|
|
// */
|
|
func _loadStat4(tls *libc.TLS, db uintptr, zDb uintptr) (r int32) {
|
|
var pStat4, v1 uintptr
|
|
var rc int32
|
|
var v2 bool
|
|
_, _, _, _ = pStat4, rc, v1, v2
|
|
rc = SQLITE_OK
|
|
if v2 = (*Tsqlite3)(unsafe.Pointer(db)).FdbOptFlags&libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_Stat4)) == uint32(0); v2 {
|
|
v1 = _sqlite3FindTable(tls, db, __ccgo_ts+12887, zDb)
|
|
pStat4 = v1
|
|
}
|
|
if v2 && v1 != uintptr(0) && libc.Int32FromUint8((*TTable)(unsafe.Pointer(pStat4)).FeTabType) == TABTYP_NORM {
|
|
rc = _loadStatTbl(tls, db, __ccgo_ts+13113, __ccgo_ts+13182, zDb)
|
|
}
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Log an error that is an API call on a connection pointer that should
|
|
// ** not have been used. The "type" of connection pointer is given as the
|
|
// ** argument. The zType is a word like "NULL" or "closed" or "invalid".
|
|
// */
|
|
func _logBadConnection(tls *libc.TLS, zType uintptr) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
Xsqlite3_log(tls, int32(SQLITE_MISUSE), __ccgo_ts+1852, libc.VaList(bp+8, zType))
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** File control method. For custom operations on an memdb-file.
|
|
// */
|
|
func _memdbFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) (r int32) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var iLimit Tsqlite3_int64
|
|
var p uintptr
|
|
var rc int32
|
|
_, _, _ = iLimit, p, rc
|
|
p = (*TMemFile)(unsafe.Pointer(pFile)).FpStore
|
|
rc = int32(SQLITE_NOTFOUND)
|
|
_memdbEnter(tls, p)
|
|
if op == int32(SQLITE_FCNTL_VFSNAME) {
|
|
**(**uintptr)(__ccgo_up(pArg)) = Xsqlite3_mprintf(tls, __ccgo_ts+4146, libc.VaList(bp+8, (*TMemStore)(unsafe.Pointer(p)).FaData, (*TMemStore)(unsafe.Pointer(p)).Fsz))
|
|
rc = SQLITE_OK
|
|
}
|
|
if op == int32(SQLITE_FCNTL_SIZE_LIMIT) {
|
|
iLimit = **(**Tsqlite3_int64)(__ccgo_up(pArg))
|
|
if iLimit < (*TMemStore)(unsafe.Pointer(p)).Fsz {
|
|
if iLimit < 0 {
|
|
iLimit = (*TMemStore)(unsafe.Pointer(p)).FszMax
|
|
} else {
|
|
iLimit = (*TMemStore)(unsafe.Pointer(p)).Fsz
|
|
}
|
|
}
|
|
(*TMemStore)(unsafe.Pointer(p)).FszMax = iLimit
|
|
**(**Tsqlite3_int64)(__ccgo_up(pArg)) = iLimit
|
|
rc = SQLITE_OK
|
|
}
|
|
_memdbLeave(tls, p)
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Populate buffer zOut with the full canonical pathname corresponding
|
|
// ** to the pathname in zPath. zOut is guaranteed to point to a buffer
|
|
// ** of at least (INST_MAX_PATHNAME+1) bytes.
|
|
// */
|
|
func _memdbFullPathname(tls *libc.TLS, pVfs uintptr, zPath uintptr, nOut int32, zOut uintptr) (r int32) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
_ = pVfs
|
|
Xsqlite3_snprintf(tls, nOut, zOut, __ccgo_ts+3968, libc.VaList(bp+8, zPath))
|
|
return SQLITE_OK
|
|
}
|
|
|
|
var _memdb_vfs = Tsqlite3_vfs{
|
|
FiVersion: int32(2),
|
|
FmxPathname: int32(1024),
|
|
FzName: __ccgo_ts + 4140,
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Handle the special case of a compound-select that originates from a
|
|
// ** VALUES clause. By handling this as a special case, we avoid deep
|
|
// ** recursion, and thus do not need to enforce the SQLITE_LIMIT_COMPOUND_SELECT
|
|
// ** on a VALUES clause.
|
|
// **
|
|
// ** Because the Select object originates from a VALUES clause:
|
|
// ** (1) There is no LIMIT or OFFSET or else there is a LIMIT of exactly 1
|
|
// ** (2) All terms are UNION ALL
|
|
// ** (3) There is no ORDER BY clause
|
|
// **
|
|
// ** The "LIMIT of exactly 1" case of condition (1) comes about when a VALUES
|
|
// ** clause occurs within scalar expression (ex: "SELECT (VALUES(1),(2),(3))").
|
|
// ** The sqlite3CodeSubselect will have added the LIMIT 1 clause in tht case.
|
|
// ** Since the limit is exactly 1, we only need to evaluate the left-most VALUES.
|
|
// */
|
|
func _multiSelectValues(tls *libc.TLS, pParse uintptr, p uintptr, pDest uintptr) (r int32) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var bShowAll, nRow, rc int32
|
|
var v1 uintptr
|
|
_, _, _, _ = bShowAll, nRow, rc, v1
|
|
nRow = int32(1)
|
|
rc = 0
|
|
bShowAll = libc.BoolInt32((*TSelect)(unsafe.Pointer(p)).FpLimit == uintptr(0))
|
|
for cond := true; cond; cond = int32(1) != 0 {
|
|
if (*TSelect)(unsafe.Pointer(p)).FpWin != 0 {
|
|
return -int32(1)
|
|
}
|
|
if (*TSelect)(unsafe.Pointer(p)).FpPrior == uintptr(0) {
|
|
break
|
|
}
|
|
p = (*TSelect)(unsafe.Pointer(p)).FpPrior
|
|
nRow = nRow + bShowAll
|
|
}
|
|
if nRow == int32(1) {
|
|
v1 = __ccgo_ts + 1704
|
|
} else {
|
|
v1 = __ccgo_ts + 20833
|
|
}
|
|
_sqlite3VdbeExplain(tls, pParse, uint8(0), __ccgo_ts+20835, libc.VaList(bp+8, nRow, v1))
|
|
for p != 0 {
|
|
_selectInnerLoop(tls, pParse, p, -int32(1), uintptr(0), uintptr(0), pDest, int32(1), int32(1))
|
|
if !(bShowAll != 0) {
|
|
break
|
|
}
|
|
(*TSelect)(unsafe.Pointer(p)).FnSelectRow = int16(nRow)
|
|
p = (*TSelect)(unsafe.Pointer(p)).FpNext
|
|
}
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Report an error that an expression is not valid for some set of
|
|
// ** pNC->ncFlags values determined by validMask.
|
|
// **
|
|
// ** static void notValid(
|
|
// ** Parse *pParse, // Leave error message here
|
|
// ** NameContext *pNC, // The name context
|
|
// ** const char *zMsg, // Type of error
|
|
// ** int validMask, // Set of contexts for which prohibited
|
|
// ** Expr *pExpr // Invalidate this expression on error
|
|
// ** ){...}
|
|
// **
|
|
// ** As an optimization, since the conditional is almost always false
|
|
// ** (because errors are rare), the conditional is moved outside of the
|
|
// ** function call using a macro.
|
|
// */
|
|
func _notValidImpl(tls *libc.TLS, pParse uintptr, pNC uintptr, zMsg uintptr, pExpr uintptr, pError uintptr) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var zIn uintptr
|
|
_ = zIn
|
|
zIn = __ccgo_ts + 7126
|
|
if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_IdxExpr) != 0 {
|
|
zIn = __ccgo_ts + 7154
|
|
} else {
|
|
if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_IsCheck) != 0 {
|
|
zIn = __ccgo_ts + 7172
|
|
} else {
|
|
if (*TNameContext)(unsafe.Pointer(pNC)).FncFlags&int32(NC_GenCol) != 0 {
|
|
zIn = __ccgo_ts + 7190
|
|
}
|
|
}
|
|
}
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7208, libc.VaList(bp+8, zMsg, zIn))
|
|
if pExpr != 0 {
|
|
(*TExpr)(unsafe.Pointer(pExpr)).Fop = uint8(TK_NULL)
|
|
}
|
|
_sqlite3RecordErrorOffsetOfExpr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pError)
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Implementation of ntile(). This assumes that the window frame has
|
|
// ** been coerced to:
|
|
// **
|
|
// ** ROWS CURRENT ROW AND UNBOUNDED FOLLOWING
|
|
// */
|
|
func _ntileStepFunc(tls *libc.TLS, pCtx uintptr, nArg int32, apArg uintptr) {
|
|
var p uintptr
|
|
_ = p
|
|
_ = nArg
|
|
p = Xsqlite3_aggregate_context(tls, pCtx, int32(24))
|
|
if p != 0 {
|
|
if (*TNtileCtx)(unsafe.Pointer(p)).FnTotal == 0 {
|
|
(*TNtileCtx)(unsafe.Pointer(p)).FnParam = Xsqlite3_value_int64(tls, **(**uintptr)(__ccgo_up(apArg)))
|
|
if (*TNtileCtx)(unsafe.Pointer(p)).FnParam <= 0 {
|
|
Xsqlite3_result_error(tls, pCtx, __ccgo_ts+24259, -int32(1))
|
|
}
|
|
}
|
|
(*TNtileCtx)(unsafe.Pointer(p)).FnTotal = (*TNtileCtx)(unsafe.Pointer(p)).FnTotal + 1
|
|
}
|
|
}
|
|
|
|
var _ofdConfirmed = int32(0)
|
|
|
|
var _ofdDecided = int32(0)
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Open File Description (OFD) locks, F_OFD_SETLK & co., on Linux instead of
|
|
// ** POSIX record locks. A POSIX lock belongs to the process and is dropped by
|
|
// ** any close() of any descriptor of the file; an OFD lock belongs to the open
|
|
// ** file description that placed it. See https://gitlab.com/cznic/sqlite/-/issues/255
|
|
// **
|
|
// ** Opt-in, and process-wide by necessity: POSIX and OFD locks are different
|
|
// ** owners even within one process, so all connections to a file must use the
|
|
// ** same kind. Enabled by the environment variable MODERNC_SQLITE_OFD_LOCK
|
|
// ** (any value but the empty string or one starting with "0"), which is read
|
|
// ** once from sqlite3_os_init(), or by modernc_ofd_locking(1), which overrides
|
|
// ** it. Both must happen before the first database file is opened.
|
|
// **
|
|
// ** The kind of lock in use cannot change under a held lock - a POSIX F_UNLCK
|
|
// ** does not release an OFD lock and vice versa - so from the first lock
|
|
// ** attempt in the process until sqlite3_shutdown() the setting is frozen and
|
|
// ** modernc_ofd_locking() refuses to change it.
|
|
// **
|
|
// ** Kernels before 3.15 reject F_OFD_* with EINVAL: if the very first OFD
|
|
// ** fcntl() fails that way the library falls back to POSIX locks for good.
|
|
// ** Once an OFD fcntl() has succeeded the mode is fixed: a later EINVAL is
|
|
// ** returned to the caller as the I/O error it is, because switching modes
|
|
// ** while OFD locks are held would leave them behind.
|
|
// **
|
|
// ** Database-file locks go through osFcntlOfd() rather than
|
|
// ** osSetPosixAdvisoryLock(), which only the -shm locks still use; with
|
|
// ** SQLITE_ENABLE_SETLK_TIMEOUT that would silently drop the blocking-lock
|
|
// ** timeout for the database file, hence the tripwire.
|
|
// */
|
|
var _ofdEnabled = int32(0)
|
|
|
|
var _ofdFrozen = int32(0)
|
|
|
|
var _ofdSupported = int32(1)
|
|
|
|
func _osFcntlOfd(tls *libc.TLS, fd int32, cmd int32, arg uintptr) (r int32) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var ofdCmd, rc int32
|
|
var pLock uintptr
|
|
_, _, _ = ofdCmd, pLock, rc
|
|
if !(libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_ofdFrozen))) != 0) {
|
|
libc.AtomicStorePInt32(uintptr(unsafe.Pointer(&_ofdFrozen)), int32(1))
|
|
}
|
|
if libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_ofdEnabled))) != 0 && libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_ofdSupported))) != 0 {
|
|
ofdCmd = cmd
|
|
if cmd == int32(F_SETLK) {
|
|
ofdCmd = int32(F_OFD_SETLK)
|
|
} else {
|
|
if cmd == int32(F_SETLKW) {
|
|
ofdCmd = int32(F_OFD_SETLKW)
|
|
} else {
|
|
if cmd == int32(F_GETLK) {
|
|
ofdCmd = int32(F_OFD_GETLK)
|
|
}
|
|
}
|
|
}
|
|
if ofdCmd != cmd {
|
|
pLock = arg
|
|
(*Tflock)(unsafe.Pointer(pLock)).Fl_pid = 0 /* Required by Linux kernel for F_OFD_* commands */
|
|
rc = (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(7)].FpCurrent})))(tls, fd, ofdCmd, libc.VaList(bp+8, arg))
|
|
if rc != -int32(1) {
|
|
libc.AtomicStorePInt32(uintptr(unsafe.Pointer(&_ofdConfirmed)), int32(1))
|
|
return rc
|
|
}
|
|
if **(**int32)(__ccgo_up(libc.X__errno_location(tls))) != int32(EINVAL) || libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_ofdConfirmed))) != 0 {
|
|
return rc
|
|
}
|
|
libc.AtomicStorePInt32(uintptr(unsafe.Pointer(&_ofdSupported)), 0)
|
|
}
|
|
}
|
|
return (*(*func(*libc.TLS, int32, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(7)].FpCurrent})))(tls, fd, cmd, libc.VaList(bp+8, arg))
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /* Add a single new term to an ExprList that is used to store a
|
|
// ** list of identifiers. Report an error if the ID list contains
|
|
// ** a COLLATE clause or an ASC or DESC keyword, except ignore the
|
|
// ** error while parsing a legacy schema.
|
|
// */
|
|
func _parserAddExprIdListTerm(tls *libc.TLS, pParse uintptr, pPrior uintptr, pIdToken uintptr, hasCollate int32, sortOrder int32) (r uintptr) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var p uintptr
|
|
_ = p
|
|
p = _sqlite3ExprListAppend(tls, pParse, pPrior, uintptr(0))
|
|
if (hasCollate != 0 || sortOrder != -int32(1)) && libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Finit1.Fbusy) == 0 {
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24969, libc.VaList(bp+8, (*TToken)(unsafe.Pointer(pIdToken)).Fn, (*TToken)(unsafe.Pointer(pIdToken)).Fz))
|
|
}
|
|
_sqlite3ExprListSetName(tls, pParse, p, pIdToken, int32(1))
|
|
return p
|
|
}
|
|
|
|
/**************** End of %include directives **********************************/
|
|
/* These constants specify the various numeric values for terminal symbols.
|
|
***************** Begin token definitions *************************************/
|
|
/**************** End token definitions ***************************************/
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Generate a syntax error
|
|
// */
|
|
func _parserSyntaxError(tls *libc.TLS, pParse uintptr, p uintptr) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24854, libc.VaList(bp+8, p))
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /* Names of columns for pragmas that return multi-column result
|
|
// ** or that return single-column results where the name of the
|
|
// ** result column is different from the name of the pragma
|
|
// */
|
|
var _pragCName = [57]uintptr{
|
|
0: __ccgo_ts + 5676,
|
|
1: __ccgo_ts + 17808,
|
|
2: __ccgo_ts + 9405,
|
|
3: __ccgo_ts + 17812,
|
|
4: __ccgo_ts + 17817,
|
|
5: __ccgo_ts + 17820,
|
|
6: __ccgo_ts + 17830,
|
|
7: __ccgo_ts + 17840,
|
|
8: __ccgo_ts + 17846,
|
|
9: __ccgo_ts + 17850,
|
|
10: __ccgo_ts + 17855,
|
|
11: __ccgo_ts + 17860,
|
|
12: __ccgo_ts + 17868,
|
|
13: __ccgo_ts + 17879,
|
|
14: __ccgo_ts + 17882,
|
|
15: __ccgo_ts + 17850,
|
|
16: __ccgo_ts + 17889,
|
|
17: __ccgo_ts + 17855,
|
|
18: __ccgo_ts + 17897,
|
|
19: __ccgo_ts + 17901,
|
|
20: __ccgo_ts + 17906,
|
|
21: __ccgo_ts + 17912,
|
|
22: __ccgo_ts + 17850,
|
|
23: __ccgo_ts + 17855,
|
|
24: __ccgo_ts + 17919,
|
|
25: __ccgo_ts + 17924,
|
|
26: __ccgo_ts + 17927,
|
|
27: __ccgo_ts + 17934,
|
|
28: __ccgo_ts + 17846,
|
|
29: __ccgo_ts + 17850,
|
|
30: __ccgo_ts + 17940,
|
|
31: __ccgo_ts + 17945,
|
|
32: __ccgo_ts + 17950,
|
|
33: __ccgo_ts + 17808,
|
|
34: __ccgo_ts + 17850,
|
|
35: __ccgo_ts + 17954,
|
|
36: __ccgo_ts + 17961,
|
|
37: __ccgo_ts + 17968,
|
|
38: __ccgo_ts + 13076,
|
|
39: __ccgo_ts + 13072,
|
|
40: __ccgo_ts + 17976,
|
|
41: __ccgo_ts + 17981,
|
|
42: __ccgo_ts + 17986,
|
|
43: __ccgo_ts + 9405,
|
|
44: __ccgo_ts + 17991,
|
|
45: __ccgo_ts + 5679,
|
|
46: __ccgo_ts + 17997,
|
|
47: __ccgo_ts + 18002,
|
|
48: __ccgo_ts + 17193,
|
|
49: __ccgo_ts + 18007,
|
|
50: __ccgo_ts + 17808,
|
|
51: __ccgo_ts + 17850,
|
|
52: __ccgo_ts + 18020,
|
|
53: __ccgo_ts + 18025,
|
|
54: __ccgo_ts + 18034,
|
|
55: __ccgo_ts + 18041,
|
|
56: __ccgo_ts + 18052,
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Create zero or more entries in the output for the SQL functions
|
|
// ** defined by FuncDef p.
|
|
// */
|
|
func _pragmaFunclistLine(tls *libc.TLS, v uintptr, p uintptr, isBuiltin int32, showInternFuncs int32) {
|
|
bp := tls.Alloc(64)
|
|
defer tls.Free(64)
|
|
var mask Tu32
|
|
var zType uintptr
|
|
_, _ = mask, zType
|
|
mask = libc.Uint32FromInt32(libc.Int32FromInt32(SQLITE_DETERMINISTIC) | libc.Int32FromInt32(SQLITE_DIRECTONLY) | libc.Int32FromInt32(SQLITE_SUBTYPE) | libc.Int32FromInt32(SQLITE_INNOCUOUS) | libc.Int32FromInt32(SQLITE_FUNC_INTERNAL))
|
|
if showInternFuncs != 0 {
|
|
mask = uint32(0xffffffff)
|
|
}
|
|
for {
|
|
if !(p != 0) {
|
|
break
|
|
}
|
|
if (*TFuncDef)(unsafe.Pointer(p)).FxSFunc == uintptr(0) {
|
|
goto _1
|
|
}
|
|
if (*TFuncDef)(unsafe.Pointer(p)).FfuncFlags&uint32(SQLITE_FUNC_INTERNAL) != uint32(0) && showInternFuncs == 0 {
|
|
goto _1
|
|
}
|
|
if (*TFuncDef)(unsafe.Pointer(p)).FxValue != uintptr(0) {
|
|
zType = __ccgo_ts + 19231
|
|
} else {
|
|
if (*TFuncDef)(unsafe.Pointer(p)).FxFinalize != uintptr(0) {
|
|
zType = __ccgo_ts + 19233
|
|
} else {
|
|
zType = __ccgo_ts + 7937
|
|
}
|
|
}
|
|
_sqlite3VdbeMultiLoad(tls, v, int32(1), __ccgo_ts+19235, libc.VaList(bp+8, (*TFuncDef)(unsafe.Pointer(p)).FzName, isBuiltin, zType, _azEnc[(*TFuncDef)(unsafe.Pointer(p)).FfuncFlags&uint32(SQLITE_FUNC_ENCMASK)], int32((*TFuncDef)(unsafe.Pointer(p)).FnArg), (*TFuncDef)(unsafe.Pointer(p)).FfuncFlags&mask^uint32(SQLITE_INNOCUOUS)))
|
|
goto _1
|
|
_1:
|
|
;
|
|
p = (*TFuncDef)(unsafe.Pointer(p)).FpNext
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Prepare the SQL statement in buffer zSql against database handle db.
|
|
// ** If successful, set *ppStmt to point to the new statement and return
|
|
// ** SQLITE_OK.
|
|
// **
|
|
// ** Otherwise, if an error does occur, set *ppStmt to NULL and return
|
|
// ** an SQLite error code. Additionally, set output variable *pzErrmsg to
|
|
// ** point to a buffer containing an error message. It is the responsibility
|
|
// ** of the caller to (eventually) free this buffer using sqlite3_free().
|
|
// */
|
|
func _prepareAndCollectError(tls *libc.TLS, db uintptr, ppStmt uintptr, pzErrmsg uintptr, zSql uintptr) (r int32) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var rc int32
|
|
_ = rc
|
|
rc = Xsqlite3_prepare_v2(tls, db, zSql, -int32(1), ppStmt, uintptr(0))
|
|
if rc != SQLITE_OK {
|
|
**(**uintptr)(__ccgo_up(pzErrmsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+3968, libc.VaList(bp+8, Xsqlite3_errmsg(tls, db)))
|
|
**(**uintptr)(__ccgo_up(ppStmt)) = uintptr(0)
|
|
}
|
|
return rc
|
|
}
|
|
|
|
func _pthreadMutexEnd(tls *libc.TLS) (r int32) {
|
|
return SQLITE_OK
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
|
|
// ** to enter a mutex. If another thread is already within the mutex,
|
|
// ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return
|
|
// ** SQLITE_BUSY. The sqlite3_mutex_try() interface returns SQLITE_OK
|
|
// ** upon successful entry. Mutexes created using SQLITE_MUTEX_RECURSIVE can
|
|
// ** be entered multiple times by the same thread. In such cases the,
|
|
// ** mutex must be exited an equal number of times before another thread
|
|
// ** can enter. If the same thread tries to enter any other kind of mutex
|
|
// ** more than once, the behavior is undefined.
|
|
// */
|
|
func _pthreadMutexEnter(tls *libc.TLS, p uintptr) {
|
|
/* Use the built-in recursive mutexes if they are available.
|
|
*/
|
|
libc.Xpthread_mutex_lock(tls, p)
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** This routine deallocates a previously
|
|
// ** allocated mutex. SQLite is careful to deallocate every
|
|
// ** mutex that it allocates.
|
|
// */
|
|
func _pthreadMutexFree(tls *libc.TLS, p uintptr) {
|
|
libc.Xpthread_mutex_destroy(tls, p)
|
|
Xsqlite3_free(tls, p)
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Initialize and deinitialize the mutex subsystem.
|
|
// */
|
|
func _pthreadMutexInit(tls *libc.TLS) (r int32) {
|
|
return SQLITE_OK
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** The sqlite3_mutex_leave() routine exits a mutex that was
|
|
// ** previously entered by the same thread. The behavior
|
|
// ** is undefined if the mutex is not currently entered or
|
|
// ** is not currently allocated. SQLite will never do either.
|
|
// */
|
|
func _pthreadMutexLeave(tls *libc.TLS, p uintptr) {
|
|
libc.Xpthread_mutex_unlock(tls, p)
|
|
}
|
|
|
|
func _pthreadMutexTry(tls *libc.TLS, p uintptr) (r int32) {
|
|
var rc int32
|
|
_ = rc
|
|
/* Use the built-in recursive mutexes if they are available.
|
|
*/
|
|
if libc.Xpthread_mutex_trylock(tls, p) == 0 {
|
|
rc = SQLITE_OK
|
|
} else {
|
|
rc = int32(SQLITE_BUSY)
|
|
}
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /* This variable holds the process id (pid) from when the xRandomness()
|
|
// ** method was called. If xOpen() is called from a different process id,
|
|
// ** indicating that a fork() has occurred, the PRNG will be reset.
|
|
// */
|
|
var _randomnessPid = int32(0)
|
|
|
|
/*
|
|
** Allowed values for the unixFile.ctrlFlags bitmask:
|
|
*/
|
|
|
|
/*
|
|
** Include code that is common to all os_*.c files
|
|
*/
|
|
/* #include "os_common.h" */
|
|
|
|
/*
|
|
** Define various macros that are missing from some systems.
|
|
*/
|
|
|
|
/*
|
|
** The threadid macro resolves to the thread-id or to 0. Used for
|
|
** testing and debugging only.
|
|
*/
|
|
|
|
/*
|
|
** HAVE_MREMAP defaults to true on Linux and false everywhere else.
|
|
*/
|
|
|
|
/*
|
|
** Explicitly call the 64-bit version of lseek() on Android. Otherwise, lseek()
|
|
** is the 32-bit version, even if _FILE_OFFSET_BITS=64 is defined.
|
|
*/
|
|
|
|
/*
|
|
** Linux-specific IOCTL magic numbers used for controlling F2FS
|
|
*/
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** The SELECT statement iterating through the keys for the current object
|
|
// ** (p->objiter.pSelect) currently points to a valid row. However, there
|
|
// ** is something wrong with the rbu_control value in the rbu_control value
|
|
// ** 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) {
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_ERROR)
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+31770, 0)
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** If there is a "*-oal" file in the file-system corresponding to the
|
|
// ** target database in the file-system, delete it. If an error occurs,
|
|
// ** leave an error code and error message in the rbu handle.
|
|
// */
|
|
func _rbuDeleteOalFile(tls *libc.TLS, p uintptr) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var zOal uintptr
|
|
var _ /* pVfs at bp+0 */ uintptr
|
|
_ = zOal
|
|
zOal = _rbuMPrintf(tls, p, __ccgo_ts+33776, libc.VaList(bp+16, (*Tsqlite3rbu)(unsafe.Pointer(p)).FzTarget))
|
|
if zOal != 0 {
|
|
**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
|
|
Xsqlite3_file_control(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+6844, int32(SQLITE_FCNTL_VFS_POINTER), bp)
|
|
(*(*func(*libc.TLS, uintptr, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_vfs)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FxDelete})))(tls, **(**uintptr)(__ccgo_up(bp)), zOal, 0)
|
|
Xsqlite3_free(tls, zOal)
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Return true if the database handle passed as the only argument
|
|
// ** was opened with the rbu_exclusive_checkpoint=1 URI parameter
|
|
// ** specified. Or false otherwise.
|
|
// */
|
|
func _rbuExclusiveCheckpoint(tls *libc.TLS, db uintptr) (r int32) {
|
|
var zUri uintptr
|
|
_ = zUri
|
|
zUri = Xsqlite3_db_filename(tls, db, uintptr(0))
|
|
return Xsqlite3_uri_boolean(tls, zUri, __ccgo_ts+33751, 0)
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Finalize the statement passed as the second argument.
|
|
// **
|
|
// ** If the sqlite3_finalize() call indicates that an error occurs, and the
|
|
// ** rbu handle error code is not already set, set the error code and error
|
|
// ** message accordingly.
|
|
// */
|
|
func _rbuFinalize(tls *libc.TLS, p uintptr, pStmt uintptr) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var db uintptr
|
|
var rc int32
|
|
_, _ = db, rc
|
|
db = Xsqlite3_db_handle(tls, pStmt)
|
|
rc = Xsqlite3_finalize(tls, pStmt)
|
|
if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && rc != SQLITE_OK {
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+3968, libc.VaList(bp+8, Xsqlite3_errmsg(tls, db)))
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Take an EXCLUSIVE lock on the database file. Return SQLITE_OK if
|
|
// ** successful, or an SQLite error code otherwise.
|
|
// */
|
|
func _rbuLockDatabase(tls *libc.TLS, db uintptr) (r int32) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var rc int32
|
|
var _ /* fd at bp+0 */ uintptr
|
|
_ = rc
|
|
rc = SQLITE_OK
|
|
**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
|
|
Xsqlite3_file_control(tls, db, __ccgo_ts+6844, int32(RBU_ZIPVFS_CTRL_FILE_POINTER), bp)
|
|
if **(**uintptr)(__ccgo_up(bp)) != 0 {
|
|
Xsqlite3_file_control(tls, db, __ccgo_ts+6844, int32(SQLITE_FCNTL_FILE_POINTER), bp)
|
|
rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpMethods)).FxLock})))(tls, **(**uintptr)(__ccgo_up(bp)), int32(SQLITE_LOCK_SHARED))
|
|
if rc == SQLITE_OK {
|
|
rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpMethods)).FxUnlock})))(tls, **(**uintptr)(__ccgo_up(bp)), SQLITE_LOCK_NONE)
|
|
}
|
|
Xsqlite3_file_control(tls, db, __ccgo_ts+6844, int32(RBU_ZIPVFS_CTRL_FILE_POINTER), bp)
|
|
} else {
|
|
Xsqlite3_file_control(tls, db, __ccgo_ts+6844, int32(SQLITE_FCNTL_FILE_POINTER), bp)
|
|
}
|
|
if rc == SQLITE_OK && (*Tsqlite3_file)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpMethods != 0 {
|
|
rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpMethods)).FxLock})))(tls, **(**uintptr)(__ccgo_up(bp)), int32(SQLITE_LOCK_SHARED))
|
|
if rc == SQLITE_OK {
|
|
rc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(**(**uintptr)(__ccgo_up(bp)))).FpMethods)).FxLock})))(tls, **(**uintptr)(__ccgo_up(bp)), int32(SQLITE_LOCK_EXCLUSIVE))
|
|
}
|
|
}
|
|
return rc
|
|
}
|
|
|
|
func _rbuOpenDbhandle(tls *libc.TLS, p uintptr, zName uintptr, bUseVfs int32) (r uintptr) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var flags int32
|
|
var v1 uintptr
|
|
var _ /* db at bp+0 */ uintptr
|
|
_, _ = flags, v1
|
|
**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
|
|
if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
|
|
flags = libc.Int32FromInt32(SQLITE_OPEN_READWRITE) | libc.Int32FromInt32(SQLITE_OPEN_CREATE) | libc.Int32FromInt32(SQLITE_OPEN_URI)
|
|
if bUseVfs != 0 {
|
|
v1 = (*Tsqlite3rbu)(unsafe.Pointer(p)).FzVfsName
|
|
} else {
|
|
v1 = uintptr(0)
|
|
}
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_open_v2(tls, zName, bp, flags, v1)
|
|
if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc != 0 {
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+3968, libc.VaList(bp+16, Xsqlite3_errmsg(tls, **(**uintptr)(__ccgo_up(bp)))))
|
|
Xsqlite3_close(tls, **(**uintptr)(__ccgo_up(bp)))
|
|
**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
|
|
}
|
|
}
|
|
return **(**uintptr)(__ccgo_up(bp))
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** This function is called as part of initializing or reinitializing an
|
|
// ** incremental checkpoint.
|
|
// **
|
|
// ** It populates the sqlite3rbu.aFrame[] array with the set of
|
|
// ** (wal frame -> db page) copy operations required to checkpoint the
|
|
// ** current wal file, and obtains the set of shm locks required to safely
|
|
// ** perform the copy operations directly on the file-system.
|
|
// **
|
|
// ** If argument pState is not NULL, then the incremental checkpoint is
|
|
// ** being resumed. In this case, if the checksum of the wal-index-header
|
|
// ** following recovery is not the same as the checksum saved in the RbuState
|
|
// ** object, then the rbu handle is set to DONE state. This occurs if some
|
|
// ** other client appends a transaction to the wal file in the middle of
|
|
// ** an incremental checkpoint.
|
|
// */
|
|
func _rbuSetupCheckpoint(tls *libc.TLS, p uintptr, pState uintptr) {
|
|
var nSectorSize, rc2, v1 int32
|
|
var pDb, pWal uintptr
|
|
_, _, _, _, _ = nSectorSize, pDb, pWal, rc2, v1
|
|
/* If pState is NULL, then the wal file may not have been opened and
|
|
** recovered. Running a read-statement here to ensure that doing so
|
|
** does not interfere with the "capture" process below. */
|
|
if pState == uintptr(0) {
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = 0
|
|
if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+33670, uintptr(0), uintptr(0), uintptr(0))
|
|
}
|
|
}
|
|
/* Assuming no error has occurred, run a "restart" checkpoint with the
|
|
** sqlite3rbu.eStage variable set to CAPTURE. This turns on the following
|
|
** special behaviour in the rbu VFS:
|
|
**
|
|
** * If the exclusive shm WRITER or READ0 lock cannot be obtained,
|
|
** the checkpoint fails with SQLITE_BUSY (normally SQLite would
|
|
** proceed with running a passive checkpoint instead of failing).
|
|
**
|
|
** * Attempts to read from the *-wal file or write to the database file
|
|
** do not perform any IO. Instead, the frame/page combinations that
|
|
** would be read/written are recorded in the sqlite3rbu.aFrame[]
|
|
** array.
|
|
**
|
|
** * Calls to xShmLock(UNLOCK) to release the exclusive shm WRITER,
|
|
** READ0 and CHECKPOINT locks taken as part of the checkpoint are
|
|
** no-ops. These locks will not be released until the connection
|
|
** is closed.
|
|
**
|
|
** * Attempting to xSync() the database file causes an SQLITE_NOTICE
|
|
** error.
|
|
**
|
|
** As a result, unless an error (i.e. OOM or SQLITE_BUSY) occurs, the
|
|
** checkpoint below fails with SQLITE_NOTICE, and leaves the aFrame[]
|
|
** array populated with a set of (frame -> page) mappings. Because the
|
|
** 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 (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = int32(RBU_STAGE_CAPTURE)
|
|
rc2 = Xsqlite3_exec(tls, (*Tsqlite3rbu)(unsafe.Pointer(p)).FdbMain, __ccgo_ts+33716, uintptr(0), uintptr(0), uintptr(0))
|
|
if rc2 != int32(SQLITE_NOTICE) {
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = rc2
|
|
}
|
|
}
|
|
if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK && (*Tsqlite3rbu)(unsafe.Pointer(p)).FnFrame > 0 {
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = int32(RBU_STAGE_CKPT)
|
|
if pState != 0 {
|
|
v1 = (*TRbuState)(unsafe.Pointer(pState)).FnRow
|
|
} else {
|
|
v1 = 0
|
|
}
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).FnStep = v1
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).FaBuf = _rbuMalloc(tls, p, int64((*Tsqlite3rbu)(unsafe.Pointer(p)).Fpgsz))
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).FiWalCksum = _rbuShmChecksum(tls, p)
|
|
}
|
|
if (*Tsqlite3rbu)(unsafe.Pointer(p)).Frc == SQLITE_OK {
|
|
if (*Tsqlite3rbu)(unsafe.Pointer(p)).FnFrame == 0 || pState != 0 && (*TRbuState)(unsafe.Pointer(pState)).FiWalCksum != (*Tsqlite3rbu)(unsafe.Pointer(p)).FiWalCksum {
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = int32(SQLITE_DONE)
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).FeStage = int32(RBU_STAGE_DONE)
|
|
} else {
|
|
pDb = (*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpReal
|
|
pWal = (*Trbu_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer((*Tsqlite3rbu)(unsafe.Pointer(p)).FpTargetFd)).FpWalFd)).FpReal
|
|
nSectorSize = (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pDb)).FpMethods)).FxSectorSize})))(tls, pDb)
|
|
if nSectorSize > (*Tsqlite3rbu)(unsafe.Pointer(p)).Fpgsz {
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).FnPagePerSector = nSectorSize / (*Tsqlite3rbu)(unsafe.Pointer(p)).Fpgsz
|
|
} else {
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).FnPagePerSector = int32(1)
|
|
}
|
|
/* Call xSync() on the wal file. This causes SQLite to sync the
|
|
** directory in which the target database and the wal file reside, in
|
|
** case it has not been synced since the rename() call in
|
|
** rbuMoveOalFile(). */
|
|
(*Tsqlite3rbu)(unsafe.Pointer(p)).Frc = (*(*func(*libc.TLS, uintptr, int32) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer(pWal)).FpMethods)).FxSync})))(tls, pWal, int32(SQLITE_SYNC_NORMAL))
|
|
}
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** File control method. For custom operations on an rbuVfs-file.
|
|
// */
|
|
func _rbuVfsFileControl(tls *libc.TLS, pFile uintptr, op int32, pArg uintptr) (r int32) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var p, pRbu, pRbu1, pRbuVfs, xControl, zIn, zOut uintptr
|
|
var rc int32
|
|
var _ /* dummy at bp+0 */ uintptr
|
|
_, _, _, _, _, _, _, _ = p, pRbu, pRbu1, pRbuVfs, rc, xControl, zIn, zOut
|
|
p = pFile
|
|
xControl = (*Tsqlite3_io_methods)(unsafe.Pointer((*Tsqlite3_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpReal)).FpMethods)).FxFileControl
|
|
if op == int32(SQLITE_FCNTL_RBU) {
|
|
pRbu = pArg
|
|
/* First try to find another RBU vfs lower down in the vfs stack. If
|
|
** one is found, this vfs will operate in pass-through mode. The lower
|
|
** level vfs will do the special RBU handling. */
|
|
rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{xControl})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, op, pArg)
|
|
if rc == int32(SQLITE_NOTFOUND) {
|
|
/* Now search for a zipvfs instance lower down in the VFS stack. If
|
|
** one is found, this is an error. */
|
|
**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
|
|
rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{xControl})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, int32(SQLITE_FCNTL_ZIPVFS), bp)
|
|
if rc == SQLITE_OK {
|
|
rc = int32(SQLITE_ERROR)
|
|
(*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FzErrmsg = Xsqlite3_mprintf(tls, __ccgo_ts+34735, 0)
|
|
} else {
|
|
if rc == int32(SQLITE_NOTFOUND) {
|
|
(*Tsqlite3rbu)(unsafe.Pointer(pRbu)).FpTargetFd = p
|
|
(*Trbu_file)(unsafe.Pointer(p)).FpRbu = pRbu
|
|
_rbuMainlistAdd(tls, p)
|
|
if (*Trbu_file)(unsafe.Pointer(p)).FpWalFd != 0 {
|
|
(*Trbu_file)(unsafe.Pointer((*Trbu_file)(unsafe.Pointer(p)).FpWalFd)).FpRbu = pRbu
|
|
}
|
|
rc = SQLITE_OK
|
|
}
|
|
}
|
|
}
|
|
return rc
|
|
} else {
|
|
if op == int32(SQLITE_FCNTL_RBUCNT) {
|
|
pRbu1 = pArg
|
|
(*Tsqlite3rbu)(unsafe.Pointer(pRbu1)).FnRbu = (*Tsqlite3rbu)(unsafe.Pointer(pRbu1)).FnRbu + 1
|
|
(*Tsqlite3rbu)(unsafe.Pointer(pRbu1)).FpRbuFd = p
|
|
(*Trbu_file)(unsafe.Pointer(p)).FbNolock = uint8(1)
|
|
}
|
|
}
|
|
rc = (*(*func(*libc.TLS, uintptr, int32, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{xControl})))(tls, (*Trbu_file)(unsafe.Pointer(p)).FpReal, op, pArg)
|
|
if rc == SQLITE_OK && op == int32(SQLITE_FCNTL_VFSNAME) {
|
|
pRbuVfs = (*Trbu_file)(unsafe.Pointer(p)).FpRbuVfs
|
|
zIn = **(**uintptr)(__ccgo_up(pArg))
|
|
zOut = Xsqlite3_mprintf(tls, __ccgo_ts+34758, libc.VaList(bp+16, (*Trbu_vfs)(unsafe.Pointer(pRbuVfs)).Fbase.FzName, zIn))
|
|
**(**uintptr)(__ccgo_up(pArg)) = zOut
|
|
if zOut == uintptr(0) {
|
|
rc = int32(SQLITE_NOMEM)
|
|
}
|
|
}
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Generate VM code to replace any double-quoted strings (but not double-quoted
|
|
// ** identifiers) within the "sql" column of the sqlite_schema table in
|
|
// ** database zDb with their single-quoted equivalents. If argument bTemp is
|
|
// ** not true, similarly update all SQL statements in the sqlite_schema table
|
|
// ** of the temp db.
|
|
// */
|
|
func _renameFixQuotes(tls *libc.TLS, pParse uintptr, zDb uintptr, bTemp int32) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
_sqlite3NestedParse(tls, pParse, __ccgo_ts+9048, libc.VaList(bp+8, zDb, zDb))
|
|
if bTemp == 0 {
|
|
_sqlite3NestedParse(tls, pParse, __ccgo_ts+9195, 0)
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Reset the SQL statement passed as the first argument. Return a copy
|
|
// ** of the value returned by sqlite3_reset().
|
|
// **
|
|
// ** If an error has occurred, then set *pzErrmsg to point to a buffer
|
|
// ** containing an error message. It is the responsibility of the caller
|
|
// ** to eventually free this buffer using sqlite3_free().
|
|
// */
|
|
func _resetAndCollectError(tls *libc.TLS, pStmt uintptr, pzErrmsg uintptr) (r int32) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var rc int32
|
|
_ = rc
|
|
rc = Xsqlite3_reset(tls, pStmt)
|
|
if rc != SQLITE_OK {
|
|
**(**uintptr)(__ccgo_up(pzErrmsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+3968, libc.VaList(bp+8, Xsqlite3_errmsg(tls, Xsqlite3_db_handle(tls, pStmt))))
|
|
}
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Generate an ORDER BY or GROUP BY term out-of-range error.
|
|
// */
|
|
func _resolveOutOfRangeError(tls *libc.TLS, pParse uintptr, zType uintptr, i int32, mx int32, pError uintptr) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+7597, libc.VaList(bp+8, i, zType, mx))
|
|
_sqlite3RecordErrorOffsetOfExpr(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, pError)
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Close a file descriptor.
|
|
// **
|
|
// ** We assume that close() almost always works, since it is only in a
|
|
// ** very sick application or on a very sick platform that it might fail.
|
|
// ** If it does fail, simply leak the file descriptor, but do log the
|
|
// ** error.
|
|
// **
|
|
// ** Note that it is not safe to retry close() after EINTR since the
|
|
// ** file descriptor might have already been reused by another thread.
|
|
// ** 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) {
|
|
var v1 uintptr
|
|
_ = v1
|
|
if (*(*func(*libc.TLS, int32) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(1)].FpCurrent})))(tls, h) != 0 {
|
|
if pFile != 0 {
|
|
v1 = (*TunixFile)(unsafe.Pointer(pFile)).FzPath
|
|
} else {
|
|
v1 = uintptr(0)
|
|
}
|
|
_unixLogErrorAtLine(tls, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(16)<<libc.Int32FromInt32(8), __ccgo_ts+3547, v1, lineno)
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Retry ftruncate() calls that fail due to EINTR
|
|
// **
|
|
// ** All calls to ftruncate() within this file should be made through
|
|
// ** this wrapper. On the Android platform, bypassing the logic below
|
|
// ** could lead to a corrupt database.
|
|
// */
|
|
func _robust_ftruncate(tls *libc.TLS, h int32, sz Tsqlite3_int64) (r int32) {
|
|
var rc int32
|
|
_ = rc
|
|
for cond := true; cond; cond = rc < 0 && **(**int32)(__ccgo_up(libc.X__errno_location(tls))) == int32(EINTR) {
|
|
rc = (*(*func(*libc.TLS, int32, Toff_t) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(6)].FpCurrent})))(tls, h, sz)
|
|
}
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** The second and subsequent arguments to this function are a printf()
|
|
// ** style format string and arguments. This function formats the string and
|
|
// ** appends it to the report being accumulated in pCheck.
|
|
// */
|
|
func _rtreeCheckAppendMsg(tls *libc.TLS, pCheck uintptr, zFmt uintptr, va uintptr) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var ap Tva_list
|
|
var z, v1 uintptr
|
|
_, _, _ = ap, z, v1
|
|
ap = va
|
|
if (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK && (*TRtreeCheck)(unsafe.Pointer(pCheck)).FnErr < int32(RTREE_CHECK_MAX_ERROR) {
|
|
z = Xsqlite3_vmprintf(tls, zFmt, ap)
|
|
if z == uintptr(0) {
|
|
(*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc = int32(SQLITE_NOMEM)
|
|
} else {
|
|
if (*TRtreeCheck)(unsafe.Pointer(pCheck)).FzReport != 0 {
|
|
v1 = __ccgo_ts + 4380
|
|
} else {
|
|
v1 = __ccgo_ts + 1704
|
|
}
|
|
(*TRtreeCheck)(unsafe.Pointer(pCheck)).FzReport = Xsqlite3_mprintf(tls, __ccgo_ts+29079, libc.VaList(bp+8, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FzReport, v1, z))
|
|
if (*TRtreeCheck)(unsafe.Pointer(pCheck)).FzReport == uintptr(0) {
|
|
(*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc = int32(SQLITE_NOMEM)
|
|
}
|
|
}
|
|
(*TRtreeCheck)(unsafe.Pointer(pCheck)).FnErr = (*TRtreeCheck)(unsafe.Pointer(pCheck)).FnErr + 1
|
|
}
|
|
_ = ap
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Argument pCell points to an array of coordinates stored on an rtree page.
|
|
// ** This function checks that the coordinates are internally consistent (no
|
|
// ** x1>x2 conditions) and adds an error message to the RtreeCheck object
|
|
// ** if they are not.
|
|
// **
|
|
// ** Additionally, if pParent is not NULL, then it is assumed to point to
|
|
// ** the array of coordinates on the parent page that bound the page
|
|
// ** containing pCell. In this case it is also verified that the two
|
|
// ** sets of coordinates are mutually consistent and an error message added
|
|
// ** to the RtreeCheck object if they are not.
|
|
// */
|
|
func _rtreeCheckCellCoord(tls *libc.TLS, pCheck uintptr, iNode Ti64, iCell int32, pCell uintptr, pParent uintptr) {
|
|
bp := tls.Alloc(48)
|
|
defer tls.Free(48)
|
|
var i, v2, v3 int32
|
|
var v5 bool
|
|
var _ /* c1 at bp+0 */ TRtreeCoord
|
|
var _ /* c2 at bp+4 */ TRtreeCoord
|
|
var _ /* p1 at bp+8 */ TRtreeCoord
|
|
var _ /* p2 at bp+12 */ TRtreeCoord
|
|
_, _, _, _ = i, v2, v3, v5
|
|
i = 0
|
|
for {
|
|
if !(i < (*TRtreeCheck)(unsafe.Pointer(pCheck)).FnDim) {
|
|
break
|
|
}
|
|
_readCoord(tls, pCell+uintptr(libc.Int32FromInt32(4)*libc.Int32FromInt32(2)*i), bp)
|
|
_readCoord(tls, pCell+uintptr(int32(4)*(int32(2)*i+int32(1))), bp+4)
|
|
/* printf("%e, %e\n", c1.u.f, c2.u.f); */
|
|
if (*TRtreeCheck)(unsafe.Pointer(pCheck)).FbInt != 0 {
|
|
v2 = libc.BoolInt32(*(*int32)(unsafe.Pointer(bp)) > *(*int32)(unsafe.Pointer(bp + 4)))
|
|
} else {
|
|
v2 = libc.BoolInt32(*(*TRtreeValue)(unsafe.Pointer(bp)) > *(*TRtreeValue)(unsafe.Pointer(bp + 4)))
|
|
}
|
|
if v2 != 0 {
|
|
_rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29385, libc.VaList(bp+24, i, iCell, iNode))
|
|
}
|
|
if pParent != 0 {
|
|
_readCoord(tls, pParent+uintptr(libc.Int32FromInt32(4)*libc.Int32FromInt32(2)*i), bp+8)
|
|
_readCoord(tls, pParent+uintptr(int32(4)*(int32(2)*i+int32(1))), bp+12)
|
|
if (*TRtreeCheck)(unsafe.Pointer(pCheck)).FbInt != 0 {
|
|
v2 = libc.BoolInt32(*(*int32)(unsafe.Pointer(bp)) < *(*int32)(unsafe.Pointer(bp + 8)))
|
|
} else {
|
|
v2 = libc.BoolInt32(*(*TRtreeValue)(unsafe.Pointer(bp)) < *(*TRtreeValue)(unsafe.Pointer(bp + 8)))
|
|
}
|
|
if v5 = v2 != 0; !v5 {
|
|
if (*TRtreeCheck)(unsafe.Pointer(pCheck)).FbInt != 0 {
|
|
v3 = libc.BoolInt32(*(*int32)(unsafe.Pointer(bp + 4)) > *(*int32)(unsafe.Pointer(bp + 12)))
|
|
} else {
|
|
v3 = libc.BoolInt32(*(*TRtreeValue)(unsafe.Pointer(bp + 4)) > *(*TRtreeValue)(unsafe.Pointer(bp + 12)))
|
|
}
|
|
}
|
|
if v5 || v3 != 0 {
|
|
_rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29433, libc.VaList(bp+24, i, iCell, iNode))
|
|
}
|
|
}
|
|
goto _1
|
|
_1:
|
|
;
|
|
i = i + 1
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** The second argument to this function must be either "_rowid" or
|
|
// ** "_parent". This function checks that the number of entries in the
|
|
// ** %_rowid or %_parent table is exactly nExpect. If not, it adds
|
|
// ** an error message to the report in the RtreeCheck object indicated
|
|
// ** by the first argument.
|
|
// */
|
|
func _rtreeCheckCount(tls *libc.TLS, pCheck uintptr, zTbl uintptr, nExpect Ti64) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var nActual Ti64
|
|
var pCount uintptr
|
|
_, _ = nActual, pCount
|
|
if (*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc == SQLITE_OK {
|
|
pCount = _rtreeCheckPrepare(tls, pCheck, __ccgo_ts+29619, libc.VaList(bp+8, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FzDb, (*TRtreeCheck)(unsafe.Pointer(pCheck)).FzTab, zTbl))
|
|
if pCount != 0 {
|
|
if Xsqlite3_step(tls, pCount) == int32(SQLITE_ROW) {
|
|
nActual = Xsqlite3_column_int64(tls, pCount, 0)
|
|
if nActual != nExpect {
|
|
_rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29650, libc.VaList(bp+8, zTbl, nExpect, nActual))
|
|
}
|
|
}
|
|
(*TRtreeCheck)(unsafe.Pointer(pCheck)).Frc = Xsqlite3_finalize(tls, pCount)
|
|
}
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Run rtreecheck() checks on node iNode, which is at depth iDepth within
|
|
// ** the r-tree structure. Argument aParent points to the array of coordinates
|
|
// ** that bound node iNode on the parent node.
|
|
// **
|
|
// ** If any problems are discovered, an error message is appended to the
|
|
// ** report accumulated in the RtreeCheck object.
|
|
// */
|
|
func _rtreeCheckNode(tls *libc.TLS, pCheck uintptr, iDepth int32, aParent uintptr, iNode Ti64) {
|
|
bp := tls.Alloc(48)
|
|
defer tls.Free(48)
|
|
var aNode, pCell uintptr
|
|
var i, nCell int32
|
|
var iVal Ti64
|
|
var _ /* nNode at bp+0 */ int32
|
|
_, _, _, _, _ = aNode, i, iVal, nCell, pCell
|
|
aNode = uintptr(0)
|
|
**(**int32)(__ccgo_up(bp)) = 0
|
|
aNode = _rtreeCheckGetNode(tls, pCheck, iNode, bp)
|
|
if aNode != 0 {
|
|
if **(**int32)(__ccgo_up(bp)) < int32(4) {
|
|
_rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29500, libc.VaList(bp+16, iNode, **(**int32)(__ccgo_up(bp))))
|
|
} else { /* Used to iterate through cells */
|
|
if aParent == uintptr(0) {
|
|
iDepth = _readInt16(tls, aNode)
|
|
if iDepth > int32(RTREE_MAX_DEPTH) {
|
|
_rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29534, libc.VaList(bp+16, iDepth))
|
|
Xsqlite3_free(tls, aNode)
|
|
return
|
|
}
|
|
}
|
|
nCell = _readInt16(tls, aNode+2)
|
|
if int32(4)+nCell*(int32(8)+(*TRtreeCheck)(unsafe.Pointer(pCheck)).FnDim*int32(2)*int32(4)) > **(**int32)(__ccgo_up(bp)) {
|
|
_rtreeCheckAppendMsg(tls, pCheck, __ccgo_ts+29564, libc.VaList(bp+16, iNode, nCell, **(**int32)(__ccgo_up(bp))))
|
|
} else {
|
|
i = 0
|
|
for {
|
|
if !(i < nCell) {
|
|
break
|
|
}
|
|
pCell = aNode + uintptr(int32(4)+i*(int32(8)+(*TRtreeCheck)(unsafe.Pointer(pCheck)).FnDim*int32(2)*int32(4)))
|
|
iVal = _readInt64(tls, pCell)
|
|
_rtreeCheckCellCoord(tls, pCheck, iNode, i, pCell+8, aParent)
|
|
if iDepth > 0 {
|
|
_rtreeCheckMapping(tls, pCheck, 0, iVal, iNode)
|
|
_rtreeCheckNode(tls, pCheck, iDepth-int32(1), pCell+8, iVal)
|
|
(*TRtreeCheck)(unsafe.Pointer(pCheck)).FnNonLeaf = (*TRtreeCheck)(unsafe.Pointer(pCheck)).FnNonLeaf + 1
|
|
} else {
|
|
_rtreeCheckMapping(tls, pCheck, int32(1), iVal, iNode)
|
|
(*TRtreeCheck)(unsafe.Pointer(pCheck)).FnLeaf = (*TRtreeCheck)(unsafe.Pointer(pCheck)).FnLeaf + 1
|
|
}
|
|
goto _1
|
|
_1:
|
|
;
|
|
i = i + 1
|
|
}
|
|
}
|
|
}
|
|
Xsqlite3_free(tls, aNode)
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** A constraint has failed while inserting a row into an rtree table.
|
|
// ** Assuming no OOM error occurs, this function sets the error message
|
|
// ** (at pRtree->base.zErrMsg) to an appropriate value and returns
|
|
// ** SQLITE_CONSTRAINT.
|
|
// **
|
|
// ** Parameter iCol is the index of the leftmost column involved in the
|
|
// ** constraint failure. If it is 0, then the constraint that failed is
|
|
// ** the unique constraint on the id column. Otherwise, it is the rtree
|
|
// ** (c1<=c2) constraint on columns iCol and iCol+1 that has failed.
|
|
// **
|
|
// ** If an OOM occurs, SQLITE_NOMEM is returned instead of SQLITE_CONSTRAINT.
|
|
// */
|
|
func _rtreeConstraintError(tls *libc.TLS, pRtree uintptr, iCol int32) (r int32) {
|
|
bp := tls.Alloc(48)
|
|
defer tls.Free(48)
|
|
var rc, v1 int32
|
|
var zCol, zCol1, zCol2, zSql uintptr
|
|
var _ /* pStmt at bp+0 */ uintptr
|
|
_, _, _, _, _, _ = rc, zCol, zCol1, zCol2, zSql, v1
|
|
**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
|
|
zSql = Xsqlite3_mprintf(tls, __ccgo_ts+27533, libc.VaList(bp+16, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName))
|
|
if zSql != 0 {
|
|
rc = Xsqlite3_prepare_v2(tls, (*TRtree)(unsafe.Pointer(pRtree)).Fdb, zSql, -int32(1), bp, uintptr(0))
|
|
} else {
|
|
rc = int32(SQLITE_NOMEM)
|
|
}
|
|
Xsqlite3_free(tls, zSql)
|
|
if rc == SQLITE_OK {
|
|
if iCol == 0 {
|
|
zCol = Xsqlite3_column_name(tls, **(**uintptr)(__ccgo_up(bp)), 0)
|
|
(*TRtree)(unsafe.Pointer(pRtree)).Fbase.FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+27553, libc.VaList(bp+16, (*TRtree)(unsafe.Pointer(pRtree)).FzName, zCol))
|
|
} else {
|
|
zCol1 = Xsqlite3_column_name(tls, **(**uintptr)(__ccgo_up(bp)), iCol)
|
|
zCol2 = Xsqlite3_column_name(tls, **(**uintptr)(__ccgo_up(bp)), iCol+int32(1))
|
|
(*TRtree)(unsafe.Pointer(pRtree)).Fbase.FzErrMsg = Xsqlite3_mprintf(tls, __ccgo_ts+27585, libc.VaList(bp+16, (*TRtree)(unsafe.Pointer(pRtree)).FzName, zCol1, zCol2))
|
|
}
|
|
}
|
|
Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp)))
|
|
if rc == SQLITE_OK {
|
|
v1 = int32(SQLITE_CONSTRAINT)
|
|
} else {
|
|
v1 = rc
|
|
}
|
|
return v1
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Rtree virtual table module xDestroy method.
|
|
// */
|
|
func _rtreeDestroy(tls *libc.TLS, pVtab uintptr) (r int32) {
|
|
bp := tls.Alloc(64)
|
|
defer tls.Free(64)
|
|
var pRtree, zCreate uintptr
|
|
var rc int32
|
|
_, _, _ = pRtree, rc, zCreate
|
|
pRtree = pVtab
|
|
zCreate = Xsqlite3_mprintf(tls, __ccgo_ts+27437, libc.VaList(bp+8, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName))
|
|
if !(zCreate != 0) {
|
|
rc = int32(SQLITE_NOMEM)
|
|
} else {
|
|
_nodeBlobReset(tls, pRtree)
|
|
rc = Xsqlite3_exec(tls, (*TRtree)(unsafe.Pointer(pRtree)).Fdb, zCreate, uintptr(0), uintptr(0), uintptr(0))
|
|
Xsqlite3_free(tls, zCreate)
|
|
}
|
|
if rc == SQLITE_OK {
|
|
_rtreeRelease(tls, pRtree)
|
|
}
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Implementation of the xIntegrity method for Rtree.
|
|
// */
|
|
func _rtreeIntegrity(tls *libc.TLS, pVtab uintptr, zSchema uintptr, zName uintptr, isQuick int32, pzErr uintptr) (r int32) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var pRtree uintptr
|
|
var rc int32
|
|
_, _ = pRtree, rc
|
|
pRtree = pVtab
|
|
_ = zSchema
|
|
_ = zName
|
|
_ = isQuick
|
|
rc = _rtreeCheckTable(tls, (*TRtree)(unsafe.Pointer(pRtree)).Fdb, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName, pzErr)
|
|
if rc == SQLITE_OK && **(**uintptr)(__ccgo_up(pzErr)) != 0 {
|
|
**(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+29791, libc.VaList(bp+8, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName, **(**uintptr)(__ccgo_up(pzErr))))
|
|
if **(**uintptr)(__ccgo_up(pzErr)) == uintptr(0) {
|
|
rc = int32(SQLITE_NOMEM)
|
|
}
|
|
}
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** This function populates the pRtree->nRowEst variable with an estimate
|
|
// ** of the number of rows in the virtual table. If possible, this is based
|
|
// ** on sqlite_stat1 data. Otherwise, use RTREE_DEFAULT_ROWEST.
|
|
// */
|
|
func _rtreeQueryStat1(tls *libc.TLS, db uintptr, pRtree uintptr) (r int32) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var nRow Ti64
|
|
var rc, v1 int32
|
|
var zFmt, zSql uintptr
|
|
var v2 int64
|
|
var _ /* p at bp+0 */ uintptr
|
|
_, _, _, _, _, _ = nRow, rc, zFmt, zSql, v1, v2
|
|
zFmt = __ccgo_ts + 27767
|
|
nRow = int64(RTREE_MIN_ROWEST)
|
|
rc = Xsqlite3_table_column_metadata(tls, db, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, __ccgo_ts+12861, uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0))
|
|
if rc != SQLITE_OK {
|
|
(*TRtree)(unsafe.Pointer(pRtree)).FnRowEst = int64(RTREE_DEFAULT_ROWEST)
|
|
if rc == int32(SQLITE_ERROR) {
|
|
v1 = SQLITE_OK
|
|
} else {
|
|
v1 = rc
|
|
}
|
|
return v1
|
|
}
|
|
zSql = Xsqlite3_mprintf(tls, zFmt, libc.VaList(bp+16, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName))
|
|
if zSql == uintptr(0) {
|
|
rc = int32(SQLITE_NOMEM)
|
|
} else {
|
|
rc = Xsqlite3_prepare_v2(tls, db, zSql, -int32(1), bp, uintptr(0))
|
|
if rc == SQLITE_OK {
|
|
if Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) == int32(SQLITE_ROW) {
|
|
nRow = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), 0)
|
|
}
|
|
rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp)))
|
|
}
|
|
Xsqlite3_free(tls, zSql)
|
|
}
|
|
if nRow > int64(libc.Int32FromInt32(RTREE_MIN_ROWEST)) {
|
|
v2 = nRow
|
|
} else {
|
|
v2 = int64(libc.Int32FromInt32(RTREE_MIN_ROWEST))
|
|
}
|
|
(*TRtree)(unsafe.Pointer(pRtree)).FnRowEst = v2
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** The xRename method for rtree module virtual tables.
|
|
// */
|
|
func _rtreeRename(tls *libc.TLS, pVtab uintptr, zNewName uintptr) (r int32) {
|
|
bp := tls.Alloc(80)
|
|
defer tls.Free(80)
|
|
var pRtree, zSql uintptr
|
|
var rc int32
|
|
_, _, _ = pRtree, rc, zSql
|
|
pRtree = pVtab
|
|
rc = int32(SQLITE_NOMEM)
|
|
zSql = Xsqlite3_mprintf(tls, __ccgo_ts+27622, libc.VaList(bp+8, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName, zNewName, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName, zNewName, (*TRtree)(unsafe.Pointer(pRtree)).FzDb, (*TRtree)(unsafe.Pointer(pRtree)).FzName, zNewName))
|
|
if zSql != 0 {
|
|
_nodeBlobReset(tls, pRtree)
|
|
rc = Xsqlite3_exec(tls, (*TRtree)(unsafe.Pointer(pRtree)).Fdb, zSql, uintptr(0), uintptr(0), uintptr(0))
|
|
Xsqlite3_free(tls, zSql)
|
|
}
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /* This routine implements an SQL function that returns the "depth" parameter
|
|
// ** from the front of a blob that is an r-tree node. For example:
|
|
// **
|
|
// ** SELECT rtreedepth(data) FROM rt_node WHERE nodeno=1;
|
|
// **
|
|
// ** The depth value is 0 for all nodes other than the root node, and the root
|
|
// ** node always has nodeno=1, so the example above is the primary use for this
|
|
// ** routine. This routine is intended for testing and analysis only.
|
|
// */
|
|
func _rtreedepth(tls *libc.TLS, ctx uintptr, nArg int32, apArg uintptr) {
|
|
var zBlob uintptr
|
|
_ = zBlob
|
|
_ = nArg
|
|
if Xsqlite3_value_type(tls, **(**uintptr)(__ccgo_up(apArg))) != int32(SQLITE_BLOB) || Xsqlite3_value_bytes(tls, **(**uintptr)(__ccgo_up(apArg))) < int32(2) {
|
|
Xsqlite3_result_error(tls, ctx, __ccgo_ts+29046, -int32(1))
|
|
} else {
|
|
zBlob = Xsqlite3_value_blob(tls, **(**uintptr)(__ccgo_up(apArg)))
|
|
if zBlob != 0 {
|
|
Xsqlite3_result_int(tls, ctx, _readInt16(tls, zBlob))
|
|
} else {
|
|
Xsqlite3_result_error_nomem(tls, ctx)
|
|
}
|
|
}
|
|
}
|
|
|
|
var _sMutex1 = Tsqlite3_mutex_methods{}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Attempt to apply the change that the iterator passed as the first argument
|
|
// ** currently points to to the database. If a conflict is encountered, invoke
|
|
// ** the conflict handler callback.
|
|
// **
|
|
// ** The difference between this function and sessionApplyOne() is that this
|
|
// ** function handles the case where the conflict-handler is invoked and
|
|
// ** returns SQLITE_CHANGESET_REPLACE - indicating that the change should be
|
|
// ** retried in some manner.
|
|
// */
|
|
func _sessionApplyOneWithRetry(tls *libc.TLS, db uintptr, pIter uintptr, pApply uintptr, __ccgo_fp_xConflict uintptr, pCtx uintptr) (r int32) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var rc int32
|
|
var _ /* bReplace at bp+0 */ int32
|
|
var _ /* bRetry at bp+4 */ int32
|
|
_ = rc
|
|
**(**int32)(__ccgo_up(bp)) = 0
|
|
**(**int32)(__ccgo_up(bp + 4)) = 0
|
|
rc = _sessionApplyOneOp(tls, pIter, pApply, __ccgo_fp_xConflict, pCtx, bp, bp+4)
|
|
if rc == SQLITE_OK {
|
|
/* If the bRetry flag is set, the change has not been applied due to an
|
|
** SQLITE_CHANGESET_DATA problem (i.e. this is an UPDATE or DELETE and
|
|
** a row with the correct PK is present in the db, but one or more other
|
|
** fields do not contain the expected values) and the conflict handler
|
|
** returned SQLITE_CHANGESET_REPLACE. In this case retry the operation,
|
|
** but pass NULL as the final argument so that sessionApplyOneOp() ignores
|
|
** the SQLITE_CHANGESET_DATA problem. */
|
|
if **(**int32)(__ccgo_up(bp + 4)) != 0 {
|
|
rc = _sessionApplyOneOp(tls, pIter, pApply, __ccgo_fp_xConflict, pCtx, uintptr(0), uintptr(0))
|
|
} else {
|
|
if **(**int32)(__ccgo_up(bp)) != 0 {
|
|
rc = Xsqlite3_exec(tls, db, __ccgo_ts+36351, uintptr(0), uintptr(0), uintptr(0))
|
|
if rc == SQLITE_OK {
|
|
rc = _sessionBindRow(tls, pIter, __ccgo_fp(Xsqlite3changeset_new), (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FnCol, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FabPK, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete)
|
|
Xsqlite3_bind_int(tls, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FnCol+int32(1), int32(1))
|
|
}
|
|
if rc == SQLITE_OK {
|
|
Xsqlite3_step(tls, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete)
|
|
rc = Xsqlite3_reset(tls, (*TSessionApplyCtx)(unsafe.Pointer(pApply)).FpDelete)
|
|
}
|
|
if rc == SQLITE_OK {
|
|
rc = _sessionApplyOneOp(tls, pIter, pApply, __ccgo_fp_xConflict, pCtx, uintptr(0), uintptr(0))
|
|
}
|
|
if rc == SQLITE_OK {
|
|
rc = Xsqlite3_exec(tls, db, __ccgo_ts+36372, uintptr(0), uintptr(0), uintptr(0))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return rc
|
|
}
|
|
|
|
func _sessionDiffFindModified(tls *libc.TLS, pSession uintptr, pTab uintptr, zFrom uintptr, zExpr uintptr) (r int32) {
|
|
bp := tls.Alloc(80)
|
|
defer tls.Free(80)
|
|
var iRowid Ti64
|
|
var pDiffCtx, z1, z2, zExpr2, zStmt uintptr
|
|
var rc int32
|
|
var v1 int64
|
|
var _ /* pStmt at bp+0 */ uintptr
|
|
_, _, _, _, _, _, _, _ = iRowid, pDiffCtx, rc, z1, z2, zExpr2, zStmt, v1
|
|
rc = SQLITE_OK
|
|
zExpr2 = _sessionExprCompareOther(tls, (*TSessionTable)(unsafe.Pointer(pTab)).FnCol, (*Tsqlite3_session)(unsafe.Pointer(pSession)).FzDb, zFrom, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, (*TSessionTable)(unsafe.Pointer(pTab)).FazCol, (*TSessionTable)(unsafe.Pointer(pTab)).FabPK)
|
|
if zExpr2 == uintptr(0) {
|
|
rc = int32(SQLITE_NOMEM)
|
|
} else {
|
|
z1 = _sessionAllCols(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).FzDb, pTab)
|
|
z2 = _sessionAllCols(tls, zFrom, pTab)
|
|
zStmt = Xsqlite3_mprintf(tls, __ccgo_ts+35574, libc.VaList(bp+16, z1, z2, (*Tsqlite3_session)(unsafe.Pointer(pSession)).FzDb, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, zFrom, (*TSessionTable)(unsafe.Pointer(pTab)).FzName, zExpr, zExpr2))
|
|
if zStmt == uintptr(0) || z1 == uintptr(0) || z2 == uintptr(0) {
|
|
rc = int32(SQLITE_NOMEM)
|
|
} else {
|
|
rc = Xsqlite3_prepare_v2(tls, (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fdb, zStmt, -int32(1), bp, uintptr(0))
|
|
if rc == SQLITE_OK {
|
|
pDiffCtx = (*Tsqlite3_session)(unsafe.Pointer(pSession)).Fhook.FpCtx
|
|
(*TSessionDiffCtx)(unsafe.Pointer(pDiffCtx)).FpStmt = **(**uintptr)(__ccgo_up(bp))
|
|
(*TSessionDiffCtx)(unsafe.Pointer(pDiffCtx)).FnOldOff = (*TSessionTable)(unsafe.Pointer(pTab)).FnCol
|
|
for int32(SQLITE_ROW) == Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp))) {
|
|
if (*TSessionTable)(unsafe.Pointer(pTab)).FbRowid != 0 {
|
|
v1 = Xsqlite3_column_int64(tls, **(**uintptr)(__ccgo_up(bp)), 0)
|
|
} else {
|
|
v1 = 0
|
|
}
|
|
iRowid = v1
|
|
_sessionPreupdateOneChange(tls, int32(SQLITE_UPDATE), iRowid, pSession, pTab)
|
|
}
|
|
rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp)))
|
|
}
|
|
}
|
|
Xsqlite3_free(tls, zStmt)
|
|
Xsqlite3_free(tls, z1)
|
|
Xsqlite3_free(tls, z2)
|
|
}
|
|
return rc
|
|
}
|
|
|
|
func _sessionPrepare(tls *libc.TLS, db uintptr, pp uintptr, pzErrmsg uintptr, zSql uintptr) (r int32) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var rc int32
|
|
_ = rc
|
|
rc = Xsqlite3_prepare_v2(tls, db, zSql, -int32(1), pp, uintptr(0))
|
|
if pzErrmsg != 0 && rc != SQLITE_OK {
|
|
**(**uintptr)(__ccgo_up(pzErrmsg)) = Xsqlite3_mprintf(tls, __ccgo_ts+3968, libc.VaList(bp+8, Xsqlite3_errmsg(tls, db)))
|
|
}
|
|
return rc
|
|
}
|
|
|
|
func _sessionSelectFindNew(tls *libc.TLS, zDb1 uintptr, zDb2 uintptr, bRowid int32, zTbl uintptr, zExpr uintptr) (r uintptr) {
|
|
bp := tls.Alloc(64)
|
|
defer tls.Free(64)
|
|
var zRet, zSel, v1 uintptr
|
|
_, _, _ = zRet, zSel, v1
|
|
if bRowid != 0 {
|
|
v1 = __ccgo_ts + 35465
|
|
} else {
|
|
v1 = __ccgo_ts + 6849
|
|
}
|
|
zSel = v1
|
|
zRet = Xsqlite3_mprintf(tls, __ccgo_ts+35476, libc.VaList(bp+8, zSel, zDb1, zTbl, zDb2, zTbl, zExpr))
|
|
return zRet
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Check if table zTab in the "main" database of db is a WITHOUT ROWID
|
|
// ** table.
|
|
// **
|
|
// ** If no error occurs, return SQLITE_OK and set output variable (*pbWR) to
|
|
// ** true if zTab is a WITHOUT ROWID table, or false otherwise. Or, if an
|
|
// ** error does occur, return an SQLite error code. The final value of (*pbWR)
|
|
// ** is undefined in this case.
|
|
// */
|
|
func _sessionTableIsWithoutRowid(tls *libc.TLS, db uintptr, zTab uintptr, pbWR uintptr) (r int32) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var rc int32
|
|
var zSql uintptr
|
|
var _ /* pList at bp+0 */ uintptr
|
|
_, _ = rc, zSql
|
|
**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
|
|
zSql = uintptr(0)
|
|
rc = SQLITE_OK
|
|
zSql = Xsqlite3_mprintf(tls, __ccgo_ts+36391, libc.VaList(bp+16, zTab))
|
|
if zSql == uintptr(0) {
|
|
rc = int32(SQLITE_NOMEM)
|
|
} else {
|
|
rc = Xsqlite3_prepare_v2(tls, db, zSql, -int32(1), bp, uintptr(0))
|
|
Xsqlite3_free(tls, zSql)
|
|
}
|
|
if rc == SQLITE_OK {
|
|
Xsqlite3_step(tls, **(**uintptr)(__ccgo_up(bp)))
|
|
**(**int32)(__ccgo_up(pbWR)) = Xsqlite3_column_int(tls, **(**uintptr)(__ccgo_up(bp)), int32(4))
|
|
rc = Xsqlite3_finalize(tls, **(**uintptr)(__ccgo_up(bp)))
|
|
}
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Do an authorization check using the code and arguments given. Return
|
|
// ** either SQLITE_OK (zero) or SQLITE_IGNORE or SQLITE_DENY. If SQLITE_DENY
|
|
// ** is returned, then the error count and error message in pParse are
|
|
// ** modified appropriately.
|
|
// */
|
|
func _sqlite3AuthCheck(tls *libc.TLS, pParse uintptr, code int32, zArg1 uintptr, zArg2 uintptr, zArg3 uintptr) (r int32) {
|
|
var db uintptr
|
|
var rc int32
|
|
_, _ = db, rc
|
|
db = (*TParse)(unsafe.Pointer(pParse)).Fdb
|
|
/* Don't do any authorization checks if the database is initializing
|
|
** or if the parser is being invoked from within sqlite3_declare_vtab.
|
|
*/
|
|
if (*Tsqlite3)(unsafe.Pointer(db)).FxAuth == uintptr(0) || (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FeParseMode) != PARSE_MODE_NORMAL {
|
|
return SQLITE_OK
|
|
}
|
|
/* EVIDENCE-OF: R-43249-19882 The third through sixth parameters to the
|
|
** callback are either NULL pointers or zero-terminated strings that
|
|
** contain additional details about the action to be authorized.
|
|
**
|
|
** The following testcase() macros show that any of the 3rd through 6th
|
|
** parameters can be either NULL or a string. */
|
|
rc = (*(*func(*libc.TLS, uintptr, int32, uintptr, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{(*Tsqlite3)(unsafe.Pointer(db)).FxAuth})))(tls, (*Tsqlite3)(unsafe.Pointer(db)).FpAuthArg, code, zArg1, zArg2, zArg3, (*TParse)(unsafe.Pointer(pParse)).FzAuthContext)
|
|
if rc == int32(SQLITE_DENY) {
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+13699, 0)
|
|
(*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_AUTH)
|
|
} else {
|
|
if rc != SQLITE_OK && rc != int32(SQLITE_IGNORE) {
|
|
rc = int32(SQLITE_DENY)
|
|
_sqliteAuthBadReturnCode(tls, pParse)
|
|
}
|
|
}
|
|
return rc
|
|
}
|
|
|
|
func _sqlite3CantopenError(tls *libc.TLS, lineno int32) (r int32) {
|
|
return _sqlite3ReportError(tls, int32(SQLITE_CANTOPEN), lineno, __ccgo_ts+26347)
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Close an existing SQLite database
|
|
// */
|
|
func _sqlite3Close(tls *libc.TLS, db uintptr, forceZombie int32) (r int32) {
|
|
var p uintptr
|
|
_ = p
|
|
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 SQLITE_OK
|
|
}
|
|
if !(_sqlite3SafetyCheckSickOrOk(tls, db) != 0) {
|
|
return _sqlite3MisuseError(tls, int32(188794))
|
|
}
|
|
Xsqlite3_mutex_enter(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
|
|
if libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).FmTrace)&int32(SQLITE_TRACE_CLOSE) != 0 {
|
|
(*(*func(*libc.TLS, Tu32, uintptr, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{*(*uintptr)(unsafe.Pointer(&(*Tsqlite3)(unsafe.Pointer(db)).Ftrace))})))(tls, uint32(SQLITE_TRACE_CLOSE), (*Tsqlite3)(unsafe.Pointer(db)).FpTraceArg, db, uintptr(0))
|
|
}
|
|
/* Force xDisconnect calls on all virtual tables */
|
|
_disconnectAllVtab(tls, db)
|
|
/* If a transaction is open, the disconnectAllVtab() call above
|
|
** will not have called the xDisconnect() method on any virtual
|
|
** tables in the db->aVTrans[] array. The following sqlite3VtabRollback()
|
|
** call will do so. We need to do this before the check for active
|
|
** SQL statements below, as the v-table implementation may be storing
|
|
** some prepared statements internally.
|
|
*/
|
|
_sqlite3VtabRollback(tls, db)
|
|
/* 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 {
|
|
_sqlite3ErrorWithMsg(tls, db, int32(SQLITE_BUSY), __ccgo_ts+25315, 0)
|
|
Xsqlite3_mutex_leave(tls, (*Tsqlite3)(unsafe.Pointer(db)).Fmutex)
|
|
return int32(SQLITE_BUSY)
|
|
}
|
|
for (*Tsqlite3)(unsafe.Pointer(db)).FpDbData != 0 {
|
|
p = (*Tsqlite3)(unsafe.Pointer(db)).FpDbData
|
|
(*Tsqlite3)(unsafe.Pointer(db)).FpDbData = (*TDbClientData)(unsafe.Pointer(p)).FpNext
|
|
if (*TDbClientData)(unsafe.Pointer(p)).FxDestructor != 0 {
|
|
(*(*func(*libc.TLS, uintptr))(unsafe.Pointer(&struct{ uintptr }{(*TDbClientData)(unsafe.Pointer(p)).FxDestructor})))(tls, (*TDbClientData)(unsafe.Pointer(p)).FpData)
|
|
}
|
|
Xsqlite3_free(tls, p)
|
|
}
|
|
/* Convert the connection into a zombie and then close it.
|
|
*/
|
|
(*Tsqlite3)(unsafe.Pointer(db)).FeOpenState = uint8(SQLITE_STATE_ZOMBIE)
|
|
_sqlite3LeaveMutexAndCloseZombie(tls, db)
|
|
return SQLITE_OK
|
|
}
|
|
|
|
func _sqlite3CorruptError(tls *libc.TLS, lineno int32) (r int32) {
|
|
return _sqlite3ReportError(tls, int32(SQLITE_CORRUPT), lineno, __ccgo_ts+26320)
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Invoke this routine to register the "dbpage" virtual table module
|
|
// */
|
|
func _sqlite3DbpageRegister(tls *libc.TLS, db uintptr) (r int32) {
|
|
return Xsqlite3_create_module(tls, db, __ccgo_ts+35204, uintptr(unsafe.Pointer(&_dbpage_module)), uintptr(0))
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Invoke this routine to register the "dbstat" virtual table module
|
|
// */
|
|
func _sqlite3DbstatRegister(tls *libc.TLS, db uintptr) (r int32) {
|
|
return Xsqlite3_create_module(tls, db, __ccgo_ts+35019, uintptr(unsafe.Pointer(&_dbstat_module)), uintptr(0))
|
|
}
|
|
|
|
func _sqlite3DefaultMutex(tls *libc.TLS) (r uintptr) {
|
|
return uintptr(unsafe.Pointer(&_sMutex1))
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Generate VDBE code for a COMMIT or ROLLBACK statement.
|
|
// ** Code for ROLLBACK is generated if eType==TK_ROLLBACK. Otherwise
|
|
// ** code is generated for a COMMIT.
|
|
// */
|
|
func _sqlite3EndTransaction(tls *libc.TLS, pParse uintptr, eType int32) {
|
|
var isRollback int32
|
|
var v, v1 uintptr
|
|
_, _, _ = isRollback, v, v1
|
|
isRollback = libc.BoolInt32(eType == int32(TK_ROLLBACK))
|
|
if isRollback != 0 {
|
|
v1 = __ccgo_ts + 16137
|
|
} else {
|
|
v1 = __ccgo_ts + 16146
|
|
}
|
|
if _sqlite3AuthCheck(tls, pParse, int32(SQLITE_TRANSACTION), v1, uintptr(0), uintptr(0)) != 0 {
|
|
return
|
|
}
|
|
v = _sqlite3GetVdbe(tls, pParse)
|
|
if v != 0 {
|
|
_sqlite3VdbeAddOp2(tls, v, int32(OP_AutoCommit), int32(1), isRollback)
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Write code that will raise an error if the table described by
|
|
// ** zDb and zTab is not empty.
|
|
// */
|
|
func _sqlite3ErrorIfNotEmpty(tls *libc.TLS, pParse uintptr, zDb uintptr, zTab uintptr, zErr uintptr) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
_sqlite3NestedParse(tls, pParse, __ccgo_ts+10279, libc.VaList(bp+8, zErr, zDb, zTab))
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Check to see if a function is usable according to current access
|
|
// ** rules:
|
|
// **
|
|
// ** SQLITE_FUNC_DIRECT - Only usable from top-level SQL
|
|
// **
|
|
// ** SQLITE_FUNC_UNSAFE - Usable if TRUSTED_SCHEMA or from
|
|
// ** top-level SQL
|
|
// **
|
|
// ** If the function is not usable, create an error.
|
|
// */
|
|
func _sqlite3ExprFunctionUsable(tls *libc.TLS, pParse uintptr, pExpr uintptr, pDef uintptr) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
if (*TExpr)(unsafe.Pointer(pExpr)).Fflags&libc.Uint32FromInt32(libc.Int32FromInt32(EP_FromDDL)) != uint32(0) || libc.Int32FromUint8((*TParse)(unsafe.Pointer(pParse)).FprepFlags)&int32(SQLITE_PREPARE_FROM_DDL) != 0 {
|
|
if (*TFuncDef)(unsafe.Pointer(pDef)).FfuncFlags&uint32(SQLITE_FUNC_DIRECT) != uint32(0) || (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(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
|
|
** is tagged with SQLITE_FUNC_UNSAFE) and
|
|
** SQLITE_DBCONFIG_TRUSTED_SCHEMA is off (meaning
|
|
** that the schema is possibly tainted).
|
|
*/
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8067, libc.VaList(bp+8, pExpr))
|
|
}
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Report an error when attempting to use an ORDER BY clause within
|
|
// ** the arguments of a non-aggregate function.
|
|
// */
|
|
func _sqlite3ExprOrderByAggregateError(tls *libc.TLS, pParse uintptr, p uintptr) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+8017, libc.VaList(bp+8, p))
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Create the shadow table named zPost, with definition zDefn. Return
|
|
// ** SQLITE_OK if successful, or an SQLite error code otherwise.
|
|
// */
|
|
func _sqlite3Fts5CreateTable(tls *libc.TLS, pConfig uintptr, zPost uintptr, zDefn uintptr, bWithout int32, pzErr uintptr) (r int32) {
|
|
bp := tls.Alloc(64)
|
|
defer tls.Free(64)
|
|
var rc int32
|
|
var v1 uintptr
|
|
var _ /* zErr at bp+0 */ uintptr
|
|
_, _ = rc, v1
|
|
**(**uintptr)(__ccgo_up(bp)) = uintptr(0)
|
|
if bWithout != 0 {
|
|
v1 = __ccgo_ts + 32107
|
|
} else {
|
|
v1 = __ccgo_ts + 1704
|
|
}
|
|
rc = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, bp, __ccgo_ts+41512, libc.VaList(bp+16, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, zPost, zDefn, v1))
|
|
if **(**uintptr)(__ccgo_up(bp)) != 0 {
|
|
**(**uintptr)(__ccgo_up(pzErr)) = Xsqlite3_mprintf(tls, __ccgo_ts+41542, libc.VaList(bp+16, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, zPost, **(**uintptr)(__ccgo_up(bp))))
|
|
Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp)))
|
|
}
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Drop all shadow tables. Return SQLITE_OK if successful or an SQLite error
|
|
// ** code otherwise.
|
|
// */
|
|
func _sqlite3Fts5DropAll(tls *libc.TLS, pConfig uintptr) (r int32) {
|
|
bp := tls.Alloc(64)
|
|
defer tls.Free(64)
|
|
var rc int32
|
|
_ = rc
|
|
rc = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), __ccgo_ts+41290, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName))
|
|
if rc == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 {
|
|
rc = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), __ccgo_ts+41394, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName))
|
|
}
|
|
if rc == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL {
|
|
rc = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), __ccgo_ts+41432, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName))
|
|
}
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Apply colset pColset to expression node pExpr and all of its descendents.
|
|
// */
|
|
func _sqlite3Fts5ParseSetColset(tls *libc.TLS, pParse uintptr, pExpr uintptr, pColset uintptr) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var _ /* pFree at bp+0 */ uintptr
|
|
**(**uintptr)(__ccgo_up(bp)) = pColset
|
|
if (*TFts5Config)(unsafe.Pointer((*TFts5Parse)(unsafe.Pointer(pParse)).FpConfig)).FeDetail == int32(FTS5_DETAIL_NONE) {
|
|
_sqlite3Fts5ParseError(tls, pParse, __ccgo_ts+38663, 0)
|
|
} else {
|
|
_fts5ParseSetColset(tls, pParse, pExpr, pColset, bp)
|
|
}
|
|
Xsqlite3_free(tls, **(**uintptr)(__ccgo_up(bp)))
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Return the fallback token corresponding to canonical token iToken, or
|
|
// ** 0 if iToken has no fallback.
|
|
// */
|
|
func _sqlite3Fts5ParserFallback(tls *libc.TLS, iToken int32) (r int32) {
|
|
_ = iToken
|
|
return 0
|
|
}
|
|
|
|
/*
|
|
** 2014 May 31
|
|
**
|
|
** The author disclaims copyright to this source code. In place of
|
|
** a legal notice, here is a blessing:
|
|
**
|
|
** May you do good and not evil.
|
|
** May you find forgiveness for yourself and forgive others.
|
|
** May you share freely, never taking more than you give.
|
|
**
|
|
******************************************************************************
|
|
*/
|
|
|
|
/* #include "fts5Int.h" */
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Delete all entries in the FTS5 index.
|
|
// */
|
|
func _sqlite3Fts5StorageDeleteAll(tls *libc.TLS, p uintptr) (r int32) {
|
|
bp := tls.Alloc(48)
|
|
defer tls.Free(48)
|
|
var pConfig uintptr
|
|
var rc int32
|
|
_, _ = pConfig, rc
|
|
pConfig = (*TFts5Storage)(unsafe.Pointer(p)).FpConfig
|
|
(*TFts5Storage)(unsafe.Pointer(p)).FbTotalsValid = 0
|
|
/* Delete the contents of the %_data and %_docsize tables. */
|
|
rc = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), __ccgo_ts+41718, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName))
|
|
if rc == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 {
|
|
rc = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), __ccgo_ts+41768, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName))
|
|
}
|
|
if rc == SQLITE_OK && (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == int32(FTS5_CONTENT_UNINDEXED) {
|
|
rc = _fts5ExecPrintf(tls, (*TFts5Config)(unsafe.Pointer(pConfig)).Fdb, uintptr(0), __ccgo_ts+41797, libc.VaList(bp+8, (*TFts5Config)(unsafe.Pointer(pConfig)).FzDb, (*TFts5Config)(unsafe.Pointer(pConfig)).FzName))
|
|
}
|
|
/* Reinitialize the %_data table. This call creates the initial structure
|
|
** and averages records. */
|
|
if rc == SQLITE_OK {
|
|
rc = _sqlite3Fts5IndexReinit(tls, (*TFts5Storage)(unsafe.Pointer(p)).FpIndex)
|
|
}
|
|
if rc == SQLITE_OK {
|
|
rc = _sqlite3Fts5StorageConfigValue(tls, p, __ccgo_ts+38492, uintptr(0), int32(FTS5_CURRENT_VERSION))
|
|
}
|
|
return rc
|
|
}
|
|
|
|
func _sqlite3Fts5StorageRename(tls *libc.TLS, pStorage uintptr, zName uintptr) (r int32) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var pConfig uintptr
|
|
var _ /* rc at bp+0 */ int32
|
|
_ = pConfig
|
|
pConfig = (*TFts5Storage)(unsafe.Pointer(pStorage)).FpConfig
|
|
**(**int32)(__ccgo_up(bp)) = _sqlite3Fts5StorageSync(tls, pStorage)
|
|
_fts5StorageRenameOne(tls, pConfig, bp, __ccgo_ts+27432, zName)
|
|
_fts5StorageRenameOne(tls, pConfig, bp, __ccgo_ts+13072, zName)
|
|
_fts5StorageRenameOne(tls, pConfig, bp, __ccgo_ts+40624, zName)
|
|
if (*TFts5Config)(unsafe.Pointer(pConfig)).FbColumnsize != 0 {
|
|
_fts5StorageRenameOne(tls, pConfig, bp, __ccgo_ts+38310, zName)
|
|
}
|
|
if (*TFts5Config)(unsafe.Pointer(pConfig)).FeContent == FTS5_CONTENT_NORMAL {
|
|
_fts5StorageRenameOne(tls, pConfig, bp, __ccgo_ts+37615, zName)
|
|
}
|
|
return **(**int32)(__ccgo_up(bp))
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Return true if the tokenizer described by p->azArg[] is the trigram
|
|
// ** tokenizer. This tokenizer needs to be loaded before xBestIndex is
|
|
// ** called for the first time in order to correctly handle LIKE/GLOB.
|
|
// */
|
|
func _sqlite3Fts5TokenizerPreload(tls *libc.TLS, p uintptr) (r int32) {
|
|
return libc.BoolInt32((*TFts5TokenizerConfig)(unsafe.Pointer(p)).FnArg >= int32(1) && 0 == Xsqlite3_stricmp(tls, **(**uintptr)(__ccgo_up((*TFts5TokenizerConfig)(unsafe.Pointer(p)).FazArg)), __ccgo_ts+42229))
|
|
}
|
|
|
|
func _sqlite3Fts5VocabInit(tls *libc.TLS, pGlobal uintptr, db uintptr) (r int32) {
|
|
var p uintptr
|
|
_ = p
|
|
p = pGlobal
|
|
return Xsqlite3_create_module_v2(tls, db, __ccgo_ts+42553, uintptr(unsafe.Pointer(&_fts5Vocab)), p, uintptr(0))
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** This function is responsible for invoking the collation factory callback
|
|
// ** or substituting a collation sequence of a different encoding when the
|
|
// ** requested collation sequence is not available in the desired encoding.
|
|
// **
|
|
// ** If it is not NULL, then pColl must point to the database native encoding
|
|
// ** collation sequence with name zName, length nName.
|
|
// **
|
|
// ** The return value is either the collation sequence to be used in database
|
|
// ** db for collation type name zName, length nName, or NULL, if no collation
|
|
// ** sequence can be found. If no collation is found, leave an error message.
|
|
// **
|
|
// ** See also: sqlite3LocateCollSeq(), sqlite3FindCollSeq()
|
|
// */
|
|
func _sqlite3GetCollSeq(tls *libc.TLS, pParse uintptr, enc Tu8, pColl uintptr, zName uintptr) (r uintptr) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var db, p uintptr
|
|
_, _ = db, p
|
|
db = (*TParse)(unsafe.Pointer(pParse)).Fdb
|
|
p = pColl
|
|
if !(p != 0) {
|
|
p = _sqlite3FindCollSeq(tls, db, enc, zName, 0)
|
|
}
|
|
if !(p != 0) || !((*TCollSeq)(unsafe.Pointer(p)).FxCmp != 0) {
|
|
/* No collation sequence of this type for this encoding is registered.
|
|
** Call the collation factory to see if it can supply us with one.
|
|
*/
|
|
_callCollNeeded(tls, db, libc.Int32FromUint8(enc), zName)
|
|
p = _sqlite3FindCollSeq(tls, db, enc, zName, 0)
|
|
}
|
|
if p != 0 && !((*TCollSeq)(unsafe.Pointer(p)).FxCmp != 0) && _synthCollSeq(tls, db, p) != 0 {
|
|
p = uintptr(0)
|
|
}
|
|
if p == uintptr(0) {
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16342, libc.VaList(bp+8, zName))
|
|
(*TParse)(unsafe.Pointer(pParse)).Frc = libc.Int32FromInt32(SQLITE_ERROR) | libc.Int32FromInt32(1)<<libc.Int32FromInt32(8)
|
|
}
|
|
return p
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** The following is the implementation of an SQL function that always
|
|
// ** fails with an error message stating that the function is used in the
|
|
// ** wrong context. The sqlite3_overload_function() API might construct
|
|
// ** SQL function that use this routine so that the functions will exist
|
|
// ** for name resolution but are actually overloaded by the xFindFunction
|
|
// ** method of virtual tables.
|
|
// */
|
|
func _sqlite3InvalidFunction(tls *libc.TLS, context uintptr, NotUsed int32, NotUsed2 uintptr) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var zErr, zName uintptr
|
|
_, _ = zErr, zName
|
|
zName = Xsqlite3_user_data(tls, context)
|
|
_ = NotUsed
|
|
_ = NotUsed2
|
|
zErr = Xsqlite3_mprintf(tls, __ccgo_ts+26002, libc.VaList(bp+8, zName))
|
|
Xsqlite3_result_error(tls, context, zErr, -int32(1))
|
|
Xsqlite3_free(tls, zErr)
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Check to make sure the given table is writable.
|
|
// **
|
|
// ** If pTab is not writable -> generate an error message and return 1.
|
|
// ** If pTab is writable but other errors have occurred -> return 1.
|
|
// ** If pTab is writable and no prior errors -> return 0;
|
|
// */
|
|
func _sqlite3IsReadOnly(tls *libc.TLS, pParse uintptr, pTab uintptr, pTrigger uintptr) (r int32) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
if _tabIsReadOnly(tls, pParse, pTab) != 0 {
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16406, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName))
|
|
return int32(1)
|
|
}
|
|
if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VIEW) && (pTrigger == uintptr(0) || (*TTrigger)(unsafe.Pointer(pTrigger)).FbReturning != 0 && (*TTrigger)(unsafe.Pointer(pTrigger)).FpNext == uintptr(0)) {
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+16435, libc.VaList(bp+8, (*TTable)(unsafe.Pointer(pTab)).FzName))
|
|
return int32(1)
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Return TRUE if the given string is a row-id column name.
|
|
// */
|
|
func _sqlite3IsRowid(tls *libc.TLS, z uintptr) (r int32) {
|
|
if _sqlite3StrICmp(tls, z, __ccgo_ts+8217) == 0 {
|
|
return int32(1)
|
|
}
|
|
if _sqlite3StrICmp(tls, z, __ccgo_ts+8225) == 0 {
|
|
return int32(1)
|
|
}
|
|
if _sqlite3StrICmp(tls, z, __ccgo_ts+8231) == 0 {
|
|
return int32(1)
|
|
}
|
|
return 0
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Check the input string to see if it is "true" or "false" (in any case).
|
|
// **
|
|
// ** If the string is.... Return
|
|
// ** "true" EP_IsTrue
|
|
// ** "false" EP_IsFalse
|
|
// ** anything else 0
|
|
// */
|
|
func _sqlite3IsTrueOrFalse(tls *libc.TLS, zIn uintptr) (r Tu32) {
|
|
if _sqlite3StrICmp(tls, zIn, __ccgo_ts+8206) == 0 {
|
|
return uint32(EP_IsTrue)
|
|
}
|
|
if _sqlite3StrICmp(tls, zIn, __ccgo_ts+8211) == 0 {
|
|
return uint32(EP_IsFalse)
|
|
}
|
|
return uint32(0)
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Try to provide a memory barrier operation, needed for initialization
|
|
// ** and also for the implementation of xShmBarrier in the VFS in cases
|
|
// ** where SQLite is compiled without mutexes.
|
|
// */
|
|
func _sqlite3MemoryBarrier(tls *libc.TLS) {
|
|
}
|
|
|
|
func _sqlite3MisuseError(tls *libc.TLS, lineno int32) (r int32) {
|
|
return _sqlite3ReportError(tls, int32(SQLITE_MISUSE), lineno, __ccgo_ts+26340)
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Open the sqlite_schema table stored in database number iDb for
|
|
// ** writing. The table is opened using cursor 0.
|
|
// */
|
|
func _sqlite3OpenSchemaTable(tls *libc.TLS, p uintptr, iDb int32) {
|
|
var v uintptr
|
|
_ = v
|
|
v = _sqlite3GetVdbe(tls, p)
|
|
_sqlite3TableLock(tls, p, iDb, uint32(SCHEMA_ROOT), uint8(1), __ccgo_ts+6312)
|
|
_sqlite3VdbeAddOp4Int(tls, v, int32(OP_OpenWrite), 0, int32(SCHEMA_ROOT), iDb, int32(5))
|
|
if (*TParse)(unsafe.Pointer(p)).FnTab == 0 {
|
|
(*TParse)(unsafe.Pointer(p)).FnTab = int32(1)
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** This function is called when the user invokes "PRAGMA wal_checkpoint",
|
|
// ** "PRAGMA wal_blocking_checkpoint" or calls the sqlite3_wal_checkpoint()
|
|
// ** or wal_blocking_checkpoint() API functions.
|
|
// **
|
|
// ** Parameter eMode is one of SQLITE_CHECKPOINT_PASSIVE, FULL or RESTART.
|
|
// */
|
|
func _sqlite3PagerCheckpoint(tls *libc.TLS, pPager uintptr, db uintptr, eMode int32, pnLog uintptr, pnCkpt uintptr) (r int32) {
|
|
var rc int32
|
|
var v1 uintptr
|
|
_, _ = rc, v1
|
|
rc = SQLITE_OK
|
|
if (*TPager)(unsafe.Pointer(pPager)).FpWal == uintptr(0) && libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FjournalMode) == int32(PAGER_JOURNALMODE_WAL) {
|
|
/* This only happens when a database file is zero bytes in size opened and
|
|
** then "PRAGMA journal_mode=WAL" is run and then sqlite3_wal_checkpoint()
|
|
** is invoked without any intervening transactions. We need to start
|
|
** a transaction to initialize pWal. The PRAGMA table_list statement is
|
|
** used for this since it starts transactions on every database file,
|
|
** including all ATTACHed databases. This seems expensive for a single
|
|
** sqlite3_wal_checkpoint() call, but it happens very rarely.
|
|
** https://sqlite.org/forum/forumpost/fd0f19d229156939
|
|
*/
|
|
Xsqlite3_exec(tls, db, __ccgo_ts+4286, uintptr(0), uintptr(0), uintptr(0))
|
|
}
|
|
if (*TPager)(unsafe.Pointer(pPager)).FpWal != 0 {
|
|
if eMode <= SQLITE_CHECKPOINT_PASSIVE {
|
|
v1 = uintptr(0)
|
|
} else {
|
|
v1 = (*TPager)(unsafe.Pointer(pPager)).FxBusyHandler
|
|
}
|
|
rc = _sqlite3WalCheckpoint(tls, (*TPager)(unsafe.Pointer(pPager)).FpWal, db, eMode, v1, (*TPager)(unsafe.Pointer(pPager)).FpBusyHandlerArg, libc.Int32FromUint8((*TPager)(unsafe.Pointer(pPager)).FwalSyncFlags), int32((*TPager)(unsafe.Pointer(pPager)).FpageSize), (*TPager)(unsafe.Pointer(pPager)).FpTmpSpace, pnLog, pnCkpt)
|
|
}
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Return the preferred table name for system tables. Translate legacy
|
|
// ** names into the new preferred names, as appropriate.
|
|
// */
|
|
func _sqlite3PreferredTableName(tls *libc.TLS, zName uintptr) (r uintptr) {
|
|
if Xsqlite3_strnicmp(tls, zName, __ccgo_ts+6784, int32(7)) == 0 {
|
|
if _sqlite3StrICmp(tls, zName+uintptr(7), __ccgo_ts+6312+7) == 0 {
|
|
return __ccgo_ts + 6830
|
|
}
|
|
if _sqlite3StrICmp(tls, zName+uintptr(7), __ccgo_ts+6792+7) == 0 {
|
|
return __ccgo_ts + 6811
|
|
}
|
|
}
|
|
return zName
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Re-register the built-in LIKE functions. The caseSensitive
|
|
// ** parameter determines whether or not the LIKE operator is case
|
|
// ** sensitive.
|
|
// */
|
|
func _sqlite3RegisterLikeFunctions(tls *libc.TLS, db uintptr, caseSensitive int32) {
|
|
var flags, nArg int32
|
|
var pDef, pInfo uintptr
|
|
_, _, _, _ = flags, nArg, pDef, pInfo
|
|
if caseSensitive != 0 {
|
|
pInfo = uintptr(unsafe.Pointer(&_likeInfoAlt))
|
|
flags = libc.Int32FromInt32(SQLITE_FUNC_LIKE) | libc.Int32FromInt32(SQLITE_FUNC_CASE)
|
|
} else {
|
|
pInfo = uintptr(unsafe.Pointer(&_likeInfoNorm))
|
|
flags = int32(SQLITE_FUNC_LIKE)
|
|
}
|
|
nArg = int32(2)
|
|
for {
|
|
if !(nArg <= int32(3)) {
|
|
break
|
|
}
|
|
_sqlite3CreateFunc(tls, db, __ccgo_ts+16633, nArg, int32(SQLITE_UTF8), pInfo, __ccgo_fp(_likeFunc), uintptr(0), uintptr(0), uintptr(0), uintptr(0), uintptr(0))
|
|
pDef = _sqlite3FindFunction(tls, db, __ccgo_ts+16633, nArg, uint8(SQLITE_UTF8), uint8(0))
|
|
/* The sqlite3CreateFunc() call above cannot fail
|
|
** because the "like" SQL-function already exists */
|
|
**(**Tu32)(__ccgo_up(pDef + 4)) |= libc.Uint32FromInt32(flags)
|
|
**(**Tu32)(__ccgo_up(pDef + 4)) &= libc.Uint32FromInt32(^libc.Int32FromInt32(SQLITE_FUNC_UNSAFE))
|
|
goto _1
|
|
_1:
|
|
;
|
|
nArg = nArg + 1
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** This routine does per-connection function registration. Most
|
|
// ** of the built-in functions above are part of the global function set.
|
|
// ** This routine only deals with those that are not global.
|
|
// */
|
|
func _sqlite3RegisterPerConnectionBuiltinFunctions(tls *libc.TLS, db uintptr) {
|
|
var rc int32
|
|
_ = rc
|
|
rc = Xsqlite3_overload_function(tls, db, __ccgo_ts+16627, int32(2))
|
|
if rc == int32(SQLITE_NOMEM) {
|
|
_sqlite3OomFault(tls, db)
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** The following routines are substitutes for constants SQLITE_CORRUPT,
|
|
// ** SQLITE_MISUSE, SQLITE_CANTOPEN, SQLITE_NOMEM and possibly other error
|
|
// ** constants. They serve two purposes:
|
|
// **
|
|
// ** 1. Serve as a convenient place to set a breakpoint in a debugger
|
|
// ** to detect when version error conditions occurs.
|
|
// **
|
|
// ** 2. Invoke sqlite3_log() to provide the source code location where
|
|
// ** a low-level error is first detected.
|
|
// */
|
|
func _sqlite3ReportError(tls *libc.TLS, iErr int32, lineno int32, zType uintptr) (r int32) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
Xsqlite3_log(tls, iErr, __ccgo_ts+26295, libc.VaList(bp+8, zType, lineno, uintptr(20)+Xsqlite3_sourceid(tls)))
|
|
return iErr
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Use the content of the StrAccum passed as the second argument
|
|
// ** as the result of an SQL function.
|
|
// */
|
|
func _sqlite3ResultStrAccum(tls *libc.TLS, pCtx uintptr, p uintptr) {
|
|
if (*TStrAccum)(unsafe.Pointer(p)).FaccError != 0 {
|
|
Xsqlite3_result_error_code(tls, pCtx, libc.Int32FromUint8((*TStrAccum)(unsafe.Pointer(p)).FaccError))
|
|
Xsqlite3_str_reset(tls, p)
|
|
} else {
|
|
if libc.Int32FromUint8((*TStrAccum)(unsafe.Pointer(p)).FprintfFlags)&int32(SQLITE_PRINTF_MALLOCED) != 0 {
|
|
Xsqlite3_result_text(tls, pCtx, (*TStrAccum)(unsafe.Pointer(p)).FzText, libc.Int32FromUint32((*TStrAccum)(unsafe.Pointer(p)).FnChar), __ccgo_fp(_sqlite3RowSetClear))
|
|
} else {
|
|
Xsqlite3_result_text(tls, pCtx, __ccgo_ts+1704, 0, libc.UintptrFromInt32(0))
|
|
Xsqlite3_str_reset(tls, p)
|
|
}
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Register the r-tree module with database handle db. This creates the
|
|
// ** virtual table module "rtree" and the debugging/analysis scalar
|
|
// ** function "rtreenode".
|
|
// */
|
|
func _sqlite3RtreeInit(tls *libc.TLS, db uintptr) (r int32) {
|
|
var c, c1 uintptr
|
|
var rc, utf8 int32
|
|
_, _, _, _ = c, c1, rc, utf8
|
|
utf8 = int32(SQLITE_UTF8)
|
|
rc = Xsqlite3_create_function(tls, db, __ccgo_ts+30253, int32(2), utf8, uintptr(0), __ccgo_fp(_rtreenode), uintptr(0), uintptr(0))
|
|
if rc == SQLITE_OK {
|
|
rc = Xsqlite3_create_function(tls, db, __ccgo_ts+30263, int32(1), utf8, uintptr(0), __ccgo_fp(_rtreedepth), uintptr(0), uintptr(0))
|
|
}
|
|
if rc == SQLITE_OK {
|
|
rc = Xsqlite3_create_function(tls, db, __ccgo_ts+30274, -int32(1), utf8, uintptr(0), __ccgo_fp(_rtreecheck), uintptr(0), uintptr(0))
|
|
}
|
|
if rc == SQLITE_OK {
|
|
c = libc.UintptrFromInt32(RTREE_COORD_REAL32)
|
|
rc = Xsqlite3_create_module_v2(tls, db, __ccgo_ts+29997, uintptr(unsafe.Pointer(&_rtreeModule)), c, uintptr(0))
|
|
}
|
|
if rc == SQLITE_OK {
|
|
c1 = libc.UintptrFromInt32(RTREE_COORD_INT32)
|
|
rc = Xsqlite3_create_module_v2(tls, db, __ccgo_ts+30285, uintptr(unsafe.Pointer(&_rtreeModule)), c1, uintptr(0))
|
|
}
|
|
if rc == SQLITE_OK {
|
|
rc = _sqlite3_geopoly_init(tls, db)
|
|
}
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Check to make sure we have a valid db pointer. This test is not
|
|
// ** foolproof but it does provide some measure of protection against
|
|
// ** misuse of the interface such as passing in db pointers that are
|
|
// ** NULL or which have been previously closed. If this routine returns
|
|
// ** 1 it means that the db pointer is valid and 0 if it should not be
|
|
// ** dereferenced for any reason. The calling function should invoke
|
|
// ** SQLITE_MISUSE immediately.
|
|
// **
|
|
// ** sqlite3SafetyCheckOk() requires that the db pointer be valid for
|
|
// ** use. sqlite3SafetyCheckSickOrOk() allows a db pointer that failed to
|
|
// ** open properly and is not fit for general use but which can be
|
|
// ** used as an argument to sqlite3_errmsg() or sqlite3_close().
|
|
// */
|
|
func _sqlite3SafetyCheckOk(tls *libc.TLS, db uintptr) (r int32) {
|
|
var eOpenState Tu8
|
|
_ = eOpenState
|
|
if db == uintptr(0) {
|
|
_logBadConnection(tls, __ccgo_ts+1705)
|
|
return 0
|
|
}
|
|
eOpenState = (*Tsqlite3)(unsafe.Pointer(db)).FeOpenState
|
|
if libc.Int32FromUint8(eOpenState) != int32(SQLITE_STATE_OPEN) {
|
|
if _sqlite3SafetyCheckSickOrOk(tls, db) != 0 {
|
|
_logBadConnection(tls, __ccgo_ts+1897)
|
|
}
|
|
return 0
|
|
} else {
|
|
return int32(1)
|
|
}
|
|
return r
|
|
}
|
|
|
|
func _sqlite3SafetyCheckSickOrOk(tls *libc.TLS, db uintptr) (r int32) {
|
|
var eOpenState Tu8
|
|
_ = eOpenState
|
|
eOpenState = (*Tsqlite3)(unsafe.Pointer(db)).FeOpenState
|
|
if libc.Int32FromUint8(eOpenState) != int32(SQLITE_STATE_SICK) && libc.Int32FromUint8(eOpenState) != int32(SQLITE_STATE_OPEN) && libc.Int32FromUint8(eOpenState) != int32(SQLITE_STATE_BUSY) {
|
|
_logBadConnection(tls, __ccgo_ts+1906)
|
|
return 0
|
|
} else {
|
|
return int32(1)
|
|
}
|
|
return r
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Name of the connection operator, used for error messages.
|
|
// */
|
|
func _sqlite3SelectOpName(tls *libc.TLS, id int32) (r uintptr) {
|
|
var z uintptr
|
|
_ = z
|
|
switch id {
|
|
case int32(TK_ALL):
|
|
z = __ccgo_ts + 20513
|
|
case int32(TK_INTERSECT):
|
|
z = __ccgo_ts + 20523
|
|
case int32(TK_EXCEPT):
|
|
z = __ccgo_ts + 20533
|
|
default:
|
|
z = __ccgo_ts + 20540
|
|
break
|
|
}
|
|
return z
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Error message for when two or more terms of a compound select have different
|
|
// ** size result sets.
|
|
// */
|
|
func _sqlite3SelectWrongNumTermsError(tls *libc.TLS, pParse uintptr, p uintptr) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
if (*TSelect)(unsafe.Pointer(p)).FselFlags&uint32(SF_Values) != 0 {
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20892, 0)
|
|
} else {
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+20938, libc.VaList(bp+8, _sqlite3SelectOpName(tls, libc.Int32FromUint8((*TSelect)(unsafe.Pointer(p)).Fop))))
|
|
}
|
|
}
|
|
|
|
var _sqlite3StdType = [6]uintptr{
|
|
0: __ccgo_ts + 1165,
|
|
1: __ccgo_ts + 1169,
|
|
2: __ccgo_ts + 1174,
|
|
3: __ccgo_ts + 1178,
|
|
4: __ccgo_ts + 1186,
|
|
5: __ccgo_ts + 1191,
|
|
}
|
|
|
|
/************** End of global.c **********************************************/
|
|
/************** Begin file status.c ******************************************/
|
|
/*
|
|
** 2008 June 18
|
|
**
|
|
** The author disclaims copyright to this source code. In place of
|
|
** a legal notice, here is a blessing:
|
|
**
|
|
** May you do good and not evil.
|
|
** May you find forgiveness for yourself and forgive others.
|
|
** May you share freely, never taking more than you give.
|
|
**
|
|
*************************************************************************
|
|
**
|
|
** This module implements the sqlite3_status() interface and related
|
|
** functionality.
|
|
*/
|
|
/* #include "sqliteInt.h" */
|
|
/************** Include vdbeInt.h in the middle of status.c ******************/
|
|
/************** Begin file vdbeInt.h *****************************************/
|
|
/*
|
|
** 2003 September 6
|
|
**
|
|
** The author disclaims copyright to this source code. In place of
|
|
** a legal notice, here is a blessing:
|
|
**
|
|
** May you do good and not evil.
|
|
** May you find forgiveness for yourself and forgive others.
|
|
** May you share freely, never taking more than you give.
|
|
**
|
|
*************************************************************************
|
|
** This is the header file for information that is private to the
|
|
** VDBE. This information used to all be at the top of the single
|
|
** source code file "vdbe.c". When that file became too big (over
|
|
** 6000 lines long) it was split up into several smaller files and
|
|
** this header information was factored out.
|
|
*/
|
|
|
|
/*
|
|
** The maximum number of times that a statement will try to reparse
|
|
** itself before giving up and returning SQLITE_SCHEMA.
|
|
*/
|
|
|
|
/*
|
|
** VDBE_DISPLAY_P4 is true or false depending on whether or not the
|
|
** "explain" P4 display logic is enabled.
|
|
*/
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Load the Parse object passed as the first argument with an error
|
|
// ** message of the form:
|
|
// **
|
|
// ** "sub-select returns N columns - expected M"
|
|
// */
|
|
func _sqlite3SubselectError(tls *libc.TLS, pParse uintptr, nActual int32, nExpect int32) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var zFmt uintptr
|
|
_ = zFmt
|
|
if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 {
|
|
zFmt = __ccgo_ts + 8313
|
|
_sqlite3ErrorMsg(tls, pParse, zFmt, libc.VaList(bp+8, nActual, nExpect))
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /* Get the results of the thread */
|
|
func _sqlite3ThreadJoin(tls *libc.TLS, p uintptr, ppOut uintptr) (r int32) {
|
|
var rc, v1 int32
|
|
_, _ = rc, v1
|
|
if p == uintptr(0) {
|
|
return int32(SQLITE_NOMEM)
|
|
}
|
|
if (*TSQLiteThread)(unsafe.Pointer(p)).Fdone != 0 {
|
|
**(**uintptr)(__ccgo_up(ppOut)) = (*TSQLiteThread)(unsafe.Pointer(p)).FpOut
|
|
rc = SQLITE_OK
|
|
} else {
|
|
if libc.Xpthread_join(tls, (*TSQLiteThread)(unsafe.Pointer(p)).Ftid, ppOut) != 0 {
|
|
v1 = int32(SQLITE_ERROR)
|
|
} else {
|
|
v1 = SQLITE_OK
|
|
}
|
|
rc = v1
|
|
}
|
|
Xsqlite3_free(tls, p)
|
|
return rc
|
|
}
|
|
|
|
/******************************** End Unix Pthreads *************************/
|
|
|
|
/********************************* Win32 Threads ****************************/
|
|
/******************************** End Win32 Threads *************************/
|
|
|
|
/********************************* Single-Threaded **************************/
|
|
/****************************** End Single-Threaded *************************/
|
|
|
|
/************** End of threads.c *********************************************/
|
|
/************** Begin file utf.c *********************************************/
|
|
/*
|
|
** 2004 April 13
|
|
**
|
|
** The author disclaims copyright to this source code. In place of
|
|
** a legal notice, here is a blessing:
|
|
**
|
|
** May you do good and not evil.
|
|
** May you find forgiveness for yourself and forgive others.
|
|
** May you share freely, never taking more than you give.
|
|
**
|
|
*************************************************************************
|
|
** This file contains routines used to translate between UTF-8,
|
|
** UTF-16, UTF-16BE, and UTF-16LE.
|
|
**
|
|
** Notes on UTF-8:
|
|
**
|
|
** Byte-0 Byte-1 Byte-2 Byte-3 Value
|
|
** 0xxxxxxx 00000000 00000000 0xxxxxxx
|
|
** 110yyyyy 10xxxxxx 00000000 00000yyy yyxxxxxx
|
|
** 1110zzzz 10yyyyyy 10xxxxxx 00000000 zzzzyyyy yyxxxxxx
|
|
** 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx 000uuuuu zzzzyyyy yyxxxxxx
|
|
**
|
|
**
|
|
** Notes on UTF-16: (with wwww+1==uuuuu)
|
|
**
|
|
** Word-0 Word-1 Value
|
|
** 110110ww wwzzzzyy 110111yy yyxxxxxx 000uuuuu zzzzyyyy yyxxxxxx
|
|
** zzzzyyyy yyxxxxxx 00000000 zzzzyyyy yyxxxxxx
|
|
**
|
|
**
|
|
** BOM or Byte Order Mark:
|
|
** 0xff 0xfe little-endian utf-16 follows
|
|
** 0xfe 0xff big-endian utf-16 follows
|
|
**
|
|
*/
|
|
/* #include "sqliteInt.h" */
|
|
/* #include <assert.h> */
|
|
/* #include "vdbeInt.h" */
|
|
|
|
// C documentation
|
|
//
|
|
// /* The table or view or trigger name is passed to this routine via tokens
|
|
// ** pName1 and pName2. If the table name was fully qualified, for example:
|
|
// **
|
|
// ** CREATE TABLE xxx.yyy (...);
|
|
// **
|
|
// ** Then pName1 is set to "xxx" and pName2 "yyy". On the other hand if
|
|
// ** the table name is not fully qualified, i.e.:
|
|
// **
|
|
// ** CREATE TABLE yyy(...);
|
|
// **
|
|
// ** Then pName1 is set to "yyy" and pName2 is "".
|
|
// **
|
|
// ** This routine sets the *ppUnqual pointer to point at the token (pName1 or
|
|
// ** pName2) that stores the unqualified table name. The index of the
|
|
// ** database "xxx" is returned.
|
|
// */
|
|
func _sqlite3TwoPartName(tls *libc.TLS, pParse uintptr, pName1 uintptr, pName2 uintptr, pUnqual uintptr) (r int32) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var db uintptr
|
|
var iDb int32
|
|
_, _ = db, iDb /* Database holding the object */
|
|
db = (*TParse)(unsafe.Pointer(pParse)).Fdb
|
|
if (*TToken)(unsafe.Pointer(pName2)).Fn > uint32(0) {
|
|
if (*Tsqlite3)(unsafe.Pointer(db)).Finit1.Fbusy != 0 {
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+13754, 0)
|
|
return -int32(1)
|
|
}
|
|
**(**uintptr)(__ccgo_up(pUnqual)) = pName2
|
|
iDb = _sqlite3FindDb(tls, db, pName1)
|
|
if iDb < 0 {
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+13771, libc.VaList(bp+8, pName1))
|
|
return -int32(1)
|
|
}
|
|
} else {
|
|
iDb = libc.Int32FromUint8((*Tsqlite3)(unsafe.Pointer(db)).Finit1.FiDb)
|
|
**(**uintptr)(__ccgo_up(pUnqual)) = pName1
|
|
}
|
|
return iDb
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Window *pWin has just been created from a WINDOW clause. Token pBase
|
|
// ** is the base window. Earlier windows from the same WINDOW clause are
|
|
// ** stored in the linked list starting at pWin->pNextWin. This function
|
|
// ** either updates *pWin according to the base specification, or else
|
|
// ** leaves an error in pParse.
|
|
// */
|
|
func _sqlite3WindowChain(tls *libc.TLS, pParse uintptr, pWin uintptr, pList uintptr) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var db, pExist, zErr uintptr
|
|
_, _, _ = db, pExist, zErr
|
|
if (*TWindow)(unsafe.Pointer(pWin)).FzBase != 0 {
|
|
db = (*TParse)(unsafe.Pointer(pParse)).Fdb
|
|
pExist = _windowFind(tls, pParse, pList, (*TWindow)(unsafe.Pointer(pWin)).FzBase)
|
|
if pExist != 0 {
|
|
zErr = uintptr(0)
|
|
/* Check for errors */
|
|
if (*TWindow)(unsafe.Pointer(pWin)).FpPartition != 0 {
|
|
zErr = __ccgo_ts + 24515
|
|
} else {
|
|
if (*TWindow)(unsafe.Pointer(pExist)).FpOrderBy != 0 && (*TWindow)(unsafe.Pointer(pWin)).FpOrderBy != 0 {
|
|
zErr = __ccgo_ts + 24532
|
|
} else {
|
|
if libc.Int32FromUint8((*TWindow)(unsafe.Pointer(pExist)).FbImplicitFrame) == 0 {
|
|
zErr = __ccgo_ts + 24548
|
|
}
|
|
}
|
|
}
|
|
if zErr != 0 {
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24568, libc.VaList(bp+8, zErr, (*TWindow)(unsafe.Pointer(pWin)).FzBase))
|
|
} else {
|
|
(*TWindow)(unsafe.Pointer(pWin)).FpPartition = _sqlite3ExprListDup(tls, db, (*TWindow)(unsafe.Pointer(pExist)).FpPartition, 0)
|
|
if (*TWindow)(unsafe.Pointer(pExist)).FpOrderBy != 0 {
|
|
(*TWindow)(unsafe.Pointer(pWin)).FpOrderBy = _sqlite3ExprListDup(tls, db, (*TWindow)(unsafe.Pointer(pExist)).FpOrderBy, 0)
|
|
}
|
|
_sqlite3DbFree(tls, db, (*TWindow)(unsafe.Pointer(pWin)).FzBase)
|
|
(*TWindow)(unsafe.Pointer(pWin)).FzBase = uintptr(0)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** An array of names of all compile-time options. This array should
|
|
// ** be sorted A-Z.
|
|
// **
|
|
// ** This array looks large, but in a typical installation actually uses
|
|
// ** only a handful of compile-time options, so most times this array is usually
|
|
// ** rather short and uses little memory space.
|
|
// */
|
|
var _sqlite3azCompileOpt = [56]uintptr{
|
|
0: __ccgo_ts,
|
|
1: __ccgo_ts + 20,
|
|
2: __ccgo_ts + 40,
|
|
3: __ccgo_ts + 59,
|
|
4: __ccgo_ts + 84,
|
|
5: __ccgo_ts + 106,
|
|
6: __ccgo_ts + 136,
|
|
7: __ccgo_ts + 156,
|
|
8: __ccgo_ts + 176,
|
|
9: __ccgo_ts + 199,
|
|
10: __ccgo_ts + 224,
|
|
11: __ccgo_ts + 251,
|
|
12: __ccgo_ts + 276,
|
|
13: __ccgo_ts + 298,
|
|
14: __ccgo_ts + 330,
|
|
15: __ccgo_ts + 356,
|
|
16: __ccgo_ts + 381,
|
|
17: __ccgo_ts + 402,
|
|
18: __ccgo_ts + 420,
|
|
19: __ccgo_ts + 443,
|
|
20: __ccgo_ts + 462,
|
|
21: __ccgo_ts + 481,
|
|
22: __ccgo_ts + 493,
|
|
23: __ccgo_ts + 508,
|
|
24: __ccgo_ts + 530,
|
|
25: __ccgo_ts + 555,
|
|
26: __ccgo_ts + 578,
|
|
27: __ccgo_ts + 600,
|
|
28: __ccgo_ts + 611,
|
|
29: __ccgo_ts + 624,
|
|
30: __ccgo_ts + 639,
|
|
31: __ccgo_ts + 655,
|
|
32: __ccgo_ts + 668,
|
|
33: __ccgo_ts + 689,
|
|
34: __ccgo_ts + 713,
|
|
35: __ccgo_ts + 736,
|
|
36: __ccgo_ts + 752,
|
|
37: __ccgo_ts + 768,
|
|
38: __ccgo_ts + 792,
|
|
39: __ccgo_ts + 819,
|
|
40: __ccgo_ts + 839,
|
|
41: __ccgo_ts + 861,
|
|
42: __ccgo_ts + 883,
|
|
43: __ccgo_ts + 913,
|
|
44: __ccgo_ts + 938,
|
|
45: __ccgo_ts + 964,
|
|
46: __ccgo_ts + 984,
|
|
47: __ccgo_ts + 1010,
|
|
48: __ccgo_ts + 1033,
|
|
49: __ccgo_ts + 1059,
|
|
50: __ccgo_ts + 1081,
|
|
51: __ccgo_ts + 1102,
|
|
52: __ccgo_ts + 1117,
|
|
53: __ccgo_ts + 1125,
|
|
54: __ccgo_ts + 1139,
|
|
55: __ccgo_ts + 1152,
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** 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) {
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+13637, 0)
|
|
(*TParse)(unsafe.Pointer(pParse)).Frc = int32(SQLITE_ERROR)
|
|
}
|
|
|
|
var _statGetFuncdef = TFuncDef{
|
|
FnArg: int16(libc.Int32FromInt32(1) + libc.Int32FromInt32(IsStat4)),
|
|
FfuncFlags: uint32(SQLITE_UTF8),
|
|
FzName: __ccgo_ts + 13049,
|
|
}
|
|
|
|
var _statInitFuncdef = TFuncDef{
|
|
FnArg: int16(4),
|
|
FfuncFlags: uint32(SQLITE_UTF8),
|
|
FzName: __ccgo_ts + 13012,
|
|
}
|
|
|
|
var _statPushFuncdef = TFuncDef{
|
|
FnArg: int16(libc.Int32FromInt32(2) + libc.Int32FromInt32(IsStat4)),
|
|
FfuncFlags: uint32(SQLITE_UTF8),
|
|
FzName: __ccgo_ts + 13022,
|
|
}
|
|
|
|
var _staticMutexes = [12]Tsqlite3_mutex{}
|
|
|
|
func _sumFinalize(tls *libc.TLS, context uintptr) {
|
|
var p uintptr
|
|
_ = p
|
|
p = Xsqlite3_aggregate_context(tls, context, 0)
|
|
if p != 0 && (*TSumCtx)(unsafe.Pointer(p)).Fcnt > 0 {
|
|
if (*TSumCtx)(unsafe.Pointer(p)).Fapprox != 0 {
|
|
if (*TSumCtx)(unsafe.Pointer(p)).Fovrfl != 0 {
|
|
Xsqlite3_result_error(tls, context, __ccgo_ts+16486, -int32(1))
|
|
} else {
|
|
if !(_sqlite3IsOverflow(tls, (*TSumCtx)(unsafe.Pointer(p)).FrErr) != 0) {
|
|
Xsqlite3_result_double(tls, context, (*TSumCtx)(unsafe.Pointer(p)).FrSum+(*TSumCtx)(unsafe.Pointer(p)).FrErr)
|
|
} else {
|
|
Xsqlite3_result_double(tls, context, (*TSumCtx)(unsafe.Pointer(p)).FrSum)
|
|
}
|
|
}
|
|
} else {
|
|
Xsqlite3_result_int64(tls, context, (*TSumCtx)(unsafe.Pointer(p)).FiSum)
|
|
}
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Return true if it is not allowed to drop the given table
|
|
// */
|
|
func _tableMayNotBeDropped(tls *libc.TLS, db uintptr, pTab uintptr) (r int32) {
|
|
if Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pTab)).FzName, __ccgo_ts+6784, int32(7)) == 0 {
|
|
if Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pTab)).FzName+uintptr(7), __ccgo_ts+3567, int32(4)) == 0 {
|
|
return 0
|
|
}
|
|
if Xsqlite3_strnicmp(tls, (*TTable)(unsafe.Pointer(pTab)).FzName+uintptr(7), __ccgo_ts+7586, int32(10)) == 0 {
|
|
return 0
|
|
}
|
|
return int32(1)
|
|
}
|
|
if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Shadow) != uint32(0) && _sqlite3ReadOnlyShadowTables(tls, db) != 0 {
|
|
return int32(1)
|
|
}
|
|
if (*TTable)(unsafe.Pointer(pTab)).FtabFlags&uint32(TF_Eponymous) != 0 {
|
|
return int32(1)
|
|
}
|
|
return 0
|
|
}
|
|
|
|
var _tkCoalesce = TToken{
|
|
Fz: __ccgo_ts + 6989,
|
|
Fn: uint32(8),
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Return a list of all triggers on table pTab if there exists at least
|
|
// ** one trigger that must be fired when an operation of type 'op' is
|
|
// ** performed on the table, and, if that operation is an UPDATE, if at
|
|
// ** least one of the columns in pChanges is being modified.
|
|
// */
|
|
func _triggersReallyExist(tls *libc.TLS, pParse uintptr, pTab uintptr, op int32, pChanges uintptr, pMask uintptr) (r uintptr) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var mask int32
|
|
var p, pList, v1 uintptr
|
|
_, _, _, _ = mask, p, pList, v1
|
|
mask = 0
|
|
pList = uintptr(0)
|
|
pList = _sqlite3TriggerList(tls, pParse, pTab)
|
|
if pList != uintptr(0) {
|
|
p = pList
|
|
if (*Tsqlite3)(unsafe.Pointer((*TParse)(unsafe.Pointer(pParse)).Fdb)).Fflags&uint64(SQLITE_EnableTrigger) == uint64(0) && (*TTable)(unsafe.Pointer(pTab)).FpTrigger != uintptr(0) && _sqlite3SchemaToIndex(tls, (*TParse)(unsafe.Pointer(pParse)).Fdb, (*TTrigger)(unsafe.Pointer((*TTable)(unsafe.Pointer(pTab)).FpTrigger)).FpSchema) != int32(1) {
|
|
/* The SQLITE_DBCONFIG_ENABLE_TRIGGER setting is off. That means that
|
|
** only TEMP triggers are allowed. Truncate the pList so that it
|
|
** includes only TEMP triggers */
|
|
if pList == (*TTable)(unsafe.Pointer(pTab)).FpTrigger {
|
|
pList = uintptr(0)
|
|
goto exit_triggers_exist
|
|
}
|
|
for (*TTrigger)(unsafe.Pointer(p)).FpNext != 0 && (*TTrigger)(unsafe.Pointer(p)).FpNext != (*TTable)(unsafe.Pointer(pTab)).FpTrigger {
|
|
p = (*TTrigger)(unsafe.Pointer(p)).FpNext
|
|
}
|
|
(*TTrigger)(unsafe.Pointer(p)).FpNext = uintptr(0)
|
|
p = pList
|
|
}
|
|
for cond := true; cond; cond = p != 0 {
|
|
if libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Fop) == op && _checkColumnOverlap(tls, (*TTrigger)(unsafe.Pointer(p)).FpColumns, pChanges) != 0 {
|
|
mask = mask | libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Ftr_tm)
|
|
} else {
|
|
if libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Fop) == int32(TK_RETURNING) {
|
|
/* The first time a RETURNING trigger is seen, the "op" value tells
|
|
** us what time of trigger it should be. */
|
|
(*TTrigger)(unsafe.Pointer(p)).Fop = libc.Uint8FromInt32(op)
|
|
if libc.Int32FromUint8((*TTable)(unsafe.Pointer(pTab)).FeTabType) == int32(TABTYP_VTAB) {
|
|
if op != int32(TK_INSERT) {
|
|
if op == int32(TK_DELETE) {
|
|
v1 = __ccgo_ts + 22488
|
|
} else {
|
|
v1 = __ccgo_ts + 22495
|
|
}
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+22502, libc.VaList(bp+8, v1))
|
|
}
|
|
(*TTrigger)(unsafe.Pointer(p)).Ftr_tm = uint8(TRIGGER_BEFORE)
|
|
} else {
|
|
(*TTrigger)(unsafe.Pointer(p)).Ftr_tm = uint8(TRIGGER_AFTER)
|
|
}
|
|
mask = mask | libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Ftr_tm)
|
|
} else {
|
|
if (*TTrigger)(unsafe.Pointer(p)).FbReturning != 0 && libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Fop) == int32(TK_INSERT) && op == int32(TK_UPDATE) && (*TParse)(unsafe.Pointer(pParse)).FpToplevel == uintptr(0) {
|
|
/* Also fire a RETURNING trigger for an UPSERT */
|
|
mask = mask | libc.Int32FromUint8((*TTrigger)(unsafe.Pointer(p)).Ftr_tm)
|
|
}
|
|
}
|
|
}
|
|
p = (*TTrigger)(unsafe.Pointer(p)).FpNext
|
|
}
|
|
}
|
|
goto exit_triggers_exist
|
|
exit_triggers_exist:
|
|
;
|
|
if pMask != 0 {
|
|
**(**int32)(__ccgo_up(pMask)) = mask
|
|
}
|
|
if mask != 0 {
|
|
v1 = pList
|
|
} else {
|
|
v1 = uintptr(0)
|
|
}
|
|
return v1
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** This routine checks if there is a RESERVED lock held on the specified
|
|
// ** file by this or any other process. If such a lock is held, set *pResOut
|
|
// ** to a non-zero value otherwise *pResOut is set to zero. The return value
|
|
// ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
|
|
// */
|
|
func _unixCheckReservedLock(tls *libc.TLS, id uintptr, pResOut uintptr) (r int32) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var pFile uintptr
|
|
var rc, reserved, v1 int32
|
|
var _ /* lock at bp+0 */ Tflock
|
|
_, _, _, _ = pFile, rc, reserved, v1
|
|
rc = SQLITE_OK
|
|
reserved = 0
|
|
pFile = id
|
|
Xsqlite3_mutex_enter(tls, (*TunixInodeInfo)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFile)).FpInode)).FpLockMutex)
|
|
/* Check if a thread in this process holds such a lock */
|
|
if libc.Int32FromUint8((*TunixInodeInfo)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFile)).FpInode)).FeFileLock) > int32(SHARED_LOCK) {
|
|
reserved = int32(1)
|
|
}
|
|
/* Otherwise see if some other process holds it.
|
|
*/
|
|
if !(reserved != 0) && !((*TunixInodeInfo)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFile)).FpInode)).FbProcessLock != 0) {
|
|
(**(**Tflock)(__ccgo_up(bp))).Fl_whence = 0
|
|
(**(**Tflock)(__ccgo_up(bp))).Fl_start = int64(_sqlite3PendingByte + libc.Int32FromInt32(1))
|
|
(**(**Tflock)(__ccgo_up(bp))).Fl_len = int64(1)
|
|
(**(**Tflock)(__ccgo_up(bp))).Fl_type = int16(F_WRLCK)
|
|
if libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_ofdEnabled))) != 0 && libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_ofdSupported))) != 0 && (*TunixInodeInfo)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFile)).FpInode)).FhLock != 0 {
|
|
v1 = (*TunixInodeInfo)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFile)).FpInode)).FhLock
|
|
} else {
|
|
v1 = (*TunixFile)(unsafe.Pointer(pFile)).Fh
|
|
}
|
|
if _osFcntlOfd(tls, v1, int32(F_GETLK), bp) != 0 {
|
|
rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(14)<<libc.Int32FromInt32(8)
|
|
_storeLastErrno(tls, pFile, **(**int32)(__ccgo_up(libc.X__errno_location(tls))))
|
|
} else {
|
|
if int32((**(**Tflock)(__ccgo_up(bp))).Fl_type) != int32(F_UNLCK) {
|
|
reserved = int32(1)
|
|
}
|
|
}
|
|
}
|
|
Xsqlite3_mutex_leave(tls, (*TunixInodeInfo)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFile)).FpInode)).FpLockMutex)
|
|
**(**int32)(__ccgo_up(pResOut)) = reserved
|
|
return rc
|
|
}
|
|
|
|
/*
|
|
** Set a posix-advisory-lock.
|
|
**
|
|
** There are two versions of this routine. If compiled with
|
|
** SQLITE_ENABLE_SETLK_TIMEOUT then the routine has an extra parameter
|
|
** which is a pointer to a unixFile. If the unixFile->iBusyTimeout
|
|
** value is set, then it is the number of milliseconds to wait before
|
|
** failing the lock. The iBusyTimeout value is always reset back to
|
|
** zero on each call.
|
|
**
|
|
** If SQLITE_ENABLE_SETLK_TIMEOUT is not defined, then do a non-blocking
|
|
** attempt to set the lock.
|
|
*/
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Delete the file at zPath. If the dirSync argument is true, fsync()
|
|
// ** the directory after deleting the file.
|
|
// */
|
|
func _unixDelete(tls *libc.TLS, NotUsed uintptr, zPath uintptr, dirSync int32) (r int32) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var rc int32
|
|
var _ /* fd at bp+0 */ int32
|
|
_ = rc
|
|
rc = SQLITE_OK
|
|
_ = NotUsed
|
|
if (*(*func(*libc.TLS, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(16)].FpCurrent})))(tls, zPath) == -int32(1) {
|
|
if **(**int32)(__ccgo_up(libc.X__errno_location(tls))) == int32(ENOENT) {
|
|
rc = libc.Int32FromInt32(SQLITE_IOERR) | libc.Int32FromInt32(23)<<libc.Int32FromInt32(8)
|
|
} else {
|
|
rc = _unixLogErrorAtLine(tls, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(10)<<libc.Int32FromInt32(8), __ccgo_ts+3652, zPath, int32(47191))
|
|
}
|
|
return rc
|
|
}
|
|
if dirSync&int32(1) != 0 {
|
|
rc = (*(*func(*libc.TLS, uintptr, uintptr) int32)(unsafe.Pointer(&struct{ uintptr }{_aSyscall[int32(17)].FpCurrent})))(tls, zPath, bp)
|
|
if rc == SQLITE_OK {
|
|
if _full_fsync(tls, **(**int32)(__ccgo_up(bp)), 0, 0) != 0 {
|
|
rc = _unixLogErrorAtLine(tls, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(5)<<libc.Int32FromInt32(8), __ccgo_ts+4093, zPath, int32(47201))
|
|
}
|
|
_robust_close(tls, uintptr(0), **(**int32)(__ccgo_up(bp)), int32(47203))
|
|
} else {
|
|
rc = SQLITE_OK
|
|
}
|
|
}
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** SQLite calls this function immediately after a call to unixDlSym() or
|
|
// ** unixDlOpen() fails (returns a null pointer). If a more detailed error
|
|
// ** message is available, it is written to zBufOut. If no error message
|
|
// ** is available, zBufOut is left unmodified and SQLite uses a default
|
|
// ** error message.
|
|
// */
|
|
func _unixDlError(tls *libc.TLS, NotUsed uintptr, nBuf int32, zBufOut uintptr) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var zErr uintptr
|
|
_ = zErr
|
|
_ = NotUsed
|
|
_unixEnterMutex(tls)
|
|
zErr = libc.Xdlerror(tls)
|
|
if zErr != 0 {
|
|
Xsqlite3_snprintf(tls, nBuf, zBufOut, __ccgo_ts+3968, libc.VaList(bp+8, zErr))
|
|
}
|
|
_unixLeaveMutex(tls)
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Attempt to set a system-lock on the file pFile. The lock is
|
|
// ** described by pLock.
|
|
// **
|
|
// ** If the pFile was opened read/write from unix-excl, then the only lock
|
|
// ** ever obtained is an exclusive lock, and it is obtained exactly once
|
|
// ** the first time any lock is attempted. All subsequent system locking
|
|
// ** operations become no-ops. Locking operations still happen internally,
|
|
// ** in order to coordinate access between separate database connections
|
|
// ** within this process, but all of that is handled in memory and the
|
|
// ** operating system does not participate.
|
|
// **
|
|
// ** This function is a pass-through to fcntl(F_SETLK) if pFile is using
|
|
// ** any VFS other than "unix-excl" or if pFile is opened on "unix-excl"
|
|
// ** and is read-only.
|
|
// **
|
|
// ** Zero is returned if the call completes successfully, or -1 if a call
|
|
// ** to fcntl() fails. In this case, errno is set appropriately (by fcntl()).
|
|
// */
|
|
func _unixFileLock(tls *libc.TLS, pFile uintptr, pLock uintptr) (r int32) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var h, rc, v1 int32
|
|
var pInode uintptr
|
|
var _ /* lock at bp+0 */ Tflock
|
|
_, _, _, _ = h, pInode, rc, v1
|
|
pInode = (*TunixFile)(unsafe.Pointer(pFile)).FpInode
|
|
if libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_ofdEnabled))) != 0 && libc.AtomicLoadPInt32(uintptr(unsafe.Pointer(&_ofdSupported))) != 0 && (*TunixInodeInfo)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFile)).FpInode)).FhLock != 0 {
|
|
v1 = (*TunixInodeInfo)(unsafe.Pointer((*TunixFile)(unsafe.Pointer(pFile)).FpInode)).FhLock
|
|
} else {
|
|
v1 = (*TunixFile)(unsafe.Pointer(pFile)).Fh
|
|
}
|
|
h = v1
|
|
if libc.Int32FromUint16((*TunixFile)(unsafe.Pointer(pFile)).FctrlFlags)&(libc.Int32FromInt32(UNIXFILE_EXCL)|libc.Int32FromInt32(UNIXFILE_RDONLY)) == int32(UNIXFILE_EXCL) {
|
|
if libc.Int32FromUint8((*TunixInodeInfo)(unsafe.Pointer(pInode)).FbProcessLock) == 0 {
|
|
/* assert( pInode->nLock==0 ); <-- Not true if unix-excl READONLY used */
|
|
(**(**Tflock)(__ccgo_up(bp))).Fl_whence = 0
|
|
(**(**Tflock)(__ccgo_up(bp))).Fl_start = int64(_sqlite3PendingByte + libc.Int32FromInt32(2))
|
|
(**(**Tflock)(__ccgo_up(bp))).Fl_len = int64(SHARED_SIZE)
|
|
(**(**Tflock)(__ccgo_up(bp))).Fl_type = int16(F_WRLCK)
|
|
rc = _osFcntlOfd(tls, h, int32(F_SETLK), bp)
|
|
if rc < 0 {
|
|
return rc
|
|
}
|
|
(*TunixInodeInfo)(unsafe.Pointer(pInode)).FbProcessLock = uint8(1)
|
|
(*TunixInodeInfo)(unsafe.Pointer(pInode)).FnLock = (*TunixInodeInfo)(unsafe.Pointer(pInode)).FnLock + 1
|
|
} else {
|
|
rc = 0
|
|
}
|
|
} else {
|
|
rc = _osFcntlOfd(tls, h, int32(F_SETLK), pLock)
|
|
}
|
|
return rc
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** The xGetLastError() method is designed to return a better
|
|
// ** low-level error message when operating-system problems come up
|
|
// ** during SQLite operation. Only the integer return code is currently
|
|
// ** used.
|
|
// */
|
|
func _unixGetLastError(tls *libc.TLS, NotUsed uintptr, NotUsed2 int32, NotUsed3 uintptr) (r int32) {
|
|
_ = NotUsed
|
|
_ = NotUsed2
|
|
_ = NotUsed3
|
|
return **(**int32)(__ccgo_up(libc.X__errno_location(tls)))
|
|
}
|
|
|
|
/*
|
|
************************ End of sqlite3_vfs methods ***************************
|
|
******************************************************************************/
|
|
|
|
/******************************************************************************
|
|
************************** Begin Proxy Locking ********************************
|
|
**
|
|
** Proxy locking is a "uber-locking-method" in this sense: It uses the
|
|
** other locking methods on secondary lock files. Proxy locking is a
|
|
** meta-layer over top of the primitive locking implemented above. For
|
|
** this reason, the division that implements of proxy locking is deferred
|
|
** until late in the file (here) after all of the other I/O methods have
|
|
** been defined - so that the primitive locking methods are available
|
|
** as services to help with the implementation of proxy locking.
|
|
**
|
|
****
|
|
**
|
|
** The default locking schemes in SQLite use byte-range locks on the
|
|
** database file to coordinate safe, concurrent access by multiple readers
|
|
** and writers [http://sqlite.org/lockingv3.html]. The five file locking
|
|
** states (UNLOCKED, PENDING, SHARED, RESERVED, EXCLUSIVE) are implemented
|
|
** as POSIX read & write locks over fixed set of locations (via fsctl),
|
|
** on AFP and SMB only exclusive byte-range locks are available via fsctl
|
|
** with _IOWR('z', 23, struct ByteRangeLockPB2) to track the same 5 states.
|
|
** To simulate a F_RDLCK on the shared range, on AFP a randomly selected
|
|
** address in the shared range is taken for a SHARED lock, the entire
|
|
** shared range is taken for an EXCLUSIVE lock):
|
|
**
|
|
** PENDING_BYTE 0x40000000
|
|
** RESERVED_BYTE 0x40000001
|
|
** SHARED_RANGE 0x40000002 -> 0x40000200
|
|
**
|
|
** This works well on the local file system, but shows a nearly 100x
|
|
** slowdown in read performance on AFP because the AFP client disables
|
|
** the read cache when byte-range locks are present. Enabling the read
|
|
** cache exposes a cache coherency problem that is present on all OS X
|
|
** supported network file systems. NFS and AFP both observe the
|
|
** close-to-open semantics for ensuring cache coherency
|
|
** [http://nfs.sourceforge.net/#faq_a8], which does not effectively
|
|
** address the requirements for concurrent database access by multiple
|
|
** readers and writers
|
|
** [http://www.nabble.com/SQLite-on-NFS-cache-coherency-td15655701.html].
|
|
**
|
|
** To address the performance and cache coherency issues, proxy file locking
|
|
** changes the way database access is controlled by limiting access to a
|
|
** single host at a time and moving file locks off of the database file
|
|
** and onto a proxy file on the local file system.
|
|
**
|
|
**
|
|
** Using proxy locks
|
|
** -----------------
|
|
**
|
|
** C APIs
|
|
**
|
|
** sqlite3_file_control(db, dbname, SQLITE_FCNTL_SET_LOCKPROXYFILE,
|
|
** <proxy_path> | ":auto:");
|
|
** sqlite3_file_control(db, dbname, SQLITE_FCNTL_GET_LOCKPROXYFILE,
|
|
** &<proxy_path>);
|
|
**
|
|
**
|
|
** SQL pragmas
|
|
**
|
|
** PRAGMA [database.]lock_proxy_file=<proxy_path> | :auto:
|
|
** PRAGMA [database.]lock_proxy_file
|
|
**
|
|
** Specifying ":auto:" means that if there is a conch file with a matching
|
|
** host ID in it, the proxy path in the conch file will be used, otherwise
|
|
** a proxy path based on the user's temp dir
|
|
** (via confstr(_CS_DARWIN_USER_TEMP_DIR,...)) will be used and the
|
|
** actual proxy file name is generated from the name and path of the
|
|
** database file. For example:
|
|
**
|
|
** For database path "/Users/me/foo.db"
|
|
** The lock path will be "<tmpdir>/sqliteplocks/_Users_me_foo.db:auto:")
|
|
**
|
|
** Once a lock proxy is configured for a database connection, it can not
|
|
** be removed, however it may be switched to a different proxy path via
|
|
** the above APIs (assuming the conch file is not being held by another
|
|
** connection or process).
|
|
**
|
|
**
|
|
** How proxy locking works
|
|
** -----------------------
|
|
**
|
|
** Proxy file locking relies primarily on two new supporting files:
|
|
**
|
|
** * conch file to limit access to the database file to a single host
|
|
** at a time
|
|
**
|
|
** * proxy file to act as a proxy for the advisory locks normally
|
|
** taken on the database
|
|
**
|
|
** The conch file - to use a proxy file, sqlite must first "hold the conch"
|
|
** by taking an sqlite-style shared lock on the conch file, reading the
|
|
** contents and comparing the host's unique host ID (see below) and lock
|
|
** proxy path against the values stored in the conch. The conch file is
|
|
** stored in the same directory as the database file and the file name
|
|
** is patterned after the database file name as ".<databasename>-conch".
|
|
** If the conch file does not exist, or its contents do not match the
|
|
** host ID and/or proxy path, then the lock is escalated to an exclusive
|
|
** lock and the conch file contents is updated with the host ID and proxy
|
|
** path and the lock is downgraded to a shared lock again. If the conch
|
|
** is held by another process (with a shared lock), the exclusive lock
|
|
** will fail and SQLITE_BUSY is returned.
|
|
**
|
|
** The proxy file - a single-byte file used for all advisory file locks
|
|
** normally taken on the database file. This allows for safe sharing
|
|
** of the database file for multiple readers and writers on the same
|
|
** host (the conch ensures that they all use the same local lock file).
|
|
**
|
|
** Requesting the lock proxy does not immediately take the conch, it is
|
|
** only taken when the first request to lock database file is made.
|
|
** This matches the semantics of the traditional locking behavior, where
|
|
** opening a connection to a database file does not take a lock on it.
|
|
** The shared lock and an open file descriptor are maintained until
|
|
** the connection to the database is closed.
|
|
**
|
|
** The proxy file and the lock file are never deleted so they only need
|
|
** to be created the first time they are used.
|
|
**
|
|
** Configuration options
|
|
** ---------------------
|
|
**
|
|
** SQLITE_PREFER_PROXY_LOCKING
|
|
**
|
|
** Database files accessed on non-local file systems are
|
|
** automatically configured for proxy locking, lock files are
|
|
** named automatically using the same logic as
|
|
** PRAGMA lock_proxy_file=":auto:"
|
|
**
|
|
** SQLITE_PROXY_DEBUG
|
|
**
|
|
** Enables the logging of error messages during host id file
|
|
** retrieval and creation
|
|
**
|
|
** LOCKPROXYDIR
|
|
**
|
|
** Overrides the default directory used for lock proxy files that
|
|
** are named automatically via the ":auto:" setting
|
|
**
|
|
** SQLITE_DEFAULT_PROXYDIR_PERMISSIONS
|
|
**
|
|
** Permissions to use when creating a directory for storing the
|
|
** lock proxy files, only used when LOCKPROXYDIR is not set.
|
|
**
|
|
**
|
|
** As mentioned above, when compiled with SQLITE_PREFER_PROXY_LOCKING,
|
|
** setting the environment variable SQLITE_FORCE_PROXY_LOCKING to 1 will
|
|
** force proxy locking to be used for every database file opened, and 0
|
|
** will force automatic proxy locking to be disabled for all database
|
|
** files (explicitly calling the SQLITE_FCNTL_SET_LOCKPROXYFILE pragma or
|
|
** sqlite_file_control API is not affected by SQLITE_FORCE_PROXY_LOCKING).
|
|
*/
|
|
|
|
/*
|
|
** Proxy locking is only available on MacOSX
|
|
*/
|
|
/*
|
|
** The proxy locking style is intended for use with AFP filesystems.
|
|
** And since AFP is only supported on MacOSX, the proxy locking is also
|
|
** restricted to MacOSX.
|
|
**
|
|
**
|
|
******************* End of the proxy lock implementation **********************
|
|
******************************************************************************/
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// **
|
|
// ** This function - unixLogErrorAtLine(), is only ever called via the macro
|
|
// ** unixLogError().
|
|
// **
|
|
// ** It is invoked after an error occurs in an OS function and errno has been
|
|
// ** set. It logs a message using sqlite3_log() containing the current value of
|
|
// ** errno and, if possible, the human-readable equivalent from strerror() or
|
|
// ** strerror_r().
|
|
// **
|
|
// ** The first argument passed to the macro should be the error code that
|
|
// ** will be returned to SQLite (e.g. SQLITE_IOERR_DELETE, SQLITE_CANTOPEN).
|
|
// ** The two subsequent arguments should be the name of the OS function that
|
|
// ** failed (e.g. "unlink", "open") and the associated file-system path,
|
|
// ** if any.
|
|
// */
|
|
func _unixLogErrorAtLine(tls *libc.TLS, errcode int32, zFunc uintptr, zPath uintptr, iLine int32) (r int32) {
|
|
bp := tls.Alloc(48)
|
|
defer tls.Free(48)
|
|
var iErrno int32
|
|
var zErr uintptr
|
|
_, _ = iErrno, zErr /* Message from strerror() or equivalent */
|
|
iErrno = **(**int32)(__ccgo_up(libc.X__errno_location(tls))) /* Saved syscall error number */
|
|
/* If this is not a threadsafe build (SQLITE_THREADSAFE==0), then use
|
|
** the strerror() function to obtain the human-readable error message
|
|
** equivalent to errno. Otherwise, use strerror_r().
|
|
*/
|
|
/* This is a threadsafe build, but strerror_r() is not available. */
|
|
zErr = __ccgo_ts + 1704
|
|
if zPath == uintptr(0) {
|
|
zPath = __ccgo_ts + 1704
|
|
}
|
|
Xsqlite3_log(tls, errcode, __ccgo_ts+3829, libc.VaList(bp+8, iLine, iErrno, zFunc, zPath, zErr))
|
|
return errcode
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Implement a memory barrier or memory fence on shared memory.
|
|
// **
|
|
// ** All loads and stores begun before the barrier must complete before
|
|
// ** any load or store begun after the barrier.
|
|
// */
|
|
func _unixShmBarrier(tls *libc.TLS, fd uintptr) {
|
|
_ = fd
|
|
_sqlite3MemoryBarrier(tls) /* compiler-defined memory barrier */
|
|
_unixEnterMutex(tls) /* Also mutex, for redundancy */
|
|
_unixLeaveMutex(tls)
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Initialize first two members of azTempDirs[] array.
|
|
// */
|
|
func _unixTempFileInit(tls *libc.TLS) {
|
|
_azTempDirs[0] = libc.Xgetenv(tls, __ccgo_ts+4048)
|
|
_azTempDirs[int32(1)] = libc.Xgetenv(tls, __ccgo_ts+4062)
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Truncate an open file to a specified size
|
|
// */
|
|
func _unixTruncate(tls *libc.TLS, id uintptr, nByte Ti64) (r int32) {
|
|
var pFile uintptr
|
|
var rc int32
|
|
_, _ = pFile, rc
|
|
pFile = id
|
|
/* If the user has configured a chunk-size for this file, truncate the
|
|
** file so that it consists of an integer number of chunks (i.e. the
|
|
** actual file size after the operation may be larger than the requested
|
|
** size).
|
|
*/
|
|
if (*TunixFile)(unsafe.Pointer(pFile)).FszChunk > 0 {
|
|
nByte = (nByte + int64((*TunixFile)(unsafe.Pointer(pFile)).FszChunk) - int64(1)) / int64((*TunixFile)(unsafe.Pointer(pFile)).FszChunk) * int64((*TunixFile)(unsafe.Pointer(pFile)).FszChunk)
|
|
}
|
|
rc = _robust_ftruncate(tls, (*TunixFile)(unsafe.Pointer(pFile)).Fh, nByte)
|
|
if rc != 0 {
|
|
_storeLastErrno(tls, pFile, **(**int32)(__ccgo_up(libc.X__errno_location(tls))))
|
|
return _unixLogErrorAtLine(tls, libc.Int32FromInt32(SQLITE_IOERR)|libc.Int32FromInt32(6)<<libc.Int32FromInt32(8), __ccgo_ts+3578, (*TunixFile)(unsafe.Pointer(pFile)).FzPath, int32(44321))
|
|
} else {
|
|
/* If the file was just truncated to a size smaller than the currently
|
|
** mapped region, reduce the effective mapping size as well. SQLite will
|
|
** use read() and write() to access data beyond this point from now on.
|
|
*/
|
|
if nByte < (*TunixFile)(unsafe.Pointer(pFile)).FmmapSize {
|
|
(*TunixFile)(unsafe.Pointer(pFile)).FmmapSize = nByte
|
|
}
|
|
return SQLITE_OK
|
|
}
|
|
return r
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** These functions are called when a transaction opened by the database
|
|
// ** handle associated with the VM passed as an argument is about to be
|
|
// ** committed. If there are outstanding foreign key constraint violations
|
|
// ** return an error code. Otherwise, SQLITE_OK.
|
|
// **
|
|
// ** If there are outstanding FK violations and this function returns
|
|
// ** non-zero, set the result of the VM to SQLITE_CONSTRAINT_FOREIGNKEY
|
|
// ** and write an error message to it.
|
|
// */
|
|
func _vdbeFkError(tls *libc.TLS, p uintptr) (r int32) {
|
|
(*TVdbe)(unsafe.Pointer(p)).Frc = libc.Int32FromInt32(SQLITE_CONSTRAINT) | libc.Int32FromInt32(3)<<libc.Int32FromInt32(8)
|
|
(*TVdbe)(unsafe.Pointer(p)).FerrorAction = uint8(OE_Abort)
|
|
_sqlite3VdbeError(tls, p, __ccgo_ts+5420, 0)
|
|
if libc.Int32FromUint8((*TVdbe)(unsafe.Pointer(p)).FprepFlags)&int32(SQLITE_PREPARE_SAVESQL) == 0 {
|
|
return int32(SQLITE_ERROR)
|
|
}
|
|
return libc.Int32FromInt32(SQLITE_CONSTRAINT) | libc.Int32FromInt32(3)<<libc.Int32FromInt32(8)
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** Check on a Vdbe to make sure it has not been finalized. Log
|
|
// ** an error and return true if it has been finalized (or is otherwise
|
|
// ** invalid). Return false if it is ok.
|
|
// */
|
|
func _vdbeSafety(tls *libc.TLS, p uintptr) (r int32) {
|
|
if (*TVdbe)(unsafe.Pointer(p)).Fdb == uintptr(0) {
|
|
Xsqlite3_log(tls, int32(SQLITE_MISUSE), __ccgo_ts+5533, 0)
|
|
return int32(1)
|
|
} else {
|
|
return 0
|
|
}
|
|
return r
|
|
}
|
|
|
|
func _vdbeSafetyNotNull(tls *libc.TLS, p uintptr) (r int32) {
|
|
if p == uintptr(0) {
|
|
Xsqlite3_log(tls, int32(SQLITE_MISUSE), __ccgo_ts+5578, 0)
|
|
return int32(1)
|
|
} else {
|
|
return _vdbeSafety(tls, p)
|
|
}
|
|
return r
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** If the WAL file is currently larger than nMax bytes in size, truncate
|
|
// ** it to exactly nMax bytes. If an error occurs while doing so, ignore it.
|
|
// */
|
|
func _walLimitSize(tls *libc.TLS, pWal uintptr, nMax Ti64) {
|
|
bp := tls.Alloc(32)
|
|
defer tls.Free(32)
|
|
var rx int32
|
|
var _ /* sz at bp+0 */ Ti64
|
|
_ = rx
|
|
_sqlite3BeginBenignMalloc(tls)
|
|
rx = _sqlite3OsFileSize(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, bp)
|
|
if rx == SQLITE_OK && **(**Ti64)(__ccgo_up(bp)) > nMax {
|
|
rx = _sqlite3OsTruncate(tls, (*TWal)(unsafe.Pointer(pWal)).FpWalFd, nMax)
|
|
}
|
|
_sqlite3EndBenignMalloc(tls)
|
|
if rx != 0 {
|
|
Xsqlite3_log(tls, rx, __ccgo_ts+4341, libc.VaList(bp+16, (*TWal)(unsafe.Pointer(pWal)).FzWalName))
|
|
}
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** A "PRECEDING <expr>" (eCond==0) or "FOLLOWING <expr>" (eCond==1) or the
|
|
// ** value of the second argument to nth_value() (eCond==2) has just been
|
|
// ** evaluated and the result left in register reg. This function generates VM
|
|
// ** code to check that the value is a non-negative integer and throws an
|
|
// ** exception if it is not.
|
|
// */
|
|
func _windowCheckValue(tls *libc.TLS, pParse uintptr, reg int32, eCond int32) {
|
|
var regString, regZero int32
|
|
var v uintptr
|
|
_, _, _ = regString, regZero, v
|
|
v = _sqlite3GetVdbe(tls, pParse)
|
|
regZero = _sqlite3GetTempReg(tls, pParse)
|
|
_sqlite3VdbeAddOp2(tls, v, int32(OP_Integer), 0, regZero)
|
|
if eCond >= int32(WINDOW_STARTING_NUM) {
|
|
regString = _sqlite3GetTempReg(tls, pParse)
|
|
_sqlite3VdbeAddOp4(tls, v, int32(OP_String8), 0, regString, 0, __ccgo_ts+1704, -int32(1))
|
|
_sqlite3VdbeAddOp3(tls, v, int32(OP_Ge), regString, _sqlite3VdbeCurrentAddr(tls, v)+int32(2), reg)
|
|
_sqlite3VdbeChangeP5(tls, v, libc.Uint16FromInt32(libc.Int32FromInt32(SQLITE_AFF_NUMERIC)|libc.Int32FromInt32(SQLITE_JUMPIFNULL)))
|
|
} else {
|
|
_sqlite3VdbeAddOp2(tls, v, int32(OP_MustBeInt), reg, _sqlite3VdbeCurrentAddr(tls, v)+int32(2))
|
|
}
|
|
_sqlite3VdbeAddOp3(tls, v, _aOp1[eCond], regZero, _sqlite3VdbeCurrentAddr(tls, v)+int32(2), reg)
|
|
_sqlite3VdbeChangeP5(tls, v, uint16(SQLITE_AFF_NUMERIC))
|
|
/* NULL case captured by */
|
|
/* the OP_MustBeInt */
|
|
/* NULL case caught by */
|
|
/* the OP_Ge */
|
|
_sqlite3MayAbort(tls, pParse)
|
|
_sqlite3VdbeAddOp2(tls, v, int32(OP_Halt), int32(SQLITE_ERROR), int32(OE_Abort))
|
|
_sqlite3VdbeAppendP4(tls, v, _azErr[eCond], -int32(1))
|
|
_sqlite3ReleaseTempReg(tls, pParse, regZero)
|
|
}
|
|
|
|
func _windowFind(tls *libc.TLS, pParse uintptr, pList uintptr, zName uintptr) (r uintptr) {
|
|
bp := tls.Alloc(16)
|
|
defer tls.Free(16)
|
|
var p uintptr
|
|
_ = p
|
|
p = pList
|
|
for {
|
|
if !(p != 0) {
|
|
break
|
|
}
|
|
if _sqlite3StrICmp(tls, (*TWindow)(unsafe.Pointer(p)).FzName, zName) == 0 {
|
|
break
|
|
}
|
|
goto _1
|
|
_1:
|
|
;
|
|
p = (*TWindow)(unsafe.Pointer(p)).FpNextWin
|
|
}
|
|
if p == uintptr(0) {
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+24304, libc.VaList(bp+8, zName))
|
|
}
|
|
return p
|
|
}
|
|
|
|
// C documentation
|
|
//
|
|
// /*
|
|
// ** The following routine is called if the stack overflows.
|
|
// */
|
|
func _yyStackOverflow(tls *libc.TLS, yypParser uintptr) {
|
|
var pParse uintptr
|
|
_ = pParse
|
|
pParse = (*TyyParser)(unsafe.Pointer(yypParser)).FpParse
|
|
for (*TyyParser)(unsafe.Pointer(yypParser)).Fyytos > (*TyyParser)(unsafe.Pointer(yypParser)).Fyystack {
|
|
_yy_pop_parser_stack(tls, yypParser)
|
|
}
|
|
/* Here code is inserted which will execute if the parser
|
|
** stack every overflows */
|
|
/******** Begin %stack_overflow code ******************************************/
|
|
if (*TParse)(unsafe.Pointer(pParse)).FnErr == 0 {
|
|
_sqlite3ErrorMsg(tls, pParse, __ccgo_ts+25007, 0)
|
|
}
|
|
/******** End %stack_overflow code ********************************************/
|
|
/* Suppress warning about unused %extra_argument var */
|
|
(*TyyParser)(unsafe.Pointer(yypParser)).FpParse = pParse
|
|
}
|
|
|
|
/*
|
|
** Print tracing information for a SHIFT action
|
|
*/
|
|
|
|
const alloca = 0
|
|
|
|
const blkcnt64_t = 0
|
|
|
|
type cpu_set_t = Tcpu_set_t
|
|
|
|
const creat64 = 0
|
|
|
|
type f_owner_ex = Tf_owner_ex
|
|
|
|
const fallocate64 = 0
|
|
|
|
const fgetpos64 = 0
|
|
|
|
type file_handle = Tfile_handle
|
|
|
|
const flock64 = 0
|
|
|
|
const fopen64 = 0
|
|
|
|
const fpos64_t = 0
|
|
|
|
const freopen64 = 0
|
|
|
|
const fsblkcnt64_t = 0
|
|
|
|
const fseeko64 = 0
|
|
|
|
const fsetpos64 = 0
|
|
|
|
const fsfilcnt64_t = 0
|
|
|
|
const fstat64 = 0
|
|
|
|
const fstatat64 = 0
|
|
|
|
const ftello64 = 0
|
|
|
|
const ftruncate64 = 0
|
|
|
|
const ino64_t = 0
|
|
|
|
type itimerspec = Titimerspec
|
|
|
|
/*
|
|
** The MSVC CRT on Windows CE may not have a localtime() function.
|
|
** So declare a substitute. The substitute function itself is
|
|
** defined in "os_win.c".
|
|
*/
|
|
|
|
const linux = 1
|
|
|
|
const lockf64 = 0
|
|
|
|
const loff_t = 0
|
|
|
|
const lseek64 = 0
|
|
|
|
const lstat64 = 0
|
|
|
|
const mkostemp64 = 0
|
|
|
|
const mkostemps64 = 0
|
|
|
|
const mkstemp64 = 0
|
|
|
|
const mkstemps64 = 0
|
|
|
|
const mmap64 = 0
|
|
|
|
const off64_t = 0
|
|
|
|
const open64 = 0
|
|
|
|
const openat64 = 0
|
|
|
|
const posix_fadvise64 = 0
|
|
|
|
const posix_fallocate64 = 0
|
|
|
|
const pread64 = 0
|
|
|
|
type ptrdiff_t = Tptrdiff_t
|
|
|
|
/*
|
|
** Use a macro to replace memcpy() if compiled with SQLITE_INLINE_MEMCPY.
|
|
** This allows better measurements of where memcpy() is used when running
|
|
** cachegrind. But this macro version of memcpy() is very slow so it
|
|
** should not be used in production. This is a performance measurement
|
|
** hack only.
|
|
*/
|
|
|
|
/*
|
|
** If compiling for a processor that lacks floating point support,
|
|
** substitute integer for floating-point
|
|
*/
|
|
|
|
/*
|
|
** OMIT_TEMPDB is set to 1 if SQLITE_OMIT_TEMPDB is defined, or 0
|
|
** afterward. Having this macro allows us to cause the C compiler
|
|
** to omit code used by TEMP tables without messy #ifndef statements.
|
|
*/
|
|
|
|
/*
|
|
** The "file format" number is an integer that is incremented whenever
|
|
** the VDBE-level file format changes. The following macros define the
|
|
** the default file format for new databases and the maximum file format
|
|
** that the library can read.
|
|
*/
|
|
|
|
/*
|
|
** Determine whether triggers are recursive by default. This can be
|
|
** changed at run-time using a pragma.
|
|
*/
|
|
|
|
/*
|
|
** Provide a default value for SQLITE_TEMP_STORE in case it is not specified
|
|
** on the command-line
|
|
*/
|
|
|
|
/*
|
|
** If no value has been provided for SQLITE_MAX_WORKER_THREADS, or if
|
|
** SQLITE_TEMP_STORE is set to 3 (never use temporary files), set it
|
|
** to zero.
|
|
*/
|
|
|
|
/*
|
|
** The default initial allocation for the pagecache when using separate
|
|
** pagecaches for each database connection. A positive number is the
|
|
** number of pages. A negative number N translations means that a buffer
|
|
** of -1024*N bytes is allocated and used for as many pages as it will hold.
|
|
**
|
|
** The default value of "20" was chosen to minimize the run-time of the
|
|
** speedtest1 test program with options: --shrink-memory --reprepare
|
|
*/
|
|
|
|
/*
|
|
** Default value for the SQLITE_CONFIG_SORTERREF_SIZE option.
|
|
*/
|
|
|
|
/*
|
|
** The compile-time options SQLITE_MMAP_READWRITE and
|
|
** SQLITE_ENABLE_BATCH_ATOMIC_WRITE are not compatible with one another.
|
|
** You must choose one or the other (or neither) but not both.
|
|
*/
|
|
|
|
/*
|
|
** GCC does not define the offsetof() macro so we'll have to do it
|
|
** ourselves.
|
|
*/
|
|
|
|
/*
|
|
** sizeof64() is like sizeof(), but always returns a 64-bit value, even
|
|
** on 32-bit builds. This can help to avoid overflow by ensuring 64-bit
|
|
** arithmetic is used consistently in both 32-bit and 64-bit builds.
|
|
*/
|
|
|
|
/*
|
|
** Work around C99 "flex-array" syntax for pre-C99 compilers, so as
|
|
** to avoid complaints from -fsanitize=strict-bounds.
|
|
*/
|
|
|
|
/*
|
|
** Macros to compute minimum and maximum of two numbers.
|
|
*/
|
|
|
|
/*
|
|
** Swap two objects of type TYPE.
|
|
*/
|
|
|
|
/*
|
|
** Check to see if this machine uses EBCDIC. (Yes, believe it or
|
|
** not, there are still machines out there that use EBCDIC.)
|
|
*/
|
|
|
|
const pwrite64 = 0
|
|
|
|
type sched_param = Tsched_param
|
|
|
|
type sqlite3_io_methods = Tsqlite3_io_methods
|
|
|
|
/*
|
|
** CAPI3REF: Standard File Control Opcodes
|
|
** KEYWORDS: {file control opcodes} {file control opcode}
|
|
**
|
|
** These integer constants are opcodes for the xFileControl method
|
|
** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
|
|
** interface.
|
|
**
|
|
** <ul>
|
|
** <li>[[SQLITE_FCNTL_LOCKSTATE]]
|
|
** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This
|
|
** opcode causes the xFileControl method to write the current state of
|
|
** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
|
|
** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
|
|
** into an integer that the pArg argument points to.
|
|
** This capability is only available if SQLite is compiled with [SQLITE_DEBUG].
|
|
**
|
|
** <li>[[SQLITE_FCNTL_SIZE_HINT]]
|
|
** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
|
|
** layer a hint of how large the database file will grow to be during the
|
|
** current transaction. This hint is not guaranteed to be accurate but it
|
|
** is often close. The underlying VFS might choose to preallocate database
|
|
** file space based on this hint in order to help writes to the database
|
|
** file run faster.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_SIZE_LIMIT]]
|
|
** The [SQLITE_FCNTL_SIZE_LIMIT] opcode is used by in-memory VFS that
|
|
** implements [sqlite3_deserialize()] to set an upper bound on the size
|
|
** of the in-memory database. The argument is a pointer to a [sqlite3_int64].
|
|
** If the integer pointed to is negative, then it is filled in with the
|
|
** current limit. Otherwise the limit is set to the larger of the value
|
|
** of the integer pointed to and the current database size. The integer
|
|
** pointed to is set to the new limit.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_CHUNK_SIZE]]
|
|
** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS
|
|
** extends and truncates the database file in chunks of a size specified
|
|
** by the user. The fourth argument to [sqlite3_file_control()] should
|
|
** point to an integer (type int) containing the new chunk-size to use
|
|
** for the nominated database. Allocating database file space in large
|
|
** chunks (say 1MB at a time), may reduce file-system fragmentation and
|
|
** improve performance on some systems.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_FILE_POINTER]]
|
|
** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer
|
|
** to the [sqlite3_file] object associated with a particular database
|
|
** connection. See also [SQLITE_FCNTL_JOURNAL_POINTER].
|
|
**
|
|
** <li>[[SQLITE_FCNTL_JOURNAL_POINTER]]
|
|
** The [SQLITE_FCNTL_JOURNAL_POINTER] opcode is used to obtain a pointer
|
|
** to the [sqlite3_file] object associated with the journal file (either
|
|
** the [rollback journal] or the [write-ahead log]) for a particular database
|
|
** connection. See also [SQLITE_FCNTL_FILE_POINTER].
|
|
**
|
|
** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]
|
|
** The SQLITE_FCNTL_SYNC_OMITTED file-control is no longer used.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_SYNC]]
|
|
** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and
|
|
** sent to the VFS immediately before the xSync method is invoked on a
|
|
** database file descriptor. Or, if the xSync method is not invoked
|
|
** because the user has configured SQLite with
|
|
** [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place
|
|
** of the xSync method. In most cases, the pointer argument passed with
|
|
** this file-control is NULL. However, if the database file is being synced
|
|
** as part of a multi-database commit, the argument points to a nul-terminated
|
|
** string containing the transactions super-journal file name. VFSes that
|
|
** do not need this signal should silently ignore this opcode. Applications
|
|
** should not call [sqlite3_file_control()] with this opcode as doing so may
|
|
** disrupt the operation of the specialized VFSes that do require it.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_COMMIT_PHASETWO]]
|
|
** The [SQLITE_FCNTL_COMMIT_PHASETWO] opcode is generated internally by SQLite
|
|
** and sent to the VFS after a transaction has been committed immediately
|
|
** but before the database is unlocked. VFSes that do not need this signal
|
|
** should silently ignore this opcode. Applications should not call
|
|
** [sqlite3_file_control()] with this opcode as doing so may disrupt the
|
|
** operation of the specialized VFSes that do require it.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_WIN32_AV_RETRY]]
|
|
** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic
|
|
** retry counts and intervals for certain disk I/O operations for the
|
|
** windows [VFS] in order to provide robustness in the presence of
|
|
** anti-virus programs. By default, the windows VFS will retry file read,
|
|
** file write, and file delete operations up to 10 times, with a delay
|
|
** of 25 milliseconds before the first retry and with the delay increasing
|
|
** by an additional 25 milliseconds with each subsequent retry. This
|
|
** opcode allows these two values (10 retries and 25 milliseconds of delay)
|
|
** to be adjusted. The values are changed for all database connections
|
|
** within the same process. The argument is a pointer to an array of two
|
|
** integers where the first integer is the new retry count and the second
|
|
** integer is the delay. If either integer is negative, then the setting
|
|
** is not changed but instead the prior value of that setting is written
|
|
** into the array entry, allowing the current retry settings to be
|
|
** interrogated. The zDbName parameter is ignored.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_PERSIST_WAL]]
|
|
** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the
|
|
** persistent [WAL | Write Ahead Log] setting. By default, the auxiliary
|
|
** write ahead log ([WAL file]) and shared memory
|
|
** files used for transaction control
|
|
** are automatically deleted when the latest connection to the database
|
|
** closes. Setting persistent WAL mode causes those files to persist after
|
|
** close. Persisting the files is useful when other processes that do not
|
|
** have write permission on the directory containing the database file want
|
|
** to read the database file, as the WAL and shared memory files must exist
|
|
** in order for the database to be readable. The fourth parameter to
|
|
** [sqlite3_file_control()] for this opcode should be a pointer to an integer.
|
|
** That integer is 0 to disable persistent WAL mode or 1 to enable persistent
|
|
** WAL mode. If the integer is -1, then it is overwritten with the current
|
|
** WAL persistence setting.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_POWERSAFE_OVERWRITE]]
|
|
** ^The [SQLITE_FCNTL_POWERSAFE_OVERWRITE] opcode is used to set or query the
|
|
** persistent "powersafe-overwrite" or "PSOW" setting. The PSOW setting
|
|
** determines the [SQLITE_IOCAP_POWERSAFE_OVERWRITE] bit of the
|
|
** xDeviceCharacteristics methods. The fourth parameter to
|
|
** [sqlite3_file_control()] for this opcode should be a pointer to an integer.
|
|
** That integer is 0 to disable zero-damage mode or 1 to enable zero-damage
|
|
** mode. If the integer is -1, then it is overwritten with the current
|
|
** zero-damage mode setting.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_OVERWRITE]]
|
|
** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening
|
|
** a write transaction to indicate that, unless it is rolled back for some
|
|
** reason, the entire database file will be overwritten by the current
|
|
** transaction. This is used by VACUUM operations.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_VFSNAME]]
|
|
** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of
|
|
** all [VFSes] in the VFS stack. The names of all VFS shims and the
|
|
** final bottom-level VFS are written into memory obtained from
|
|
** [sqlite3_malloc()] and the result is stored in the char* variable
|
|
** that the fourth parameter of [sqlite3_file_control()] points to.
|
|
** The caller is responsible for freeing the memory when done. As with
|
|
** all file-control actions, there is no guarantee that this will actually
|
|
** do anything. Callers should initialize the char* variable to a NULL
|
|
** pointer in case this file-control is not implemented. This file-control
|
|
** is intended for diagnostic use only.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_VFS_POINTER]]
|
|
** ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level
|
|
** [VFSes] currently in use. ^(The argument X in
|
|
** sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be
|
|
** of type "[sqlite3_vfs] **". This opcode will set *X
|
|
** to a pointer to the top-level VFS.)^
|
|
** ^When there are multiple VFS shims in the stack, this opcode finds the
|
|
** upper-most shim only.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_PRAGMA]]
|
|
** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA]
|
|
** file control is sent to the open [sqlite3_file] object corresponding
|
|
** to the database file to which the pragma statement refers. ^The argument
|
|
** to the [SQLITE_FCNTL_PRAGMA] file control is an array of
|
|
** pointers to strings (char**) in which the 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. ^The handler for an
|
|
** [SQLITE_FCNTL_PRAGMA] file control can optionally make the first element
|
|
** of the char** 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. ^If the
|
|
** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal
|
|
** [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA]
|
|
** file control returns [SQLITE_OK], then the parser assumes that the
|
|
** VFS has handled the PRAGMA itself and the parser generates a no-op
|
|
** prepared statement if result string is NULL, or that returns a copy
|
|
** of the result string if the string is non-NULL.
|
|
** ^If the [SQLITE_FCNTL_PRAGMA] file control returns
|
|
** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means
|
|
** that the VFS encountered an error while handling the [PRAGMA] and the
|
|
** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA]
|
|
** file control occurs at the beginning of pragma statement analysis and so
|
|
** it is able to override built-in [PRAGMA] statements.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_BUSYHANDLER]]
|
|
** ^The [SQLITE_FCNTL_BUSYHANDLER]
|
|
** file-control may be invoked by SQLite on the database file handle
|
|
** shortly after it is opened in order to provide a custom VFS with access
|
|
** to the connection's busy-handler callback. The argument is of type (void**)
|
|
** - an array of two (void *) values. The first (void *) actually points
|
|
** to a function of type (int (*)(void *)). In order to invoke the connection's
|
|
** busy-handler, this function should be invoked with the second (void *) in
|
|
** the array as the only argument. If it returns non-zero, then the operation
|
|
** should be retried. If it returns zero, the custom VFS should abandon the
|
|
** current operation.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_TEMPFILENAME]]
|
|
** ^Applications can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control
|
|
** to have SQLite generate a
|
|
** temporary filename using the same algorithm that is followed to generate
|
|
** temporary filenames for TEMP tables and other internal uses. The
|
|
** argument should be a char** which will be filled with the filename
|
|
** written into memory obtained from [sqlite3_malloc()]. The caller should
|
|
** invoke [sqlite3_free()] on the result to avoid a memory leak.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_MMAP_SIZE]]
|
|
** The [SQLITE_FCNTL_MMAP_SIZE] file control is used to query or set the
|
|
** maximum number of bytes that will be used for memory-mapped I/O.
|
|
** The argument is a pointer to a value of type sqlite3_int64 that
|
|
** is an advisory maximum number of bytes in the file to memory map. The
|
|
** pointer is overwritten with the old value. The limit is not changed if
|
|
** the value originally pointed to is negative, and so the current limit
|
|
** can be queried by passing in a pointer to a negative number. This
|
|
** file-control is used internally to implement [PRAGMA mmap_size].
|
|
**
|
|
** <li>[[SQLITE_FCNTL_TRACE]]
|
|
** The [SQLITE_FCNTL_TRACE] file control provides advisory information
|
|
** to the VFS about what the higher layers of the SQLite stack are doing.
|
|
** This file control is used by some VFS activity tracing [shims].
|
|
** The argument is a zero-terminated string. Higher layers in the
|
|
** SQLite stack may generate instances of this file control if
|
|
** the [SQLITE_USE_FCNTL_TRACE] compile-time option is enabled.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_HAS_MOVED]]
|
|
** The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a
|
|
** pointer to an integer and it writes a boolean into that integer depending
|
|
** on whether or not the file has been renamed, moved, or deleted since it
|
|
** was first opened.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_WIN32_GET_HANDLE]]
|
|
** The [SQLITE_FCNTL_WIN32_GET_HANDLE] opcode can be used to obtain the
|
|
** underlying native file handle associated with a file handle. This file
|
|
** control interprets its argument as a pointer to a native file handle and
|
|
** writes the resulting value there.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]]
|
|
** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This
|
|
** opcode causes the xFileControl method to swap the file handle with the one
|
|
** pointed to by the pArg argument. This capability is used during testing
|
|
** and only needs to be supported when SQLITE_TEST is defined.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_NULL_IO]]
|
|
** The [SQLITE_FCNTL_NULL_IO] opcode sets the low-level file descriptor
|
|
** or file handle for the [sqlite3_file] object such that it will no longer
|
|
** read or write to the database file.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_WAL_BLOCK]]
|
|
** The [SQLITE_FCNTL_WAL_BLOCK] is a signal to the VFS layer that it might
|
|
** be advantageous to block on the next WAL lock if the lock is not immediately
|
|
** available. The WAL subsystem issues this signal during rare
|
|
** circumstances in order to fix a problem with priority inversion.
|
|
** Applications should <em>not</em> use this file-control.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_ZIPVFS]]
|
|
** The [SQLITE_FCNTL_ZIPVFS] opcode is implemented by zipvfs only. All other
|
|
** VFS should return SQLITE_NOTFOUND for this opcode.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_RBU]]
|
|
** The [SQLITE_FCNTL_RBU] opcode is implemented by the special VFS used by
|
|
** the RBU extension only. All other VFS should return SQLITE_NOTFOUND for
|
|
** this opcode.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]]
|
|
** If the [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] opcode returns SQLITE_OK, then
|
|
** the file descriptor is placed in "batch write mode", which
|
|
** means all subsequent write operations will be deferred and done
|
|
** atomically at the next [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]. Systems
|
|
** that do not support batch atomic writes will return SQLITE_NOTFOUND.
|
|
** ^Following a successful SQLITE_FCNTL_BEGIN_ATOMIC_WRITE and prior to
|
|
** the closing [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] or
|
|
** [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE], SQLite will make
|
|
** no VFS interface calls on the same [sqlite3_file] file descriptor
|
|
** except for calls to the xWrite method and the xFileControl method
|
|
** with [SQLITE_FCNTL_SIZE_HINT].
|
|
**
|
|
** <li>[[SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]]
|
|
** The [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] opcode causes all write
|
|
** operations since the previous successful call to
|
|
** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be performed atomically.
|
|
** This file control returns [SQLITE_OK] if and only if the writes were
|
|
** all performed successfully and have been committed to persistent storage.
|
|
** ^Regardless of whether or not it is successful, this file control takes
|
|
** the file descriptor out of batch write mode so that all subsequent
|
|
** write operations are independent.
|
|
** ^SQLite will never invoke SQLITE_FCNTL_COMMIT_ATOMIC_WRITE without
|
|
** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE].
|
|
**
|
|
** <li>[[SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE]]
|
|
** The [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write
|
|
** operations since the previous successful call to
|
|
** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rolled back.
|
|
** ^This file control takes the file descriptor out of batch write mode
|
|
** so that all subsequent write operations are independent.
|
|
** ^SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without
|
|
** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE].
|
|
**
|
|
** <li>[[SQLITE_FCNTL_LOCK_TIMEOUT]]
|
|
** The [SQLITE_FCNTL_LOCK_TIMEOUT] opcode is used to configure a VFS
|
|
** to block for up to M milliseconds before failing when attempting to
|
|
** obtain a file lock using the xLock or xShmLock methods of the VFS.
|
|
** The parameter is a pointer to a 32-bit signed integer that contains
|
|
** the value that M is to be set to. Before returning, the 32-bit signed
|
|
** integer is overwritten with the previous value of M.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_BLOCK_ON_CONNECT]]
|
|
** The [SQLITE_FCNTL_BLOCK_ON_CONNECT] opcode is used to configure the
|
|
** VFS to block when taking a SHARED lock to connect to a wal mode database.
|
|
** This is used to implement the functionality associated with
|
|
** SQLITE_SETLK_BLOCK_ON_CONNECT.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_DATA_VERSION]]
|
|
** The [SQLITE_FCNTL_DATA_VERSION] opcode is used to detect changes to
|
|
** a database file. The argument is a pointer to a 32-bit unsigned integer.
|
|
** The "data version" for the pager is written into the pointer. The
|
|
** "data version" changes whenever any change occurs to the corresponding
|
|
** database file, either through SQL statements on the same database
|
|
** connection or through transactions committed by separate database
|
|
** connections possibly in other processes. The [sqlite3_total_changes()]
|
|
** interface can be used to find if any database on the connection has changed,
|
|
** but that interface responds to changes on TEMP as well as MAIN and does
|
|
** not provide a mechanism to detect changes to MAIN only. Also, the
|
|
** [sqlite3_total_changes()] interface responds to internal changes only and
|
|
** omits changes made by other database connections. The
|
|
** [PRAGMA data_version] command provides a mechanism to detect changes to
|
|
** a single attached database that occur due to other database connections,
|
|
** but omits changes implemented by the database connection on which it is
|
|
** called. This file control is the only mechanism to detect changes that
|
|
** happen either internally or externally and that are associated with
|
|
** a particular attached database.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_CKPT_START]]
|
|
** The [SQLITE_FCNTL_CKPT_START] opcode is invoked from within a checkpoint
|
|
** in wal mode before the client starts to copy pages from the wal
|
|
** file to the database file.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_CKPT_DONE]]
|
|
** The [SQLITE_FCNTL_CKPT_DONE] opcode is invoked from within a checkpoint
|
|
** in wal mode after the client has finished copying pages from the wal
|
|
** file to the database file, but before the *-shm file is updated to
|
|
** record the fact that the pages have been checkpointed.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_EXTERNAL_READER]]
|
|
** The EXPERIMENTAL [SQLITE_FCNTL_EXTERNAL_READER] opcode is used to detect
|
|
** whether or not there is a database client in another process with a wal-mode
|
|
** transaction open on the database or not. It is only available on unix. The
|
|
** (void*) argument passed with this file-control should be a pointer to a
|
|
** value of type (int). The integer value is set to 1 if the database is a wal
|
|
** mode database and there exists at least one client in another process that
|
|
** currently has an SQL transaction open on the database. It is set to 0 if
|
|
** the database is not a wal-mode db, or if there is no such connection in any
|
|
** other process. This opcode cannot be used to detect transactions opened
|
|
** by clients within the current process, only within other processes.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_CKSM_FILE]]
|
|
** The [SQLITE_FCNTL_CKSM_FILE] opcode is for use internally by the
|
|
** [checksum VFS shim] only.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_RESET_CACHE]]
|
|
** If there is currently no transaction open on the database, and the
|
|
** database is not a temp db, then the [SQLITE_FCNTL_RESET_CACHE] file-control
|
|
** purges the contents of the in-memory page cache. If there is an open
|
|
** transaction, or if the db is a temp-db, this opcode is a no-op, not an error.
|
|
**
|
|
** <li>[[SQLITE_FCNTL_FILESTAT]]
|
|
** The [SQLITE_FCNTL_FILESTAT] opcode returns low-level diagnostic information
|
|
** about the [sqlite3_file] objects used access the database and journal files
|
|
** for the given schema. The fourth parameter to [sqlite3_file_control()]
|
|
** should be an initialized [sqlite3_str] pointer. JSON text describing
|
|
** various aspects of the sqlite3_file object is appended to the sqlite3_str.
|
|
** The SQLITE_FCNTL_FILESTAT opcode is usually a no-op, unless compile-time
|
|
** options are used to enable it.
|
|
** </ul>
|
|
*/
|
|
|
|
/* deprecated names */
|
|
|
|
/* reserved file-control numbers:
|
|
** 101
|
|
** 102
|
|
** 103
|
|
*/
|
|
|
|
type sqlite3_mutex = Tsqlite3_mutex
|
|
|
|
const stat64 = 0
|
|
|
|
type statx = Tstatx
|
|
|
|
type statx_timestamp = Tstatx_timestamp
|
|
|
|
type t__isoc_va_list = uintptr
|
|
|
|
type t__ptcb = struct {
|
|
F__f uintptr
|
|
F__x uintptr
|
|
F__next uintptr
|
|
}
|
|
|
|
/*
|
|
** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are
|
|
** intended for use only inside assert() statements. On some platforms,
|
|
** there might be race conditions that can cause these routines to
|
|
** deliver incorrect results. In particular, if pthread_equal() is
|
|
** not an atomic operation, then these routines might delivery
|
|
** incorrect results. On most platforms, pthread_equal() is a
|
|
** comparison of two integers and is therefore atomic. But we are
|
|
** told that HPUX is not such a platform. If so, then these routines
|
|
** will not always work correctly on HPUX.
|
|
**
|
|
** On those platforms where pthread_equal() is not atomic, SQLite
|
|
** should be compiled without -DSQLITE_DEBUG and with -DNDEBUG to
|
|
** make sure no assert() statements are evaluated and hence these
|
|
** routines are never called.
|
|
*/
|
|
|
|
type t__sigset_t = Tsigset_t
|
|
|
|
type timezone = Ttimezone
|
|
|
|
/*
|
|
** Try to determine if gethostuuid() is available based on standard
|
|
** macros. This might sometimes compute the wrong value for some
|
|
** obscure platforms. For those cases, simply compile with one of
|
|
** the following:
|
|
**
|
|
** -DHAVE_GETHOSTUUID=0
|
|
** -DHAVE_GETHOSTUUID=1
|
|
**
|
|
** None if this matters except when building on Apple products with
|
|
** -DSQLITE_ENABLE_LOCKING_STYLE.
|
|
*/
|
|
|
|
/*
|
|
** Allowed values of unixFile.fsFlags
|
|
*/
|
|
|
|
/*
|
|
** If we are to be thread-safe, include the pthreads header.
|
|
*/
|
|
/* # include <pthread.h> */
|
|
|
|
/*
|
|
** Default permissions when creating a new file
|
|
*/
|
|
|
|
/*
|
|
** Default permissions when creating auto proxy dir
|
|
*/
|
|
|
|
/*
|
|
** Maximum supported path-length.
|
|
*/
|
|
|
|
/*
|
|
** Maximum supported symbolic links
|
|
*/
|
|
|
|
/*
|
|
** Remove and stub certain info for WASI (WebAssembly System
|
|
** Interface) builds.
|
|
*/
|
|
|
|
/* Always cast the getpid() return type for compatibility with
|
|
** kernel modules in VxWorks. */
|
|
|
|
/*
|
|
** Only set the lastErrno if the error code is a real error and not
|
|
** a normal expected return code of SQLITE_BUSY or SQLITE_OK
|
|
*/
|
|
|
|
const tmpfile64 = 0
|
|
|
|
const truncate64 = 0
|
|
|
|
type uint_fast32_t = Tuint_fast32_t
|
|
|
|
/*
|
|
** The following macros are used to cast pointers to integers and
|
|
** integers to pointers. The way you do this varies from one compiler
|
|
** to the next, so we have developed the following set of #if statements
|
|
** to generate appropriate macros for a wide range of compilers.
|
|
**
|
|
** The correct "ANSI" way to do this is to use the intptr_t type.
|
|
** Unfortunately, that typedef is not available on all compilers, or
|
|
** if it is available, it requires an #include of specific headers
|
|
** that vary from one machine to the next.
|
|
**
|
|
** Ticket #3860: The llvm-gcc-4.2 compiler from Apple chokes on
|
|
** the ((void*)&((char*)0)[X]) construct. But MSVC chokes on ((void*)(X)).
|
|
** So we have to define the macros in different ways depending on the
|
|
** compiler.
|
|
*/
|
|
|
|
/*
|
|
** Macros to hint to the compiler that a function should or should not be
|
|
** inlined.
|
|
*/
|
|
|
|
/*
|
|
** Make sure that the compiler intrinsics we desire are enabled when
|
|
** compiling with an appropriate version of MSVC unless prevented by
|
|
** the SQLITE_DISABLE_INTRINSIC define.
|
|
*/
|
|
|
|
/*
|
|
** Enable SQLITE_USE_SEH by default on MSVC builds. Only omit
|
|
** SEH support if the -DSQLITE_OMIT_SEH option is given.
|
|
*/
|
|
|
|
/*
|
|
** Enable SQLITE_DIRECT_OVERFLOW_READ, unless the build explicitly
|
|
** disables it using -DSQLITE_DIRECT_OVERFLOW_READ=0
|
|
*/
|
|
/* In all other cases, enable */
|
|
|
|
/*
|
|
** The SQLITE_THREADSAFE macro must be defined as 0, 1, or 2.
|
|
** 0 means mutexes are permanently disable and the library is never
|
|
** threadsafe. 1 means the library is serialized which is the highest
|
|
** level of threadsafety. 2 means the library is multithreaded - multiple
|
|
** threads can use SQLite as long as no two threads try to use the same
|
|
** database connection at the same time.
|
|
**
|
|
** Older versions of SQLite used an optional THREADSAFE macro.
|
|
** We support that for legacy.
|
|
**
|
|
** To ensure that the correct value of "THREADSAFE" is reported when querying
|
|
** for compile-time options at runtime (e.g. "PRAGMA compile_options"), this
|
|
** logic is partially replicated in ctime.c. If it is updated here, it should
|
|
** also be updated there.
|
|
*/
|
|
|
|
/*
|
|
** Powersafe overwrite is on by default. But can be turned off using
|
|
** the -DSQLITE_POWERSAFE_OVERWRITE=0 command-line option.
|
|
*/
|
|
|
|
/*
|
|
** EVIDENCE-OF: R-25715-37072 Memory allocation statistics are enabled by
|
|
** default unless SQLite is compiled with SQLITE_DEFAULT_MEMSTATUS=0 in
|
|
** which case memory allocation statistics are disabled by default.
|
|
*/
|
|
|
|
/*
|
|
** Exactly one of the following macros must be defined in order to
|
|
** specify which memory allocation subsystem to use.
|
|
**
|
|
** SQLITE_SYSTEM_MALLOC // Use normal system malloc()
|
|
** SQLITE_WIN32_MALLOC // Use Win32 native heap API
|
|
** SQLITE_ZERO_MALLOC // Use a stub allocator that always fails
|
|
** SQLITE_MEMDEBUG // Debugging version of system malloc()
|
|
**
|
|
** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the
|
|
** assert() macro is enabled, each call into the Win32 native heap subsystem
|
|
** will cause HeapValidate to be called. If heap validation should fail, an
|
|
** assertion will be triggered.
|
|
**
|
|
** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as
|
|
** the default.
|
|
*/
|
|
|
|
/*
|
|
** If SQLITE_MALLOC_SOFT_LIMIT is not zero, then try to keep the
|
|
** sizes of memory allocations below this value where possible.
|
|
*/
|
|
|
|
/*
|
|
** We need to define _XOPEN_SOURCE as follows in order to enable
|
|
** recursive mutexes on most Unix systems and fchmod() on OpenBSD.
|
|
** But _XOPEN_SOURCE define causes problems for Mac OS X, so omit
|
|
** it.
|
|
*/
|
|
|
|
/*
|
|
** NDEBUG and SQLITE_DEBUG are opposites. It should always be true that
|
|
** defined(NDEBUG)==!defined(SQLITE_DEBUG). If this is not currently true,
|
|
** make it true by defining or undefining NDEBUG.
|
|
**
|
|
** Setting NDEBUG makes the code smaller and faster by disabling the
|
|
** assert() statements in the code. So we want the default action
|
|
** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
|
|
** is set. Thus NDEBUG becomes an opt-in rather than an opt-out
|
|
** feature.
|
|
*/
|
|
|
|
/*
|
|
** Enable SQLITE_ENABLE_EXPLAIN_COMMENTS if SQLITE_DEBUG is turned on.
|
|
*/
|
|
|
|
/*
|
|
** The testcase() macro is used to aid in coverage testing. When
|
|
** doing coverage testing, the condition inside the argument to
|
|
** testcase() must be evaluated both true and false in order to
|
|
** get full branch coverage. The testcase() macro is inserted
|
|
** to help ensure adequate test coverage in places where simple
|
|
** condition/decision coverage is inadequate. For example, testcase()
|
|
** can be used to make sure boundary values are tested. For
|
|
** bitmask tests, testcase() can be used to make sure each bit
|
|
** is significant and used at least once. On switch statements
|
|
** where multiple cases go to the same block of code, testcase()
|
|
** can insure that all cases are evaluated.
|
|
*/
|
|
|
|
/*
|
|
** The TESTONLY macro is used to enclose variable declarations or
|
|
** other bits of code that are needed to support the arguments
|
|
** within testcase() and assert() macros.
|
|
*/
|
|
|
|
/*
|
|
** Sometimes we need a small amount of code such as a variable initialization
|
|
** to setup for a later assert() statement. We do not want this code to
|
|
** appear when assert() is disabled. The following macro is therefore
|
|
** used to contain that setup code. The "VVA" acronym stands for
|
|
** "Verification, Validation, and Accreditation". In other words, the
|
|
** code within VVA_ONLY() will only run during verification processes.
|
|
*/
|
|
|
|
/*
|
|
** Disable ALWAYS() and NEVER() (make them pass-throughs) for coverage
|
|
** and mutation testing
|
|
*/
|
|
|
|
/*
|
|
** The ALWAYS and NEVER macros surround boolean expressions which
|
|
** are intended to always be true or false, respectively. Such
|
|
** expressions could be omitted from the code completely. But they
|
|
** are included in a few cases in order to enhance the resilience
|
|
** of SQLite to unexpected behavior - to make the code "self-healing"
|
|
** or "ductile" rather than being "brittle" and crashing at the first
|
|
** hint of unplanned behavior.
|
|
**
|
|
** In other words, ALWAYS and NEVER are added for defensive code.
|
|
**
|
|
** When doing coverage testing ALWAYS and NEVER are hard-coded to
|
|
** be true and false so that the unreachable code they specify will
|
|
** not be counted as untested code.
|
|
*/
|
|
|
|
/*
|
|
** Some conditionals are optimizations only. In other words, if the
|
|
** conditionals are replaced with a constant 1 (true) or 0 (false) then
|
|
** the correct answer is still obtained, though perhaps not as quickly.
|
|
**
|
|
** The following macros mark these optimizations conditionals.
|
|
*/
|
|
|
|
/*
|
|
** Some malloc failures are only possible if SQLITE_TEST_REALLOC_STRESS is
|
|
** defined. We need to defend against those failures when testing with
|
|
** SQLITE_TEST_REALLOC_STRESS, but we don't want the unreachable branches
|
|
** during a normal build. The following macro can be used to disable tests
|
|
** that are always false except when SQLITE_TEST_REALLOC_STRESS is set.
|
|
*/
|
|
|
|
/*
|
|
** Declarations used for tracing the operating system interfaces.
|
|
*/
|
|
|
|
/*
|
|
** Is the sqlite3ErrName() function needed in the build? Currently,
|
|
** it is needed by "mutex_w32.c" (when debugging), "os_win.c" (when
|
|
** OSTRACE is enabled), and by several "test*.c" files (which are
|
|
** compiled using SQLITE_TEST).
|
|
*/
|
|
|
|
/*
|
|
** SQLITE_ENABLE_EXPLAIN_COMMENTS is incompatible with SQLITE_OMIT_EXPLAIN
|
|
*/
|
|
|
|
/*
|
|
** SQLITE_OMIT_VIRTUALTABLE implies SQLITE_OMIT_ALTERTABLE
|
|
*/
|
|
|
|
/*
|
|
** Return true (non-zero) if the input is an integer that is too large
|
|
** to fit in 32-bits. This macro is used inside of various testcase()
|
|
** macros to verify that we have tested SQLite for large-file support.
|
|
*/
|
|
|
|
/*
|
|
** The macro unlikely() is a hint that surrounds a boolean
|
|
** expression that is usually false. Macro likely() surrounds
|
|
** a boolean expression that is usually true. These hints could,
|
|
** in theory, be used by the compiler to generate better code, but
|
|
** currently they are just comments for human readers.
|
|
*/
|
|
|
|
/************** Include hash.h in the middle of sqliteInt.h ******************/
|
|
/************** Begin file hash.h ********************************************/
|
|
/*
|
|
** 2001 September 22
|
|
**
|
|
** The author disclaims copyright to this source code. In place of
|
|
** a legal notice, here is a blessing:
|
|
**
|
|
** May you do good and not evil.
|
|
** May you find forgiveness for yourself and forgive others.
|
|
** May you share freely, never taking more than you give.
|
|
**
|
|
*************************************************************************
|
|
** This is the header file for the generic hash-table implementation
|
|
** used in SQLite.
|
|
*/
|