Skip to content

sql: add \x slash command as alias for \set display_format=records #56706

@erikgrinaker

Description

@erikgrinaker

psql has a \x [on|off|auto] slash command to switch between table and record output:

test=# SELECT 1, 2, 3;
 ?column? | ?column? | ?column? 
----------+----------+----------
        1 |        2 |        3
(1 row)

test=# \x
Expanded display is on.
test=# SELECT 1, 2, 3;
-[ RECORD 1 ]
?column? | 1
?column? | 2
?column? | 3

cockroach sql supports the same output formats, but uses \set display_format=records instead:

root@:26257/defaultdb> SELECT 1, 2, 3;
  ?column? | ?column? | ?column?
-----------+----------+-----------
         1 |        2 |        3
(1 row)

Time: 0ms total (execution 0ms / network 0ms)

root@:26257/defaultdb> \set display_format=records
root@:26257/defaultdb> SELECT 1, 2, 3;
-[ RECORD 1 ]
?column? | 1
?column? | 2
?column? | 3

Time: 0ms total (execution 0ms / network 0ms)

I propose adding \x as an alias for toggling between records and table, and supporting the optional on and off parameters (but not auto in the first iteration).

Metadata

Metadata

Assignees

No one assigned

    Labels

    O-communityOriginated from the community

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions