Search in sources :

Example 1 with ProcType

use of org.jooq.util.mysql.mysql.enums.ProcType in project jOOQ by jOOQ.

the class MySQLDatabase method getRoutines0.

@Override
protected List<RoutineDefinition> getRoutines0() throws SQLException {
    List<RoutineDefinition> result = new ArrayList<RoutineDefinition>();
    try {
        create(true).fetchCount(PROC);
    } catch (DataAccessException e) {
        log.warn("Table unavailable", "The `mysql`.`proc` table is unavailable. Stored procedures cannot be loaded. Check if you have sufficient grants");
        return result;
    }
    Result<Record6<String, String, String, byte[], byte[], ProcType>> records = create().select(Proc.DB, Proc.NAME, Proc.COMMENT, Proc.PARAM_LIST, Proc.RETURNS, Proc.TYPE).from(PROC).where(DB.in(getInputSchemata())).orderBy(DB, Proc.NAME).fetch();
    Map<Record, Result<Record6<String, String, String, byte[], byte[], ProcType>>> groups = records.intoGroups(new Field[] { Proc.DB, Proc.NAME });
    // procedures and functions with the same signature.
    for (Entry<Record, Result<Record6<String, String, String, byte[], byte[], ProcType>>> entry : groups.entrySet()) {
        Result<?> overloads = entry.getValue();
        for (int i = 0; i < overloads.size(); i++) {
            Record record = overloads.get(i);
            SchemaDefinition schema = getSchema(record.get(DB));
            String name = record.get(Proc.NAME);
            String comment = record.get(Proc.COMMENT);
            String params = new String(record.get(Proc.PARAM_LIST));
            String returns = new String(record.get(Proc.RETURNS));
            ProcType type = record.get(Proc.TYPE);
            if (overloads.size() > 1) {
                result.add(new MySQLRoutineDefinition(schema, name, comment, params, returns, type, "_" + type.name()));
            } else {
                result.add(new MySQLRoutineDefinition(schema, name, comment, params, returns, type, null));
            }
        }
    }
    return result;
}
Also used : RoutineDefinition(org.jooq.util.RoutineDefinition) SchemaDefinition(org.jooq.util.SchemaDefinition) ArrayList(java.util.ArrayList) Result(org.jooq.Result) ProcType(org.jooq.util.mysql.mysql.enums.ProcType) Record6(org.jooq.Record6) Record(org.jooq.Record) DataAccessException(org.jooq.exception.DataAccessException)

Aggregations

ArrayList (java.util.ArrayList)1 Record (org.jooq.Record)1 Record6 (org.jooq.Record6)1 Result (org.jooq.Result)1 DataAccessException (org.jooq.exception.DataAccessException)1 RoutineDefinition (org.jooq.util.RoutineDefinition)1 SchemaDefinition (org.jooq.util.SchemaDefinition)1 ProcType (org.jooq.util.mysql.mysql.enums.ProcType)1