Examples of ConstraintType


Examples of org.voltdb.types.ConstraintType

        for (Table src_tbl : src_db.getTables()) {
            Table dest_tbl = dest_db.getTables().get(src_tbl.getName());
            if (dest_tbl != null) {
                for (Constraint src_cons : src_tbl.getConstraints()) {
                    // Only clone FKEY constraint if the other table is in the catalog
                    ConstraintType cons_type = ConstraintType.get(src_cons.getType());
                    if (cons_type != ConstraintType.FOREIGN_KEY || (cons_type == ConstraintType.FOREIGN_KEY && dest_db.getTables().get(src_cons.getForeignkeytable().getName()) != null)) {
                        Constraint dest_cons = clone(src_cons, dest_catalog);
                        assert (dest_cons != null);
                    }
                } // FOR
View Full Code Here

Examples of org.voltdb.types.ConstraintType

        NamedNodeMap attrs = node.getAttributes();

        String name = attrs.getNamedItem("name").getNodeValue();
        String typeName = attrs.getNamedItem("type").getNodeValue();
        ConstraintType type = ConstraintType.valueOf(typeName);
        if (type == null) {
            throw this.m_compiler.new VoltCompilerException("Invalid constraint type '" + typeName + "'");
        }

        // The constraint is backed by an index, therefore we need to create it
        // TODO: We need to be able to use indexes for foreign keys. I am purposely
        //       leaving those out right now because HSQLDB just makes too many of them.
        Constraint catalog_const = null;
        if (attrs.getNamedItem("index") != null) {
            String indexName = attrs.getNamedItem("index") .getNodeValue();
            Index catalog_index = indexMap.get(indexName);
           
            if (catalog_index != null) {
                // If this is a foreign key, then we *do not* want to include an index for it
                // since we don't actually do anything to enforce these constraints
                if (type == ConstraintType.FOREIGN_KEY) {
                    boolean ret = table.getIndexes().remove(catalog_index);
                    LOG.debug("Removing foreign key index " + catalog_index.fullName() + " [" + ret + "]");
                    indexMap.remove(indexName);
                    catalog_index = null;
                }
                else {
                    // if the constraint name contains index type hints, exercise them (giant hack)
                    String constraintNameNoCase = name.toLowerCase();
                    if (constraintNameNoCase.contains("tree"))
                        catalog_index.setType(IndexType.BALANCED_TREE.getValue());
                    if (constraintNameNoCase.contains("array"))
                        catalog_index.setType(IndexType.ARRAY.getValue());
                }
            }

            catalog_const = table.getConstraints().add(name);
            if (catalog_index != null) {
                catalog_const.setIndex(catalog_index);
                catalog_index.setUnique(type == ConstraintType.UNIQUE || type == ConstraintType.PRIMARY_KEY);
            }
        } else {
            catalog_const = table.getConstraints().add(name);
        }
        catalog_const.setType(type.getValue());

        // Foreign Keys
        if (type == ConstraintType.FOREIGN_KEY) {
            String fkey_table_name = attrs.getNamedItem("foreignkeytable").getNodeValue();
            Table catalog_fkey_tbl = ((Database)table.getParent()).getTables().getIgnoreCase(fkey_table_name);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.