add line number as prompt option to psql - Mailing list pgsql-hackers

From Sawada Masahiko
Subject add line number as prompt option to psql
Date
Msg-id CAD21AoBCcSEmXvB4eF3Z+Bo+2buqK9ecidtAzV=gAniK5x0puQ@mail.gmail.com
Whole thread Raw
Responses Re: add line number as prompt option to psql  (Jeevan Chalke <jeevan.chalke@enterprisedb.com>)
List pgsql-hackers
Hi all,

The attached IWP patch is one prompt option for psql, which shows
current line number.
If the user made syntax error with too long SQL then psql outputs
message as following.

ERROR:  syntax error at or near "a"
LINE 250: hoge
                ^
psql teaches me where syntax error is occurred, but it is not kind
when SQL is too long.
We can use write SQL with ¥e(editor) command(e.g., emacs) , and we can
know line number.
but it would make terminal log dirty . It will make analyzing of log
difficult after error is occurred.
(I think that we usually use copy & paste)

After attached this patch, we will be able to use %l option as prompting option.

e.g.,
$ cat ~/.psqlrc
\set PROMPT2 '%/[%l]%R%# '
\set PROMPT1 '%/[%l]%R%# '
$ psql -d postgres
postgres[1]=# select
postgres[2]-# *
postgres[3]-# from
postgres[4]-# hoge;

The past discussion is following.
<http://www.postgresql.org/message-id/CAFj8pRC1ruPk6+chA1jpxPh3uS_zipaBDOvmcEex4wPbp2kZMQ@mail.gmail.com>

Please give me feedback.

Regards,

-------
Sawada Masahiko

Attachment

pgsql-hackers by date:

Previous
From: Claudio Freire
Date:
Subject: Re: B-Tree support function number 3 (strxfrm() optimization)
Next
From: Tom Lane
Date:
Subject: Re: lo_create(oid, bytea) breaks every extant release of libpq