Jooq: Postgres 12 exception in code generation output: "column c.consrc does not exist"

Created on 6 Oct 2019  路  8Comments  路  Source: jOOQ/jOOQ

When trying to generate code with Postgres 12 I get the following error (which looks like postgres has changed something).

org.jooq.exception.DataAccessException: SQL [with recursive "domains"("domain_id", "base_id", "typbasetype", "src") as ((select "d".oid, "d".oid, "d"."typbasetype", array["c"."consrc"] from "pg_catalog"."pg_type" as "d" join "pg_catalog"."pg_namespace" as "n" on "n".oid = "d"."typnamespace" left outer join "pg_catalog"."pg_constraint" as "c" on "d".oid = "c"."contypid" where ("d"."typtype" = ? and "n"."nspname" in (?))) union all (select "domains"."domain_id", "d".oid, "d"."typbasetype", case when "c"."consrc" is null then "domains"."src" else array_append("domains"."src", "c"."consrc") end from "domains" join "pg_catalog"."pg_type" as "d" on "domains"."typbasetype" = "d".oid left outer join "pg_catalog"."pg_constraint" as "c" on "d".oid = "c"."contypid")) select "n"."nspname", "d"."typname", "d"."typnotnull", "d"."typdefault", "b"."typname", "b"."typlen", "domains"."src" from "pg_catalog"."pg_type" as "d" join "domains" on ("domains"."typbasetype" = ? and "domains"."domain_id" = "d".oid) join "pg_catalog"."pg_type" as "b" on "domains"."base_id" = "b".oid join "pg_catalog"."pg_namespace" as "n" on "n".oid = "d"."typnamespace" where ("d"."typtype" = ? and "n"."nspname" in (?)) order by "n"."nspname", "d"."typname"]; ERROR: column c.consrc does not exist
  Hinweis: Perhaps you meant to reference the column "c.conkey" or the column "c.conbin".
  Position: 127

Please let me know if I can provide further assistance.
PS I'm on 3.11.12

Code Generation All Editions Urgent Fixed Defect

Most helpful comment

Fixed for jOOQ 3.13.0. Backport scheduled for 3.12.2 (#9334)

All 8 comments

Thanks a lot for your report. We'll look into this ASAP. It appears that a backwards incompatible change in PostgreSQL's pg_catalog schema has happened between 11 and 12.

The error is produced when fetching domains:

[ERROR] Error while fetching domains
org.jooq.exception.DataAccessException: SQL [with recursive "domains"("domain_id", "base_id", "typbasetype", "src") as ((select "d".oid, "d".oid, "d"."typbasetype", array["c"."consrc"] from "pg_catalog"."pg_type" as "d" join "pg_catalog"."pg_namespace" as "n" on "n".oid = "d"."typnamespace" left outer join "pg_catalog"."pg_constraint" as "c" on "d".oid = "c"."contypid" where ("d"."typtype" = ? and "n"."nspname" in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?))) union all (select "domains"."domain_id", "d".oid, "d"."typbasetype", case when "c"."consrc" is null then "domains"."src" else array_append("domains"."src", "c"."consrc") end from "domains" join "pg_catalog"."pg_type" as "d" on "domains"."typbasetype" = "d".oid left outer join "pg_catalog"."pg_constraint" as "c" on "d".oid = "c"."contypid")) select "n"."nspname", "d"."typname", "d"."typnotnull", "d"."typdefault", "b"."typname", "b"."typlen", "domains"."src" from "pg_catalog"."pg_type" as "d" join "domains" on ("domains"."typbasetype" = ? and "domains"."domain_id" = "d".oid) join "pg_catalog"."pg_type" as "b" on "domains"."base_id" = "b".oid join "pg_catalog"."pg_namespace" as "n" on "n".oid = "d"."typnamespace" where ("d"."typtype" = ? and "n"."nspname" in (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)) order by "n"."nspname", "d"."typname" -- SQL rendered with a free trial version of jOOQ 3.13.0-SNAPSHOT]; ERROR: column c.consrc does not exist
  Hinweis: Perhaps you meant to reference the column "c.conkey" or the column "c.conbin".
  Position: 127
    at org.jooq_3.13.0-SNAPSHOT.POSTGRES.debug (Unknown Source)
    at org.jooq.impl.Tools.translate (Tools.java:2717)
    at org.jooq.impl.DefaultExecuteContext.sqlException (DefaultExecuteContext.java:755)
    at org.jooq.impl.AbstractQuery.execute (AbstractQuery.java:382)
    at org.jooq.impl.AbstractResultQuery.fetch (AbstractResultQuery.java:353)
    at org.jooq.impl.AbstractResultQuery.iterator (AbstractResultQuery.java:364)
    at org.jooq.impl.SelectImpl.iterator (SelectImpl.java:2700)
    at org.jooq.meta.postgres.PostgresDatabase.getDomains0 (PostgresDatabase.java:635)
    at org.jooq.meta.AbstractDatabase.getDomains (AbstractDatabase.java:1781)
    at org.jooq.codegen.JavaGenerator.generate (JavaGenerator.java:581)
    at org.jooq.codegen.JavaGenerator.generate (JavaGenerator.java:468)
    at org.jooq.codegen.JavaGenerator.generate (JavaGenerator.java:389)
    at org.jooq.codegen.GenerationTool.run0 (GenerationTool.java:805)
    at org.jooq.codegen.GenerationTool.run (GenerationTool.java:221)
    at org.jooq.codegen.GenerationTool.generate (GenerationTool.java:216)
    at org.jooq.codegen.maven.Plugin.execute (Plugin.java:198)

Domains are currently not really used yet, so the error is merely cosmetic.

The pg_constraint.consrc column should not have been used before PostgreSQL 12. I suspect it was deprecated, at least that's how I read the docs:

consrc is not updated when referenced objects change; for example, it won't track renaming of columns. Rather than relying on this field, it's best to use pg_get_constraintdef() to extract the definition of a check constraint.

From: https://www.postgresql.org/docs/11/catalog-pg-constraint.html

Given that pg_get_constraintdef() has been available for a long time, we'll just use that instead, for now.

Fixed for jOOQ 3.13.0. Backport scheduled for 3.12.2 (#9334)

Hi @lukaseder thank you for the scheduled update but what should we do in the meantime to fix this error ?

As mentioned before:

Domains are currently not really used yet, so the error is merely cosmetic.

We'll release a patch version soon.

I run maven with --fail-at-end wich helped overcome this in the build process.

Thank you @eiswind that did the trick

Was this page helpful?
0 / 5 - 0 ratings