You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2021/07/08 14:21:03 UTC

[GitHub] [cassandra] adelapena opened a new pull request #1105: CASANDRA-15663 (3.11) DESCRIBE KEYSPACE does not properly quote table names

adelapena opened a new pull request #1105:
URL: https://github.com/apache/cassandra/pull/1105


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] Gerrrr commented on a change in pull request #1105: CASANDRA-15663 (3.11) DESCRIBE KEYSPACE does not properly quote table names

Posted by GitBox <gi...@apache.org>.
Gerrrr commented on a change in pull request #1105:
URL: https://github.com/apache/cassandra/pull/1105#discussion_r666487619



##########
File path: src/antlr/Lexer.g
##########
@@ -56,7 +56,8 @@ lexer grammar Lexer;
 }
 
 // Case-insensitive keywords
-// When adding a new reserved keyword, add entry to o.a.c.cql3.ReservedKeywords as well
+// When adding a new reserved keyword, add entry to o.a.c.cql3.ReservedKeywords and
+// pylib/cqlshlib/cqlhandling.py::CqlParsingRuleSet.cql_keywords_reserved as well

Review comment:
       Fixed in https://github.com/apache/cassandra/pull/1105/commits/489fe9db380d055e2b350b2c457a1fd6e0e4859b#diff-30dc21e0dca41aab4d29072667b449dc39157d645ebba1297d0ca12ef62b713eL58-R61.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] Gerrrr commented on a change in pull request #1105: CASANDRA-15663 (3.11) DESCRIBE KEYSPACE does not properly quote table names

Posted by GitBox <gi...@apache.org>.
Gerrrr commented on a change in pull request #1105:
URL: https://github.com/apache/cassandra/pull/1105#discussion_r666487123



##########
File path: pylib/cqlshlib/cqlhandling.py
##########
@@ -18,11 +18,58 @@
 # i.e., stuff that's not necessarily cqlsh-specific
 
 import traceback
-from cassandra.metadata import cql_keywords_reserved
+import cassandra
 from . import pylexotron, util
 
 Hint = pylexotron.Hint
 
+cql_keywords = set((
+    'add', 'aggregate', 'all', 'allow', 'alter', 'and', 'apply', 'as', 'asc', 'ascii', 'authorize', 'batch', 'begin',
+    'bigint', 'blob', 'boolean', 'by', 'called', 'cast', 'clustering', 'columnfamily', 'compact', 'contains', 'count',
+    'counter', 'create', 'custom', 'date', 'decimal', 'default', 'delete', 'desc', 'describe', 'distinct', 'double',
+    'drop', 'duration', 'entries', 'execute', 'exists', 'filtering', 'finalfunc', 'float', 'from', 'frozen', 'full',
+    'function', 'functions', 'grant', 'group', 'if', 'in', 'index', 'inet', 'infinity', 'initcond', 'input', 'insert',
+    'int', 'into', 'is', 'json', 'key', 'keys', 'keyspace', 'keyspaces', 'language', 'like', 'limit', 'list', 'login',
+    'map', 'materialized', 'mbean', 'mbeans', 'modify', 'nan', 'nologin', 'norecursive', 'nosuperuser', 'not', 'null',
+    'of', 'on', 'options', 'or', 'order', 'partition', 'password', 'per', 'permission', 'permissions', 'primary',
+    'rename', 'replace', 'returns', 'revoke', 'role', 'roles', 'schema', 'select', 'set', 'sfunc', 'smallint', 'static',
+    'storage', 'stype', 'superuser', 'table', 'text', 'time', 'timestamp', 'timeuuid', 'tinyint', 'to', 'token',
+    'trigger', 'truncate', 'ttl', 'tuple', 'type', 'unlogged', 'unset', 'update', 'use', 'user', 'users', 'using',
+    'uuid', 'values', 'varchar', 'varint', 'view', 'where', 'with', 'writetime'
+))
+"""
+Set of keywords in CQL.
+
+Derived from .../cassandra/src/java/org/apache/cassandra/cql3/Lexer.g
+"""
+
+cql_keywords_unreserved = set((
+    'aggregate', 'all', 'as', 'called', 'clustering', 'compact', 'contains', 'custom', 'exists', 'filtering',
+    'finalfunc', 'frozen', 'function', 'functions', 'group', 'initcond', 'input', 'keys', 'keyspaces', 'language',
+    'like', 'list', 'login', 'map', 'nologin', 'nosuperuser', 'options', 'partition', 'password', 'per', 'permission',
+    'permissions', 'returns', 'role', 'roles', 'sfunc', 'static', 'storage', 'stype', 'superuser', 'trigger', 'tuple',
+    'type', 'user', 'users', 'values'
+))
+"""
+Set of unreserved keywords in CQL.
+
+Derived from .../cassandra/src/java/org/apache/cassandra/cql3/Parser.g
+"""

Review comment:
       Fixed in https://github.com/apache/cassandra/pull/1105/commits/489fe9db380d055e2b350b2c457a1fd6e0e4859b#diff-161e810fc6b29acd5307d1edbd01b314b7590c41eb92bbf6b18766588e0e0ef4L26-L58.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] Gerrrr commented on a change in pull request #1105: CASANDRA-15663 (3.11) DESCRIBE KEYSPACE does not properly quote table names

Posted by GitBox <gi...@apache.org>.
Gerrrr commented on a change in pull request #1105:
URL: https://github.com/apache/cassandra/pull/1105#discussion_r666487724



##########
File path: src/java/org/apache/cassandra/cql3/ReservedKeywords.java
##########
@@ -18,83 +18,46 @@
 
 package org.apache.cassandra.cql3;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
 import java.util.Set;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableSet;
 
+import org.apache.cassandra.exceptions.ConfigurationException;
+
 class ReservedKeywords
 {
-    @VisibleForTesting
-    static final String[] reservedKeywords = new String[]
-                                                     {
-                                                     "SELECT",
-                                                     "FROM",
-                                                     "WHERE",
-                                                     "AND",
-                                                     "ENTRIES",
-                                                     "FULL",
-                                                     "INSERT",
-                                                     "UPDATE",
-                                                     "WITH",
-                                                     "LIMIT",
-                                                     "USING",
-                                                     "USE",
-                                                     "SET",
-                                                     "BEGIN",
-                                                     "UNLOGGED",
-                                                     "BATCH",
-                                                     "APPLY",
-                                                     "TRUNCATE",
-                                                     "DELETE",
-                                                     "IN",
-                                                     "CREATE",
-                                                     "KEYSPACE",
-                                                     "SCHEMA",
-                                                     "COLUMNFAMILY",
-                                                     "TABLE",
-                                                     "MATERIALIZED",
-                                                     "VIEW",
-                                                     "INDEX",
-                                                     "ON",
-                                                     "TO",
-                                                     "DROP",
-                                                     "PRIMARY",
-                                                     "INTO",
-                                                     "ALTER",
-                                                     "RENAME",
-                                                     "ADD",
-                                                     "ORDER",
-                                                     "BY",
-                                                     "ASC",
-                                                     "DESC",
-                                                     "ALLOW",
-                                                     "IF",
-                                                     "IS",
-                                                     "GRANT",
-                                                     "OF",
-                                                     "REVOKE",
-                                                     "MODIFY",
-                                                     "AUTHORIZE",
-                                                     "DESCRIBE",
-                                                     "EXECUTE",
-                                                     "NORECURSIVE",
-                                                     "TOKEN",
-                                                     "NULL",
-                                                     "NOT",
-                                                     "NAN",
-                                                     "INFINITY",
-                                                     "OR",
-                                                     "REPLACE",
-                                                     "DEFAULT",
-                                                     "UNSET",
-                                                     "MBEAN",
-                                                     "MBEANS"};
 
-    private static final Set<String> reservedSet = ImmutableSet.copyOf(reservedKeywords);
+    private static final String FILE_NAME = "reserved_keywords.txt";
+
+    static final Set<String> reservedKeywords = getFromResource();

Review comment:
       Fixed in https://github.com/apache/cassandra/pull/1105/commits/489fe9db380d055e2b350b2c457a1fd6e0e4859b#diff-1502b99515caea9cb7adc7f530e8fede2dcb1bd640ea322e78ed289526188bd4R38.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] adelapena commented on a change in pull request #1105: CASANDRA-15663 (3.11) DESCRIBE KEYSPACE does not properly quote table names

Posted by GitBox <gi...@apache.org>.
adelapena commented on a change in pull request #1105:
URL: https://github.com/apache/cassandra/pull/1105#discussion_r666242355



##########
File path: src/antlr/Lexer.g
##########
@@ -56,7 +56,8 @@ lexer grammar Lexer;
 }
 
 // Case-insensitive keywords
-// When adding a new reserved keyword, add entry to o.a.c.cql3.ReservedKeywords as well
+// When adding a new reserved keyword, add entry to o.a.c.cql3.ReservedKeywords and
+// pylib/cqlshlib/cqlhandling.py::CqlParsingRuleSet.cql_keywords_reserved as well

Review comment:
       Nit: I think it's `pylib/cqlshlib/cqlhandling.py::cql_keywords_reserved`

##########
File path: pylib/cqlshlib/cqlhandling.py
##########
@@ -18,11 +18,58 @@
 # i.e., stuff that's not necessarily cqlsh-specific
 
 import traceback
-from cassandra.metadata import cql_keywords_reserved
+import cassandra
 from . import pylexotron, util
 
 Hint = pylexotron.Hint
 
+cql_keywords = set((
+    'add', 'aggregate', 'all', 'allow', 'alter', 'and', 'apply', 'as', 'asc', 'ascii', 'authorize', 'batch', 'begin',
+    'bigint', 'blob', 'boolean', 'by', 'called', 'cast', 'clustering', 'columnfamily', 'compact', 'contains', 'count',
+    'counter', 'create', 'custom', 'date', 'decimal', 'default', 'delete', 'desc', 'describe', 'distinct', 'double',
+    'drop', 'duration', 'entries', 'execute', 'exists', 'filtering', 'finalfunc', 'float', 'from', 'frozen', 'full',
+    'function', 'functions', 'grant', 'group', 'if', 'in', 'index', 'inet', 'infinity', 'initcond', 'input', 'insert',
+    'int', 'into', 'is', 'json', 'key', 'keys', 'keyspace', 'keyspaces', 'language', 'like', 'limit', 'list', 'login',
+    'map', 'materialized', 'mbean', 'mbeans', 'modify', 'nan', 'nologin', 'norecursive', 'nosuperuser', 'not', 'null',
+    'of', 'on', 'options', 'or', 'order', 'partition', 'password', 'per', 'permission', 'permissions', 'primary',
+    'rename', 'replace', 'returns', 'revoke', 'role', 'roles', 'schema', 'select', 'set', 'sfunc', 'smallint', 'static',
+    'storage', 'stype', 'superuser', 'table', 'text', 'time', 'timestamp', 'timeuuid', 'tinyint', 'to', 'token',
+    'trigger', 'truncate', 'ttl', 'tuple', 'type', 'unlogged', 'unset', 'update', 'use', 'user', 'users', 'using',
+    'uuid', 'values', 'varchar', 'varint', 'view', 'where', 'with', 'writetime'
+))
+"""
+Set of keywords in CQL.
+
+Derived from .../cassandra/src/java/org/apache/cassandra/cql3/Lexer.g
+"""
+
+cql_keywords_unreserved = set((
+    'aggregate', 'all', 'as', 'called', 'clustering', 'compact', 'contains', 'custom', 'exists', 'filtering',
+    'finalfunc', 'frozen', 'function', 'functions', 'group', 'initcond', 'input', 'keys', 'keyspaces', 'language',
+    'like', 'list', 'login', 'map', 'nologin', 'nosuperuser', 'options', 'partition', 'password', 'per', 'permission',
+    'permissions', 'returns', 'role', 'roles', 'sfunc', 'static', 'storage', 'stype', 'superuser', 'trigger', 'tuple',
+    'type', 'user', 'users', 'values'
+))
+"""
+Set of unreserved keywords in CQL.
+
+Derived from .../cassandra/src/java/org/apache/cassandra/cql3/Parser.g
+"""

