import copy
import math
from typing import Any

EDGE_INTS: list[int] = [
  -1,
  0,
  1,
  2147483646,  # INT32_MAX - 1
  2147483647,  # INT32_MAX
  2147483648,  # INT32_MAX + 1
  -2147483649,  # INT32_MIN - 1
  -2147483648,  # INT32_MIN
  -2147483647,  # INT32_MIN + 1
  9223372036854775806,  # INT64_MAX - 1
  9223372036854775807,  # INT64_MAX
  9223372036854775808,  # INT64_MAX + 1
  -9223372036854775809,  # INT64_MIN - 1
  -9223372036854775808,  # INT64_MIN
  -9223372036854775807,  # INT64_MIN + 1
  10**1024,
  -10**1024
]

EDGE_FLOATS: list[float] = [
  1.7976931348623157e+308 - 1,  # DBL_MAX - 1
  1.7976931348623157e+308,  # DBL_MAX
  1.7976931348623157e+308 + 1,  # DBL_MAX + 1
  2.2250738585072014e-308 - 1,  # DBL_MIN - 1
  2.2250738585072014e-308,  # DBL_MIN
  2.2250738585072014e-308 + 1,  # DBL_MIN + 1
  0.0,
  math.pi,
  math.e,
  math.tau,
  math.inf,
  -math.inf,
  math.nan,
]

EDGE_STRINGS: list[str] = [
  "",
  " ",
  "\n",
  "\t",
  "%",
  "\x00",
  ";",
  "(",
  ")",
  "<",
  ">",
  "-",
  "_",
  "''",
  "\"",
  "|",
  "{",
  "}",
  "@",
  "#",
  "$",
  "%",
  "^",
  "&",
  "*",
  "?",
  "+",
  "`",
  "~",
  ",",
  ".",
  "%abc%",
  "abc",
  "0",
  "0.0",
  "1e10",
  "true",
  "false",
  "NaN",
  "Inf",
  "-Inf",
  "𠜎",
  "🙂",
  "𝕊𝕢𝕝",
  "ÅÄÖËŸÏaáàưôốồỗổộơớờỡởợđ",
  "x" * 256,
  '{"a":1,"b":[1,2,3]}',
  '[1,2,3]',
  '(TRUE,FALSE,TRUE)',
]

# https://sqlite.org/lang_aggfunc.html
AGG_FUNCS = [
  "AVG", "COUNT", "MAX", "MIN", "SUM", "TOTAL", "GROUP_CONCAT", "STRING_AGG"
]

# https://sqlite.org/windowfunctions.html
WINDOW_FUNCS = [
  "ROW_NUMBER()",
  "RANK()",
  "DENSE_RANK()",
  "PERCENT_RANK()",
  "CUME_DIST()",
  "NTILE(4)",
  "NTILE(1)",
  "NTILE(0)",
  "NTILE(-1)",
  "NTILE({c})",
  "FIRST_VALUE({c})",
  "LAST_VALUE({c})",
  "NTH_VALUE({c}, 2)",
  "NTH_VALUE({c}, 1)",
  "NTH_VALUE({c}, 0)",
  "NTH_VALUE({c}, -1)",
  "NTH_VALUE({c}, {c})",
  "LAG({c})",
  "LAG({c}, 1)",
  "LAG({c}, 0)",
  "LAG({c}, 2)",
  "LAG({c}, {c})",
  "LAG({c}, 2, 'default')",
  "LAG({c}, 2, {c})",
  "LAG({c}, 0, 'default')",
  "LAG({c}, 1, NULL)",
  "LEAD({c})",
  "LEAD({c}, 1)",
  "LEAD({c}, 0)",
  "LEAD({c}, 2)",
  "LEAD({c}, {c})",
  "LEAD({c}, 2, 'default')",
  "LEAD({c}, 2, {c})",
  "LEAD({c}, 0, 'default')",
  "LEAD({c}, 1, NULL)",
  "SUM({c})",
  "AVG({c})",
  "COUNT({c})",
  "COUNT(*)",
  "MAX({c})",
  "MIN({c})",
  "GROUP_CONCAT({c})",
  "GROUP_CONCAT({c}, '.')",
  "GROUP_CONCAT({c}, {c})",
  "TOTAL({c})",
  "SUM({c}) FILTER (WHERE {c} > 0)",
  "COUNT({c}) FILTER (WHERE {c} IS NOT NULL)",
  "COUNT(*) FILTER (WHERE {c} > 0)",
  "AVG({c}) FILTER (WHERE {c} != 0)",
  "MAX({c}) FILTER (WHERE {c} IS NOT NULL)",
  "MIN({c}) FILTER (WHERE {c} IS NOT NULL)",
  "GROUP_CONCAT({c}, '.') FILTER (WHERE {c} IS NOT NULL)",
  "SUM({c}) FILTER (WHERE 1=0)",
  "COUNT({c}) FILTER (WHERE NULL)",
]

# https://www.sqlite.org/datatype3.html
TYPES = [
  "CHAR(10)", "CLOB", "ANY", 'INT', 'INTEGER', 'TINYINT', 'SMALLINT',
  'MEDIUMINT', 'BIGINT', 'UNSIGNED BIG INT', 'INT2', 'INT8', 'CHARACTER(20)',
  'VARCHAR(255)', 'NCHAR(55)', 'NATIVE CHARACTER(70)'
  'NVARCHAR(100)', 'TEXT', 'BLOB', 'REAL', 'DOUBLE', 'DOUBLE PRECISION',
  'FLOAT', 'NUMERIC', 'DECIMAL(10,5)', 'BOOLEAN', 'DATE', 'DATETIME', "FLOA",
  "DOUB", "CHARINT", "NONE"
]

COLLATIONS = ["BINARY", "NOCASE", "RTRIM"]

CMP_OPS = ['=', '<>', '<', '>', '<=', '>=', '!=', 'IS', 'IS NOT', "=="]

