Skip to content

catalog: add pg_class.relpages and pg_am.amcanorder for pgjdbc getIndexInfo - #39720

Merged
sjwiesman merged 3 commits into
MaterializeInc:mainfrom
sjwiesman:pgjdbc-get-index-info
Oct 12, 2026
Merged

sjwiesman merged 3 commits into
MaterializeInc:mainfrom
sjwiesman:pgjdbc-get-index-info

Conversation

@sjwiesman

Copy link
Copy Markdown
Contributor

Motivation

pgjdbc's DatabaseMetaData.getIndexInfo fails against Materialize with column "ci.relpages" does not exist. Once that's fixed it fails again on am.amcanorder. It reads amcanorder because Materialize reports server_version 9.5, and pgjdbc's pre-9.6 path still selects that column. Postgres removed it in 9.6.

The AWS Glue Data Catalog JDBC crawler calls getIndexInfo for every table and view it registers, so a crawl against Materialize aborts on the first object. I checked this end to end with a real Glue crawler in a scratch AWS account. Stock Materialize fails the crawl. With this change, tables, sources and views register with their column types and comments, matching a Postgres 16 control crawled the same way.

Changes

  • pg_class.relpages: new int4 column, always 0. That's what Postgres reports for a relation that has never been vacuumed or analyzed, and it matches the existing reltuples = -1.
  • pg_am.amcanorder: new bool column on a view that still has no rows. It adds a column and reports nothing about Materialize indexes.
  • Result: getIndexInfo now succeeds and returns no rows, because it inner-joins on the empty pg_am. Populating pg_am would mean labeling arrangements as a Postgres access method like btree, so it's out of scope here.

Tests

  • pg_catalog_class.slt asserts relpages.
  • test/testdrive/pg-catalog.td lists the new pg_class column.
  • catalog_server_explain.slt and mz_catalog_server_index_accounting.slt were regenerated. Every diff is either a shifted column number or two extra rows in a builtin-catalog constant.
  • relpages is added to the workload-replay identifier allowlist.

Release notes

This release will let the AWS Glue Data Catalog JDBC crawler, and other pgjdbc clients that call DatabaseMetaData.getIndexInfo, read metadata from Materialize. It adds pg_class.relpages and pg_am.amcanorder.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GaoLYNnyZ2j3BJsTDD59uH

@sjwiesman
sjwiesman requested a review from a team as a code owner October 11, 2026 19:36
@sjwiesman
sjwiesman force-pushed the pgjdbc-get-index-info branch from 80fdedb to 1e4abf6 Compare October 11, 2026 20:08
…exInfo

pgjdbc's DatabaseMetaData.getIndexInfo selects pg_class.relpages and,
because Materialize reports server_version 9.5, the pre-9.6 column
pg_am.amcanorder. Both were missing, so the call failed with "column
does not exist". The AWS Glue Data Catalog JDBC crawler calls
getIndexInfo for every table and view it registers, so a crawl against
Materialize aborted on the first object.

relpages reports 0, which is what PostgreSQL reports for a relation that
has never been vacuumed or analyzed and matches the existing
reltuples = -1. pg_am has no rows, so amcanorder only adds a column and
reports nothing about Materialize indexes. getIndexInfo now succeeds and
returns no rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GaoLYNnyZ2j3BJsTDD59uH
@sjwiesman
sjwiesman force-pushed the pgjdbc-get-index-info branch from 1e4abf6 to b31c1b3 Compare October 11, 2026 22:03
@ggevay
ggevay self-requested a review October 12, 2026 11:54
ggevay and others added 2 commits October 12, 2026 14:07
pgjdbc's getIndexInfo query selects pg_class.relpages and, below server
version 9.6, pg_am.amcanorder. Without those columns the call fails with
`column "ci.relpages" does not exist`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The file lists every builtin column name, per the generator query in its
header, and pg_am.amcanorder is a new one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@ggevay ggevay left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I pushed two small commits to your branch: a getIndexInfo test in the Java smoketest and amcanorder in the workload-replay identifier list.

@sjwiesman
sjwiesman merged commit e332aba into MaterializeInc:main Oct 12, 2026
89 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants