Version: 10.0As I understand it, the only valid constant datatype in an ORDER BY is integer. That's validated by the following test:jordan=# SELECT * FROM t ORDER BY 'foo';ERROR: non-integer constant in ORDER BYLINE 1: SELECT * FROM t ORDER BY 'foo';However, using a prepared statement, this behavior can be avoided:jordan=# PREPARE x as SELECT * FROM t ORDER BY $1;PREPAREjordan=# EXECUTE x('foo'); c--- 1It seems to me that there is some missing type checking from ORDER BY.
pgsql-bugs by date:
Соглашаюсь с условиями обработки персональных данных