Skip to content

Field aliases in qualified catalog queries #77

@qwenger

Description

@qwenger

Hi,

Sorry to bother you again...

It looks like column aliases are not correctly supported in catalog queries when qualified with pg_catalog or information_schema. A few examples:

=> SELECT oid, datname FROM pg_catalog.pg_database;
 oid | datname
-----+---------
 1   | main
(1 row)

=> SELECT oid AS did, datname FROM pg_database;
 did | datname
-----+---------
 1   | main
(1 row)

-- expected: also a column "did" with value 1
=> SELECT oid AS did, datname FROM pg_catalog.pg_database;
 datname
---------
 main
(1 row)
=> SELECT rolname FROM pg_catalog.pg_roles;
    rolname
---------------
 postgres
 public
 pgsqlite_user
(3 rows)

=> SELECT rolname AS name FROM pg_roles;
     name
---------------
 postgres
 public
 pgsqlite_user
(3 rows)

-- expected: non-empty content in the column "name"
=> SELECT rolname AS name FROM pg_catalog.pg_roles;
 name
------



(3 rows)

-- expected: content in the column "rolsuper" to correspond to pg_roles.rolname, not pg_roles.rolsuper
=> SELECT rolname AS rolsuper FROM pg_catalog.pg_roles;
 rolsuper
----------
 t
 f
 t
(3 rows)
=> SELECT oid as did FROM pg_namespace;
 did
------
 11
 2200
(2 rows)

-- expected: a single column "did"
=> SELECT oid as did FROM pg_catalog.pg_namespace;
 oid  |  nspname
------+------------
 11   | pg_catalog
 2200 | public
(2 rows)
=> SELECT catalog_name FROM information_schema.schemata;
 catalog_name
--------------
 main
 main
 main
(3 rows)

-- expected: a column "x" with values
=> SELECT catalog_name AS x FROM information_schema.schemata;
--
(3 rows)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions