Skip to content

Commit f6260d5

Browse files
authored
CNDB-13375 don't use keyspace name length in error message (#1639)
Part of riptano/cndb#13375 ### What is the issue Using keyspace name length in the error message for too long table name is confusing, since the length might include CNDB's generated prefix invisible to users. ### What does this PR fix and why was it fixed Reformulates the error message for too long table name to avoid using the keyspace name length, since it might contain CNDB generated prefix, which is not visible to users.
1 parent f0ed83e commit f6260d5

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/java/org/apache/cassandra/cql3/statements/schema/CreateTableStatement.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ public void validate(QueryState state)
110110
super.validate(state);
111111

112112
if (!state.getClientState().isInternal && tableName.length() > SchemaConstants.NAME_LENGTH - keyspaceName.length())
113-
throw ire("Keyspace and table names combined shouldn't be more than %s characters long (got keyspace of %s chars and table of %s chars for %s.%s)",
114-
SchemaConstants.NAME_LENGTH, keyspaceName.length(), tableName.length(), keyspaceName, tableName);
113+
throw ire("Table name is too long, it needs to fit %s characters (got table name of %s chars for %s.%s)",
114+
SchemaConstants.NAME_LENGTH - keyspaceName.length(), tableName.length(), keyspaceName, tableName);
115115

116116
// Some tools use CreateTableStatement, and the guardrails below both don't make too much sense for tools and
117117
// require the server to be initialized, so skipping them if it isn't.

test/unit/org/apache/cassandra/schema/CreateTableValidationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ public void failCreatingNewTableWithLongName()
113113
"key int PRIMARY KEY," +
114114
"val int)",
115115
KEYSPACE, table)))
116-
.withMessageContaining(String.format("Keyspace and table names combined shouldn't be more than %s characters long (got keyspace of %s chars and table of %s chars for %s.%s)",
117-
SchemaConstants.NAME_LENGTH, KEYSPACE.length(), table.length(), KEYSPACE, table));
116+
.withMessageContaining(String.format("Table name is too long, it needs to fit %s characters (got table name of %s chars for %s.%s)",
117+
SchemaConstants.NAME_LENGTH - KEYSPACE.length(), table.length(), KEYSPACE, table));
118118
}
119119

120120
@Test

0 commit comments

Comments
 (0)