Skip to content

information_schema.columns returns blank metadata instead of view columns #3244

Description

@fulghum

Doltgres does not expose view output columns correctly through information_schema.columns. Each view is represented by a single fabricated row with an empty column name, ordinal position 0, and no type metadata.

Reproduction

CREATE TABLE view_metadata_probe (
    id integer,
    label varchar(20)
);

CREATE VIEW view_metadata_probe_v AS
SELECT id, label
FROM view_metadata_probe;

SELECT
    column_name,
    ordinal_position,
    data_type,
    udt_schema,
    udt_name
FROM information_schema.columns
WHERE table_schema = 'public'
  AND table_name = 'view_metadata_probe_v'
ORDER BY ordinal_position;

Doltgres result

The view is represented by one row resembling:

column_name | ordinal_position | data_type | udt_schema | udt_name
------------+------------------+-----------+------------+---------
            | 0                | NULL      | NULL       | NULL

PostgreSQL result

PostgreSQL 16 returns:

column_name | ordinal_position | data_type         | udt_schema | udt_name
------------+------------------+-------------------+------------+---------
id          | 1                | integer           | pg_catalog | int4
label       | 2                | character varying | pg_catalog | varchar

Impact

Schema-discovery tools and database clients cannot determine a view's columns or types through the standard information schema, even though the underlying view data is available.

Implementation context

getRowsFromViews in server/tables/information_schema/columns_table.go currently appends one literal placeholder row for each view. It does not analyze the view definition or iterate over its output schema.

The pg_attribute catalog already analyzes view queries and emits one entry per output column. The information-schema implementation should similarly derive the analyzed view schema and build a normal metadata row for each output column.

This was identified as a pre-existing issue while validating #3241.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions