final PgDatabase database) {
final String functionName = parser.parseIdentifier();
final String objectName = ParserUtils.getObjectName(functionName);
final String schemaName =
ParserUtils.getSchemaName(functionName, database);
final PgSchema schema = database.getSchema(schemaName);
parser.expect("(");
final PgFunction tmpFunction = new PgFunction();
tmpFunction.setName(objectName);
while (!parser.expectOptional(")")) {
final String mode;
if (parser.expectOptional("IN")) {
mode = "IN";
} else if (parser.expectOptional("OUT")) {
mode = "OUT";
} else if (parser.expectOptional("INOUT")) {
mode = "INOUT";
} else if (parser.expectOptional("VARIADIC")) {
mode = "VARIADIC";
} else {
mode = null;
}
final int position = parser.getPosition();
String argumentName = null;
String dataType = parser.parseDataType();
final int position2 = parser.getPosition();
if (!parser.expectOptional(")") && !parser.expectOptional(",")) {
parser.setPosition(position);
argumentName =
ParserUtils.getObjectName(parser.parseIdentifier());
dataType = parser.parseDataType();
} else {
parser.setPosition(position2);
}
final PgFunction.Argument argument = new PgFunction.Argument();
argument.setDataType(dataType);
argument.setMode(mode);
argument.setName(argumentName);
tmpFunction.addArgument(argument);
if (parser.expectOptional(")")) {
break;
} else {
parser.expect(",");
}
}
final PgFunction function =
schema.getFunction(tmpFunction.getSignature());
parser.expect("IS");
function.setComment(getComment(parser));
parser.expect(";");
}