Review comment:
       As mentioned on the Jira ticket, I think we only need to override `cql_keywords_reserved`

##########
File path: src/java/org/apache/cassandra/cql3/ReservedKeywords.java
##########
@@ -18,83 +18,46 @@
 
 package org.apache.cassandra.cql3;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
 import java.util.Set;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableSet;
 
+import org.apache.cassandra.exceptions.ConfigurationException;
+
 class ReservedKeywords
 {
-    @VisibleForTesting
-    static final String[] reservedKeywords = new String[]
-                                                     {
-                                                     "SELECT",
-                                                     "FROM",
-                                                     "WHERE",
-                                                     "AND",
-                                                     "ENTRIES",
-                                                     "FULL",
-                                                     "INSERT",
-                                                     "UPDATE",
-                                                     "WITH",
-                                                     "LIMIT",
-                                                     "USING",
-                                                     "USE",
-                                                     "SET",
-                                                     "BEGIN",
-                                                     "UNLOGGED",
-                                                     "BATCH",
-                                                     "APPLY",
-                                                     "TRUNCATE",
-                                                     "DELETE",
-                                                     "IN",
-                                                     "CREATE",
-                                                     "KEYSPACE",
-                                                     "SCHEMA",
-                                                     "COLUMNFAMILY",
-                                                     "TABLE",
-                                                     "MATERIALIZED",
-                                                     "VIEW",
-                                                     "INDEX",
-                                                     "ON",
-                                                     "TO",
-                                                     "DROP",
-                                                     "PRIMARY",
-                                                     "INTO",
-                                                     "ALTER",
-                                                     "RENAME",
-                                                     "ADD",
-                                                     "ORDER",
-                                                     "BY",
-                                                     "ASC",
-                                                     "DESC",
-                                                     "ALLOW",
-                                                     "IF",
-                                                     "IS",
-                                                     "GRANT",
-                                                     "OF",
-                                                     "REVOKE",
-                                                     "MODIFY",
-                                                     "AUTHORIZE",
-                                                     "DESCRIBE",
-                                                     "EXECUTE",
-                                                     "NORECURSIVE",
-                                                     "TOKEN",
-                                                     "NULL",
-                                                     "NOT",
-                                                     "NAN",
-                                                     "INFINITY",
-                                                     "OR",
-                                                     "REPLACE",
-                                                     "DEFAULT",
-                                                     "UNSET",
-                                                     "MBEAN",
-                                                     "MBEANS"};
 
-    private static final Set<String> reservedSet = ImmutableSet.copyOf(reservedKeywords);
+    private static final String FILE_NAME = "reserved_keywords.txt";
+
+    static final Set<String> reservedKeywords = getFromResource();

Review comment:
       Nit: we have missed the `@VisibleForTesting`annotation for `reservedKeywords `




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


[GitHub] [cassandra] adelapena closed pull request #1105: CASANDRA-15663 (3.11) DESCRIBE KEYSPACE does not properly quote table names

Posted by GitBox <gi...@apache.org>.
adelapena closed pull request #1105:
URL: https://github.com/apache/cassandra/pull/1105


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org