Skip to content

sql: ORDER BY does not work on pg_type table when sorting by virtual index key #78578

@rafiss

Description

@rafiss

Describe the problem

I ran the same query twice, but the ordering was different each time

To Reproduce

root@:26257/defaultdb> select oid, typname from pg_type order by oid limit 10;
  oid  |   typname
-------+--------------
    17 | bytea
   700 | float4
   869 | inet
  1000 | _bool
  1041 | _inet
  1184 | timestamptz
  1270 | _timetz
  1562 | varbit
  2210 | _regclass
  4097 | _regrole
(10 rows)


root@:26257/defaultdb> select oid, typname from pg_type order by oid limit 10;
   oid  |    typname
--------+----------------
   1008 | _regproc
   1009 | _text
   1043 | varchar
   1083 | time
   1114 | timestamp
   1185 | _timestamptz
   1266 | timetz
   2207 | _regprocedure
  90000 | geometry
  90003 | _geography
(10 rows)

Additional context
It seems related to virtual indexes. If I order by typname instead, if works as expected.

Environment:
Using master branch, commit 9c38f65
v21.1.13 is also affected.

Jira issue: CRDB-14190

Metadata

Metadata

Assignees

Labels

A-sql-pgcatalogA-sql-vtablesVirtual tables - pg_catalog, information_schema etcC-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.T-sql-queriesSQL Queries Team

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions