use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName in project voltdb by VoltDB.
the class ParserDDL method compileCreateStream.
// skip Export to target of statment
// skip constraint ?
StatementSchema compileCreateStream(int type) {
HsqlName name = readNewSchemaObjectNameNoCheck(SchemaObject.TABLE);
HsqlArrayList tempConstraints = new HsqlArrayList();
name.setSchemaIfNull(session.getCurrentSchemaHsqlName());
Table table = TableUtil.newTable(database, type, name);
if (token.tokenType == Tokens.AS) {
return readTableAsSubqueryDefinition(table);
}
int position = getPosition();
readUntilThis(Tokens.OPENBRACKET);
readThis(Tokens.OPENBRACKET);
{
Constraint c = new Constraint(null, true, null, Constraint.TEMP);
tempConstraints.add(c);
}
boolean start = true;
boolean startPart = true;
boolean end = false;
while (!end) {
switch(token.tokenType) {
case Tokens.LIKE:
{
ColumnSchema[] likeColumns = readLikeTable(table);
for (int i = 0; i < likeColumns.length; i++) {
table.addColumn(likeColumns[i]);
}
start = false;
startPart = false;
break;
}
case Tokens.CONSTRAINT:
case Tokens.PRIMARY:
case Tokens.FOREIGN:
// A VoltDB extension to support the assume unique attribute
case Tokens.ASSUMEUNIQUE:
// End of VoltDB extension
case Tokens.UNIQUE:
case Tokens.CHECK:
// A VoltDB extension to support LIMIT PARTITION ROWS
case Tokens.LIMIT:
// End of VoltDB extension
if (!startPart) {
throw unexpectedToken();
}
readConstraint(table, tempConstraints);
start = false;
startPart = false;
break;
case Tokens.COMMA:
if (startPart) {
throw unexpectedToken();
}
read();
startPart = true;
break;
case Tokens.CLOSEBRACKET:
read();
end = true;
break;
default:
if (!startPart) {
throw unexpectedToken();
}
checkIsSchemaObjectName();
HsqlName hsqlName = database.nameManager.newColumnHsqlName(name, token.tokenString, isDelimitedIdentifier());
read();
ColumnSchema newcolumn = readColumnDefinitionOrNull(table, hsqlName, tempConstraints);
if (newcolumn == null) {
if (start) {
rewind(position);
return readTableAsSubqueryDefinition(table);
} else {
throw Error.error(ErrorCode.X_42000);
}
}
table.addColumn(newcolumn);
start = false;
startPart = false;
}
}
if (token.tokenType == Tokens.ON) {
if (!table.isTemp()) {
throw unexpectedToken();
}
read();
readThis(Tokens.COMMIT);
if (token.tokenType == Tokens.DELETE) {
} else if (token.tokenType == Tokens.PRESERVE) {
table.persistenceScope = TableBase.SCOPE_SESSION;
}
read();
readThis(Tokens.ROWS);
}
Object[] args = new Object[] { table, tempConstraints, null };
String sql = getLastPart();
return new StatementSchema(sql, StatementTypes.CREATE_TABLE, args, null, null);
}
use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName in project voltdb by VoltDB.
the class ParserDQL method readSchemaName.
HsqlName readSchemaName() {
checkIsSchemaObjectName();
checkValidCatalogName(token.namePrefix);
HsqlName schema = session.getSchemaHsqlName(token.tokenString);
read();
return schema;
}
use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName in project voltdb by VoltDB.
the class ParserDQL method readNewSchemaName.
HsqlName readNewSchemaName() {
checkIsSchemaObjectName();
checkValidCatalogName(token.namePrefix);
SqlInvariants.checkSchemaNameNotSystem(token.tokenString);
HsqlName name = database.nameManager.newHsqlName(token.tokenString, isDelimitedIdentifier(), SchemaObject.SCHEMA);
read();
return name;
}
use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName in project voltdb by VoltDB.
the class ParserDDL method compileCreateAlias.
StatementSchema compileCreateAlias() {
HsqlName name = null;
Routine[] routines = null;
String alias;
String methodFQN = null;
if (!session.isProcessingScript()) {
throw super.unsupportedFeature();
}
read();
try {
alias = token.tokenString;
read();
readThis(Tokens.FOR);
methodFQN = token.tokenString;
read();
} catch (HsqlException e) {
alias = null;
}
if (alias != null) {
HsqlName schema = database.schemaManager.getDefaultSchemaHsqlName();
name = database.nameManager.newHsqlName(schema, alias, SchemaObject.FUNCTION);
Method[] methods = Routine.getMethods(methodFQN);
routines = Routine.newRoutines(methods);
}
String sql = getLastPart();
Object[] args = new Object[] { name, routines };
return new StatementSchema(sql, StatementTypes.CREATE_ALIAS, args, null, null);
}
use of org.hsqldb_voltpatches.HsqlNameManager.HsqlName in project voltdb by VoltDB.
the class ParserDDL method compileCreateUser.
StatementSchema compileCreateUser() {
HsqlName name;
String password;
boolean admin = false;
Grantee grantor = session.getGrantee();
read();
name = readNewUserIdentifier();
readThis(Tokens.PASSWORD);
password = readPassword();
if (token.tokenType == Tokens.ADMIN) {
read();
admin = true;
}
checkDatabaseUpdateAuthorisation();
String sql = getLastPart();
Object[] args = new Object[] { name, password, grantor, Boolean.valueOf(admin) };
return new StatementSchema(sql, StatementTypes.CREATE_USER, args, null, null);
}
Aggregations