Search in sources :

Example 1 with PG_NAMESPACE

use of org.jooq.meta.postgres.pg_catalog.Tables.PG_NAMESPACE in project jOOQ by jOOQ.

the class PostgresDatabase method getRoutines0.

@Override
protected List<RoutineDefinition> getRoutines0() throws SQLException {
    List<RoutineDefinition> result = new ArrayList<>();
    if (!canUseRoutines())
        return result;
    Routines r1 = ROUTINES.as("r1");
    // [#7785] The pg_proc.proisagg column has been replaced incompatibly in PostgreSQL 11
    Field<Boolean> isAgg = (is11() ? field(PG_PROC.PROKIND.eq(inline("a"))) : field("{0}.proisagg", SQLDataType.BOOLEAN, PG_PROC)).as("is_agg");
    return create().select(r1.ROUTINE_SCHEMA, r1.ROUTINE_NAME, r1.SPECIFIC_NAME, r1.ROUTINE_TYPE, when(r1.DATA_TYPE.eq(inline("USER-DEFINED")).and(r1.TYPE_UDT_NAME.eq(inline("geometry"))), inline("geometry")).else_(canCombineArrays() ? when(condition("{0} && ARRAY['o','b']::\"char\"[]", PG_PROC.PROARGMODES), inline("void")).else_(r1.DATA_TYPE) : r1.DATA_TYPE).as("data_type"), r1.CHARACTER_MAXIMUM_LENGTH, // [#12048] TODO: Maintain whether we know the precision or not
    when(r1.NUMERIC_PRECISION.isNull().and(r1.DATA_TYPE.in(inline("time"), inline("timetz"), inline("time without time zone"), inline("time with time zone"), inline("timestamp"), inline("timestamptz"), inline("timestamp without time zone"), inline("timestamp with time zone"))), inline(6)).else_(r1.NUMERIC_PRECISION).as(r1.NUMERIC_PRECISION), r1.NUMERIC_SCALE, r1.TYPE_UDT_SCHEMA, r1.TYPE_UDT_NAME, // Calculate overload index if applicable
    when(count().over(partitionBy(r1.ROUTINE_SCHEMA, r1.ROUTINE_NAME)).gt(one()), rowNumber().over(partitionBy(r1.ROUTINE_SCHEMA, r1.ROUTINE_NAME).orderBy(// replace(field("pg_get_function_arguments({0})", VARCHAR, PG_PROC.OID), inline('"'), inline("")),
    r1.SPECIFIC_NAME))).as("overload"), isAgg).from(r1).join(PG_NAMESPACE).on(PG_NAMESPACE.NSPNAME.eq(r1.SPECIFIC_SCHEMA)).join(PG_PROC).on(PG_PROC.PRONAMESPACE.eq(PG_NAMESPACE.OID)).and(is12() ? condition("nameconcatoid({0}, {1}) = {2}", PG_PROC.PRONAME, PG_PROC.OID, r1.SPECIFIC_NAME) : PG_PROC.PRONAME.concat("_").concat(PG_PROC.OID).eq(r1.SPECIFIC_NAME)).where(r1.ROUTINE_SCHEMA.in(getInputSchemata())).and(tableValuedFunctions() ? condition(not(PG_PROC.PRORETSET)) : noCondition()).and(!getIncludeTriggerRoutines() ? r1.DATA_TYPE.isDistinctFrom(inline("trigger")) : noCondition()).orderBy(r1.ROUTINE_SCHEMA.asc(), r1.ROUTINE_NAME.asc(), field(name("overload")).asc()).collect(mapping(r -> new PostgresRoutineDefinition(this, r), Collectors.<RoutineDefinition>toList()));
}
Also used : RoutineDefinition(org.jooq.meta.RoutineDefinition) Routines(org.jooq.meta.postgres.information_schema.tables.Routines) DSL(org.jooq.impl.DSL) DefaultIndexColumnDefinition(org.jooq.meta.DefaultIndexColumnDefinition) Records.intoList(org.jooq.Records.intoList) DefaultDomainDefinition(org.jooq.meta.DefaultDomainDefinition) DSL.field(org.jooq.impl.DSL.field) DefaultSequenceDefinition(org.jooq.meta.DefaultSequenceDefinition) DSL.condition(org.jooq.impl.DSL.condition) POSTGRES(org.jooq.SQLDialect.POSTGRES) DSL.when(org.jooq.impl.DSL.when) Condition(org.jooq.Condition) ColumnDefinition(org.jooq.meta.ColumnDefinition) BigDecimal(java.math.BigDecimal) Record5(org.jooq.Record5) RoutineDefinition(org.jooq.meta.RoutineDefinition) IndexColumnDefinition(org.jooq.meta.IndexColumnDefinition) Record1(org.jooq.Record1) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) DSL.values(org.jooq.impl.DSL.values) BigInteger(java.math.BigInteger) SQLDialect(org.jooq.SQLDialect) PG_INDEX(org.jooq.meta.postgres.pg_catalog.Tables.PG_INDEX) Record6(org.jooq.Record6) Select(org.jooq.Select) PG_ENUM(org.jooq.meta.postgres.pg_catalog.Tables.PG_ENUM) DSL.partitionBy(org.jooq.impl.DSL.partitionBy) PostgresDSL.arrayAppend(org.jooq.util.postgres.PostgresDSL.arrayAppend) Result(org.jooq.Result) TableType(org.jooq.TableOptions.TableType) BOOLEAN(org.jooq.impl.SQLDataType.BOOLEAN) TableField(org.jooq.TableField) SQLDataType(org.jooq.impl.SQLDataType) DSL.noCondition(org.jooq.impl.DSL.noCondition) ParserException(org.jooq.impl.ParserException) DOMAINS(org.jooq.meta.postgres.information_schema.Tables.DOMAINS) Records.mapping(org.jooq.Records.mapping) AbstractIndexDefinition(org.jooq.meta.AbstractIndexDefinition) SequenceDefinition(org.jooq.meta.SequenceDefinition) DefaultEnumDefinition(org.jooq.meta.DefaultEnumDefinition) DSL.not(org.jooq.impl.DSL.not) PgType(org.jooq.meta.postgres.pg_catalog.tables.PgType) PG_DESCRIPTION(org.jooq.meta.postgres.pg_catalog.Tables.PG_DESCRIPTION) TableDefinition(org.jooq.meta.TableDefinition) DSL.row(org.jooq.impl.DSL.row) IndexDefinition(org.jooq.meta.IndexDefinition) ArrayList(java.util.ArrayList) CHECK_CONSTRAINTS(org.jooq.meta.postgres.information_schema.Tables.CHECK_CONSTRAINTS) SQLException(java.sql.SQLException) DSL.sql(org.jooq.impl.DSL.sql) KEY_COLUMN_USAGE(org.jooq.meta.postgres.information_schema.Tables.KEY_COLUMN_USAGE) PgNamespace(org.jooq.meta.postgres.pg_catalog.tables.PgNamespace) VARCHAR(org.jooq.impl.SQLDataType.VARCHAR) Record(org.jooq.Record) PG_SEQUENCE(org.jooq.meta.postgres.pg_catalog.Tables.PG_SEQUENCE) TABLES(org.jooq.meta.postgres.information_schema.Tables.TABLES) Rows.toRowArray(org.jooq.Rows.toRowArray) PG_CONSTRAINT(org.jooq.meta.postgres.pg_catalog.Tables.PG_CONSTRAINT) SchemaDefinition(org.jooq.meta.SchemaDefinition) PG_TYPE(org.jooq.meta.postgres.pg_catalog.Tables.PG_TYPE) DSL.table(org.jooq.impl.DSL.table) AbstractDatabase(org.jooq.meta.AbstractDatabase) CatalogDefinition(org.jooq.meta.CatalogDefinition) PgIndex(org.jooq.meta.postgres.pg_catalog.tables.PgIndex) DSL.power(org.jooq.impl.DSL.power) COLUMNS(org.jooq.meta.postgres.information_schema.Tables.COLUMNS) VIEWS(org.jooq.meta.postgres.information_schema.Tables.VIEWS) PgInherits(org.jooq.meta.postgres.pg_catalog.tables.PgInherits) Table(org.jooq.Table) DSL.rowNumber(org.jooq.impl.DSL.rowNumber) DataTypeDefinition(org.jooq.meta.DataTypeDefinition) PackageDefinition(org.jooq.meta.PackageDefinition) PG_PROC(org.jooq.meta.postgres.pg_catalog.Tables.PG_PROC) ResultQuery(org.jooq.ResultQuery) DSLContext(org.jooq.DSLContext) PgClass(org.jooq.meta.postgres.pg_catalog.tables.PgClass) SortOrder(org.jooq.SortOrder) Routines(org.jooq.meta.postgres.information_schema.tables.Routines) DSL.name(org.jooq.impl.DSL.name) PG_INHERITS(org.jooq.meta.postgres.pg_catalog.Tables.PG_INHERITS) JooqLogger(org.jooq.tools.JooqLogger) KeyColumnUsage(org.jooq.meta.postgres.information_schema.tables.KeyColumnUsage) Name(org.jooq.Name) DSL.falseCondition(org.jooq.impl.DSL.falseCondition) Field(org.jooq.Field) DSL.select(org.jooq.impl.DSL.select) Collectors(java.util.stream.Collectors) PG_NAMESPACE(org.jooq.meta.postgres.pg_catalog.Tables.PG_NAMESPACE) PARAMETERS(org.jooq.meta.postgres.information_schema.Tables.PARAMETERS) DomainDefinition(org.jooq.meta.DomainDefinition) List(java.util.List) INTEGER(org.jooq.impl.SQLDataType.INTEGER) HSQLDBDatabase(org.jooq.meta.hsqldb.HSQLDBDatabase) PG_DEPEND(org.jooq.meta.postgres.pg_catalog.Tables.PG_DEPEND) SEQUENCES(org.jooq.meta.postgres.information_schema.Tables.SEQUENCES) DefaultCheckConstraintDefinition(org.jooq.meta.DefaultCheckConstraintDefinition) DefaultRelations(org.jooq.meta.DefaultRelations) DSL.count(org.jooq.impl.DSL.count) DefaultDataTypeDefinition(org.jooq.meta.DefaultDataTypeDefinition) DSL.decode(org.jooq.impl.DSL.decode) DSL.nullif(org.jooq.impl.DSL.nullif) HashMap(java.util.HashMap) ParseUnknownFunctions(org.jooq.conf.ParseUnknownFunctions) DSL.replace(org.jooq.impl.DSL.replace) DECIMAL_INTEGER(org.jooq.impl.SQLDataType.DECIMAL_INTEGER) PgConstraint(org.jooq.meta.postgres.pg_catalog.tables.PgConstraint) BIGINT(org.jooq.impl.SQLDataType.BIGINT) NUMERIC(org.jooq.impl.SQLDataType.NUMERIC) DSL.selectFrom(org.jooq.impl.DSL.selectFrom) Collectors.mapping(java.util.stream.Collectors.mapping) ArrayDefinition(org.jooq.meta.ArrayDefinition) UDTDefinition(org.jooq.meta.UDTDefinition) DSL.inline(org.jooq.impl.DSL.inline) CheckConstraints(org.jooq.meta.postgres.information_schema.tables.CheckConstraints) DataAccessException(org.jooq.exception.DataAccessException) ATTRIBUTES(org.jooq.meta.postgres.information_schema.Tables.ATTRIBUTES) DSL.cast(org.jooq.impl.DSL.cast) ForcedType(org.jooq.meta.jaxb.ForcedType) PG_CLASS(org.jooq.meta.postgres.pg_catalog.Tables.PG_CLASS) DSL.one(org.jooq.impl.DSL.one) ROUTINES(org.jooq.meta.postgres.information_schema.Tables.ROUTINES) Collectors.toList(java.util.stream.Collectors.toList) Record12(org.jooq.Record12) DSL.max(org.jooq.impl.DSL.max) DSL.array(org.jooq.impl.DSL.array) EnumDefinition(org.jooq.meta.EnumDefinition) ResultQueryDatabase(org.jooq.meta.ResultQueryDatabase) CommonTableExpression(org.jooq.CommonTableExpression) ArrayList(java.util.ArrayList)

Aggregations

BigDecimal (java.math.BigDecimal)1 BigInteger (java.math.BigInteger)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 Arrays.asList (java.util.Arrays.asList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Collectors.mapping (java.util.stream.Collectors.mapping)1 Collectors.toList (java.util.stream.Collectors.toList)1 CommonTableExpression (org.jooq.CommonTableExpression)1 Condition (org.jooq.Condition)1 DSLContext (org.jooq.DSLContext)1 Field (org.jooq.Field)1 Name (org.jooq.Name)1 Record (org.jooq.Record)1 Record1 (org.jooq.Record1)1 Record12 (org.jooq.Record12)1 Record5 (org.jooq.Record5)1