初めに
Qiita Engineer Festa 2024に参加中。完走目指してます。
他のメタコマンドについては以下から読んでください。
\errverboseとは
最も最近のサーバのエラーメッセージを最大の冗長さ、つまり
VERBOSITY
がverbose
に、そしてSHOW_CONTEXT
がalways
に設定されているかのようにして、繰り返します。
試してみた
存在しないテーブルを参照してみる
postgres=# \dt
List of relations
Schema | Name | Type | Owner
--------+-----------+-------+----------
public | sales | table | postgres
public | test | table | postgres
public | test_data | table | postgres
public | users | table | postgres
(4 rows)
postgres=# select * from table;
ERROR: syntax error at or near "table"
LINE 1: select * from table;
\errverboseを使ってみる
postgres=# \errverbose
ERROR: 42601: syntax error at or near "table"
LINE 1: select * from table;
LOCATION: scanner_yyerror, scan.l:1188
LOCATION: scanner_yyerror, scan.l:1188
でエラーの発生箇所(PostgreSQL側)を教えてくれています。.l
と言うのは初めて見たけどLex(レックス)という。
まとめ
PostgreSQLのソースを理解するのに使えそう。
また、ソースを理解している人がどこで起きているエラーなのかで原因特定の方法が変わってきそうだなと思いました。