Examples of FKConstraintDefinitionNode


Examples of com.foundationdb.sql.parser.FKConstraintDefinitionNode

        // constraint before the column definition. For example:
        // CREATE TABLE t1 (c1 INT PRIMARY KEY) produces such a result.
        // The Builder complains if you try to do such a thing.
        for (TableElementNode tableElement : createTable.getTableElementList()) {
            if (tableElement instanceof FKConstraintDefinitionNode) {
                FKConstraintDefinitionNode fkdn = (FKConstraintDefinitionNode)tableElement;
                if (fkdn.isGrouping()) {
                    addJoin (builder, fkdn, defaultSchemaName, schemaName, tableName);
                } else {
                    addForeignKey(builder, ddlFunctions.getAIS(session), fkdn, defaultSchemaName, schemaName, tableName);
                }
            }
View Full Code Here

Examples of com.foundationdb.sql.parser.FKConstraintDefinitionNode

                                      final AkibanInformationSchema targetAIS,
                                      TableElementList nodes) {
        final Set<Group> groups = new HashSet<>();
        for(TableElementNode elem : nodes) {
            if(elem instanceof FKConstraintDefinitionNode) {
                FKConstraintDefinitionNode fkdn = (FKConstraintDefinitionNode)elem;
                if(fkdn.getRefTableName() != null) {
                    TableName name = getReferencedName(defaultSchema, (FKConstraintDefinitionNode)elem);
                    Table t = curAIS.getTable(name);
                    if(t != null) {
                        groups.add(t.getGroup());
                    }
View Full Code Here

Examples of com.foundationdb.sql.parser.FKConstraintDefinitionNode

                        }
                    }
                } break;

                case NodeTypes.FK_CONSTRAINT_DEFINITION_NODE: {
                    FKConstraintDefinitionNode fkNode = (FKConstraintDefinitionNode) node;
                    if(fkNode.getConstraintType() == ConstraintType.DROP) {
                        if(fkNode.isGrouping()) {
                            if(origTable.getParentJoin() == null) {
                                skipOrThrow(context, fkNode.getExistenceCheck(), null, new NoSuchGroupingFKException(origTable.getName()));
                                fkNode = null;
                            }
                        } else {
                            if(fkNode.getConstraintName() == null) {
                                Collection<ForeignKey> fkeys = origTable.getReferencingForeignKeys();
                                if(fkeys.size() == 0) {
                                    skipOrThrow(context, fkNode.getExistenceCheck(), null, new UnsupportedFKIndexException());
                                    fkNode = null;
                                } else if(fkeys.size() != 1) {
                                    throw new UnsupportedFKIndexException();
                                } else {
                                    try {
                                        fkNode.setConstraintName(fkeys.iterator().next().getConstraintName().getTableName());
                                    } catch(StandardException ex) {
                                        throw new SQLParserInternalException(ex);
                                    }
                                }
                            } else if(origTable.getReferencingForeignKey(fkNode.getConstraintName().getTableName()) == null) {
                                skipOrThrow(context,
                                            fkNode.getExistenceCheck(),
                                            null,
                                            new NoSuchForeignKeyException(fkNode.getConstraintName().getTableName(), origTable.getName()));
                                fkNode = null;
                            }
                            if(fkNode != null) {
                                // Also drop the referencing index.
                                indexChanges.add(TableChange.createDrop(fkNode.getConstraintName().getTableName()));
                            }
                        }
                    }
                    if(fkNode != null) {
                        fkDefNodes.add(fkNode);
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.