# https://sqlite.org/lang_datefunc.html
DATETIME_FUNCS = [
  "date({v})", "time({v})", "datetime({v})", "julianday({v})", "unixepoch({v})",
  "strftime('%Y-%m-%d', {v})", "strftime('%s', {v})", "datetime({v}, '+1 day')",
  "date({v}, 'start of month')", "timediff({v}, {v})", "timediff(NULL, {v})"
  "timediff(NULL, NULL)"
]

# https://sqlite.org/lang_corefunc.html
CORE_FUNCS = [
  "abs({v})",
  "abs(1)",
  "abs(-1)",
  "abs(0)",
  "abs(123.456)",
  "abs(NULL)",
  "abs('123')",
  "abs('abc')",
  "abs(-9223372036854775808)",
  "changes()",
  "char({v})",
  "char(65)",
  "char(65, 66, 67)",
  "char(1, 2, 3, 4, 5)",
  "char(NULL)",
  "char(65, NULL, 67)",
  "char(-1)",
  "char(0)",
  "char(1114111)",
  "coalesce({v}, {v})",
  "coalesce({v}, 'fallback')",
  "coalesce(NULL, {v})",
  "coalesce(NULL, NULL, {v})",
  "coalesce(NULL, NULL, NULL)",
  "coalesce(1, 2, 3)",
  "coalesce('a', 'b', 'c')",
  "coalesce({v}, {v}, {v}, {v}, {v})",
  "concat({v})",
  "concat({v}, {v})",
  "concat({v}, {v}, {v})",
  "concat('a', 'b', 'c')",
  "concat(NULL)",
  "concat(NULL, NULL)",
  "concat({v}, NULL, {v})",
  "concat(1, 2, 3)",
  "concat('text', 123, NULL)",
  "concat_ws('|', {v}, {v})",
  "concat_ws('|', 'a', 'b', 'c')",
  "concat_ws('|', NULL, 'a', 'b')",
  "concat_ws('|', 'a', NULL, 'b')",
  "concat_ws('|', NULL, NULL, NULL)",
  "concat_ws(NULL, 'a', 'b')",
  "concat_ws('', 'a', 'b', 'c')",
  "concat_ws({v}, {v}, {v})",
  "concat_ws(',', 1, 2, 3)",
  "format('%s', {v})",
  "format('%d', {v})",
  "format('%f', {v})",
  "format('%x', {v})",
  "format('%05d', {v})",
  "format('%.*s', 3, {v})",
  "format('%s %s', {v}, {v})",
  "format(NULL, {v})",
  "format({v}, {v})",
  "format('%s', NULL)",
  "format('%s', 'a', 'b')",
  "format('%s')",
  "glob({v}, {v})",
  "glob('*helium*', {v})",
  "glob('{v}', 'hello')",
  "glob('*', 'hello')",
  "glob('?', 'hello')",
  "glob('[0-9]', '5')",
  "glob('[!0-9]', 'a')",
  "glob(NULL, {v})",
  "glob({v}, NULL)",
  "glob(NULL, NULL)",
  "glob('**[0-9]+>)!<(K!@AD++****)))', {v})",
  "hex({v})",
  "hex('hello')",
  "hex(12345678)",
  "hex(NULL)",
  "hex(randomblob(10))",
  "hex(123.456)",
  "hex('')",
  "if(1, {v}, {v})",
  "if(0, {v}, {v})",
  "if(1, {v})",
  "if(0, {v})",
  "if(NULL, {v}, {v})",
  "if(NULL, {v})",
  "if(1, NULL, {v})",
  "if(0, {v}, NULL)",
  "if(NULL, NULL, NULL)",
  "if(0, {v}, 0, {v})",
  "if(0, {v}, 0, {v}, 0, {v})",
  "if(0, {v}, 0, {v}, {v})",
  "if(0, {v}, 0, {v}, 0, {v}, {v})",
  "if(0, {v}, 1, {v})",
  "if(0, {v}, 0, {v}, 1, {v})",
  "if(0, {v}, 1, {v}, {v})",
  "if(1, {v}, 0, {v})",
  "if(1, {v}, 0, {v}, 0, {v})",
  "if(1, {v}, 0, {v}, 0, {v}, {v})",
  "if({v}, {v}, {v})",
  "if({v}, {v})",
  "if('', {v}, {v})",
  "if(0.0, {v}, {v})",
  "if(-1, {v}, {v})",
  "if(0x0, {v}, {v})",
  "if(1, {v}, 1/0)",
  "if(0, 1/0, {v})",
  "if(0,{v},0,{v},0,{v},0,{v},0,{v},0,{v},{v})",
  "iif(1, {v}, {v})",
  "iif(0, {v}, {v})",
  "iif(NULL, {v}, {v})",
  "iif(0, {v}, 0, {v}, {v})",
  "ifnull({v}, {v})",
  "ifnull({v}, 'fallback')",
  "ifnull(NULL, {v})",
  "ifnull({v}, NULL)",
  "ifnull(NULL, NULL)",
  "ifnull(1, 2)",
  "ifnull('a', 'b')",
  "instr({v}, {v})",
  "instr('hello', 'ell')",
  "instr('hello', 'x')",
  "instr('hello', '')",
  "instr(NULL, {v})",
  "instr({v}, NULL)",
  "instr(NULL, NULL)",
  "instr('hello', 'l')",
  "instr('hello', 'lo')",
  "instr(randomblob(10), randomblob(2))",
  "last_insert_rowid()",
  "length({v})",
  "length('hello')",
  "length('你好')",
  "length(NULL)",
  "length(123)",
  "length(12.5)",
  "length(randomblob(10))",
  "length('')",
  "length('contains\0null')",
  "like('%{v}', {v})",
  "like('{v}%', {v})",
  "like('%{v}%', {v})",
  "like('_{v}_', {v})",
  "like('{v}', {v})",
  "like('%{v}%', {v}, '|')",
  "like('{v}%', {v}, '\\\\')",
  "like('%{v}', {v}, '!')",
  "like('_', {v}, '#')",
  "like('%{v}%', {v}, '%')",
  "like('_{v}%', {v}, '_')",
  "like('', {v})",
  "like({v}, '')",
  "like('', '', '')",
  "like(NULL, {v})",
  "like({v}, NULL)",
  "like(NULL, NULL)",
  "like('%{v}', {v}, NULL)",
  "like({v}, {v}, NULL)",
  "like('[0-9]{v}', {v})",
  "like('*{v}', {v})",
  "like('{v}?*', {v})",
  "like('{v}||{v}', {v})",
  "like('%UPPER%', {v})",
  "like('%lower%', {v})",
  "like('%MiXeD%', {v})",
  "likelihood({v}, 0.5)",
  "likelihood({v}, 0.0)",
  "likelihood({v}, 1.0)",
  "likelihood({v}, 0.9375)",
  "likelihood({v}, 0.0625)",
  "likelihood(1, 0.5)",
  "likelihood(NULL, 0.5)",
  "likelihood({v}, NULL)",
  "likelihood({v}, 0.5, {v})",
  "likely({v})",
  "likely(1)",
  "likely(0)",
  "likely(NULL)",
  "load_extension('/nonexistent.so')",
  "load_extension('/nonexistent.so', 'entry_point')",
  "load_extension(NULL)",
  "load_extension({v})",
  "load_extension({v}, {v})",
  "lower({v})",
  "lower('HELLO')",
  "lower('HeLLo')",
  "lower(NULL)",
  "lower(123)",
  "lower('你好')",
  "ltrim({v})",
  "ltrim({v}, 'xyz')",
  "ltrim('  hello  ')",
  "ltrim('xxxhelloxxx', 'x')",
  "ltrim(NULL, 'x')",
  "ltrim('hello', NULL)",
  "ltrim(NULL)",
  "max({v}, {v})",
  "max({v}, 1, 2, 3)",
  "max(NULL, {v})",
  "max({v}, NULL)",
  "max('a', 'b', 'c')",
  "max(1, '2', 3)",
  "max({v})",
  "max(1, 2, 3, 4, 5)",
  "min({v}, {v})",
  "min({v}, 1, 2, 3)",
  "min(NULL, {v})",
  "min({v}, NULL)",
  "min('z', 'a', 'm')",
  "min(1, '2', 3)",
  "min({v})",
  "min(1, 2, 3, 4, 5)",
  "nullif({v}, {v})",
  "nullif({v}, 'same')",
  "nullif('same', {v})",
  "nullif(NULL, {v})",
  "nullif({v}, NULL)",
  "nullif(NULL, NULL)",
  "nullif(1, 1)",
  "nullif(1, 2)",
  "nullif('a', 'A')",
  "octet_length({v})",
  "octet_length('Hello')",
  "octet_length('你好')",
  "octet_length(NULL)",
  "octet_length(randomblob(10))",
  "octet_length(123)",
  "octet_length('')",
  "printf('%s', {v})",
  "printf('%d', {v})",
  "printf('%f', {v})",
  "printf('%x', {v})",
  "printf('%05d', {v})",
  "printf('%.*s', 3, {v})",
  "printf('%s %s', {v}, {v})",
  "printf(NULL, {v})",
  "printf({v}, {v})",
  "printf('%s', NULL)",
  "quote({v})",
  "quote('simple')",
  "quote('with''quote')",
  "quote(NULL)",
  "quote(123)",
  "quote(12.5)",
  "quote(randomblob(4))",
  "quote('contains\0null')",
  "random()",
  "random() % 100",
  "randomblob(1)",
  "randomblob(16)",
  "randomblob(0)",
  "randomblob(-5)",
  "randomblob({v})",
  "replace({v}, 'a', 'b')",
  "replace({v}, '', 'x')",
  "replace({v}, 'a', '')",
  "replace({v}, 'a', NULL)",
  "replace(NULL, 'a', 'b')",
  "replace('aaa', 'a', 'bb')",
  "replace({v}, {v}, {v})",
  "round({v})",
  "round({v}, 2)",
  "round({v}, 0)",
  "round({v}, -1)",
  "round(123.456, 2)",
  "round(123.456, -2)",
  "round(NULL, 2)",
  "round('123.45', 2)",
  "rtrim({v})",
  "rtrim({v}, 'xyz')",
  "rtrim('  hello  ')",
  "rtrim('xxxhelloxxx', 'x')",
  "rtrim(NULL, 'x')",
  "rtrim('hello', NULL)",
  "rtrim(NULL)",
  "sign({v})",
  "sign(0)",
  "sign(1)",
  "sign(-1)",
  "sign(NULL)",
  "sign('10')",
  "sign('abc')",
  "sign(randomblob(1))",
  "soundex({v})",
  "soundex('Robert')",
  "soundex('Rupert')",
  "soundex(NULL)",
  "soundex('')",
  "soundex('123')",
  "sqlite_compileoption_get(0)",
  "sqlite_compileoption_get(100)",
  "sqlite_compileoption_get(NULL)",
  "sqlite_compileoption_get(-1)",
  "sqlite_compileoption_used('ENABLE_FTS3')",
  "sqlite_compileoption_used('UNKNOWN_OPTION')",
  "sqlite_compileoption_used(NULL)",
  "sqlite_compileoption_used({v})",
  "sqlite_offset({v})",
  "sqlite_offset(1)",
  "sqlite_source_id()",
  "sqlite_version()",
  "substr({v}, 1)",
  "substr({v}, 1, 3)",
  "substr({v}, -2)",
  "substr({v}, -2, 1)",
  "substr({v}, 0)",
  "substr({v}, 100)",
  "substr({v}, 1, -1)",
  "substr(NULL, 1, 1)",
  "substr('hello', 1, 100)",
  "substring({v}, 1, 2)",
  "substring({v}, 1)",
  "substr(randomblob(10), 1, 5)",
  "total_changes()",
  "trim({v})",
  "trim({v}, 'xyz')",
  "trim('  hello  ')",
  "trim('xxxhelloxxx', 'x')",
  "trim(NULL, 'x')",
  "trim('hello', NULL)",
  "trim(NULL)",
  "typeof({v})",
  "typeof(1)",
  "typeof(1.0)",
  "typeof('text')",
  "typeof(NULL)",
  "typeof(randomblob(1))",
  "unicode({v})",
  "unicode('A')",
  "unicode('你好')",
  "unicode(NULL)",
  "unicode('')",
  "unicode(123)",
  "unhex({v})",
  "unhex('48656C6C6F')",
  "unhex('48 65', ' ')",
  "unhex('4G')",
  "unhex('4')",
  "unhex(NULL)",
  "unhex({v}, ' ')",
  "unhex('4865', 'x')",
  "unistr('Hello\\u0041')",
  "unistr('Test\\u0041\\u0042')",
  "unistr('\\\\')",
  "unistr(NULL)",
  "unistr('Invalid\\uGGGG')",
  "unistr('Short\\u123')",
  "unistr({v})",
  "unistr_quote({v})",
  "unistr_quote('Hello')",
  "unistr_quote('Control\\x01')",
  "unistr_quote(NULL)",
  "unlikely({v})",
  "unlikely(1)",
  "unlikely(0)",
  "unlikely(NULL)",
  "upper({v})",
  "upper('hello')",
  "upper('HeLLo')",
  "upper(NULL)",
  "upper(123)",
  "upper('你好')",
  "zeroblob(10)",
  "zeroblob(0)",
  "zeroblob(-1)",
  "zeroblob({v})",
  "zeroblob(1000000)",
]

