This is an automated email from the ASF dual-hosted git repository.
jgemignani pushed a commit to branch PG12
in repository https://gitbox.apache.org/repos/asf/age.git
The following commit(s) were added to refs/heads/PG12 by this push:
new 7e8522d1 Fixed case sensitivity on label usage of reserved keyword
(#1072)
7e8522d1 is described below
commit 7e8522d1ff998b5e3f095af904f00533f4022570
Author: Panagiotis Foliadis <[email protected]>
AuthorDate: Sat Jul 22 01:17:56 2023 +0300
Fixed case sensitivity on label usage of reserved keyword (#1072)
and added regression tests.
Fixed the case when a label was assigned a name of a
reserved keyword, resulting in the label being lowercase
regardless of the user input.
Signed-off-by: Panagiotis Foliadis<[email protected]>
---
regress/expected/cypher_create.out | 33 ++++++++++++++++++++++++++++++++-
regress/sql/cypher_create.sql | 18 ++++++++++++++++++
src/backend/parser/cypher_parser.c | 3 +++
3 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/regress/expected/cypher_create.out
b/regress/expected/cypher_create.out
index 9e5b1a24..91b95d39 100644
--- a/regress/expected/cypher_create.out
+++ b/regress/expected/cypher_create.out
@@ -765,13 +765,41 @@ $$) as (a agtype);
ERROR: variable e already exists
LINE 3: CREATE (p)-[e:new]->(a)
^
+-- Validate usage of keywords as labels is supported and case sensitive
+SELECT * FROM cypher('cypher_create', $$
+ CREATE (a:CREATE)
+ RETURN a
+$$) as (a agtype);
+ a
+-----------------------------------------------------------------------
+ {"id": 5348024557502465, "label": "CREATE", "properties": {}}::vertex
+(1 row)
+
+SELECT * FROM cypher('cypher_create', $$
+ CREATE (a:create)
+ RETURN a
+$$) as (a agtype);
+ a
+-----------------------------------------------------------------------
+ {"id": 5629499534213121, "label": "create", "properties": {}}::vertex
+(1 row)
+
+SELECT * FROM cypher('cypher_create', $$
+ CREATE (a:CrEaTe)
+ RETURN a
+$$) as (a agtype);
+ a
+-----------------------------------------------------------------------
+ {"id": 5910974510923777, "label": "CrEaTe", "properties": {}}::vertex
+(1 row)
+
--
-- Clean up
--
DROP TABLE simple_path;
DROP FUNCTION create_test;
SELECT drop_graph('cypher_create', true);
-NOTICE: drop cascades to 16 other objects
+NOTICE: drop cascades to 19 other objects
DETAIL: drop cascades to table cypher_create._ag_label_vertex
drop cascades to table cypher_create._ag_label_edge
drop cascades to table cypher_create.v
@@ -788,6 +816,9 @@ drop cascades to table cypher_create."Part"
drop cascades to table cypher_create.new
drop cascades to table cypher_create.node
drop cascades to table cypher_create.n1
+drop cascades to table cypher_create."CREATE"
+drop cascades to table cypher_create."create"
+drop cascades to table cypher_create."CrEaTe"
NOTICE: graph "cypher_create" has been dropped
drop_graph
------------
diff --git a/regress/sql/cypher_create.sql b/regress/sql/cypher_create.sql
index dd950698..8c9ac899 100644
--- a/regress/sql/cypher_create.sql
+++ b/regress/sql/cypher_create.sql
@@ -385,6 +385,24 @@ SELECT * FROM cypher('cypher_create', $$
CREATE (p)-[e:new]->(a)
$$) as (a agtype);
+
+-- Validate usage of keywords as labels is supported and case sensitive
+
+SELECT * FROM cypher('cypher_create', $$
+ CREATE (a:CREATE)
+ RETURN a
+$$) as (a agtype);
+
+SELECT * FROM cypher('cypher_create', $$
+ CREATE (a:create)
+ RETURN a
+$$) as (a agtype);
+
+SELECT * FROM cypher('cypher_create', $$
+ CREATE (a:CrEaTe)
+ RETURN a
+$$) as (a agtype);
+
--
-- Clean up
--
diff --git a/src/backend/parser/cypher_parser.c
b/src/backend/parser/cypher_parser.c
index c6a95d39..487f5607 100644
--- a/src/backend/parser/cypher_parser.c
+++ b/src/backend/parser/cypher_parser.c
@@ -77,6 +77,9 @@ int cypher_yylex(YYSTYPE *lvalp, YYLTYPE *llocp, ag_scanner_t
scanner)
* case sensitivity
*/
lvalp->keyword = GetScanKeyword(kwnum, &CypherKeyword);
+ ident = pstrdup(token.value.s);
+ truncate_identifier(ident, strlen(ident), true);
+ lvalp->string = ident;
*llocp = token.location;
return CypherKeywordTokens[kwnum];
}