Commit 66505eb
committed
Don't fail parsing a column definition with unexpected tokens
Since PR apache#93
`parse_column_def` parses a set of column options in a loop, e.g. given:
```
_______ column_def _______
CREATE TABLE foo (bar INT NOT NULL DEFAULT 1, )
-------- ---------
option 1 option 2
````
it parses column options until it encounters one of the delimiter tokens
First when we only supported `CREATE TABLE`, the set of delimiters that
stopped the parsing used to be `Token::Comma | Token::RParen`.
Then we added support for `ALTER TABLE ADD COLUMN <column_def>`. Turns
out the parser started to bail if the statement ended with a semicolon,
while attempting to parse the semicolon as a column option, as we forgot
to add it to the set of delimiter tokens.
This was recently fixed in apache#246
by including Token::SemiColon to the list, but it felt wrong to have
to update this list, and to have a common list of delimiters for two
different contexts (CREATE TABLE with parens vs ALTER TABLE ADD COLUMN
without parens).
Also our current approach cannot handle multiple statements NOT
separated by a semicolon, as is common in MS SQL DDL. We don't
explicitly support it in `parse_statements`, but that's a use-case
like to keep in mind nevertheless.1 parent 23f5c7e commit 66505eb
2 files changed
+40
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1228 | 1228 | | |
1229 | 1229 | | |
1230 | 1230 | | |
1231 | | - | |
1232 | | - | |
1233 | | - | |
1234 | | - | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
1235 | 1246 | | |
1236 | 1247 | | |
1237 | 1248 | | |
| |||
1241 | 1252 | | |
1242 | 1253 | | |
1243 | 1254 | | |
1244 | | - | |
1245 | | - | |
1246 | | - | |
1247 | | - | |
1248 | | - | |
1249 | | - | |
1250 | | - | |
1251 | | - | |
1252 | | - | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
1253 | 1258 | | |
1254 | | - | |
| 1259 | + | |
1255 | 1260 | | |
1256 | | - | |
| 1261 | + | |
1257 | 1262 | | |
1258 | | - | |
| 1263 | + | |
1259 | 1264 | | |
1260 | | - | |
| 1265 | + | |
1261 | 1266 | | |
1262 | 1267 | | |
1263 | 1268 | | |
| |||
1276 | 1281 | | |
1277 | 1282 | | |
1278 | 1283 | | |
1279 | | - | |
| 1284 | + | |
1280 | 1285 | | |
1281 | 1286 | | |
1282 | 1287 | | |
1283 | 1288 | | |
1284 | | - | |
| 1289 | + | |
1285 | 1290 | | |
1286 | 1291 | | |
1287 | 1292 | | |
1288 | 1293 | | |
1289 | | - | |
| 1294 | + | |
1290 | 1295 | | |
1291 | 1296 | | |
1292 | 1297 | | |
1293 | 1298 | | |
1294 | | - | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
1295 | 1302 | | |
1296 | 1303 | | |
1297 | 1304 | | |
1298 | 1305 | | |
1299 | | - | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
1300 | 1309 | | |
1301 | | - | |
1302 | | - | |
1303 | | - | |
1304 | | - | |
| 1310 | + | |
| 1311 | + | |
1305 | 1312 | | |
1306 | 1313 | | |
1307 | 1314 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1142 | 1142 | | |
1143 | 1143 | | |
1144 | 1144 | | |
1145 | | - | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
1146 | 1152 | | |
1147 | 1153 | | |
1148 | 1154 | | |
| |||
0 commit comments