| 1 | module sqlite |
| 2 | |
| 3 | // Result represents Sqlite Result and Error Codes |
| 4 | // see https://www.sqlite.org/rescode.html |
| 5 | pub enum Result { |
| 6 | ok = 0 |
| 7 | error = 1 |
| 8 | internal = 2 |
| 9 | perm = 3 |
| 10 | abort = 4 |
| 11 | busy = 5 |
| 12 | locked = 6 |
| 13 | nomem = 7 |
| 14 | readonly = 8 |
| 15 | interrupt = 9 |
| 16 | ioerr = 10 |
| 17 | corrupt = 11 |
| 18 | notfound = 12 |
| 19 | full = 13 |
| 20 | cantopen = 14 |
| 21 | protocol = 15 |
| 22 | empty = 16 |
| 23 | schema = 17 |
| 24 | toobig = 18 |
| 25 | constraint = 19 |
| 26 | mismatch = 20 |
| 27 | misuse = 21 |
| 28 | nolfs = 22 |
| 29 | auth = 23 |
| 30 | format = 24 |
| 31 | range = 25 |
| 32 | notadb = 26 |
| 33 | notice = 27 |
| 34 | warning = 28 |
| 35 | row = 100 |
| 36 | done = 101 |
| 37 | ok_load_permanently = 256 |
| 38 | error_missing_collseq = 257 |
| 39 | busy_recovery = 261 |
| 40 | locked_sharedcache = 262 |
| 41 | readonly_recovery = 264 |
| 42 | ioerr_read = 266 |
| 43 | corrupt_vtab = 267 |
| 44 | cantopen_notempdir = 270 |
| 45 | constraint_check = 275 |
| 46 | notice_recover_wal = 283 |
| 47 | warning_autoindex = 284 |
| 48 | error_retry = 513 |
| 49 | abort_rollback = 516 |
| 50 | busy_snapshot = 517 |
| 51 | locked_vtab = 518 |
| 52 | readonly_cantlock = 520 |
| 53 | ioerr_short_read = 522 |
| 54 | corrupt_sequence = 523 |
| 55 | cantopen_isdir = 526 |
| 56 | constraint_commithook = 531 |
| 57 | notice_recover_rollback = 539 |
| 58 | error_snapshot = 769 |
| 59 | busy_timeout = 773 |
| 60 | readonly_rollback = 776 |
| 61 | ioerr_write = 778 |
| 62 | corrupt_index = 779 |
| 63 | cantopen_fullpath = 782 |
| 64 | constraint_foreignkey = 787 |
| 65 | readonly_dbmoved = 1032 |
| 66 | ioerr_fsync = 1034 |
| 67 | cantopen_convpath = 1038 |
| 68 | constraint_function = 1043 |
| 69 | readonly_cantinit = 1288 |
| 70 | ioerr_dir_fsync = 1290 |
| 71 | cantopen_dirtywal = 1294 |
| 72 | constraint_notnull = 1299 |
| 73 | readonly_directory = 1544 |
| 74 | ioerr_truncate = 1546 |
| 75 | cantopen_symlink = 1550 |
| 76 | constraint_primarykey = 1555 |
| 77 | ioerr_fstat = 1802 |
| 78 | constraint_trigger = 1811 |
| 79 | ioerr_unlock = 2058 |
| 80 | constraint_unique = 2067 |
| 81 | ioerr_rdlock = 2314 |
| 82 | constraint_vtab = 2323 |
| 83 | ioerr_delete = 2570 |
| 84 | constraint_rowid = 2579 |
| 85 | ioerr_blocked = 2826 |
| 86 | constraint_pinned = 2835 |
| 87 | ioerr_nomem = 3082 |
| 88 | ioerr_access = 3338 |
| 89 | ioerr_checkreservedlock = 3594 |
| 90 | ioerr_lock = 3850 |
| 91 | ioerr_close = 4106 |
| 92 | ioerr_dir_close = 4362 |
| 93 | ioerr_shmopen = 4618 |
| 94 | ioerr_shmsize = 4874 |
| 95 | ioerr_shmlock = 5130 |
| 96 | ioerr_shmmap = 5386 |
| 97 | ioerr_seek = 5642 |
| 98 | ioerr_delete_noent = 5898 |
| 99 | ioerr_mmap = 6154 |
| 100 | ioerr_gettemppath = 6410 |
| 101 | ioerr_convpath = 6666 |
| 102 | ioerr_vnode = 6922 |
| 103 | ioerr_auth = 7178 |
| 104 | ioerr_begin_atomic = 7434 |
| 105 | ioerr_commit_atomic = 7690 |
| 106 | ioerr_rollback_atomic = 7946 |
| 107 | ioerr_data = 8202 |
| 108 | } |
| 109 | |
| 110 | // is_error checks if it is an error code. |
| 111 | pub fn (r Result) is_error() bool { |
| 112 | return r !in [.ok, .row, .done] |
| 113 | } |
| 114 | |
| 115 | // is_error checks if `code` is an error code. |
| 116 | pub fn is_error(code int) bool { |
| 117 | return unsafe { Result(code).is_error() } |
| 118 | } |
| 119 | |