table.createPrimaryKey();
}
private void readRoutineCharacteristics(Routine routine) {
OrderedIntHashSet set = new OrderedIntHashSet();
boolean end = false;
while (!end) {
switch (token.tokenType) {
case Tokens.LANGUAGE : {
if (!set.add(Tokens.LANGUAGE)) {
throw unexpectedToken();
}
read();
if (token.tokenType == Tokens.JAVA) {
read();
routine.setLanguage(Routine.LANGUAGE_JAVA);
} else if (token.tokenType == Tokens.SQL) {
read();
routine.setLanguage(Routine.LANGUAGE_SQL);
} else {
throw unexpectedToken();
}
break;
}
case Tokens.PARAMETER : {
if (!set.add(Tokens.PARAMETER)) {
throw unexpectedToken();
}
read();
readThis(Tokens.STYLE);
if (token.tokenType == Tokens.JAVA) {
read();
routine.setParameterStyle(Routine.PARAM_STYLE_JAVA);
} else {
readThis(Tokens.SQL);
routine.setParameterStyle(Routine.PARAM_STYLE_SQL);
}
break;
}
case Tokens.SPECIFIC : {
if (!set.add(Tokens.SPECIFIC)) {
throw unexpectedToken();
}
read();
HsqlName name =
readNewSchemaObjectName(SchemaObject.SPECIFIC_ROUTINE,
false);
routine.setSpecificName(name);
break;
}
case Tokens.DETERMINISTIC : {
if (!set.add(Tokens.DETERMINISTIC)) {
throw unexpectedToken();
}
read();
routine.setDeterministic(true);
break;
}
case Tokens.NOT : {
if (!set.add(Tokens.DETERMINISTIC)) {
throw unexpectedToken();
}
read();
readThis(Tokens.DETERMINISTIC);
routine.setDeterministic(false);
break;
}
case Tokens.MODIFIES : {
if (!set.add(Tokens.SQL)) {
throw unexpectedToken();
}
if (routine.getType() == SchemaObject.FUNCTION) {
throw unexpectedToken();
}
read();
readThis(Tokens.SQL);
readThis(Tokens.DATA);
routine.setDataImpact(Routine.MODIFIES_SQL);
break;
}
case Tokens.NO : {
if (!set.add(Tokens.SQL)) {
throw unexpectedToken();
}
read();
readThis(Tokens.SQL);
routine.setDataImpact(Routine.NO_SQL);
break;
}
case Tokens.READS : {
if (!set.add(Tokens.SQL)) {
throw unexpectedToken();
}
read();
readThis(Tokens.SQL);
readThis(Tokens.DATA);
routine.setDataImpact(Routine.READS_SQL);
break;
}
case Tokens.CONTAINS : {
if (!set.add(Tokens.SQL)) {
throw unexpectedToken();
}
read();
readThis(Tokens.SQL);
routine.setDataImpact(Routine.CONTAINS_SQL);
break;
}
case Tokens.RETURNS : {
if (!set.add(Tokens.NULL) || routine.isProcedure()) {
throw unexpectedToken();
}
if (routine.isAggregate()) {
throw Error.error(ErrorCode.X_42604,
token.tokenString);
}
read();
readThis(Tokens.NULL);
readThis(Tokens.ON);
readThis(Tokens.NULL);
readThis(Tokens.INPUT);
routine.setNullInputOutput(true);
break;
}
case Tokens.CALLED : {
if (!set.add(Tokens.NULL) || routine.isProcedure()) {
throw unexpectedToken();
}
read();
readThis(Tokens.ON);
readThis(Tokens.NULL);
readThis(Tokens.INPUT);
routine.setNullInputOutput(false);
break;
}
case Tokens.DYNAMIC : {
if (!set.add(Tokens.RESULT) || routine.isFunction()) {
throw unexpectedToken();
}
read();
readThis(Tokens.RESULT);
readThis(Tokens.SETS);
int results = readInteger();
if (results < 0 || results > 16) {
throw Error.error(ErrorCode.X_42604,
String.valueOf(results));
}
routine.setMaxDynamicResults(results);
break;
}
case Tokens.NEW : {
if (routine.getType() == SchemaObject.FUNCTION
|| !set.add(Tokens.SAVEPOINT)) {
throw unexpectedToken();
}
read();
readThis(Tokens.SAVEPOINT);
readThis(Tokens.LEVEL);
routine.setNewSavepointLevel(true);
break;
}
case Tokens.OLD : {
if (routine.getType() == SchemaObject.FUNCTION
|| !set.add(Tokens.SAVEPOINT)) {
throw unexpectedToken();
}
read();
readThis(Tokens.SAVEPOINT);