use of org.hsqldb_voltpatches.lib.OrderedHashSet in project voltdb by VoltDB.
the class UserTypeModifier method getComponents.
public final OrderedHashSet getComponents() {
if (constraints == null) {
return null;
}
OrderedHashSet set = new OrderedHashSet();
set.addAll(constraints);
return set;
}
use of org.hsqldb_voltpatches.lib.OrderedHashSet in project voltdb by VoltDB.
the class Charset method getReferences.
public OrderedHashSet getReferences() {
OrderedHashSet set = new OrderedHashSet();
set.add(base);
return set;
}
use of org.hsqldb_voltpatches.lib.OrderedHashSet in project voltdb by VoltDB.
the class ParserDDL method compileRightGrantOrRevoke.
private StatementSchema compileRightGrantOrRevoke(boolean grant) {
OrderedHashSet granteeList = new OrderedHashSet();
Grantee grantor = null;
Right right = null;
// SchemaObject schemaObject;
HsqlName objectName = null;
boolean isTable = false;
boolean isUsage = false;
boolean isExec = false;
boolean isAll = false;
boolean isGrantOption = false;
boolean cascade = false;
if (!grant) {
if (token.tokenType == Tokens.GRANT) {
read();
readThis(Tokens.OPTION);
readThis(Tokens.FOR);
isGrantOption = true;
// throw not suppoerted
} else if (token.tokenType == Tokens.HIERARCHY) {
throw unsupportedFeature();
/*
read();
readThis(Token.OPTION);
readThis(Token.FOR);
*/
}
}
// ALL means all the rights the grantor can grant
if (token.tokenType == Tokens.ALL) {
read();
if (token.tokenType == Tokens.PRIVILEGES) {
read();
}
right = Right.fullRights;
isAll = true;
} else {
right = new Right();
boolean loop = true;
while (loop) {
checkIsNotQuoted();
int rightType = GranteeManager.getCheckSingleRight(token.tokenString);
int grantType = token.tokenType;
OrderedHashSet columnSet = null;
read();
switch(grantType) {
case Tokens.REFERENCES:
case Tokens.SELECT:
case Tokens.INSERT:
case Tokens.UPDATE:
if (token.tokenType == Tokens.OPENBRACKET) {
columnSet = readColumnNames(false);
}
// $FALL-THROUGH$
case Tokens.DELETE:
case Tokens.TRIGGER:
if (right == null) {
right = new Right();
}
right.set(rightType, columnSet);
isTable = true;
break;
case Tokens.USAGE:
if (isTable) {
throw unexpectedToken();
}
right = Right.fullRights;
isUsage = true;
loop = false;
continue;
case Tokens.EXECUTE:
if (isTable) {
throw unexpectedToken();
}
right = Right.fullRights;
isExec = true;
loop = false;
continue;
}
if (token.tokenType == Tokens.COMMA) {
read();
continue;
}
break;
}
}
readThis(Tokens.ON);
if (token.tokenString.equals(Tokens.T_CLASS)) {
if (!isExec && !isAll) {
throw unexpectedToken();
}
read();
if (!isSimpleName() || !isDelimitedIdentifier()) {
throw Error.error(ErrorCode.X_42569);
}
objectName = readNewSchemaObjectNameNoCheck(SchemaObject.FUNCTION);
} else if (token.tokenType == Tokens.TYPE || token.tokenType == Tokens.DOMAIN || token.tokenType == Tokens.SEQUENCE || token.tokenType == Tokens.CHARACTER) {
if (!isUsage && !isAll) {
throw unexpectedToken();
}
int type = 0;
switch(token.tokenType) {
case Tokens.TYPE:
read();
type = SchemaObject.TYPE;
break;
case Tokens.DOMAIN:
read();
type = SchemaObject.DOMAIN;
break;
case Tokens.SEQUENCE:
read();
type = SchemaObject.SEQUENCE;
break;
case Tokens.CHARACTER:
read();
readThis(Tokens.SET);
type = SchemaObject.CHARSET;
break;
}
objectName = readNewSchemaObjectNameNoCheck(type);
} else {
if (!isTable && !isAll) {
throw unexpectedToken();
}
readIfThis(Tokens.TABLE);
objectName = readNewSchemaObjectNameNoCheck(SchemaObject.TABLE);
}
if (grant) {
readThis(Tokens.TO);
} else {
readThis(Tokens.FROM);
}
while (true) {
checkIsSimpleName();
granteeList.add(token.tokenString);
read();
if (token.tokenType == Tokens.COMMA) {
read();
} else {
break;
}
}
if (grant) {
if (token.tokenType == Tokens.WITH) {
read();
readThis(Tokens.GRANT);
readThis(Tokens.OPTION);
isGrantOption = true;
}
/** @todo - implement */
if (token.tokenType == Tokens.GRANTED) {
read();
readThis(Tokens.BY);
if (token.tokenType == Tokens.CURRENT_USER) {
read();
//
} else {
readThis(Tokens.CURRENT_ROLE);
}
}
} else {
if (token.tokenType == Tokens.CASCADE) {
cascade = true;
read();
} else {
readThis(Tokens.RESTRICT);
}
}
int type = grant ? StatementTypes.GRANT : StatementTypes.REVOKE;
Object[] args = new Object[] { granteeList, objectName, right, grantor, Boolean.valueOf(cascade), Boolean.valueOf(isGrantOption) };
String sql = getLastPart();
StatementSchema cs = new StatementSchema(sql, type, args, null, null);
return cs;
}
use of org.hsqldb_voltpatches.lib.OrderedHashSet in project voltdb by VoltDB.
the class ParserDDL method processAlterTableAddUniqueConstraint.
// A VoltDB extension to support indexed expressions and the assume unique attribute
void processAlterTableAddUniqueConstraint(Table table, HsqlName name, boolean assumeUnique) {
boolean isAutogeneratedName = false;
if (name == null) {
name = database.nameManager.newAutoName("CT", table.getSchemaName(), table.getName(), SchemaObject.CONSTRAINT);
isAutogeneratedName = true;
}
// A VoltDB extension to "readColumnList(table, false)" to support indexed expressions.
java.util.List<Expression> indexExprs = XreadExpressions(null);
OrderedHashSet set = getSimpleColumnNames(indexExprs);
int[] cols = getColumnList(set, table);
/* disable 1 line ...
int[] cols = this.readColumnList(table, false);
... disabled 1 line */
// End of VoltDB extension
session.commit(false);
TableWorks tableWorks = new TableWorks(session, table);
// A VoltDB extension to support indexed expressions and the assume unique attribute
if ((indexExprs != null) && (cols == null)) {
// A VoltDB extension to support indexed expressions.
// Not just indexing columns.
// The meaning of cols shifts here to be
// the set of unique base columns for the indexed expressions.
set = getBaseColumnNames(indexExprs);
cols = getColumnList(set, table);
tableWorks.addUniqueExprConstraint(cols, indexExprs.toArray(new Expression[indexExprs.size()]), name, isAutogeneratedName, assumeUnique);
return;
}
tableWorks.addUniqueConstraint(cols, name, isAutogeneratedName, assumeUnique);
/* disable 1 line ...
tableWorks.addUniqueConstraint(cols, name);
... disabled 1 line */
// End of VoltDB extension
}
use of org.hsqldb_voltpatches.lib.OrderedHashSet in project voltdb by VoltDB.
the class ParserDDL method readColumnDefinitionOrNull.
/**
* Responsible for handling the creation of table columns during the process
* of executing CREATE TABLE or ADD COLUMN etc. statements.
*
* @param table this table
* @param hsqlName column name
* @param constraintList list of constraints
* @return a Column object with indicated attributes
*/
ColumnSchema readColumnDefinitionOrNull(Table table, HsqlName hsqlName, HsqlArrayList constraintList) {
boolean isIdentity = false;
boolean isPKIdentity = false;
boolean identityAlways = false;
Expression generateExpr = null;
boolean isNullable = true;
Expression defaultExpr = null;
Type typeObject;
NumberSequence sequence = null;
if (token.tokenType == Tokens.IDENTITY) {
read();
isIdentity = true;
isPKIdentity = true;
typeObject = Type.SQL_INTEGER;
sequence = new NumberSequence(null, 0, 1, typeObject);
} else if (token.tokenType == Tokens.COMMA) {
;
return null;
} else {
typeObject = readTypeDefinition(true);
}
if (isIdentity) {
} else if (token.tokenType == Tokens.DEFAULT) {
read();
defaultExpr = readDefaultClause(typeObject);
} else if (token.tokenType == Tokens.GENERATED && !isIdentity) {
read();
if (token.tokenType == Tokens.BY) {
read();
readThis(Tokens.DEFAULT);
} else {
readThis(Tokens.ALWAYS);
identityAlways = true;
}
readThis(Tokens.AS);
if (token.tokenType == Tokens.IDENTITY) {
read();
sequence = new NumberSequence(null, typeObject);
sequence.setAlways(identityAlways);
if (token.tokenType == Tokens.OPENBRACKET) {
read();
readSequenceOptions(sequence, false, false);
readThis(Tokens.CLOSEBRACKET);
}
isIdentity = true;
} else if (token.tokenType == Tokens.OPENBRACKET) {
read();
generateExpr = XreadValueExpression();
readThis(Tokens.CLOSEBRACKET);
}
}
ColumnSchema column = new ColumnSchema(hsqlName, typeObject, isNullable, false, defaultExpr);
readColumnConstraints(table, column, constraintList);
if (token.tokenType == Tokens.IDENTITY && !isIdentity) {
read();
isIdentity = true;
isPKIdentity = true;
sequence = new NumberSequence(null, 0, 1, typeObject);
}
if (isIdentity) {
column.setIdentity(sequence);
}
if (isPKIdentity && !column.isPrimaryKey()) {
OrderedHashSet set = new OrderedHashSet();
set.add(column.getName().name);
HsqlName constName = database.nameManager.newAutoName("PK", table.getSchemaName(), table.getName(), SchemaObject.CONSTRAINT);
Constraint c = new Constraint(constName, true, set, Constraint.PRIMARY_KEY);
constraintList.set(0, c);
column.setPrimaryKey(true);
}
return column;
}
Aggregations