(t *testing.T)
| 34 | ) |
| 35 | |
| 36 | func TestSimple(t *testing.T) { |
| 37 | p := parser.New() |
| 38 | |
| 39 | reservedKws := []string{ |
| 40 | "add", "all", "alter", "analyze", "and", "as", "asc", "between", "bigint", |
| 41 | "binary", "blob", "both", "by", "call", "cascade", "case", "change", "character", "check", "collate", |
| 42 | "column", "constraint", "convert", "create", "cross", "current_date", "current_time", |
| 43 | "current_timestamp", "current_user", "database", "databases", "day_hour", "day_microsecond", |
| 44 | "day_minute", "day_second", "decimal", "default", "delete", "desc", "describe", |
| 45 | "distinct", "distinctRow", "div", "double", "drop", "dual", "else", "enclosed", "escaped", |
| 46 | "exists", "explain", "false", "float", "fetch", "for", "force", "foreign", "from", |
| 47 | "fulltext", "grant", "group", "having", "hour_microsecond", "hour_minute", |
| 48 | "hour_second", "if", "ignore", "in", "index", "infile", "inner", "insert", "int", "into", "integer", |
| 49 | "interval", "is", "join", "key", "keys", "kill", "leading", "left", "like", "ilike", "limit", "lines", "load", |
| 50 | "localtime", "localtimestamp", "lock", "longblob", "longtext", "mediumblob", "maxvalue", "mediumint", "mediumtext", |
| 51 | "minute_microsecond", "minute_second", "mod", "not", "no_write_to_binlog", "null", "numeric", |
| 52 | "on", "option", "optionally", "or", "order", "outer", "partition", "precision", "primary", "procedure", "range", "read", "real", "recursive", |
| 53 | "references", "regexp", "rename", "repeat", "replace", "revoke", "restrict", "right", "rlike", |
| 54 | "schema", "schemas", "second_microsecond", "select", "set", "show", "smallint", |
| 55 | "starting", "table", "terminated", "then", "tinyblob", "tinyint", "tinytext", "to", |
| 56 | "trailing", "true", "union", "unique", "unlock", "unsigned", |
| 57 | "update", "use", "using", "utc_date", "values", "varbinary", "varchar", |
| 58 | "when", "where", "write", "xor", "year_month", "zerofill", |
| 59 | "generated", "virtual", "stored", "usage", |
| 60 | "delayed", "high_priority", "low_priority", |
| 61 | "cumeDist", "denseRank", "firstValue", "lag", "lastValue", "lead", "nthValue", "ntile", |
| 62 | "over", "percentRank", "rank", "row", "rows", "rowNumber", "window", "linear", |
| 63 | "match", "until", "placement", "tablesample", "failedLoginAttempts", "passwordLockTime", |
| 64 | // TODO: support the following keywords |
| 65 | // "with", |
| 66 | } |
| 67 | for _, kw := range reservedKws { |
| 68 | src := fmt.Sprintf("SELECT * FROM db.%s;", kw) |
| 69 | _, err := p.ParseOneStmt(src, "", "") |
| 70 | |
| 71 | require.NoErrorf(t, err, "source %s", src) |
| 72 | |
| 73 | src = fmt.Sprintf("SELECT * FROM %s.desc", kw) |
| 74 | _, err = p.ParseOneStmt(src, "", "") |
| 75 | require.NoErrorf(t, err, "source %s", src) |
| 76 | |
| 77 | src = fmt.Sprintf("SELECT t.%s FROM t", kw) |
| 78 | _, err = p.ParseOneStmt(src, "", "") |
| 79 | require.NoErrorf(t, err, "source %s", src) |
| 80 | } |
| 81 | |
| 82 | // Testcase for unreserved keywords |
| 83 | unreservedKws := []string{ |
| 84 | "auto_increment", "after", "begin", "bit", "bool", "boolean", "charset", "columns", "commit", |
| 85 | "date", "datediff", "datetime", "deallocate", "do", "from_days", "end", "engine", "engines", "execute", "extended", "first", "file", "full", |
| 86 | "local", "names", "offset", "password", "prepare", "quick", "rollback", "savepoint", "session", "signed", |
| 87 | "start", "global", "tables", "tablespace", "target", "text", "time", "timestamp", "tidb", "transaction", "truncate", "unknown", |
| 88 | "value", "warnings", "year", "now", "substr", "subpartition", "subpartitions", "substring", "mode", "any", "some", "user", "identified", |
| 89 | "collation", "comment", "avg_row_length", "checksum", "compression", "connection", "key_block_size", |
| 90 | "max_rows", "min_rows", "national", "quarter", "escape", "grants", "status", "fields", "triggers", "language", |
| 91 | "delay_key_write", "isolation", "partitions", "repeatable", "committed", "uncommitted", "only", "serializable", "level", |
| 92 | "curtime", "variables", "dayname", "version", "btree", "hash", "row_format", "dynamic", "fixed", "compressed", |
| 93 | "compact", "redundant", "1 sql_no_cache", "1 sql_cache", "action", "round", |
nothing calls this directly
no test coverage detected