db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lance J. Andersen" <Lance.Ander...@Sun.COM>
Subject Re: [PATCH] Change all Identifier Limitations to 128
Date Thu, 16 Dec 2004 15:53:45 GMT
If  the changes being made differ from the DB2 limits, and it does make 
sense to change this now that Derby is part of apache, I would pull the 
constants out of DB2Limit.java as this seems confusing from the outside 
looking in.



Philipp Hug wrote:

> this patch changes maximum length of column names, index/contraint 
> names, cursor names and schema names to 128 and keeps 
> MaxUserNameLength at 30.
> it also fixes the metadata to return correct values
>
> philipp
> Philipp Hug wrote:
>
>> I know this has been discussed before, but there hasn't been a consus 
>> if those limitations should be extended...
>> At the moment, I patched Derby to allow longer identifier for 
>> index/constraint names, because the CMP engine I'm using, uses 
>> getMaxColumnNameLength() as limitation for index name.
>> Does anyone know of any metadata attribute that would specify the 
>> maximum allowed length for an index/constraint name? If there is such 
>> an attribute, I could live with that and would just fix the CMP 
>> engine? Otherwise we should really think about extending it to a 
>> decent value (e.g. 30 or 128).
>>
>> btw: cloudscape 9 didn't have this limitation, it has been added in 
>> cloudscape 10/derby
>>
>> greets
>> philipp
>>
>------------------------------------------------------------------------
>
>Index: java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
>===================================================================
>--- java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj	(revision 111709)
>+++ java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj	(working copy)
>@@ -2648,8 +2648,8 @@
> 	String cursorName = null;
> }
> {
>-	//cursor names are limited to 18 characters
>-	<CURRENT> <OF> cursorName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH18,
true)
>+	//cursor names are limited to 128 characters
>+	<CURRENT> <OF> cursorName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128,
true)
> 	{ 
> 		return (FromTable) nodeFactory.getNode(
> 								C_NodeTypes.CURRENT_OF_NODE,
>@@ -3240,8 +3240,8 @@
> 	*/
> 
> 	/* identifier() used to be columnName() */
>-	//unqualified column names are limited to 30 characters
>-	columnName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH30, true) 
>+	//unqualified column names are limited to 128 characters
>+	columnName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128, true) 
> 		( typeDescriptor = dataTypeDDL() 
> 		)
> 	[ defaultNode = defaultAndConstraints(typeDescriptor, tableElementList, columnName,
autoIncrementInfo) ]
>@@ -4115,7 +4115,7 @@
> 		//limit the qualifiedId to the id length limit passed to this method
> 		checkIdentifierLengthLimit(qualifiedId, id_length_limit);
> 		if (schemaName != null)
>-			checkIdentifierLengthLimit(schemaName, DB2Limit.DB2_MAX_IDENTIFIER_LENGTH30);
>+			checkIdentifierLengthLimit(schemaName, DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128);
> 
> 		return (TableName) nodeFactory.getNode(
> 								nodeType,
>@@ -4418,8 +4418,8 @@
> }
> {
> 	/* identifier() used to be columnName() */
>-	//unqualified column names are limited to 30 characters
>-	[ <AS> ] columnName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH30, true)
>+	//unqualified column names are limited to 128 characters
>+	[ <AS> ] columnName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128, true)
> 	{
> 		return columnName;
> 	}
>@@ -6402,10 +6402,10 @@
> 			columnName = thirdName;
> 		}
> 
>-		//column name and schema name can not be longer than 30 characters and table name can
not be longer than 128 characters
>-		checkIdentifierLengthLimit(columnName, DB2Limit.DB2_MAX_IDENTIFIER_LENGTH30);
>+		//column name, schema name and table name can not be longer than 128 characters
>+		checkIdentifierLengthLimit(columnName, DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128);
> 		if (schemaName != null)
>-			checkIdentifierLengthLimit(schemaName, DB2Limit.DB2_MAX_IDENTIFIER_LENGTH30);
>+			checkIdentifierLengthLimit(schemaName, DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128);
> 		if (tableName != null)
> 			checkIdentifierLengthLimit(tableName, DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128);
> 
>@@ -6549,10 +6549,10 @@
> 			columnName = thirdName;
> 		}
> 
>-		//column name and schema name can not be longer than 30 characters and correlation
name can not be longer than 128 characters
>-		checkIdentifierLengthLimit(columnName, DB2Limit.DB2_MAX_IDENTIFIER_LENGTH30);
>+		//column name, schema name and correlation name can not be longer than 128 characters
>+		checkIdentifierLengthLimit(columnName, DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128);
> 		if (schemaName != null)
>-			checkIdentifierLengthLimit(schemaName, DB2Limit.DB2_MAX_IDENTIFIER_LENGTH30);
>+			checkIdentifierLengthLimit(schemaName, DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128);
> 		if (correlationName != null)
> 			checkIdentifierLengthLimit(correlationName, DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128);
> 		return (OrderByColumn) nodeFactory.getNode(
>@@ -6632,8 +6632,8 @@
> }
> {
> 	/* identifier() used to be columnName() */
>-	//unqualified column names are limited to 30 characters
>-	columnName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH30, true)
>+	//unqualified column names are limited to 128 characters
>+	columnName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128, true)
> 	{
> 		columnList.addElement(columnName);
> 	}
>@@ -7681,8 +7681,8 @@
> }
> {
> 	/* identifier() used to be columnName() */
>-	//unqualified column names are limited to 30 characters
>-	columnName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH30, true)
>+	//unqualified column names are limited to 128 characters
>+	columnName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128, true)
> 	{
> 		/*
> 		** Store the column names for the result columns in the
>@@ -7719,7 +7719,7 @@
> }
> {
> 	/* identifier never ends with a space; appending a space meaning desc */
>-	columnName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH30, true) [<ASC> | <DESC>
{columnName = columnName + ' ';}]
>+	columnName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128, true) [<ASC> |
<DESC> {columnName = columnName + ' ';}]
> 	{
> 		/*
> 		** Store the column names for the index columns in the
>@@ -8310,7 +8310,7 @@
> 	** We are not currently handling character set
> 	** specifications for schema, or schema bodies.
> 	*/
>-	<SCHEMA> schemaName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH30, true)
>+	<SCHEMA> schemaName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128, true)
> 	{
> 
> 		if (schemaName.startsWith("SYS"))
>@@ -8461,7 +8461,7 @@
> 	** production to get the grammar to work...
> 	*/
> 	[ unique = unique() ] <INDEX>
>-		indexName = qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH18) <ON> tableName
= qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128)
>+		indexName = qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128) <ON> tableName
= qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128)
> 				<LEFT_PAREN> indexColumnList(indexColumnList) <RIGHT_PAREN>
> 		[ properties = propertyList()]
> 	{
>@@ -8709,7 +8709,7 @@
> 	Object[] functionElements = new Object[9];
> }
> {
>-		<FUNCTION> functionName = qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH18)
>+		<FUNCTION> functionName = qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128)
> 		functionElements[0] = functionParameterList()
> 		<RETURNS> functionElements[8] = dataTypeCommon() 
> 		( routineElement(false, functionElements) ) +
>@@ -8839,7 +8839,7 @@
> 	Vector				refClause = null;
> }
> {
>-	<TRIGGER> triggerName = qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH18)
>+	<TRIGGER> triggerName = qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128)
> 	isBefore = beforeOrAfter()
> 		triggerEvent = triggerEvent(triggerColumns)		// { INSERT | DELETE | UPDATE [ colList
] }
> 		<ON> tableName = qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128)
>@@ -9491,7 +9491,7 @@
> }
> {
> 	/* changed constraintName() to qualifiedName() for compaction */
>-	<CONSTRAINT> constraintName = qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH18)
>+	<CONSTRAINT> constraintName = qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128)
> 	{
> 		return constraintName;
> 	}
>@@ -9599,7 +9599,7 @@
> 	String newIndexName;
> }
> {
>-	<INDEX> oldIndexName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH18, true)
<TO> newIndexName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH18, true)
>+	<INDEX> oldIndexName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128, true)
<TO> newIndexName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128, true)
> 	{
> 		QueryTreeNode qtn = nodeFactory.getNode(
> 								C_NodeTypes.RENAME_NODE,
>@@ -9889,7 +9889,7 @@
> 	String schemaName;
> }
> {
>-	schemaName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH30, true)
>+	schemaName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128, true)
> 	{
> 		return (QueryTreeNode) nodeFactory.getNode(
> 								C_NodeTypes.SET_SCHEMA_NODE,
>@@ -9917,7 +9917,7 @@
> |	schemaName = string()
> 	{
> 		/* Max length for schema name is DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128 */
>-		checkIdentifierLengthLimit(schemaName, DB2Limit.DB2_MAX_IDENTIFIER_LENGTH30);
>+		checkIdentifierLengthLimit(schemaName, DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128);
> 		return (QueryTreeNode) nodeFactory.getNode(
> 								C_NodeTypes.SET_SCHEMA_NODE,
> 								schemaName,
>@@ -10456,7 +10456,7 @@
> 	String schemaName;
> }
> {
>-	<SCHEMA> schemaName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH30, true) <RESTRICT>
>+	<SCHEMA> schemaName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128, true)
<RESTRICT>
> 	{
> 		QueryTreeNode stmt =  nodeFactory.getNode(
> 							C_NodeTypes.DROP_SCHEMA_NODE,
>@@ -10557,7 +10557,7 @@
> 	String newColumnName;
> }
> {
>-	oldColumnName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH30, true) <TO> newColumnName
= identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH30, true)
>+	oldColumnName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128, true) <TO> newColumnName
= identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128, true)
> 	{
> 		return (QueryTreeNode) nodeFactory.getNode(
> 							C_NodeTypes.RENAME_NODE,
>@@ -10600,7 +10600,7 @@
> 		return lockGranularity;
> 	}
> |
>-	<ALTER> [ <COLUMN> ] columnName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH30,
true) <SET>
>+	<ALTER> [ <COLUMN> ] columnName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128,
true) <SET>
> 		typeDescriptor = DB2AlterColumn(autoIncrementInfo)
> 	{
> 		changeType[0] = CreateStatementNode.MODIFY_TYPE;
>@@ -10660,7 +10660,7 @@
> 	TableElementNode tn;
> }
> {
>-	columnName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH30, true) tn = columnAlterClause(columnName)
>+	columnName = identifier(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128, true) tn = columnAlterClause(columnName)
> 	{
> 		return tn;
> 	}
>@@ -10763,7 +10763,7 @@
> {
> 	LOOKAHEAD( {getToken(2).kind == CONSTRAINT} )
> 	/* changed constraintName() to qualifiedName() for compaction */
>-	<DROP> <CONSTRAINT> constraintName = qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH18)
>+	<DROP> <CONSTRAINT> constraintName = qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128)
> 	{
> 		return (TableElementNode) nodeFactory.getNode(
> 						C_NodeTypes.CONSTRAINT_DEFINITION_NODE,
>@@ -10795,7 +10795,7 @@
> 	}
> |
> 	LOOKAHEAD( {getToken(2).kind == FOREIGN} )
>-        <DROP> <FOREIGN> <KEY> constraintName = qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH18)
>+        <DROP> <FOREIGN> <KEY> constraintName = qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128)
> 	{
> 		return (TableElementNode) nodeFactory.getNode(
> 						C_NodeTypes.CONSTRAINT_DEFINITION_NODE,
>@@ -10812,7 +10812,7 @@
> 	}
> |
> 	LOOKAHEAD( {getToken(2).kind == UNIQUE} )
>-        <DROP> <UNIQUE> constraintName = qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH18)
>+        <DROP> <UNIQUE> constraintName = qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128)
> 	{
> 		return (TableElementNode) nodeFactory.getNode(
> 						C_NodeTypes.CONSTRAINT_DEFINITION_NODE,
>@@ -10828,7 +10828,7 @@
> 						);
> 	}
> |
>-        <DROP> <CHECK> constraintName = qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH18)
>+        <DROP> <CHECK> constraintName = qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128)
> 	{
> 		return (TableElementNode) nodeFactory.getNode(
> 						C_NodeTypes.CONSTRAINT_DEFINITION_NODE,
>@@ -10874,7 +10874,7 @@
> 	TableName indexName;
> }
> {
>-	<INDEX> indexName = qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH18)
>+	<INDEX> indexName = qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128)
> 	{
> 		return (QueryTreeNode) nodeFactory.getNode(
> 								C_NodeTypes.DROP_INDEX_NODE,
>@@ -10940,7 +10940,7 @@
> 	TableName triggerName;
> }
> {
>-	<TRIGGER> triggerName = qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH18) 
>+	<TRIGGER> triggerName = qualifiedName(DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128) 
> 	{
> 		return (QueryTreeNode) nodeFactory.getNode(
> 								C_NodeTypes.DROP_TRIGGER_NODE,
>Index: java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java
>===================================================================
>--- java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java	(revision 111709)
>+++ java/engine/org/apache/derby/impl/jdbc/EmbedDatabaseMetaData.java	(working copy)
>@@ -1108,7 +1108,7 @@
>      * @return max literal length
>      */
> 	public int getMaxColumnNameLength() {
>-		return DB2Limit.DB2_MAX_IDENTIFIER_LENGTH30;
>+		return DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128;
> 	}
> 
>     /**
>@@ -1173,7 +1173,7 @@
>      * @return max cursor name length in bytes
>      */
> 	public int getMaxCursorNameLength() {
>-		return DB2Limit.DB2_MAX_IDENTIFIER_LENGTH18;
>+		return DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128;
> 	}
> 
>     /**
>@@ -1191,7 +1191,7 @@
>      * @return max name length in bytes
>      */
> 	public int getMaxSchemaNameLength()  {
>-		return DB2Limit.DB2_MAX_IDENTIFIER_LENGTH30;
>+		return DB2Limit.DB2_MAX_IDENTIFIER_LENGTH128;
> 	}
> 
>     /**
>@@ -1274,7 +1274,7 @@
>      * @return max name length  in bytes
>      */
> 	public int getMaxUserNameLength() {
>-		return DB2Limit.DB2_MAX_IDENTIFIER_LENGTH30;
>+		return DB2Limit.MAX_USERID_LENGTH;
> 	}
> 
>     //----------------------------------------------------------------------
>Index: java/engine/org/apache/derby/iapi/reference/DB2Limit.java
>===================================================================
>--- java/engine/org/apache/derby/iapi/reference/DB2Limit.java	(revision 111709)
>+++ java/engine/org/apache/derby/iapi/reference/DB2Limit.java	(working copy)
>@@ -53,12 +53,7 @@
> 	// SQLCAMESSAGE procedure. See org.apache.derby.impl.sql.catalog.
> 	public static final int DB2_JCC_MAX_EXCEPTION_PARAM_LENGTH = 2400;
> 
>-	/* Some identifiers like Constraint name, Cursor name, Function name, Index name, Trigger
name
>-	* are limited to 18 character in DB2*/
>-	public static final int DB2_MAX_IDENTIFIER_LENGTH18 = 18;
>-	/* Some identifiers like Column name, Schema name are limited to 30 characters in DB2*/
>-	public static final int DB2_MAX_IDENTIFIER_LENGTH30 = 30;
>-	/* Some identifiers like Savepoint names, Table names, view names etc are limited to
128 characters in DB2*/
>+	/* Some identifiers like Constraint name, Cursor name, Function name, Index name, Trigger
name, Column name, Schema name, Savepoint names, Table names, view names etc are limited to
128 characters in DB2*/
> 	public static final int DB2_MAX_IDENTIFIER_LENGTH128 = 128;
> 	public static final int	DB2_CHAR_MAXWIDTH = 254;
> 	public static final int	DB2_VARCHAR_MAXWIDTH = 32672;
>  
>

Mime
View raw message