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

From Jeevan Chalke
Subject Re: add line number as prompt option to psql
Date
Msg-id CAM2+6=U1uuy33Y+sW7y4AtnQz5VEo+Xst1=PyHsTsyE=i_y-TA@mail.gmail.com
Whole thread Raw
In response to add line number as prompt option to psql  (Sawada Masahiko <sawada.mshk@gmail.com>)
Responses Re: add line number as prompt option to psql  (Sawada Masahiko <sawada.mshk@gmail.com>)
List pgsql-hackers
<div dir="ltr">Hi Sawada Masahiko,<br /><br />I liked this feature. So I have reviewed it.<br /><br />Changes are
straightforward and looks perfect.<br />No issues found with make/make install/initdb/regression.<br /><br />However I
wouldsuggest removing un-necessary braces at if, as we have only<br /> one statement into it.<br /><br /><span
style="font-family:couriernew,monospace">    if (++cur_line >= INT_MAX)<br />    {<br />        cur_line = 1;<br
/>   }<br /></span><br />Also following looks wrong:<br /><br /><span style="font-family:courier
new,monospace">postgres[1]=#select<br /> postgres[2]-# *<br />postgres[3]-# from<br />postgres[4]-# tab;<br /> a <br
/>---<br/>(0 rows)<br /><br />postgres[1]=# select<br />*<br />from<br />tab<br />postgres[2]-# where t > 10;<br
/>ERROR: column "t" does not exist<br />LINE 5: where t > 10;<br />               ^</span><br /><br />Line number in
ERRORis 5 which is correct.<br />But line number in psql prompt is wrong.<br /><br />To get first 4 lines I have simply
usedup arrow followed by an enter for<br />which I was expecting 5 in psql prompt.<br /> But NO it was 2 which is
certainlywrong.<br /><br />Need to handle above carefully.<br /><br />Thanks<br /></div><div class="gmail_extra"><br
/><br/><div class="gmail_quote">On Thu, Jun 12, 2014 at 10:46 PM, Sawada Masahiko <span dir="ltr"><<a
href="mailto:sawada.mshk@gmail.com"target="_blank">sawada.mshk@gmail.com</a>></span> wrote:<br /><blockquote
class="gmail_quote"style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br /><br /> The
attachedIWP patch is one prompt option for psql, which shows<br /> current line number.<br /> If the user made syntax
errorwith too long SQL then psql outputs<br /> message as following.<br /><br /> ERROR:  syntax error at or near "a"<br
/>LINE 250: hoge<br />                 ^<br /> psql teaches me where syntax error is occurred, but it is not kind<br />
whenSQL is too long.<br /> We can use write SQL with ¥e(editor) command(e.g., emacs) , and we can<br /> know line
number.<br/> but it would make terminal log dirty . It will make analyzing of log<br /> difficult after error is
occurred.<br/> (I think that we usually use copy & paste)<br /><br /> After attached this patch, we will be able to
use%l option as prompting option.<br /><br /> e.g.,<br /> $ cat ~/.psqlrc<br /> \set PROMPT2 '%/[%l]%R%# '<br /> \set
PROMPT1'%/[%l]%R%# '<br /> $ psql -d postgres<br /> postgres[1]=# select<br /> postgres[2]-# *<br /> postgres[3]-#
from<br/> postgres[4]-# hoge;<br /><br /> The past discussion is following.<br /> <<a
href="http://www.postgresql.org/message-id/CAFj8pRC1ruPk6+chA1jpxPh3uS_zipaBDOvmcEex4wPbp2kZMQ@mail.gmail.com"
target="_blank">http://www.postgresql.org/message-id/CAFj8pRC1ruPk6+chA1jpxPh3uS_zipaBDOvmcEex4wPbp2kZMQ@mail.gmail.com</a>><br
/><br/> Please give me feedback.<br /><br /> Regards,<br /><br /> -------<br /> Sawada Masahiko<br /><br /><br /> --<br
/>Sent via pgsql-hackers mailing list (<a
href="mailto:pgsql-hackers@postgresql.org">pgsql-hackers@postgresql.org</a>)<br/> To make changes to your
subscription:<br/><a href="http://www.postgresql.org/mailpref/pgsql-hackers"
target="_blank">http://www.postgresql.org/mailpref/pgsql-hackers</a><br/><br /></blockquote></div><br /><br clear="all"
/><br/>-- <br /><div dir="ltr">Jeevan B Chalke<br />Principal Software Engineer, Product Development<br />EnterpriseDB
Corporation<br/>The Enterprise PostgreSQL Company<br /><br />Phone: +91 20 30589500<br /><br />Website: <a
href="http://www.enterprisedb.com"target="_blank">www.enterprisedb.com</a><br />EnterpriseDB Blog: <a
href="http://blogs.enterprisedb.com/"target="_blank">http://blogs.enterprisedb.com/</a><br />Follow us on Twitter: <a
href="http://www.twitter.com/enterprisedb"target="_blank">http://www.twitter.com/enterprisedb</a><br /><br />This
e-mailmessage (and any attachment) is intended for the use of the individual or entity to whom it is addressed. This
messagecontains information from EnterpriseDB Corporation that may be privileged, confidential, or exempt from
disclosureunder applicable law. If you are not the intended recipient or authorized to receive this for the intended
recipient,any use, dissemination, distribution, retention, archiving, or copying of this communication is strictly
prohibited.If you have received this e-mail in error, please notify the sender immediately by reply e-mail and delete
thismessage.</div></div> 

pgsql-hackers by date:

Previous
From: Kyotaro HORIGUCHI
Date:
Subject: Re: inherit support for foreign tables
Next
From: Fujii Masao
Date:
Subject: Re: replication commands and log_statements