# https://sqlite.org/lang_mathfunc.html
MATH_FUNCS = [
  "abs({v})",
  "round({v})",
  "round({v}, 2)",
  "ceil({v})",
  "ceiling({v})",
  "floor({v})",
  "sqrt({v})",
  "exp({v})",
  "ln({v})",
  "log({v})",
  "log10({v})",
  "log2({v})",
  "sign({v})",
  "trunc({v})",
  "sin({v})",
  "cos({v})",
  "tan({v})",
  "asin({v})",
  "acos({v})",
  "atan({v})",
  "acosh({v})",
  "asinh({v})",
  "atanh({v})",
  "cosh({v})",
  "sinh({v})",
  "tanh({v})",
  "atan2({v}, {v})",
  "log({v}, {v})",
  "mod({v}, {v})",
  "pow({v}, {v})",
  "power({v}, {v})",
  "degrees({v})",
  "radians({v})",
  "pi()",
]

# https://sqlite.org/json1.html
JSON_VALUE_FUNCS = [
  "json({v})",
  "jsonb({v})",
  "json_valid({v})",
  "json_valid({v}, 1)",
  "json_valid({v}, 2)",
  "json_valid({v}, 4)",
  "json_valid({v}, 6)",
  "json_valid({v}, 8)",
  "json_error_position({v})",
  "json_pretty({v})",
  "json_pretty({v}, '  ')",
  "json_array()",
  "json_array({v})",
  "json_array({v}, {v})",
  "json_array({v}, NULL, {v})",
  "jsonb_array()",
  "jsonb_array({v})",
  "jsonb_array({v}, {v}, NULL)",
  "json_object()",
  "json_object('k', {v})",
  "json_object('k1', {v}, 'k2', {v})",
  "json_object('k', json({v}))",
  "jsonb_object()",
  "jsonb_object('k', {v})",
  "jsonb_object('k1', {v}, 'k2', {v})",
  "json_extract({v}, '$')",
  "json_extract({v}, '$.key')",
  "json_extract({v}, '$[0]')",
  "json_extract({v}, '$.key', '$[0]')",
  "json_extract({v}, '$[#-1]')",
  "jsonb_extract({v}, '$')",
  "jsonb_extract({v}, '$.key')",
  "{v} -> '$'",
  "{v} -> '$.key'",
  "{v} -> '$[0]'",
  "{v} -> 'key'",
  "{v} -> 0",
  "{v} ->> '$'",
  "{v} ->> '$.key'",
  "{v} ->> '$[0]'",
  "{v} ->> 'key'",
  "{v} ->> 0",
  "{v} -> '$.a' -> '$.b'",
  "{v} -> '$.a' ->> 'b'",
  "json_insert({v}, '$.key', {v})",
  "json_insert({v}, '$[0]', {v})",
  "json_insert({v}, '$[#]', {v})",
  "json_replace({v}, '$.key', {v})",
  "json_set({v}, '$.key', {v})",
  "json_set({v}, '$.new_key', {v})",
  "jsonb_insert({v}, '$.key', {v})",
  "jsonb_replace({v}, '$.key', {v})",
  "jsonb_set({v}, '$.key', {v})",
  "json_array_insert({v}, '$[0]', {v})",
  "json_array_insert({v}, '$.arr[0]', {v})",
  "jsonb_array_insert({v}, '$[0]', {v})",
  "json_remove({v})",
  "json_remove({v}, '$.key')",
  "json_remove({v}, '$[0]')",
  "json_remove({v}, '$.key', '$[0]')",
  "json_remove({v}, '$')",
  "jsonb_remove({v}, '$.key')",
  "json_patch({v}, {v})",
  "json_patch({v}, '{\"key\": null}')",
  "jsonb_patch({v}, {v})",
  "json_type({v})",
  "json_type({v}, '$')",
  "json_type({v}, '$.key')",
  "json_type({v}, '$[0]')",
  "json_array_length({v})",
  "json_array_length({v}, '$')",
  "json_array_length({v}, '$.arr')",
  "json_array_length({v}, '$.nonexistent')",
  "json_quote({v})",
  "json_quote({v})",
  "json_quote('string')",
  "json_quote(123)",
  "json_group_array({v})",
  "jsonb_group_array({v})",
  "json_group_object('k', {v})",
  "jsonb_group_object('k', {v})",
  "json_each({v})",
  "json_each({v}, '$.arr')",
  "jsonb_each({v})",
  "jsonb_each({v}, '$.arr')",
  "json_tree({v})",
  "json_tree({v}, '$.obj')",
  "jsonb_tree({v})",
  "jsonb_tree({v}, '$.obj')",
]

PRAGMAS = [
  'PRAGMA analysis_limit;',
  'PRAGMA analysis_limit = 50;',
  'PRAGMA application_id;',
  'PRAGMA application_id = 12345;',
  'PRAGMA auto_vacuum;',
  'PRAGMA auto_vacuum = 0;',
  'PRAGMA auto_vacuum = NONE;',
  'PRAGMA auto_vacuum = 1;',
  'PRAGMA auto_vacuum = FULL;',
  'PRAGMA auto_vacuum = 2;',
  'PRAGMA auto_vacuum = INCREMENTAL;',
  'PRAGMA automatic_index;',
  'PRAGMA automatic_index = 1;',
  'PRAGMA automatic_index = YES;',
  'PRAGMA automatic_index = TRUE;',
  'PRAGMA automatic_index = ON;',
  'PRAGMA automatic_index = 0;',
  'PRAGMA automatic_index = NO;',
  'PRAGMA automatic_index = FALSE;',
  'PRAGMA automatic_index = OFF;',
  'PRAGMA busy_timeout;',
  'PRAGMA busy_timeout = 5000;',
  'PRAGMA cache_size;',
  'PRAGMA cache_size = -2000;',
  'PRAGMA cache_spill;',
  'PRAGMA cache_spill = 1;',
  'PRAGMA cache_spill = YES;',
  'PRAGMA cache_spill = TRUE;',
  'PRAGMA cache_spill = ON;',
  'PRAGMA cache_spill = 0;',
  'PRAGMA cache_spill = NO;',
  'PRAGMA cache_spill = FALSE;',
  'PRAGMA cache_spill = OFF;',
  'PRAGMA cache_spill = 1234;',
  'PRAGMA case_sensitive_like = 1;',
  'PRAGMA case_sensitive_like = YES;',
  'PRAGMA case_sensitive_like = TRUE;',
  'PRAGMA case_sensitive_like = ON;',
  'PRAGMA case_sensitive_like = 0;',
  'PRAGMA case_sensitive_like = NO;',
  'PRAGMA case_sensitive_like = FALSE;',
  'PRAGMA case_sensitive_like = OFF;',
  'PRAGMA cell_size_check;',
  'PRAGMA cell_size_check = 1;',
  'PRAGMA cell_size_check = YES;',
  'PRAGMA cell_size_check = TRUE;',
  'PRAGMA cell_size_check = ON;',
  'PRAGMA cell_size_check = 0;',
  'PRAGMA cell_size_check = NO;',
  'PRAGMA cell_size_check = FALSE;',
  'PRAGMA cell_size_check = OFF;',
  'PRAGMA checkpoint_fullsync;',
  'PRAGMA checkpoint_fullsync = 1;',
  'PRAGMA checkpoint_fullsync = YES;',
  'PRAGMA checkpoint_fullsync = TRUE;',
  'PRAGMA checkpoint_fullsync = ON;',
  'PRAGMA checkpoint_fullsync = 0;',
  'PRAGMA checkpoint_fullsync = NO;',
  'PRAGMA checkpoint_fullsync = FALSE;',
  'PRAGMA checkpoint_fullsync = OFF;',
  'PRAGMA collation_list;',
  'PRAGMA compile_options;',
  'PRAGMA count_changes;',
  'PRAGMA count_changes = 1;',
  'PRAGMA count_changes = YES;',
  'PRAGMA count_changes = TRUE;',
  'PRAGMA count_changes = ON;',
  'PRAGMA count_changes = 0;',
  'PRAGMA count_changes = NO;',
  'PRAGMA count_changes = FALSE;',
  'PRAGMA count_changes = OFF;',
  'PRAGMA data_store_directory = "/tmp";',
  'PRAGMA data_version;',
  'PRAGMA database_list;',
  'PRAGMA default_cache_size = -1000;',
  'PRAGMA defer_foreign_keys;',
  'PRAGMA defer_foreign_keys = 1;',
  'PRAGMA defer_foreign_keys = YES;',
  'PRAGMA defer_foreign_keys = TRUE;',
  'PRAGMA defer_foreign_keys = ON;',
  'PRAGMA defer_foreign_keys = 0;',
  'PRAGMA defer_foreign_keys = NO;',
  'PRAGMA defer_foreign_keys = FALSE;',
  'PRAGMA defer_foreign_keys = OFF;',
  'PRAGMA empty_result_callbacks;',
  'PRAGMA empty_result_callbacks = 1;',
  'PRAGMA empty_result_callbacks = YES;',
  'PRAGMA empty_result_callbacks = TRUE;',
  'PRAGMA empty_result_callbacks = ON;',
  'PRAGMA empty_result_callbacks = 0;',
  'PRAGMA empty_result_callbacks = NO;',
  'PRAGMA empty_result_callbacks = FALSE;',
  'PRAGMA empty_result_callbacks = OFF;',
  'PRAGMA encoding;',
  "PRAGMA encoding = 'UTF-8';",
  "PRAGMA encoding = 'UTF-16';",
  "PRAGMA encoding = 'UTF-16le';",
  "PRAGMA encoding = 'UTF-16be';",
  'PRAGMA foreign_key_check;',
  'PRAGMA foreign_key_check("users");',
  'PRAGMA foreign_key_list(users);',
  'PRAGMA foreign_keys;',
  'PRAGMA foreign_keys = 1;',
  'PRAGMA foreign_keys = YES;',
  'PRAGMA foreign_keys = TRUE;',
  'PRAGMA foreign_keys = ON;',
  'PRAGMA foreign_keys = 0;',
  'PRAGMA foreign_keys = NO;',
  'PRAGMA foreign_keys = FALSE;',
  'PRAGMA foreign_keys = OFF;',
  'PRAGMA freelist_count;',
  'PRAGMA full_column_names;',
  'PRAGMA full_column_names = 1;',
  'PRAGMA full_column_names = YES;',
  'PRAGMA full_column_names = TRUE;',
  'PRAGMA full_column_names = ON;',
  'PRAGMA full_column_names = 0;',
  'PRAGMA full_column_names = NO;',
  'PRAGMA full_column_names = FALSE;',
  'PRAGMA full_column_names = OFF;',
  'PRAGMA fullfsync;',
  'PRAGMA fullsync = 1;',
  'PRAGMA fullsync = YES;',
  'PRAGMA fullsync = TRUE;',
  'PRAGMA fullsync = ON;',
  'PRAGMA fullsync = 0;',
  'PRAGMA fullsync = NO;',
  'PRAGMA fullsync = FALSE;',
  'PRAGMA fullsync = OFF;',
  'PRAGMA function_list;',
  'PRAGMA hard_heap_limit = 50000000;',
  'PRAGMA ignore_check_constraints = 1;',
  'PRAGMA ignore_check_constraints = YES;',
  'PRAGMA ignore_check_constraints = TRUE;',
  'PRAGMA ignore_check_constraints = ON;',
  'PRAGMA ignore_check_constraints = 0;',
  'PRAGMA ignore_check_constraints = NO;',
  'PRAGMA ignore_check_constraints = FALSE;',
  'PRAGMA ignore_check_constraints = OFF;',
  'PRAGMA incremental_vacuum;',
  'PRAGMA incremental_vacuum(100);',
  'PRAGMA index_info(idx1);',
  'PRAGMA index_list(users);',
  'PRAGMA index_xinfo(idx1);',
  'PRAGMA integrity_check;',
  'PRAGMA integrity_check(50);',
  'PRAGMA integrity_check("users");',
  'PRAGMA journal_mode;',
  "PRAGMA journal_mode = 'DELETE';",
  "PRAGMA journal_mode = 'TRUNCATE';",
  "PRAGMA journal_mode = 'PERSIST';",
  "PRAGMA journal_mode = 'MEMORY';",
  "PRAGMA journal_mode = 'WAL';",
  "PRAGMA journal_mode = 'OFF';",
  'PRAGMA journal_size_limit;',
  'PRAGMA journal_size_limit = 1000000;',
  'PRAGMA legacy_alter_table;',
  'PRAGMA legacy_alter_table = 1;',
  'PRAGMA legacy_alter_table = YES;',
  'PRAGMA legacy_alter_table = TRUE;',
  'PRAGMA legacy_alter_table = ON;',
  'PRAGMA legacy_alter_table = 0;',
  'PRAGMA legacy_alter_table = NO;',
  'PRAGMA legacy_alter_table = FALSE;',
  'PRAGMA legacy_alter_table = OFF;',
  'PRAGMA legacy_file_format;',
  'PRAGMA locking_mode;',
  "PRAGMA locking_mode = 'NORMAL';",
  "PRAGMA locking_mode = 'EXCLUSIVE';",
  'PRAGMA max_page_count;',
  'PRAGMA max_page_count = 5000000;',
  'PRAGMA mmap_size;',
  'PRAGMA mmap_size = 50000000;',
  'PRAGMA module_list;',
  'PRAGMA optimize;',
  'PRAGMA optimize(0x00002);',
  'PRAGMA page_count;',
  'PRAGMA page_size;',
  'PRAGMA page_size = 4096;',
  'PRAGMA parser_trace = 1;',
  'PRAGMA parser_trace = YES;',
  'PRAGMA parser_trace = TRUE;',
  'PRAGMA parser_trace = ON;',
  'PRAGMA parser_trace = 0;',
  'PRAGMA parser_trace = NO;',
  'PRAGMA parser_trace = FALSE;',
  'PRAGMA parser_trace = OFF;',
  'PRAGMA pragma_list;',
  'PRAGMA query_only;',
  'PRAGMA query_only = 1;',
  'PRAGMA query_only = YES;',
  'PRAGMA query_only = TRUE;',
  'PRAGMA query_only = ON;',
  'PRAGMA query_only = 0;',
  'PRAGMA query_only = NO;',
  'PRAGMA query_only = FALSE;',
  'PRAGMA query_only = OFF;',
  'PRAGMA quick_check;',
  'PRAGMA quick_check(20);',
  'PRAGMA quick_check("users");',
  'PRAGMA read_uncommitted;',
  'PRAGMA read_uncommitted = 1;',
  'PRAGMA read_uncommitted = YES;',
  'PRAGMA read_uncommitted = TRUE;',
  'PRAGMA read_uncommitted = ON;',
  'PRAGMA read_uncommitted = 0;',
  'PRAGMA read_uncommitted = NO;',
  'PRAGMA read_uncommitted = FALSE;',
  'PRAGMA read_uncommitted = OFF;',
  'PRAGMA recursive_triggers;',
  'PRAGMA recursive_triggers = 1;',
  'PRAGMA recursive_triggers = YES;',
  'PRAGMA recursive_triggers = TRUE;',
  'PRAGMA recursive_triggers = ON;',
  'PRAGMA recursive_triggers = 0;',
  'PRAGMA recursive_triggers = NO;',
  'PRAGMA recursive_triggers = FALSE;',
  'PRAGMA recursive_triggers = OFF;',
  'PRAGMA reverse_unordered_selects;',
  'PRAGMA reverse_unordered_selects = 1;',
  'PRAGMA reverse_unordered_selects = YES;',
  'PRAGMA reverse_unordered_selects = TRUE;',
  'PRAGMA reverse_unordered_selects = ON;',
  'PRAGMA reverse_unordered_selects = 0;',
  'PRAGMA reverse_unordered_selects = NO;',
  'PRAGMA reverse_unordered_selects = FALSE;',
  'PRAGMA reverse_unordered_selects = OFF;',
  'PRAGMA schema_version;',
  'PRAGMA schema_version = 5;',
  'PRAGMA secure_delete;',
  "PRAGMA secure_delete = 'FAST';",
  'PRAGMA secure_delete = 1;',
  'PRAGMA secure_delete = YES;',
  'PRAGMA secure_delete = TRUE;',
  'PRAGMA secure_delete = ON;',
  'PRAGMA secure_delete = 0;',
  'PRAGMA secure_delete = NO;',
  'PRAGMA secure_delete = FALSE;',
  'PRAGMA secure_delete = OFF;',
  'PRAGMA short_column_names;',
  'PRAGMA short_column_names = 1;',
  'PRAGMA short_column_names = YES;',
  'PRAGMA short_column_names = TRUE;',
  'PRAGMA short_column_names = ON;',
  'PRAGMA short_column_names = 0;',
  'PRAGMA short_column_names = NO;',
  'PRAGMA short_column_names = FALSE;',
  'PRAGMA short_column_names = OFF;',
  'PRAGMA shrink_memory;',
  'PRAGMA soft_heap_limit = 10000000;',
  'PRAGMA stats;',
  'PRAGMA synchronous;',
  "PRAGMA synchronous = '0';",
  "PRAGMA synchronous = 'OFF';",
  "PRAGMA synchronous = '1';",
  "PRAGMA synchronous = 'NORMAL';",
  "PRAGMA synchronous = '2';",
  "PRAGMA synchronous = 'FULL';",
  "PRAGMA synchronous = '3';",
  "PRAGMA synchronous = 'EXTRA';",
  'PRAGMA table_info(users);',
  'PRAGMA table_list;',
  'PRAGMA table_list("users");',
  'PRAGMA table_xinfo(users);',
  'PRAGMA temp_store;',
  "PRAGMA temp_store = '0';",
  "PRAGMA temp_store = 'DEFAULT';",
  "PRAGMA temp_store = '1';",
  "PRAGMA temp_store = 'FILE';",
  "PRAGMA temp_store = '2';",
  "PRAGMA temp_store = 'MEMORY';",
  'PRAGMA temp_store_directory;',
  'PRAGMA temp_store_directory = "/tmp";',
  'PRAGMA threads;',
  'PRAGMA threads = 2;',
  'PRAGMA trusted_schema;',
  'PRAGMA trusted_schema = 1;',
  'PRAGMA trusted_schema = YES;',
  'PRAGMA trusted_schema = TRUE;',
  'PRAGMA trusted_schema = ON;',
  'PRAGMA trusted_schema = 0;',
  'PRAGMA trusted_schema = NO;',
  'PRAGMA trusted_schema = FALSE;',
  'PRAGMA trusted_schema = OFF;',
  'PRAGMA user_version;',
  'PRAGMA user_version = 999;',
  'PRAGMA vdbe_addoptrace = 1;',
  'PRAGMA vdbe_addoptrace = YES;',
  'PRAGMA vdbe_addoptrace = TRUE;',
  'PRAGMA vdbe_addoptrace = ON;',
  'PRAGMA vdbe_addoptrace = 0;',
  'PRAGMA vdbe_addoptrace = NO;',
  'PRAGMA vdbe_addoptrace = FALSE;',
  'PRAGMA vdbe_addoptrace = OFF;',
  'PRAGMA vdbe_debug = 1;',
  'PRAGMA vdbe_debug = YES;',
  'PRAGMA vdbe_debug = TRUE;',
  'PRAGMA vdbe_debug = ON;',
  'PRAGMA vdbe_debug = 0;',
  'PRAGMA vdbe_debug = NO;',
  'PRAGMA vdbe_debug = FALSE;',
  'PRAGMA vdbe_debug = OFF;',
  'PRAGMA vdbe_listing = 1;',
  'PRAGMA vdbe_listing = YES;',
  'PRAGMA vdbe_listing = TRUE;',
  'PRAGMA vdbe_listing = ON;',
  'PRAGMA vdbe_listing = 0;',
  'PRAGMA vdbe_listing = NO;',
  'PRAGMA vdbe_listing = FALSE;',
  'PRAGMA vdbe_listing = OFF;',
  'PRAGMA vdbe_trace = 1;',
  'PRAGMA vdbe_trace = YES;',
  'PRAGMA vdbe_trace = TRUE;',
  'PRAGMA vdbe_trace = ON;',
  'PRAGMA vdbe_trace = 0;',
  'PRAGMA vdbe_trace = NO;',
  'PRAGMA vdbe_trace = FALSE;',
  'PRAGMA vdbe_trace = OFF;',
  'PRAGMA wal_autocheckpoint;',
  'PRAGMA wal_autocheckpoint = 1000;',
  'PRAGMA wal_checkpoint;',
  "PRAGMA wal_checkpoint('PASSIVE');",
  "PRAGMA wal_checkpoint('FULL');",
  "PRAGMA wal_checkpoint('RESTART');",
  "PRAGMA wal_checkpoint('TRUNCATE');",
  "PRAGMA wal_checkpoint('NOOP');",
  'PRAGMA writable_schema = 1;',
  'PRAGMA writable_schema = YES;',
  'PRAGMA writable_schema = TRUE;',
  'PRAGMA writable_schema = ON;',
  'PRAGMA writable_schema = 0;',
  'PRAGMA writable_schema = NO;',
  'PRAGMA writable_schema = FALSE;',
  'PRAGMA writable_schema = OFF;',
  'PRAGMA writable_schema = RESET;',
]

JOINS = [
  'JOIN',
  'INNER JOIN',
  'LEFT JOIN',
  'LEFT OUTER JOIN',
  'RIGHT JOIN',
  'RIGHT OUTER JOIN',
  'FULL JOIN',
  'FULL OUTER JOIN',
  'CROSS JOIN',
  'NATURAL JOIN',
]

META_COMMANDS = [
  ".archive", ".auth", ".auth ON", ".auth OFF", ".backup",
  ".backup main output.db", ".backup main output.db", ".bail", ".bail on",
  ".bail off", ".cd", ".cd bugs", ".changes", ".changes on", ".changes off",
  ".check", ".clone", ".clone new_db", ".connection", ".connection close",
  ".databases", ".dbconfig", ".dbconfig fk on", ".dbconfig fk off",
  ".dbconfig fk 9999", ".dbinfo", ".dbinfo main", ".dump", ".dump main",
  ".dump ------------------------------------------------------------", ".echo",
  ".echo on", ".echo off", ".eqp", ".eqp on", ".eqp off", ".eqp full",
  ".eqp auto", ".excel", ".exit", ".exit -1", ".exit 9999", ".expert",
  ".explain", ".explain on", ".explain off", ".explain auto", ".filectrl",
  ".filectrl main TRUNCATE 10", ".fullschema", ".fullschema --indent 5",
  ".fullschema --indent 4", ".fullschema --indent -1", ".headers",
  ".headers on", ".headers off", """
.help
.help .archive
.help .auth
.help .backup
.help .bail
.help .cd
.help .changes
.help .check
.help .clone
.help .connection
.help .databases
.help .dbconfig
.help .dbinfo
.help .dump
.help .echo
.help .eqp
.help .excel
.help .exit
.help .expert
.help .explain
.help .filectrl
.help .fullschema
.help .headers
.help .help
.help .import
.help .imposter
.help .indexes
.help .limit
.help .lint
.help .load
.help .log
.help .mode
.help .nonce
.help .nullvalue
.help .once
.help .open
.help .output
.help .parameter
.help .print
.help .progress
.help .prompt
.help .quit
.help .read
.help .recover
.help .restore
.help .save
.help .scanstats
.help .schema
.help .separator
.help .sha3sum
.help .shell
.help .show
.help .stats
.help .system
.help .tables
.help .timeout
.help .timer
.help .trace
.help .version
.help .vfsinfo
.help .vfslist
.help .vfsname
.help .width
 """, ".import", ".import random-json.db main", ".import employee.db main",
  ".import corrupt001.db main", ".import manyblobs-512.db", ".imposter",
  ".imposter off", ".indexes", ".indexes main", ".limit", ".limit COLUMN -1",
  ".limit COLUMN 5", ".lint", ".load",
  ".load /home/test/sqlite3-src/build/rot13.so\nSELECT rot13('SMI 31/12 CHF 100000 PUTS');\n",
  ".log", ".log stderr", ".log stdout", ".log ON", ".log OFF", ".mode",
  ".nonce", ".nonce 202cc246-5d25-4977-ac39-9f1516ae7f5e", ".nullvalue",
  ".nullvalue 232327d3-536b-41de-a764-a6301986aeab", ".once", ".once log.txt",
  ".open", ".open employee.db", ".open corrupt001.db", ".open random-json.db",
  ".output", ".output blablabla.whatever", ".parameter", ".print",
  ".print https://yewtu.be/watch?v=dQw4w9WgXcQ", ".progress", ".progress 0",
  ".progress -1", ".progress 1", ".progress 2", ".progress 3", ".progress 9999",
  ".prompt",
  ".prompt 'IPA eli isopropanoli on loistava puhdistusaine joka irrataa'",
  ".quit", ".read", ".read commands.sql", ".recover", ".restore",
  ".restore emplyeee.db", ".save", ".save output.db", ".save /dev/null",
  ".scanstats", ".scanstats on", ".scanstats off", ".scanstats est", ".schema",
  ".schema @@@@@@@@@@@@@@@@",
  ".schema !@#$%^&*()qwertyuiop[]\\{}|asdfghjkl;':\"zxcvbnm,./<>?",
  ".separator", ".separator >_<", ".sha3sum", ".shell", ".shell pwd",
  ".shell echo \"please let me pass i will do anything uwu\"", ".show",
  ".stats", ".stats on", ".stats off", ".stats stmt", ".stats vmstep",
  ".system", ".system echo \"mwahaha i am root\"",
  ".system false && echo \"success\" || echo \"error code: $?\"", ".tables",
  "CREATE TABLE T(a, b, c); .tables T", ".tables non_existent_table",
  ".timeout", ".timeout -1", ".timeout 999999", ".timer", ".timer on",
  ".timer off", ".timer 192319231923", ".trace", ".version", ".vfsinfo",
  ".vfslist", ".vfsname", ".width", ".width 1 2 3", ".width -1 -2 -3"
]

FLAGS = [
  '-ascii',
  '-bail',
  '-batch',
  '-box',
  '-column',
  '-cmd "SELECT 1;"',
  '-csv',
  '-deserialize',
  '-echo',
  '-init employee.db',
  '-header',
  '-noheader',
  '-help',
  '-html',
  '-interactive',
  '-json',
  '-line',
  '-list',
  '-lookaside 1024 5',
  '-markdown',
  '-maxsize 5',
  '-memtrace',
  '-mmap 5',
  '-newline "\n\n"',
  '-nofollow',
  '-nonce "n0Nc3"',
  '-nullvalue "NU11"',
  '-pagecache 1024 5',
  '-quote',
  '-readonly',
  '-safe',
  '-separator ","',
  '-stats',
  '-table',
  '-tabs',
  '-version',
  '-vfs unix',
  '-vfs apndvfs',
  '-vfs memdb',
  '-vfs unix-excl',
  '-vfs unix-dotfile',
  '-vfs unix-none',
]

VALUES: list[Any] = copy.deepcopy(EDGE_INTS)
VALUES.extend(EDGE_FLOATS)
VALUES.extend(EDGE_STRINGS)
VALUES.extend(AGG_FUNCS)
VALUES.extend(WINDOW_FUNCS)
VALUES.extend(TYPES)
VALUES.extend(COLLATIONS)
VALUES.extend(CMP_OPS)
VALUES.extend(DATETIME_FUNCS)
VALUES.extend(CORE_FUNCS)
VALUES.extend(MATH_FUNCS)
VALUES.extend(JSON_VALUE_FUNCS)
VALUES.extend(PRAGMAS)
VALUES.extend(META_COMMANDS)
VALUES.extend(JOINS)
VALUES.extend(FLAGS)
