Skip to content

Commit f0b8c2b

Browse files
k-rusdjatnieks
authored andcommitted
CNDB-13375 don't use keyspace name length in error message (#1639)
Part of riptano/cndb#13375 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. 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 8c43746 commit f0b8c2b

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
@@ -164,8 +164,8 @@ public void validate(ClientState state)
164164
super.validate(state);
165165

166166
if (!state.isInternal && tableName.length() > SchemaConstants.NAME_LENGTH - keyspaceName.length())
167-
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)",
168-
SchemaConstants.NAME_LENGTH, keyspaceName.length(), tableName.length(), keyspaceName, tableName);
167+
throw ire("Table name is too long, it needs to fit %s characters (got table name of %s chars for %s.%s)",
168+
SchemaConstants.NAME_LENGTH - keyspaceName.length(), tableName.length(), keyspaceName, tableName);
169169

170170
// Guardrail on table properties
171171
Guardrails.tableProperties.guard(attrs.updatedProperties(), attrs::removeProperty, state);

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)