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=VgWpZFxgoA5uujYwSOKc9sBy7GRAVd5=dOPrpG4MAD1w@mail.gmail.com
Whole thread Raw
In response to Re: 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,<br /><br />Found few more bugs in new code:<br /><br />A:<br />This got bad:<br /><br /><span
style="font-family:couriernew,monospace">jeevan@ubuntu:~/pg_master$ ./install/bin/psql postgres<br />psql (9.5devel)<br
/>Type"help" for help.<br /><br />postgres=# \set PROMPT1 '%/[%l]%R%# '<br />postgres[1]=# \set PROMPT2 '%/[%l]%R%#
'<br/>postgres[1]=# select<br />postgres[2]-# *<br />postgres[3]-# from<br />postgres[4]-# abc;<br />ERROR:  syntax
errorat or near "fromabc"<br /> LINE 1: select*fromabc;<br />               ^<br />postgres[1]=# <br />postgres[1]=#
<br/>postgres[1]=# \e<br />ERROR:  syntax error at or near "fromabc"<br />LINE 1: select*fromabc;<br />              
^<br/>postgres[1]=# select*fromabc;<br /> ERROR:  syntax error at or near "fromabc"<br />LINE 1: select*fromabc;<br
/>              ^<br />postgres[1]=# <br /></span><br /><br />See query text in LINE 1:. This is because, you have
removedaddition of<br />newline character. Related added_nl_pos. Need more investigation here.<br /> However I don't
thinkthese changes are relevant to what you wanted in this<br />feature.<br />Will you please explain the idea behind
thesechanges ?<br /><br />Moreover, if you don't want to add newline character, then I guess entire<br /> logic related
toadded_nl_pos is NO more required. You may remove this<br />variable and its logic altogether, not sure though. Also
makesure you<br />update the relevant comments while doing so. Here you have removed the code<br /> which is adding the
newlinebut the comment there still reads:<br /><span style="font-family:courier new,monospace">/* insert newlines into
querybuffer between source lines */</span><br /><br />Need more thoughts on this.<br /><br /><br />B:<br />postgres=#
\setPROMPT1 '%/[%l]%R%# '<br />postgres[1]=# \set PROMPT2 '%/[%l]%R%# '<br />postgres[1]=# \e<br
/>postgres[-2147483645]-#limit 1;<br />   relname    <br />--------------<br /> pg_statistic<br /> (1 row)<br /><br
/>postgres[1]=#<br />postgres[1]=# select<br />relname<br />from<br />pg_class<br />limit 1;<br /><br />Logic related
towrapping around the cur_line counter is wrong. Actually<br />issue is with newline variable. If number of lines in \e
editorgoes beyond<br /> INT_MAX (NOT sure about the practical use), then newline will be -ve which<br />then enforces
cur_lineto be negative. To mimic this I have initialized<br />newline = INT_MAX - 1.<br /><br />Thanks<br /><div
class="gmail_extra"><br/> -- <br /><div dir="ltr">Jeevan B Chalke<br />Principal Software Engineer, Product
Development<br/>EnterpriseDB Corporation<br />The Enterprise PostgreSQL Company<br /><br /></div></div></div> 

pgsql-hackers by date:

Previous
From: Guillaume Lelarge
Date:
Subject: Re: Re: how to find the order of joins from Explain command XML plan output in PostgreSQL
Next
From: Pavel Stehule
Date:
Subject: Re: psql: show only failed queries