|
| 1 | +" SQL auto uppercase |
| 2 | +" Maintainer: Jorengarenar <https://joren.ga> |
| 3 | +" License: MIT |
| 4 | + |
| 5 | +" List from: https://www.drupal.org/docs/develop/coding-standards/list-of-sql-reserved-words |
| 6 | +let s:keywords = [ |
| 7 | + \ "a", "abort", "abs", "absolute", "access", "action", "ada", "add", |
| 8 | + \ "admin", "after", "aggregate", "alias", "all", "allocate", "also", |
| 9 | + \ "alter", "always", "analyse", "analyze", "and", "any", "are", "array", |
| 10 | + \ "as", "asc", "asensitive", "assertion", "assignment", "asymmetric", |
| 11 | + \ "at", "atomic", "attribute", "attributes", "audit", "authorization", |
| 12 | + \ "auto_increment", "avg", "avg_row_length", "backup", "backward", |
| 13 | + \ "before", "begin", "bernoulli", "between", "bigint", "binary", "bit", |
| 14 | + \ "bit_length", "bitvar", "blob", "bool", "boolean", "both", "breadth", |
| 15 | + \ "break", "browse", "bulk", "by", "c", "cache", "call", "called", |
| 16 | + \ "cardinality", "cascade", "cascaded", "case", "cast", "catalog", |
| 17 | + \ "catalog_name", "ceil", "ceiling", "chain", "change", "char", |
| 18 | + \ "char_length", "character", "character_length", "character_set_catalog", |
| 19 | + \ "character_set_name", "character_set_schema", "characteristics", |
| 20 | + \ "characters", "upper", "checked", "checkpoint", "checksum", "class", |
| 21 | + \ "class_origin", "clob", "close", "cluster", "clustered", "coalesce", |
| 22 | + \ "cobol", "collate", "collation", "collation_catalog", "collation_name", |
| 23 | + \ "collation_schema", "collect", "column", "column_name", "columns", |
| 24 | + \ "command_function", "command_function_code", "comment", "commit", |
| 25 | + \ "committed", "completion", "compress", "compute", "condition", |
| 26 | + \ "condition_number", "connect", "connection", "connection_name", |
| 27 | + \ "constraint", "constraint_catalog", "constraint_name", |
| 28 | + \ "constraint_schema", "constraints", "constructor", "contains", |
| 29 | + \ "containstable", "continue", "conversion", "convert", "copy", "corr", |
| 30 | + \ "corresponding", "count", "covar_pop", "covar_samp", "create", |
| 31 | + \ "createdb", "createrole", "createuser", "cross", "csv", "cube", |
| 32 | + \ "cume_dist", "current", "current_date", |
| 33 | + \ "current_default_transform_group", "current_path", "current_role", |
| 34 | + \ "current_time", "current_timestamp", "current_transform_group_for_type", |
| 35 | + \ "current_user", "cursor", "cursor_name", "cycle", "data", "database", |
| 36 | + \ "databases", "date", "datetime", "datetime_interval_code", |
| 37 | + \ "datetime_interval_precision", "day", "day_hour", "day_microsecond", |
| 38 | + \ "day_minute", "day_second", "dayofmonth", "dayofweek", "dayofyear", |
| 39 | + \ "dbcc", "deallocate", "dec", "decimal", "declare", "default", |
| 40 | + \ "defaults", "deferrable", "deferred", "defined", "definer", "degree", |
| 41 | + \ "delay_key_write", "delayed", "delete", "delimiter", "delimiters", |
| 42 | + \ "dense_rank", "deny", "depth", "deref", "derived", "desc", "describe", |
| 43 | + \ "descriptor", "destroy", "destructor", "deterministic", "diagnostics", |
| 44 | + \ "dictionary", "disable", "disconnect", "disk", "dispatch", "distinct", |
| 45 | + \ "distinctrow", "distributed", "div", "do", "domain", "double", "drop", |
| 46 | + \ "dual", "dummy", "dump", "dynamic", "dynamic_function", |
| 47 | + \ "dynamic_function_code", "each", "element", "else", "elseif", "enable", |
| 48 | + \ "enclosed", "encoding", "encrypted", "end", "enum", "equals", "errlvl", |
| 49 | + \ "escape", "escaped", "every", "except", "exception", "exclude", |
| 50 | + \ "excluding", "exclusive", "exec", "execute", "existing", "exists", |
| 51 | + \ "exit", "exp", "explain", "external", "extract", "false", "fetch", |
| 52 | + \ "fields", "file", "fillfactor", "filter", "final", "first", "float", |
| 53 | + \ "float4", "float8", "floor", "flush", "following", "for", "force", |
| 54 | + \ "foreign", "fortran", "forward", "found", "free", "freetext", |
| 55 | + \ "freetexttable", "freeze", "from", "full", "fulltext", "function", |
| 56 | + \ "fusion", "g", "general", "generated", "get", "global", "go", "goto", |
| 57 | + \ "grant", "granted", "grants", "greatest", "group", "grouping", |
| 58 | + \ "handler", "having", "header", "heap", "hierarchy", "high_priority", |
| 59 | + \ "hold", "holdlock", "host", "hosts", "hour", "hour_microsecond", |
| 60 | + \ "hour_minute", "hour_second", "identified", "identity", |
| 61 | + \ "identity_insert", "identitycol", "if", "ignore", "ilike", "immediate", |
| 62 | + \ "immutable", "implementation", "implicit", "in", "include", "including", |
| 63 | + \ "increment", "index", "indicator", "infile", "infix", "inherit", |
| 64 | + \ "inherits", "initial", "initialize", "initially", "inner", "inout", |
| 65 | + \ "input", "insensitive", "insert", "insert_id", "instance", |
| 66 | + \ "instantiable", "instead", "int", "int1", "int2", "int3", "int4", |
| 67 | + \ "int8", "integer", "intersect", "intersection", "interval", "into", |
| 68 | + \ "invoker", "is", "isam", "isnull", "isolation", "iterate", "join", "k", |
| 69 | + \ "key", "key_member", "key_type", "keys", "kill", "lancompiler", |
| 70 | + \ "language", "large", "last", "last_insert_id", "lateral", "leading", |
| 71 | + \ "least", "leave", "left", "length", "less", "level", "like", "limit", |
| 72 | + \ "lineno", "lines", "listen", "ln", "load", "local", "localtime", |
| 73 | + \ "localtimestamp", "location", "locator", "lock", "login", "logs", |
| 74 | + \ "long", "longblob", "longtext", "loop", "low_priority", "lower", "m", |
| 75 | + \ "map", "match", "matched", "max", "max_rows", "maxextents", "maxvalue", |
| 76 | + \ "mediumblob", "mediumint", "mediumtext", "member", "merge", |
| 77 | + \ "message_length", "message_octet_length", "message_text", "method", |
| 78 | + \ "middleint", "min", "min_rows", "minus", "minute", "minute_microsecond", |
| 79 | + \ "minute_second", "minvalue", "mlslabel", "mod", "mode", "modifies", |
| 80 | + \ "modify", "module", "month", "monthname", "more", "move", "multiset", |
| 81 | + \ "mumps", "myisam", "name", "names", "national", "natural", "nchar", |
| 82 | + \ "nclob", "nesting", "new", "next", "no", "no_write_to_binlog", |
| 83 | + \ "noaudit", "nocheck", "nocompress", "nocreatedb", "nocreaterole", |
| 84 | + \ "nocreateuser", "noinherit", "nologin", "nonclustered", "none", |
| 85 | + \ "normalize", "normalized", "nosuperuser", "not", "nothing", "notify", |
| 86 | + \ "notnull", "nowait", "null", "nullable", "nullif", "nulls", "number", |
| 87 | + \ "numeric", "object", "octet_length", "octets", "of", "off", "offline", |
| 88 | + \ "offset", "offsets", "oids", "old", "on", "online", "only", "open", |
| 89 | + \ "opendatasource", "openquery", "openrowset", "openxml", "operation", |
| 90 | + \ "operator", "optimize", "option", "optionally", "options", "or", |
| 91 | + \ "order", "ordering", "ordinality", "others", "out", "outer", "outfile", |
| 92 | + \ "output", "over", "overlaps", "overlay", "overriding", "owner", |
| 93 | + \ "pack_keys", "pad", "parameter", "parameter_mode", "parameter_name", |
| 94 | + \ "parameter_ordinal_position", "parameter_specific_catalog", |
| 95 | + \ "parameter_specific_name", "parameter_specific_schema", "parameters", |
| 96 | + \ "partial", "partition", "pascal", "password", "path", "pctfree", |
| 97 | + \ "percent", "percent_rank", "percentile_cont", "percentile_disc", |
| 98 | + \ "placing", "plan", "pli", "position", "postfix", "power", "preceding", |
| 99 | + \ "precision", "prefix", "preorder", "prepare", "prepared", "preserve", |
| 100 | + \ "primary", "print", "prior", "privileges", "proc", "procedural", |
| 101 | + \ "procedure", "process", "processlist", "public", "purge", "quote", |
| 102 | + \ "raid0", "raiserror", "range", "rank", "raw", "read", "reads", |
| 103 | + \ "readtext", "real", "recheck", "reconfigure", "recursive", "ref", |
| 104 | + \ "references", "referencing", "regexp", "regr_avgx", "regr_avgy", |
| 105 | + \ "regr_count", "regr_intercept", "regr_r2", "regr_slope", "regr_sxx", |
| 106 | + \ "regr_sxy", "regr_syy", "reindex", "relative", "release", "reload", |
| 107 | + \ "rename", "repeat", "repeatable", "replace", "replication", "require", |
| 108 | + \ "reset", "resignal", "resource", "restart", "restore", "restrict", |
| 109 | + \ "result", "return", "returned_cardinality", "returned_length", |
| 110 | + \ "returned_octet_length", "returned_sqlstate", "returns", "revoke", |
| 111 | + \ "right", "rlike", "role", "rollback", "rollup", "routine", |
| 112 | + \ "routine_catalog", "routine_name", "routine_schema", "row", "row_count", |
| 113 | + \ "row_number", "rowcount", "rowguidcol", "rowid", "rownum", "rows", |
| 114 | + \ "rule", "save", "savepoint", "scale", "schema", "schema_name", |
| 115 | + \ "schemas", "scope", "scope_catalog", "scope_name", "scope_schema", |
| 116 | + \ "scroll", "search", "second", "second_microsecond", "section", |
| 117 | + \ "security", "select", "self", "sensitive", "separator", "sequence", |
| 118 | + \ "serializable", "server_name", "session", "session_user", "set", |
| 119 | + \ "setof", "sets", "setuser", "share", "show", "shutdown", "signal", |
| 120 | + \ "similar", "simple", "size", "smallint", "some", "soname", "source", |
| 121 | + \ "space", "spatial", "specific", "specific_name", "specifictype", "sql", |
| 122 | + \ "sql_big_result", "sql_big_selects", "sql_big_tables", |
| 123 | + \ "sql_calc_found_rows", "sql_log_off", "sql_log_update", |
| 124 | + \ "sql_low_priority_updates", "sql_select_limit", "sql_small_result", |
| 125 | + \ "sql_warnings", "sqlca", "sqlcode", "sqlerror", "sqlexception", |
| 126 | + \ "sqlstate", "sqlwarning", "sqrt", "ssl", "stable", "start", "starting", |
| 127 | + \ "state", "statement", "static", "statistics", "status", "stddev_pop", |
| 128 | + \ "stddev_samp", "stdin", "stdout", "storage", "straight_join", "strict", |
| 129 | + \ "string", "structure", "style", "subclass_origin", "sublist", |
| 130 | + \ "submultiset", "substring", "successful", "sum", "superuser", |
| 131 | + \ "symmetric", "synonym", "sysdate", "sysid", "system", "system_user", |
| 132 | + \ "table", "table_name", "tables", "tablesample", "tablespace", "temp", |
| 133 | + \ "template", "temporary", "terminate", "terminated", "text", "textsize", |
| 134 | + \ "than", "then", "ties", "time", "timestamp", "timezone_hour", |
| 135 | + \ "timezone_minute", "tinyblob", "tinyint", "tinytext", "to", "toast", |
| 136 | + \ "top", "top_level_count", "trailing", "tran", "transaction", |
| 137 | + \ "transaction_active", "transactions_committed", |
| 138 | + \ "transactions_rolled_back", "transform", "transforms", "translate", |
| 139 | + \ "translation", "treat", "trigger", "trigger_catalog", "trigger_name", |
| 140 | + \ "trigger_schema", "trim", "true", "truncate", "trusted", "tsequal", |
| 141 | + \ "type", "uescape", "uid", "unbounded", "uncommitted", "under", "undo", |
| 142 | + \ "unencrypted", "union", "unique", "unknown", "unlisten", "unlock", |
| 143 | + \ "unnamed", "unnest", "unsigned", "until", "update", "updatetext", |
| 144 | + \ "upper", "usage", "use", "user", "user_defined_type_catalog", |
| 145 | + \ "user_defined_type_code", "user_defined_type_name", |
| 146 | + \ "user_defined_type_schema", "using", "utc_date", "utc_time", |
| 147 | + \ "utc_timestamp", "vacuum", "valid", "validate", "validator", "value", |
| 148 | + \ "values", "var_pop", "var_samp", "varbinary", "varchar", "varchar2", |
| 149 | + \ "varcharacter", "variable", "variables", "varying", "verbose", "view", |
| 150 | + \ "volatile", "waitfor", "when", "whenever", "where", "while", |
| 151 | + \ "width_bucket", "window", "with", "within", "without", "work", "write", |
| 152 | + \ "writetext", "x509", "xor", "year", "year_month", "zerofill", "zone", |
| 153 | + \ ] |
| 154 | + |
| 155 | +function! s:upper(k) |
| 156 | + if synIDattr(synIDtrans(synID(line('.'), col('.')-1, 0)), "name") !~# 'Comment\|String' |
| 157 | + return toupper(a:k) |
| 158 | + else |
| 159 | + return a:k " was comment or string, so don't change case |
| 160 | + endif |
| 161 | +endfunction |
| 162 | + |
| 163 | +for k in s:keywords |
| 164 | + exec "iabbrev <expr> <buffer> " . k . " <SID>upper('" . k . "')" |
| 165 | +endfor |
0 commit comments