Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 83466 invoked from network); 21 Aug 2006 20:31:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 21 Aug 2006 20:31:40 -0000 Received: (qmail 59161 invoked by uid 500); 21 Aug 2006 20:31:31 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 59112 invoked by uid 500); 21 Aug 2006 20:31:31 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 59044 invoked by uid 99); 21 Aug 2006 20:31:30 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Aug 2006 13:31:30 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 Aug 2006 13:31:29 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 12F8A1A981A; Mon, 21 Aug 2006 13:31:09 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r433349 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/sql/dictionary/SystemColumn.java impl/sql/catalog/DataDictionaryImpl.java impl/sql/catalog/SystemColumnImpl.java Date: Mon, 21 Aug 2006 20:31:08 -0000 To: derby-commits@db.apache.org From: djd@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060821203109.12F8A1A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: djd Date: Mon Aug 21 13:31:07 2006 New Revision: 433349 URL: http://svn.apache.org/viewvc?rev=433349&view=rev Log: DERBY-1734 (partial) Add some utilitiy static factory methods to SystemColumnImpl to allow easier building of system column lists for CatalogRowFactory. Remove column position (identifer) from SystemColumn since it was redundant information. Still passed in some constructors of SystemColumnImpl until all of the CatalogRowFactory implementations are modified to have cleaner buildColumnList methods. Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SystemColumn.java db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SystemColumnImpl.java Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SystemColumn.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SystemColumn.java?rev=433349&r1=433348&r2=433349&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SystemColumn.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SystemColumn.java Mon Aug 21 13:31:07 2006 @@ -40,13 +40,6 @@ * @return The column name. */ public String getName(); - - /** - * Gets the id of this column. - * - * @return The column id. - */ - public int getID(); /** * Return the type of this column. Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java?rev=433349&r1=433348&r2=433349&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java Mon Aug 21 13:31:07 2006 @@ -6505,7 +6505,7 @@ TableDescriptor td = getTableDescriptor(rowFactory.getCatalogName(), sd); theColumn = columns[columnNumber - 1]; // from 1 to 0 based - ColumnDescriptor cd = makeColumnDescriptor(theColumn, td ); + ColumnDescriptor cd = makeColumnDescriptor(theColumn, columnNumber, td ); columnName = cd.getColumnName(); cd.getType().setNullability(nullability); int[] columnNameColArray = new int[1]; @@ -6583,7 +6583,7 @@ columnID = newColumnIDs[ix]; currentColumn = columns[ columnID - 1 ]; // from 1 to 0 based - cdArray[ix] = makeColumnDescriptor( currentColumn, td ); + cdArray[ix] = makeColumnDescriptor( currentColumn, ix + 1, td ); } addDescriptorArray(cdArray, td, SYSCOLUMNS_CATALOG_NUM, false, tc); @@ -7215,7 +7215,8 @@ SanityManager.THROWASSERT("column "+columnNumber+" for table "+ti.getTableName()+" is null"); } } - cdlArray[columnNumber] = makeColumnDescriptor( column, td ); + cdlArray[columnNumber] = makeColumnDescriptor( column, + columnNumber + 1, td ); } addDescriptorArray(cdlArray, td, SYSCOLUMNS_CATALOG_NUM, false, tc); @@ -7229,6 +7230,7 @@ * Converts a SystemColumn to a ColumnDescriptor. * * @param column a SystemColumn + * @param columnPosition Position of the column in the table, one based. * @param td descriptor for table that column lives in * * @return a ColumnDes*criptor @@ -7236,12 +7238,13 @@ * @exception StandardException Standard Cloudscape error policy */ private ColumnDescriptor makeColumnDescriptor( SystemColumn column, + int columnPosition, TableDescriptor td ) throws StandardException { //RESOLVEAUTOINCREMENT return new ColumnDescriptor - (column.getName(), column.getID(), column.getType(), null, null, td, + (column.getName(), columnPosition, column.getType(), null, null, td, (UUID) null, // No defaults yet for system columns 0, 0 ); Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SystemColumnImpl.java URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SystemColumnImpl.java?rev=433349&r1=433348&r2=433349&view=diff ============================================================================== --- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SystemColumnImpl.java (original) +++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/SystemColumnImpl.java Mon Aug 21 13:31:07 2006 @@ -21,6 +21,8 @@ package org.apache.derby.impl.sql.catalog; +import java.sql.Types; + import org.apache.derby.iapi.sql.dictionary.SystemColumn; import org.apache.derby.iapi.error.StandardException; import org.apache.derby.iapi.types.DataTypeDescriptor; @@ -36,38 +38,123 @@ * @author Rick Hillegas */ -public class SystemColumnImpl implements SystemColumn +class SystemColumnImpl implements SystemColumn { private final String name; - private final int id; - + /** * Fully described type of the column. */ private final DataTypeDescriptor type; + + /** + * Create a system column for a builtin type. + * + * @param name + * name of column + * @param jdbcTypeId + * JDBC type id from java.sql.Types + * @param nullability + * Whether or not column accepts nulls. + */ + static SystemColumn getColumn(String name, int jdbcTypeId, + boolean nullability) { + return new SystemColumnImpl(name, DataTypeDescriptor + .getBuiltInDataTypeDescriptor(jdbcTypeId, nullability)); + } + + /** + * Create a system column for an identifer with consistent type of + * VARCHAR(128) + * + * @param name + * Name of the column. + * @param nullability + * Nullability of the column. + * @return Object representing the column. + */ + static SystemColumn getIdentifierColumn(String name, boolean nullability) { + return new SystemColumnImpl(name, DataTypeDescriptor + .getBuiltInDataTypeDescriptor(Types.VARCHAR, nullability, 128)); + } + + /** + * Create a system column for a character representation of a UUID with + * consistent type of CHAR(36) + * + * @param name + * Name of the column. + * @param nullability + * Nullability of the column. + * @return Object representing the column. + */ + static SystemColumn getUUIDColumn(String name, boolean nullability) { + return new SystemColumnImpl(name, DataTypeDescriptor + .getBuiltInDataTypeDescriptor(Types.CHAR, nullability, 36)); + } + + /** + * Create a system column for a character representation of an indicator + * column with consistent type of CHAR(1) NOT NULL + * + * @param name + * Name of the column. + * @return Object representing the column. + */ + static SystemColumn getIndicatorColumn(String name) { + return new SystemColumnImpl(name, DataTypeDescriptor + .getBuiltInDataTypeDescriptor(Types.CHAR, false, 1)); + } + + /** + * Create a system column for a java column. + * + * @param name + * Name of the column. + * @param javaClassName + * @param nullability + * Nullability of the column. + * @return Object representing the column. + */ + static SystemColumn getJavaColumn(String name, String javaClassName, + boolean nullability) { + + TypeId typeId = TypeId.getUserDefinedTypeId(javaClassName, false); + + DataTypeDescriptor dtd = new DataTypeDescriptor(typeId, nullability); + return new SystemColumnImpl(name, dtd); + } + + /** + * Create a SystemColumnImpl representing the given name and type. + */ + private SystemColumnImpl(String name, DataTypeDescriptor type) { + this.name = name; + this.type = type; + } /** - * Constructor to create a description of a column in a system table. - * - * @param name of column. - * @param id of column. - * @param precision of data in column. - * @param scale of data in column. - * @param nullability Whether or not column accepts nulls. - * @param dataType Datatype of column. - * @param maxLength Maximum length of data in column. - */ - public SystemColumnImpl( String name, + * Constructor to create a description of a column in a system table. + * + * @param name + * of column. + * @param id + * of column. + * @param nullability + * Whether or not column accepts nulls. + * @param dataType + * Datatype of column. + * @param maxLength + * Maximum length of data in column. + */ + SystemColumnImpl( String name, int id, - int precision, - int scale, boolean nullability, String dataType, boolean builtInType, int maxLength ) { this.name = name; - this.id = id; TypeId typeId; @@ -83,12 +170,23 @@ this.type = new DataTypeDescriptor( typeId, - precision, - scale, + 0, + 0, nullability, maxLength ); } + SystemColumnImpl( String name, + int id, + int ignoreP, + int ignoreS, + boolean nullability, + String dataType, + boolean builtInType, + int maxLength ) +{ + this(name, id, nullability, dataType, builtInType, maxLength); +} /** * Constructor to create a description of a column in a system table. @@ -98,11 +196,11 @@ * @param id of column. * @param nullability Whether or not column accepts nulls. */ - public SystemColumnImpl( String name, + SystemColumnImpl( String name, int id, boolean nullability) { - this(name, id, 0, 0, nullability, "VARCHAR", true, 128); + this(name, id, nullability, "VARCHAR", true, 128); } /** @@ -113,16 +211,6 @@ public String getName() { return name; - } - - /** - * Gets the id of this column. - * - * @return The column id. - */ - public int getID() - { - return id; } /**