Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / MyDerby-10.3 / java / engine / org / apache / derby / impl / sql / catalog / SYSCONSTRAINTSRowFactory.java
diff --git a/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/impl/sql/catalog/SYSCONSTRAINTSRowFactory.java b/JMCR-Stable/real-world application/MyDerby-10.3/java/engine/org/apache/derby/impl/sql/catalog/SYSCONSTRAINTSRowFactory.java
new file mode 100644 (file)
index 0000000..562f63d
--- /dev/null
@@ -0,0 +1,684 @@
+/*\r
+\r
+   Derby - Class org.apache.derby.impl.sql.catalog.SYSCONSTRAINTSRowFactory\r
+\r
+   Licensed to the Apache Software Foundation (ASF) under one or more\r
+   contributor license agreements.  See the NOTICE file distributed with\r
+   this work for additional information regarding copyright ownership.\r
+   The ASF licenses this file to you under the Apache License, Version 2.0\r
+   (the "License"); you may not use this file except in compliance with\r
+   the License.  You may obtain a copy of the License at\r
+\r
+      http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+*/\r
+\r
+package org.apache.derby.impl.sql.catalog;\r
+\r
+import java.sql.Types;\r
+\r
+import org.apache.derby.catalog.UUID;\r
+import org.apache.derby.iapi.error.StandardException;\r
+import org.apache.derby.iapi.services.sanity.SanityManager;\r
+import org.apache.derby.iapi.services.uuid.UUIDFactory;\r
+import org.apache.derby.iapi.sql.dictionary.CatalogRowFactory;\r
+import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;\r
+import org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor;\r
+import org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator;\r
+import org.apache.derby.iapi.sql.dictionary.DataDictionary;\r
+import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;\r
+import org.apache.derby.iapi.sql.dictionary.SubCheckConstraintDescriptor;\r
+import org.apache.derby.iapi.sql.dictionary.SubConstraintDescriptor;\r
+import org.apache.derby.iapi.sql.dictionary.SubKeyConstraintDescriptor;\r
+import org.apache.derby.iapi.sql.dictionary.SystemColumn;\r
+import org.apache.derby.iapi.sql.dictionary.TableDescriptor;\r
+import org.apache.derby.iapi.sql.dictionary.TupleDescriptor;\r
+import org.apache.derby.iapi.sql.execute.ExecRow;\r
+import org.apache.derby.iapi.sql.execute.ExecutionFactory;\r
+import org.apache.derby.iapi.types.DataValueDescriptor;\r
+import org.apache.derby.iapi.types.DataValueFactory;\r
+import org.apache.derby.iapi.types.SQLChar;\r
+import org.apache.derby.iapi.types.SQLVarchar;\r
+\r
+/**\r
+ * Factory for creating a SYSCONTRAINTS row.\r
+ *\r
+ */\r
+\r
+public class SYSCONSTRAINTSRowFactory extends CatalogRowFactory\r
+{\r
+       private static final String             TABLENAME_STRING = "SYSCONSTRAINTS";\r
+\r
+       protected static final int              SYSCONSTRAINTS_COLUMN_COUNT = 7;\r
+       protected static final int              SYSCONSTRAINTS_CONSTRAINTID = 1;\r
+       protected static final int              SYSCONSTRAINTS_TABLEID = 2;\r
+       protected static final int              SYSCONSTRAINTS_CONSTRAINTNAME = 3;\r
+       protected static final int              SYSCONSTRAINTS_TYPE = 4;\r
+       protected static final int              SYSCONSTRAINTS_SCHEMAID = 5;\r
+       protected static final int              SYSCONSTRAINTS_STATE = ConstraintDescriptor.SYSCONSTRAINTS_STATE_FIELD;\r
+       protected static final int              SYSCONSTRAINTS_REFERENCECOUNT = 7;\r
+\r
+       protected static final int              SYSCONSTRAINTS_INDEX1_ID = 0;\r
+       protected static final int              SYSCONSTRAINTS_INDEX2_ID = 1;\r
+       protected static final int              SYSCONSTRAINTS_INDEX3_ID = 2;\r
+\r
+    private    static  final   boolean[]       uniqueness = {\r
+                                                              true,\r
+                                                                                                          true,\r
+                                                                                                          false\r
+                                                        };\r
+\r
+       private static final int[][] indexColumnPositions =\r
+       {\r
+               {SYSCONSTRAINTS_CONSTRAINTID},\r
+               {SYSCONSTRAINTS_CONSTRAINTNAME, SYSCONSTRAINTS_SCHEMAID},\r
+               {SYSCONSTRAINTS_TABLEID}\r
+       };\r
+\r
+       private static  final   String[]        uuids =\r
+       {\r
+                "8000002f-00d0-fd77-3ed8-000a0a0b1900" // catalog UUID\r
+               ,"80000036-00d0-fd77-3ed8-000a0a0b1900" // heap UUID\r
+               ,"80000031-00d0-fd77-3ed8-000a0a0b1900" // SYSCONSTRAINTS_INDEX1\r
+               ,"80000033-00d0-fd77-3ed8-000a0a0b1900" // SYSCONSTRAINTS_INDEX2\r
+               ,"80000035-00d0-fd77-3ed8-000a0a0b1900" // SYSCONSTRAINTS_INDEX3\r
+       };\r
+\r
+       /////////////////////////////////////////////////////////////////////////////\r
+       //\r
+       //      CONSTRUCTORS\r
+       //\r
+       /////////////////////////////////////////////////////////////////////////////\r
+\r
+    SYSCONSTRAINTSRowFactory(UUIDFactory uuidf, ExecutionFactory ef, DataValueFactory dvf)\r
+       {\r
+               super(uuidf,ef,dvf);\r
+               initInfo(SYSCONSTRAINTS_COLUMN_COUNT, TABLENAME_STRING, \r
+                                indexColumnPositions, uniqueness, uuids );\r
+       }\r
+\r
+       /////////////////////////////////////////////////////////////////////////////\r
+       //\r
+       //      METHODS\r
+       //\r
+       /////////////////////////////////////////////////////////////////////////////\r
+\r
+  /**\r
+        * Make a SYSCONTRAINTS row\r
+        *\r
+        * @return      Row suitable for inserting into SYSCONTRAINTS.\r
+        *\r
+        * @exception   StandardException thrown on failure\r
+        */\r
+       public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent)\r
+                                       throws StandardException \r
+       {\r
+               DataValueDescriptor             col;\r
+               ExecRow                                 row;\r
+               int                                             constraintIType;\r
+               UUID                                    oid;\r
+               String                                  constraintSType = null;\r
+               String                                  constraintID = null;\r
+               String                                  tableID = null;\r
+               String                                  constraintName = null;\r
+               String                                  schemaID = null;\r
+               boolean                                 isEnabled = true;\r
+               int                                             referenceCount = 0;\r
+\r
+               if (td != null)\r
+               {\r
+                       ConstraintDescriptor constraint = (ConstraintDescriptor)td;\r
+                       /*\r
+                       ** We only allocate a new UUID if the descriptor doesn't already have one.\r
+                       ** For descriptors replicated from a Source system, we already have an UUID.\r
+                       */\r
+                       oid = constraint.getUUID();\r
+                       constraintID = oid.toString();\r
+\r
+                       oid = constraint.getTableId();\r
+                       tableID = oid.toString();\r
+\r
+                       constraintName = constraint.getConstraintName();\r
+\r
+                       constraintIType = constraint.getConstraintType();\r
+                       switch (constraintIType)\r
+                       {\r
+                           case DataDictionary.PRIMARYKEY_CONSTRAINT:\r
+                                   constraintSType = "P";\r
+                                       break;\r
+\r
+                           case DataDictionary.UNIQUE_CONSTRAINT:\r
+                                       constraintSType = "U";\r
+                                       break;\r
+\r
+                           case DataDictionary.CHECK_CONSTRAINT:\r
+                                       constraintSType = "C";\r
+                                       break;\r
+\r
+                           case DataDictionary.FOREIGNKEY_CONSTRAINT:\r
+                                       constraintSType = "F";\r
+                                       break;\r
+\r
+                           default:\r
+                                       if (SanityManager.DEBUG)\r
+                                       {\r
+                                               SanityManager.THROWASSERT("invalid constraint type");\r
+                                       }\r
+                       }\r
+\r
+                       schemaID = constraint.getSchemaDescriptor().getUUID().toString();\r
+                       isEnabled = constraint.isEnabled();\r
+                       referenceCount = constraint.getReferenceCount();\r
+               }\r
+\r
+               /* Insert info into sysconstraints */\r
+\r
+               /* RESOLVE - It would be nice to require less knowledge about sysconstraints\r
+                * and have this be more table driven.\r
+                */\r
+\r
+               /* Build the row to insert  */\r
+               row = getExecutionFactory().getValueRow(SYSCONSTRAINTS_COLUMN_COUNT);\r
+\r
+               /* 1st column is CONSTRAINTID (UUID - char(36)) */\r
+               row.setColumn(SYSCONSTRAINTS_CONSTRAINTID, new SQLChar(constraintID));\r
+\r
+               /* 2nd column is TABLEID (UUID - char(36)) */\r
+               row.setColumn(SYSCONSTRAINTS_TABLEID, new SQLChar(tableID));\r
+\r
+               /* 3rd column is NAME (varchar(128)) */\r
+               row.setColumn(SYSCONSTRAINTS_CONSTRAINTNAME, new SQLVarchar(constraintName));\r
+\r
+               /* 4th column is TYPE (char(1)) */\r
+               row.setColumn(SYSCONSTRAINTS_TYPE, new SQLChar(constraintSType));\r
+\r
+               /* 5th column is SCHEMAID (UUID - char(36)) */\r
+               row.setColumn(SYSCONSTRAINTS_SCHEMAID, new SQLChar(schemaID));\r
+\r
+               /* 6th column is STATE (char(1)) */\r
+               row.setColumn(SYSCONSTRAINTS_STATE, new SQLChar(isEnabled ? "E" : "D"));\r
+\r
+               /* 7th column is REFERENCED */\r
+               row.setColumn(SYSCONSTRAINTS_REFERENCECOUNT, dvf.getDataValue(referenceCount));\r
+\r
+               return row;\r
+       }\r
+\r
+\r
+       ///////////////////////////////////////////////////////////////////////////\r
+       //\r
+       //      ABSTRACT METHODS TO BE IMPLEMENTED BY CHILDREN OF CatalogRowFactory\r
+       //\r
+       ///////////////////////////////////////////////////////////////////////////\r
+\r
+       /**\r
+        * Make a ConstraintDescriptor out of a SYSCONSTRAINTS row\r
+        *\r
+        * @param row a SYSCONSTRAINTS row\r
+        * @param parentTupleDescriptor Subconstraint descriptor with auxiliary info.\r
+        * @param dd dataDictionary\r
+        *\r
+        * @exception   StandardException thrown on failure\r
+        */\r
+       public TupleDescriptor buildDescriptor(\r
+               ExecRow                                 row,\r
+               TupleDescriptor                 parentTupleDescriptor,\r
+               DataDictionary                  dd )\r
+                                       throws StandardException\r
+       {\r
+               ConstraintDescriptor constraintDesc = null;\r
+\r
+               if (SanityManager.DEBUG)\r
+               {\r
+                       SanityManager.ASSERT(\r
+                               row.nColumns() == SYSCONSTRAINTS_COLUMN_COUNT, \r
+                               "Wrong number of columns for a SYSCONSTRAINTS row");\r
+               }\r
+\r
+               DataValueDescriptor     col;\r
+               ConglomerateDescriptor conglomDesc;\r
+               DataDescriptorGenerator ddg;\r
+               TableDescriptor         td = null;\r
+               int                                     constraintIType = -1;\r
+               int[]                           keyColumns = null;\r
+               UUID                            constraintUUID;\r
+               UUID                            schemaUUID;\r
+               UUID                            tableUUID;\r
+               UUID                            referencedConstraintId = null; \r
+               SchemaDescriptor        schema;\r
+               String                          tableUUIDString;\r
+               String                          constraintName;\r
+               String                          constraintSType;\r
+               String                          constraintStateStr;\r
+               boolean                         constraintEnabled;\r
+               int                                     referenceCount;\r
+               String                          constraintUUIDString;\r
+               String                          schemaUUIDString;\r
+               SubConstraintDescriptor scd;\r
+\r
+               if (SanityManager.DEBUG)\r
+               {\r
+                       if (!(parentTupleDescriptor instanceof SubConstraintDescriptor))\r
+                       {\r
+                               SanityManager.THROWASSERT(\r
+                                       "parentTupleDescriptor expected to be instanceof " +\r
+                                       "SubConstraintDescriptor, not " +\r
+                                       parentTupleDescriptor.getClass().getName());\r
+                       }\r
+               }\r
+\r
+               scd = (SubConstraintDescriptor) parentTupleDescriptor;\r
+\r
+               ddg = dd.getDataDescriptorGenerator();\r
+\r
+               /* 1st column is CONSTRAINTID (UUID - char(36)) */\r
+               col = row.getColumn(SYSCONSTRAINTS_CONSTRAINTID);\r
+               constraintUUIDString = col.getString();\r
+               constraintUUID = getUUIDFactory().recreateUUID(constraintUUIDString);\r
+\r
+               /* 2nd column is TABLEID (UUID - char(36)) */\r
+               col = row.getColumn(SYSCONSTRAINTS_TABLEID);\r
+               tableUUIDString = col.getString();\r
+               tableUUID = getUUIDFactory().recreateUUID(tableUUIDString);\r
+\r
+               /* Get the TableDescriptor.  \r
+                * It may be cached in the SCD, \r
+                * otherwise we need to go to the\r
+                * DD.\r
+                */\r
+               if (scd != null)\r
+               {\r
+                       td = scd.getTableDescriptor();\r
+               }\r
+               if (td == null)\r
+               {\r
+                       td = dd.getTableDescriptor(tableUUID);\r
+               }\r
+\r
+               /* 3rd column is NAME (varchar(128)) */\r
+               col = row.getColumn(SYSCONSTRAINTS_CONSTRAINTNAME);\r
+               constraintName = col.getString();\r
+\r
+               /* 4th column is TYPE (char(1)) */\r
+               col = row.getColumn(SYSCONSTRAINTS_TYPE);\r
+               constraintSType = col.getString();\r
+               if (SanityManager.DEBUG)\r
+               {\r
+                       SanityManager.ASSERT(constraintSType.length() == 1, \r
+                               "Fourth column type incorrect");\r
+               }\r
+\r
+               boolean typeSet = false;\r
+               switch (constraintSType.charAt(0))\r
+               {\r
+                       case 'P' : \r
+                               constraintIType = DataDictionary.PRIMARYKEY_CONSTRAINT;\r
+                               typeSet = true;\r
+                               // fall through\r
+\r
+                       case 'U' :\r
+                               if (! typeSet)\r
+                               {\r
+                                       constraintIType = DataDictionary.UNIQUE_CONSTRAINT;\r
+                                       typeSet = true;\r
+                               }\r
+                               // fall through\r
+\r
+                       case 'F' :\r
+                               if (! typeSet)\r
+                                       constraintIType = DataDictionary.FOREIGNKEY_CONSTRAINT;\r
+                               if (SanityManager.DEBUG)\r
+                               {\r
+                                       if (!(parentTupleDescriptor instanceof SubKeyConstraintDescriptor))\r
+                                       {\r
+                                               SanityManager.THROWASSERT(\r
+                                               "parentTupleDescriptor expected to be instanceof " +\r
+                                               "SubKeyConstraintDescriptor, not " +\r
+                                               parentTupleDescriptor.getClass().getName());\r
+                                       }\r
+                               }\r
+                               conglomDesc = td.getConglomerateDescriptor( \r
+                                                                               ((SubKeyConstraintDescriptor) \r
+                                                                                       parentTupleDescriptor).getIndexId());\r
+                               /* Take care the rare case of conglomDesc being null.  The\r
+                                * reason is that our "td" is out of date.  Another thread\r
+                                * which was adding a constraint committed between the moment\r
+                                * we got the table descriptor (conglomerate list) and the\r
+                                * moment we scanned and got the constraint desc list.  Since\r
+                                * that thread just added a new row to SYSCONGLOMERATES, \r
+                                * SYSCONSTRAINTS, etc.  We wouldn't have wanted to lock the\r
+                                * system tables just to prevent other threads from adding new\r
+                                * rows.\r
+                                */\r
+                               if (conglomDesc == null)\r
+                               {\r
+                                       // we can't be getting td from cache because if we are\r
+                                       // here, we must have been in dd's ddl mode (that's why\r
+                                       // the ddl thread went through), we are not done yet, the\r
+                                       // dd ref count is not 0, hence it couldn't have turned\r
+                                       // into COMPILE_ONLY mode\r
+                                       td = dd.getTableDescriptor(tableUUID);\r
+                                       if (scd != null)\r
+                                               scd.setTableDescriptor(td);\r
+                                       // try again now\r
+                                       conglomDesc = td.getConglomerateDescriptor( \r
+                                                                       ((SubKeyConstraintDescriptor) \r
+                                                                               parentTupleDescriptor).getIndexId());\r
+                               }\r
+\r
+                               if (SanityManager.DEBUG)\r
+                               {\r
+                                       SanityManager.ASSERT(conglomDesc != null,\r
+                                       "conglomDesc is expected to be non-null for backing index");\r
+                               }\r
+                               keyColumns = conglomDesc.getIndexDescriptor().baseColumnPositions();\r
+                               referencedConstraintId = ((SubKeyConstraintDescriptor) \r
+                                                                                       parentTupleDescriptor).getKeyConstraintId();\r
+                               keyColumns = conglomDesc.getIndexDescriptor().baseColumnPositions();\r
+                               break;\r
+\r
+                       case 'C' :\r
+                               constraintIType = DataDictionary.CHECK_CONSTRAINT;\r
+                               if (SanityManager.DEBUG)\r
+                               {\r
+                                       if (!(parentTupleDescriptor instanceof SubCheckConstraintDescriptor))\r
+                                       {\r
+                                               SanityManager.THROWASSERT("parentTupleDescriptor expected to be instanceof " +\r
+                                               "SubCheckConstraintDescriptor, not " +\r
+                                               parentTupleDescriptor.getClass().getName());\r
+                                       }\r
+                               }\r
+                               break;\r
+\r
+                       default:\r
+                               if (SanityManager.DEBUG)\r
+                               {\r
+                                       SanityManager.THROWASSERT("Fourth column value invalid");\r
+                               }\r
+               }\r
+\r
+               /* 5th column is SCHEMAID (UUID - char(36)) */\r
+               col = row.getColumn(SYSCONSTRAINTS_SCHEMAID);\r
+               schemaUUIDString = col.getString();\r
+               schemaUUID = getUUIDFactory().recreateUUID(schemaUUIDString);\r
+\r
+               schema = dd.getSchemaDescriptor(schemaUUID, null);\r
+\r
+               /* 6th column is STATE (char(1)) */\r
+               col = row.getColumn(SYSCONSTRAINTS_STATE);\r
+               constraintStateStr = col.getString();\r
+               if (SanityManager.DEBUG)\r
+               {\r
+                       SanityManager.ASSERT(constraintStateStr.length() == 1, \r
+                               "Sixth column (state) type incorrect");\r
+               }\r
+\r
+               switch (constraintStateStr.charAt(0))\r
+               {\r
+                       case 'E': \r
+                               constraintEnabled = true;\r
+                               break;\r
+                       case 'D':\r
+                               constraintEnabled = false;\r
+                               break;\r
+                       default: \r
+                               constraintEnabled = true;\r
+                               if (SanityManager.DEBUG)\r
+                               {\r
+                                       SanityManager.THROWASSERT("Invalidate state value '"\r
+                                                       +constraintStateStr+ "' for constraint");\r
+                               }\r
+               }\r
+\r
+               /* 7th column is REFERENCECOUNT, boolean */\r
+               col = row.getColumn(SYSCONSTRAINTS_REFERENCECOUNT);\r
+               referenceCount = col.getInt();\r
+               \r
+               /* now build and return the descriptor */\r
+\r
+               switch (constraintIType)\r
+               {\r
+                       case DataDictionary.PRIMARYKEY_CONSTRAINT : \r
+                               constraintDesc = ddg.newPrimaryKeyConstraintDescriptor(\r
+                                                                               td, \r
+                                                                               constraintName, \r
+                                                                               false, //deferable,\r
+                                                                               false, //initiallyDeferred,\r
+                                                                               keyColumns,//genReferencedColumns(dd, td), //int referencedColumns[],\r
+                                                                               constraintUUID,\r
+                                                                               ((SubKeyConstraintDescriptor) \r
+                                                                                       parentTupleDescriptor).getIndexId(),\r
+                                                                               schema,\r
+                                                                               constraintEnabled,\r
+                                                                               referenceCount);\r
+                               break;\r
+\r
+                       case DataDictionary.UNIQUE_CONSTRAINT :\r
+                               constraintDesc = ddg.newUniqueConstraintDescriptor(\r
+                                                                               td, \r
+                                                                               constraintName, \r
+                                                                               false, //deferable,\r
+                                                                               false, //initiallyDeferred,\r
+                                                                               keyColumns,//genReferencedColumns(dd, td), //int referencedColumns[],\r
+                                                                               constraintUUID,\r
+                                                                               ((SubKeyConstraintDescriptor) \r
+                                                                                       parentTupleDescriptor).getIndexId(),\r
+                                                                               schema,\r
+                                                                               constraintEnabled,\r
+                                                                               referenceCount);\r
+                               break;\r
+\r
+                       case DataDictionary.FOREIGNKEY_CONSTRAINT : \r
+                               if (SanityManager.DEBUG)\r
+                               {\r
+                                       SanityManager.ASSERT(referenceCount == 0, \r
+                                               "REFERENCECOUNT column is nonzero for fk constraint");\r
+                               }\r
+                                       \r
+                               constraintDesc = ddg.newForeignKeyConstraintDescriptor(\r
+                                                                               td, \r
+                                                                               constraintName, \r
+                                                                               false, //deferable,\r
+                                                                               false, //initiallyDeferred,\r
+                                                                               keyColumns,//genReferencedColumns(dd, td), //int referencedColumns[],\r
+                                                                               constraintUUID,\r
+                                                                               ((SubKeyConstraintDescriptor) \r
+                                                                                       parentTupleDescriptor).getIndexId(),\r
+                                                                               schema,\r
+                                                                               referencedConstraintId,\r
+                                                                               constraintEnabled,\r
+                                                                               ((SubKeyConstraintDescriptor) \r
+                                                                                       parentTupleDescriptor).getRaDeleteRule(),\r
+                                                                               ((SubKeyConstraintDescriptor) \r
+                                                                                       parentTupleDescriptor).getRaUpdateRule()\r
+                                                                               );\r
+                               break;\r
+\r
+                       case DataDictionary.CHECK_CONSTRAINT :\r
+                               if (SanityManager.DEBUG)\r
+                               {\r
+                                       SanityManager.ASSERT(referenceCount == 0, \r
+                                               "REFERENCECOUNT column is nonzero for check constraint");\r
+                               }\r
+                                       \r
+                               constraintDesc = ddg.newCheckConstraintDescriptor(\r
+                                                                               td, \r
+                                                                               constraintName, \r
+                                                                               false, //deferable,\r
+                                                                               false, //initiallyDeferred,\r
+                                                                               constraintUUID,\r
+                                                                               ((SubCheckConstraintDescriptor) \r
+                                                                                       parentTupleDescriptor).getConstraintText(),\r
+                                                                               ((SubCheckConstraintDescriptor) \r
+                                                                                       parentTupleDescriptor).getReferencedColumnsDescriptor(),\r
+                                                                               schema,\r
+                                                                               constraintEnabled);\r
+                               break;\r
+               }\r
+               return constraintDesc;\r
+       }\r
+\r
+       /**\r
+        * Get the constraint ID of the row.\r
+        * \r
+        * @param row   The row from sysconstraints\r
+        *\r
+        * @return UUID The constraint id\r
+        *\r
+        * @exception   StandardException thrown on failure\r
+        */\r
+        protected UUID getConstraintId(ExecRow row)\r
+                throws StandardException\r
+        {\r
+               DataValueDescriptor     col;\r
+               String                          constraintUUIDString;\r
+\r
+               /* 1st column is CONSTRAINTID (UUID - char(36)) */\r
+               col = row.getColumn(SYSCONSTRAINTS_CONSTRAINTID);\r
+               constraintUUIDString = col.getString();\r
+               return getUUIDFactory().recreateUUID(constraintUUIDString);\r
+        }\r
+\r
+       /**\r
+        * Get the constraint name of the row.\r
+        * \r
+        * @param row   The row from sysconstraints\r
+        *\r
+        * @return UUID The constraint name\r
+        *\r
+        * @exception   StandardException thrown on failure\r
+        */\r
+        protected String getConstraintName(ExecRow row)\r
+                throws StandardException\r
+        {\r
+               DataValueDescriptor     col;\r
+               String                          constraintName;\r
+\r
+               /* 3rd column is CONSTRAINTNAME (char(128)) */\r
+               col = row.getColumn(SYSCONSTRAINTS_CONSTRAINTNAME);\r
+               constraintName = col.getString();\r
+               return constraintName;\r
+        }\r
+\r
+       /**\r
+        * Get the schema ID of the row.\r
+        * \r
+        * @param row   The row from sysconstraints\r
+        *\r
+        * @return UUID The schema\r
+        *\r
+        * @exception   StandardException thrown on failure\r
+        */\r
+        protected UUID getSchemaId(ExecRow row)\r
+                throws StandardException\r
+        {\r
+               DataValueDescriptor     col;\r
+               String                          schemaUUIDString;\r
+\r
+               /* 5th column is SCHEMAID (UUID - char(36)) */\r
+               col = row.getColumn(SYSCONSTRAINTS_SCHEMAID);\r
+               schemaUUIDString =col.getString();\r
+               return getUUIDFactory().recreateUUID(schemaUUIDString);\r
+        }\r
+\r
+       /**\r
+        * Get the table ID of the row.\r
+        * \r
+        * @param row   The row from sysconstraints\r
+        *\r
+        * @return UUID The table id\r
+        *\r
+        * @exception   StandardException thrown on failure\r
+        */\r
+        protected UUID getTableId(ExecRow row)\r
+                throws StandardException\r
+        {\r
+               DataValueDescriptor     col;\r
+               String                          tableUUIDString;\r
+\r
+               /* 2nd column is TABLEID (UUID - char(36)) */\r
+               col = row.getColumn(SYSCONSTRAINTS_TABLEID);\r
+               tableUUIDString = col.getString();\r
+               return getUUIDFactory().recreateUUID(tableUUIDString);\r
+        }\r
+\r
+       /**\r
+        * Get the constraint type out of the row.\r
+        * \r
+        * @param row   The row from sysconstraints\r
+        *\r
+        * @return int  The constraint type     as an int\r
+        *\r
+        * @exception   StandardException thrown on failure\r
+        */\r
+        protected int getConstraintType(ExecRow row)\r
+                throws StandardException\r
+        {\r
+               DataValueDescriptor     col;\r
+               int                                     constraintIType;\r
+               String                          constraintSType;\r
+\r
+               /* 4th column is TYPE (char(1)) */\r
+               col = row.getColumn(SYSCONSTRAINTS_TYPE);\r
+               constraintSType = col.getString();\r
+               if (SanityManager.DEBUG)\r
+               {\r
+                       SanityManager.ASSERT(constraintSType.length() == 1, \r
+                               "Fourth column type incorrect");\r
+               }\r
+\r
+               switch (constraintSType.charAt(0))\r
+               {\r
+                       case 'P' : \r
+                               constraintIType = DataDictionary.PRIMARYKEY_CONSTRAINT;\r
+                               break;\r
+\r
+                       case 'U' :\r
+                               constraintIType = DataDictionary.UNIQUE_CONSTRAINT;\r
+                               break;\r
+\r
+                       case 'C' :\r
+                               constraintIType = DataDictionary.CHECK_CONSTRAINT;\r
+                               break;\r
+\r
+                       case 'F' :\r
+                               constraintIType = DataDictionary.FOREIGNKEY_CONSTRAINT;\r
+                               break;\r
+\r
+                       default:\r
+                               if (SanityManager.DEBUG)\r
+                               {\r
+                                       SanityManager.THROWASSERT("Fourth column value invalid");\r
+                               }\r
+                               constraintIType = -1;\r
+               }\r
+\r
+               return constraintIType;\r
+        }\r
+\r
+       /**\r
+        * Builds a list of columns suitable for creating this Catalog.\r
+        *\r
+        *\r
+        * @return array of SystemColumn suitable for making this catalog.\r
+        */\r
+       public SystemColumn[]   buildColumnList()\r
+       {\r
+            return new SystemColumn[] {\r
+               SystemColumnImpl.getUUIDColumn("CONSTRAINTID", false),\r
+               SystemColumnImpl.getUUIDColumn("TABLEID", false),\r
+               SystemColumnImpl.getIdentifierColumn("CONSTRAINTNAME", false),\r
+               SystemColumnImpl.getIndicatorColumn("TYPE"),\r
+               SystemColumnImpl.getUUIDColumn("SCHEMAID", false),\r
+               SystemColumnImpl.getIndicatorColumn("STATE"),\r
+               SystemColumnImpl.getColumn("REFERENCECOUNT", Types.INTEGER, false) \r
+            };\r
+       }\r
+\r
+}\r