Changeset: 922ed232487c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/922ed232487c
Modified Files:
sql/server/sql_parser.y
sql/server/sql_scan.c
Branch: escape-sequences
Log Message:
escape date poc
diffs (98 lines):
diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -377,6 +377,7 @@ int yydebug=1;
XML_query
XML_text
XML_validate
+ odbc_date_escape
%type <type>
data_type
@@ -670,7 +671,7 @@ int yydebug=1;
%left UNION EXCEPT INTERSECT CORRESPONDING
%left JOIN CROSS LEFT FULL RIGHT INNER NATURAL
%left WITH DATA
-%left <operation> '(' ')'
+%left <operation> '(' ')' '{' '}'
%left <operation> NOT
%left <operation> '='
@@ -720,6 +721,8 @@ SQLCODE SQLERROR UNDER WHENEVER
%token X_BODY
%token MAX_MEMORY MAX_WORKERS OPTIMIZER
+/* escape sequence tokens */
+%token<sval> DATE_ESCAPE_PREFIX
%%
sqlstmt:
@@ -4848,6 +4851,7 @@ literal:
} else {
$$ = _newAtomNode(a);
} }
+ | odbc_date_escape
| TIME time_precision tz string
{ sql_subtype t;
atom *a;
@@ -5566,6 +5570,9 @@ non_reserved_word:
| STRIP { $$ = sa_strdup(SA, "strip"); }
| URI { $$ = sa_strdup(SA, "uri"); }
| WHITESPACE { $$ = sa_strdup(SA, "whitespace"); }
+
+/* escape sequence non reserved words */
+| DATE_ESCAPE_PREFIX { $$ = sa_strdup(SA, "d"); }
;
lngval:
@@ -6248,6 +6255,21 @@ XML_aggregate:
}
;
+odbc_date_escape: '{' DATE_ESCAPE_PREFIX string '}'
+ { sql_subtype t;
+ atom *a;
+ int r;
+
+ r = sql_find_subtype(&t, "date", 0, 0 );
+ if (!r || (a = atom_general(SA, &t, $3)) == NULL) {
+ sqlformaterror(m, SQLSTATE(22007) "Incorrect date value
(%s)", $3);
+ $$ = NULL;
+ YYABORT;
+ } else {
+ $$ = _newAtomNode(a);
+ } }
+;
+
%%
int find_subgeometry_type(mvc *m, char* geoSubType) {
int subType = 0;
diff --git a/sql/server/sql_scan.c b/sql/server/sql_scan.c
--- a/sql/server/sql_scan.c
+++ b/sql/server/sql_scan.c
@@ -520,6 +520,8 @@ scanner_init_keywords(void)
failed += keywords_insert("MULTILINESTRINGZM", GEOMETRYSUBTYPE);
failed += keywords_insert("MULTIPOLYGONZM", GEOMETRYSUBTYPE);
failed += keywords_insert("GEOMETRYCOLLECTIONZM", GEOMETRYSUBTYPE);
+ // escape sequence keywords
+ failed += keywords_insert("d", DATE_ESCAPE_PREFIX);
return failed;
}
@@ -1052,7 +1054,15 @@ int scanner_symbol(mvc * c, int cur)
case '"':
return scanner_string(c, cur, false);
case '{':
- return scanner_body(c);
+ // if previous tokens like LANGUAGE IDENT
+ // TODO checking on IDENT only may not be enough
+ if (lc->yylast == IDENT)
+ return scanner_body(c);
+ lc->started = 1;
+ return scanner_token(lc, cur);
+ case '}':
+ lc->started = 1;
+ return scanner_token(lc, cur);
case '-':
lc->started = 1;
next = scanner_getc(lc);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]