提交 c182e960 authored 作者: Thomas Mueller's avatar Thomas Mueller

support $1 (parameter) and name$1 (identifier)

上级 c1d91a75
...@@ -2674,6 +2674,7 @@ public class Parser { ...@@ -2674,6 +2674,7 @@ public class Parser {
boolean changed = false; boolean changed = false;
command[len] = ' '; command[len] = ' ';
int startLoop = 0; int startLoop = 0;
int lastType = 0;
// TODO optimization in parser: could remember the length of each token // TODO optimization in parser: could remember the length of each token
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
char c = command[i]; char c = command[i];
...@@ -2745,7 +2746,13 @@ public class Parser { ...@@ -2745,7 +2746,13 @@ public class Parser {
command[i + 1] = ' '; command[i + 1] = ' ';
i++; i++;
} else { } else {
if (lastType == CHAR_NAME) {
// $ inside an identifier is supported
type = CHAR_NAME; type = CHAR_NAME;
} else {
// but not at the start, to support PostgreSQL $1
type = CHAR_SPECIAL_1;
}
} }
break; break;
case '(': case '(':
...@@ -2829,8 +2836,6 @@ public class Parser { ...@@ -2829,8 +2836,6 @@ public class Parser {
} else if (c >= '0' && c <= '9') { } else if (c >= '0' && c <= '9') {
type = CHAR_VALUE; type = CHAR_VALUE;
} else { } else {
// $ is not supported at this time (compatibility for
// PostgreSQL: $1 )
if (Character.isJavaIdentifierPart(c)) { if (Character.isJavaIdentifierPart(c)) {
type = CHAR_NAME; type = CHAR_NAME;
char u = Character.toUpperCase(c); char u = Character.toUpperCase(c);
...@@ -2842,6 +2847,7 @@ public class Parser { ...@@ -2842,6 +2847,7 @@ public class Parser {
} }
} }
types[i] = (byte) type; types[i] = (byte) type;
lastType = type;
} }
sqlCommandChars = command; sqlCommandChars = command;
types[len] = CHAR_END; types[len] = CHAR_END;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论