-
Notifications
You must be signed in to change notification settings - Fork 116
/
Copy pathsql_signature_examples.json
146 lines (146 loc) · 3.07 KB
/
sql_signature_examples.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
[
{
"input": "",
"output": ""
},
{
"input": " ",
"output": ""
},
{
"input": "SELECT * FROM foo.bar",
"output": "SELECT FROM foo.bar"
},
{
"input": "SELECT * FROM foo.bar.baz",
"output": "SELECT FROM foo.bar.baz"
},
{
"input": "SELECT * FROM `foo.bar`",
"output": "SELECT FROM foo.bar"
},
{
"input": "SELECT * FROM \"foo.bar\"",
"output": "SELECT FROM foo.bar"
},
{
"input": "SELECT * FROM [foo.bar]",
"output": "SELECT FROM foo.bar"
},
{
"input": "SELECT (x, y) FROM foo,bar,baz",
"output": "SELECT FROM foo"
},
{
"input": "SELECT * FROM foo JOIN bar",
"output": "SELECT FROM foo"
},
{
"input": "SELECT * FROM dollar$bill",
"output": "SELECT FROM dollar$bill"
},
{
"input": "SELECT id FROM \"myta\n-æøåble\" WHERE id = 2323",
"output": "SELECT FROM myta\n-æøåble"
},
{
"input": "SELECT * FROM foo-- abc\n./*def*/bar",
"output": "SELECT FROM foo.bar"
},
{
"comment": "We capture the first table of the outermost select statement",
"input": "SELECT *,(SELECT COUNT(*) FROM table2 WHERE table2.field1 = table1.id) AS count FROM table1 WHERE table1.field1 = 'value'",
"output": "SELECT FROM table1"
},
{
"comment": "If the outermost select operates on derived tables, then we just return 'SELECT' (i.e. the fallback)",
"input": "SELECT * FROM (SELECT foo FROM bar) AS foo_bar",
"output": "SELECT"
},
{
"input": "DELETE FROM foo.bar WHERE baz=1",
"output": "DELETE FROM foo.bar"
},
{
"input": "UPDATE IGNORE foo.bar SET bar=1 WHERE baz=2",
"output": "UPDATE foo.bar"
},
{
"input": "UPDATE ONLY foo AS bar SET baz=1",
"output": "UPDATE foo"
},
{
"input": "INSERT INTO foo.bar (col) VALUES(?)",
"output": "INSERT INTO foo.bar"
},
{
"input": "INSERT LOW_PRIORITY IGNORE INTO foo.bar (col) VALUES(?)",
"output": "INSERT INTO foo.bar"
},
{
"input": "CALL foo(bar, 123)",
"output": "CALL foo"
},
{
"comment": "For DDL we only capture the first token",
"input": "ALTER TABLE foo ADD ()",
"output": "ALTER"
},
{
"input": "CREATE TABLE foo ...",
"output": "CREATE"
},
{
"input": "DROP TABLE foo",
"output": "DROP"
},
{
"input": "SAVEPOINT x_asd1234",
"output": "SAVEPOINT"
},
{
"input": "BEGIN",
"output": "BEGIN"
},
{
"input": "COMMIT",
"output": "COMMIT"
},
{
"input": "ROLLBACK",
"output": "ROLLBACK"
},
{
"comment": "For broken statements we only capture the first token",
"input": "SELECT * FROM (SELECT EOF",
"output": "SELECT"
},
{
"input": "SELECT 'neverending literal FROM (SELECT * FROM ...",
"output": "SELECT"
},
{
"input": "INSERT COIN TO PLAY",
"output": "INSERT"
},
{
"input": "INSERT $2 INTO",
"output": "INSERT"
},
{
"input": "UPDATE 99",
"output": "UPDATE"
},
{
"input": "DELETE 99",
"output": "DELETE"
},
{
"input": "DELETE FROM",
"output": "DELETE"
},
{
"input": "CALL",
"output": "CALL"
}
]