Skip to content

Commit 012db14

Browse files
amannmTomáš Kraus
authored andcommitted
relax named parameter identifier rules and fix helidon-io#2922
1 parent c9d9734 commit 012db14

2 files changed

Lines changed: 56 additions & 56 deletions

File tree

dbclient/jdbc/src/main/java/io/helidon/dbclient/jdbc/JdbcStatement.java

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -208,16 +208,16 @@ private interface Action extends Consumer<Parser> {}
208208
* Character classes used in state machine.
209209
*/
210210
private enum CharClass {
211-
LETTER, // Letter (any unicode letter)
212-
NUMBER, // Number (any unicode digit)
213-
LF, // Line feed / new line (\n), terminates line alone or in CR LF sequence
214-
CR, // Carriage return (\r), terminates line in CR LF sequence
215-
APOSTROPHE, // Single quote ('), begins string in SQL
216-
STAR, // Star (*), part of multiline comment beginning "/*" and ending "*/" sequence
217-
DASH, // Dash (-), part of single line comment beginning sequence "--"
218-
SLASH, // Slash (/), part of multiline comment beginning "/*" and ending "*/" sequence
219-
COLON, // Colon (:), begins named parameter
220-
OTHER; // Other characters
211+
IDENTIFIER_START, // Any character for which the method Character.isJavaIdentifierStart returns true
212+
IDENTIFIER_PART, // Any character for which the method Character.isJavaIdentifierPart returns true
213+
LF, // Line feed / new line (\n), terminates line alone or in CR LF sequence
214+
CR, // Carriage return (\r), terminates line in CR LF sequence
215+
APOSTROPHE, // Single quote ('), begins string in SQL
216+
STAR, // Star (*), part of multiline comment beginning "/*" and ending "*/" sequence
217+
DASH, // Dash (-), part of single line comment beginning sequence "--"
218+
SLASH, // Slash (/), part of multiline comment beginning "/*" and ending "*/" sequence
219+
COLON, // Colon (:), begins named parameter
220+
OTHER; // Other characters
221221

222222
/**
223223
* Returns character class corresponding to provided character.
@@ -235,9 +235,9 @@ private static CharClass charClass(char c) {
235235
case '/': return SLASH;
236236
case ':': return COLON;
237237
default:
238-
return Character.isLetter(c) || c == '_'
239-
? LETTER
240-
: (Character.isDigit(c) ? NUMBER : OTHER);
238+
return Character.isJavaIdentifierStart(c) || c == '_'
239+
? IDENTIFIER_START
240+
: (Character.isJavaIdentifierPart(c) ? IDENTIFIER_PART : OTHER);
241241
}
242242
}
243243

@@ -263,8 +263,8 @@ private enum State {
263263
private static final State[][] TRANSITION = {
264264
// Transitions from STATEMENT state
265265
{
266-
STATEMENT, // LETTER: regular part of the statement, keep processing it
267-
STATEMENT, // NUMBER: regular part of the statement, keep processing it
266+
STATEMENT, // IDENTIFIER_START: regular part of the statement, keep processing it
267+
STATEMENT, // IDENTIFIER_PART: regular part of the statement, keep processing it
268268
STATEMENT, // LF: regular part of the statement, keep processing it
269269
STATEMENT, // CR: regular part of the statement, keep processing it
270270
STRING, // APOSTROPHE: beginning of SQL string processing, switch to STRING state
@@ -278,8 +278,8 @@ private enum State {
278278
},
279279
// Transitions from STRING state
280280
{
281-
STRING, // LETTER: regular part of the SQL string, keep processing it
282-
STRING, // NUMBER: regular part of the SQL string, keep processing it
281+
STRING, // IDENTIFIER_START: regular part of the SQL string, keep processing it
282+
STRING, // IDENTIFIER_PART: regular part of the SQL string, keep processing it
283283
STRING, // LF: regular part of the SQL string, keep processing it
284284
STRING, // CR: regular part of the SQL string, keep processing it
285285
STATEMENT, // APOSTROPHE: end of SQL string processing, go back to STATEMENT state
@@ -291,8 +291,8 @@ private enum State {
291291
},
292292
// Transitions from COLON state
293293
{
294-
PARAMETER, // LETTER: first character of named parameter, switch to PARAMETER state
295-
STATEMENT, // NUMBER: can't be first character of named parameter, go back to STATEMENT state
294+
PARAMETER, // IDENTIFIER_START: first character of named parameter, switch to PARAMETER state
295+
STATEMENT, // IDENTIFIER_PART: can't be first character of named parameter, go back to STATEMENT state
296296
STATEMENT, // LF: can't be first character of named parameter, go back to STATEMENT state
297297
STATEMENT, // CR: can't be first character of named parameter, go back to STATEMENT state
298298
STRING, // APOSTROPHE: not a named parameter but beginning of SQL string processing,
@@ -308,8 +308,8 @@ private enum State {
308308
},
309309
// Transitions from PARAMETER state
310310
{
311-
PARAMETER, // LETTER: next character of named parameter, keep processing it
312-
PARAMETER, // NUMBER: next character of named parameter, keep processing it
311+
PARAMETER, // IDENTIFIER_START: next character of named parameter, keep processing it
312+
PARAMETER, // IDENTIFIER_PART: next character of named parameter, keep processing it
313313
STATEMENT, // LF: can't be next character of named parameter, go back to STATEMENT state
314314
STATEMENT, // CR: can't be next character of named parameter, go back to STATEMENT state
315315
STRING, // APOSTROPHE: end of named parameter and beginning of SQL string processing,
@@ -325,8 +325,8 @@ private enum State {
325325
},
326326
// Transitions from MULTILN_COMMENT_BG state
327327
{
328-
STATEMENT, // LETTER: not starting sequence of multi line comment, go back to STATEMENT state
329-
STATEMENT, // NUMBER: not starting sequence of multi line comment, go back to STATEMENT state
328+
STATEMENT, // IDENTIFIER_START: not starting sequence of multi line comment, go back to STATEMENT state
329+
STATEMENT, // IDENTIFIER_PART: not starting sequence of multi line comment, go back to STATEMENT state
330330
STATEMENT, // LF: not starting sequence of multi line comment, go back to STATEMENT state
331331
STATEMENT, // CR: not starting sequence of multi line comment, go back to STATEMENT state
332332
STRING, // APOSTROPHE: not starting sequence of multi line comment but beginning of SQL
@@ -343,8 +343,8 @@ private enum State {
343343
},
344344
// Transitions from MULTILN_COMMENT_END state
345345
{
346-
MULTILN_COMMENT, // LETTER: not ending sequence of multi line comment, go back to MULTILN_COMMENT state
347-
MULTILN_COMMENT, // NUMBER: not ending sequence of multi line comment, go back to MULTILN_COMMENT state
346+
MULTILN_COMMENT, // IDENTIFIER_START: not ending sequence of multi line comment, go back to MULTILN_COMMENT state
347+
MULTILN_COMMENT, // IDENTIFIER_PART: not ending sequence of multi line comment, go back to MULTILN_COMMENT state
348348
MULTILN_COMMENT, // LF: not ending sequence of multi line comment, go back to MULTILN_COMMENT state
349349
MULTILN_COMMENT, // CR: not ending sequence of multi line comment, go back to MULTILN_COMMENT state
350350
MULTILN_COMMENT, // APOSTROPHE: not ending sequence of multi line comment,
@@ -359,8 +359,8 @@ private enum State {
359359
},
360360
// Transitions from MULTILN_COMMENT state
361361
{
362-
MULTILN_COMMENT, // LETTER: regular multi line comment, keep processing it
363-
MULTILN_COMMENT, // NUMBER: regular multi line comment, keep processing it
362+
MULTILN_COMMENT, // IDENTIFIER_START: regular multi line comment, keep processing it
363+
MULTILN_COMMENT, // IDENTIFIER_PART: regular multi line comment, keep processing it
364364
MULTILN_COMMENT, // LF: regular multi line comment, keep processing it
365365
MULTILN_COMMENT, // CR: regular multi line comment, keep processing it
366366
MULTILN_COMMENT, // APOSTROPHE: regular multi line comment, keep processing it
@@ -373,8 +373,8 @@ private enum State {
373373
},
374374
// Transitions from SINGLELN_COMMENT_BG state
375375
{
376-
STATEMENT, // LETTER: not starting sequence of single line comment, go back to STATEMENT state
377-
STATEMENT, // NUMBER: not starting sequence of single line comment, go back to STATEMENT state
376+
STATEMENT, // IDENTIFIER_START: not starting sequence of single line comment, go back to STATEMENT state
377+
STATEMENT, // IDENTIFIER_PART: not starting sequence of single line comment, go back to STATEMENT state
378378
STATEMENT, // LF: not starting sequence of single line comment, go back to STATEMENT state
379379
STATEMENT, // CR: not starting sequence of single line comment, go back to STATEMENT state
380380
STRING, // APOSTROPHE: not starting sequence of single line comment but beginning of SQL
@@ -390,8 +390,8 @@ private enum State {
390390
},
391391
// Transitions from SINGLELN_COMMENT_END state
392392
{
393-
SINGLELN_COMMENT, // LETTER: not ending sequence of single line comment, go back to SINGLELN_COMMENT state
394-
SINGLELN_COMMENT, // NUMBER: not ending sequence of single line comment, go back to SINGLELN_COMMENT state
393+
SINGLELN_COMMENT, // IDENTIFIER_START: not ending sequence of single line comment, go back to SINGLELN_COMMENT state
394+
SINGLELN_COMMENT, // IDENTIFIER_PART: not ending sequence of single line comment, go back to SINGLELN_COMMENT state
395395
STATEMENT, // LF: end of single line comment, switch to STATEMENT state
396396
SINGLELN_COMMENT_END, // CR: not ending sequence of single line comment but possible ending sequence
397397
// of next single line comment, retry end of single line comment processing
@@ -405,8 +405,8 @@ private enum State {
405405
},
406406
// Transitions from SINGLELN_COMMENT state
407407
{
408-
SINGLELN_COMMENT, // LETTER: regular single line comment, keep processing it
409-
SINGLELN_COMMENT, // NUMBER: regular single line comment, keep processing it
408+
SINGLELN_COMMENT, // IDENTIFIER_START: regular single line comment, keep processing it
409+
SINGLELN_COMMENT, // IDENTIFIER_PART: regular single line comment, keep processing it
410410
STATEMENT, // LF: end of single line comment, switch to STATEMENT state
411411
SINGLELN_COMMENT_END, // CR: possible beginning of ending sequence of multi line comment,
412412
// switch to SINGLELN_COMMENT_END state
@@ -426,8 +426,8 @@ private enum State {
426426
private static final Action[][] ACTION = {
427427
// Actions performed on transitions from STATEMENT state
428428
{
429-
Parser::copyChar, // LETTER: copy regular statement character to output
430-
Parser::copyChar, // NUMBER: copy regular statement character to output
429+
Parser::copyChar, // IDENTIFIER_START: copy regular statement character to output
430+
Parser::copyChar, // IDENTIFIER_PART: copy regular statement character to output
431431
Parser::copyChar, // LF: copy regular statement character to output
432432
Parser::copyChar, // CR: copy regular statement character to output
433433
Parser::copyChar, // APOSTROPHE: copy SQL string character to output
@@ -439,8 +439,8 @@ private enum State {
439439
},
440440
// Actions performed on transitions from STRING state
441441
{
442-
Parser::copyChar, // LETTER: copy SQL string character to output
443-
Parser::copyChar, // NUMBER: copy SQL string character to output
442+
Parser::copyChar, // IDENTIFIER_START: copy SQL string character to output
443+
Parser::copyChar, // IDENTIFIER_PART: copy SQL string character to output
444444
Parser::copyChar, // LF: copy SQL string character to output
445445
Parser::copyChar, // CR: copy SQL string character to output
446446
Parser::copyChar, // APOSTROPHE: copy SQL string character to output
@@ -452,8 +452,8 @@ private enum State {
452452
},
453453
// Actions performed on transitions from COLON state
454454
{
455-
Parser::setFirstParamChar, // LETTER: set first parameter character
456-
Parser::addColonAndCopyChar, // NUMBER: not a parameter, add delayed colon and copy current statement character
455+
Parser::setFirstParamChar, // IDENTIFIER_START: set first parameter character
456+
Parser::addColonAndCopyChar, // IDENTIFIER_PART: not a parameter, add delayed colon and copy current statement character
457457
// to output
458458
Parser::addColonAndCopyChar, // LF: not a parameter, add delayed colon and copy current statement character
459459
// to output
@@ -474,8 +474,8 @@ private enum State {
474474
},
475475
// Actions performed on transitions from PARAMETER state
476476
{
477-
Parser::setNextParamChar, // LETTER: set next parameter character
478-
Parser::setNextParamChar, // NUMBER: set next parameter character
477+
Parser::setNextParamChar, // IDENTIFIER_START: set next parameter character
478+
Parser::setNextParamChar, // IDENTIFIER_PART: set next parameter character
479479
Parser::finishParamAndCopyChar, // LF: finish parameter processing and copy current character as part
480480
// of regular statement
481481
Parser::finishParamAndCopyChar, // CR: finish parameter processing and copy current character as part
@@ -495,8 +495,8 @@ private enum State {
495495
},
496496
// Actions performed on transitions from MULTILN_COMMENT_BG state
497497
{
498-
Parser::copyChar, // LETTER: copy regular statement character to output
499-
Parser::copyChar, // NUMBER: copy regular statement character to output
498+
Parser::copyChar, // IDENTIFIER_START: copy regular statement character to output
499+
Parser::copyChar, // IDENTIFIER_PART: copy regular statement character to output
500500
Parser::copyChar, // LF: copy regular statement character to output
501501
Parser::copyChar, // CR: copy regular statement character to output
502502
Parser::copyChar, // APOSTROPHE: copy SQL string character to output
@@ -508,8 +508,8 @@ private enum State {
508508
},
509509
// Actions performed on transitions from MULTILN_COMMENT_END state
510510
{
511-
Parser::copyChar, // LETTER: copy multi line comment character to output
512-
Parser::copyChar, // NUMBER: copy multi line comment character to output
511+
Parser::copyChar, // IDENTIFIER_START: copy multi line comment character to output
512+
Parser::copyChar, // IDENTIFIER_PART: copy multi line comment character to output
513513
Parser::copyChar, // LF: copy multi line comment character to output
514514
Parser::copyChar, // CR: copy multi line comment character to output
515515
Parser::copyChar, // APOSTROPHE: copy multi line comment character to output
@@ -521,8 +521,8 @@ private enum State {
521521
},
522522
// Actions performed on transitions from MULTILN_COMMENT state
523523
{
524-
Parser::copyChar, // LETTER: copy multi line comment character to output
525-
Parser::copyChar, // NUMBER: copy multi line comment character to output
524+
Parser::copyChar, // IDENTIFIER_START: copy multi line comment character to output
525+
Parser::copyChar, // IDENTIFIER_PART: copy multi line comment character to output
526526
Parser::copyChar, // LF: copy multi line comment character to output
527527
Parser::copyChar, // CR: copy multi line comment character to output
528528
Parser::copyChar, // APOSTROPHE: copy multi line comment character to output
@@ -534,8 +534,8 @@ private enum State {
534534
},
535535
// Actions performed on transitions from SINGLELN_COMMENT_BG state
536536
{
537-
Parser::copyChar, // LETTER: copy regular statement character to output
538-
Parser::copyChar, // NUMBER: copy regular statement character to output
537+
Parser::copyChar, // IDENTIFIER_START: copy regular statement character to output
538+
Parser::copyChar, // IDENTIFIER_PART: copy regular statement character to output
539539
Parser::copyChar, // LF: copy regular statement character to output
540540
Parser::copyChar, // CR: copy regular statement character to output
541541
Parser::copyChar, // APOSTROPHE: copy SQL string character to output
@@ -547,8 +547,8 @@ private enum State {
547547
},
548548
// Actions performed on transitions from SINGLELN_COMMENT_END state
549549
{
550-
Parser::copyChar, // LETTER: copy single line comment character to output
551-
Parser::copyChar, // NUMBER: copy single line comment character to output
550+
Parser::copyChar, // IDENTIFIER_START: copy single line comment character to output
551+
Parser::copyChar, // IDENTIFIER_PART: copy single line comment character to output
552552
Parser::copyChar, // LF: copy single line comment character to output
553553
Parser::copyChar, // CR: copy single line comment character to output
554554
Parser::copyChar, // APOSTROPHE: copy single line comment character to output
@@ -560,8 +560,8 @@ private enum State {
560560
},
561561
// Actions performed on transitions from SINGLELN_COMMENT state
562562
{
563-
Parser::copyChar, // LETTER: copy single line comment character to output
564-
Parser::copyChar, // NUMBER: copy single line comment character to output
563+
Parser::copyChar, // IDENTIFIER_START: copy single line comment character to output
564+
Parser::copyChar, // IDENTIFIER_PART: copy single line comment character to output
565565
Parser::copyChar, // LF: copy single line comment character to output
566566
Parser::copyChar, // CR: copy single line comment character to output
567567
Parser::copyChar, // APOSTROPHE: copy single line comment character to output

0 commit comments

Comments
 (0)