Re: tab-completion debug print

From: David Fetter <david(at)fetter(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: tab-completion debug print
Date: 2018-11-25 00:17:27
Message-ID: 20181125001727.GM958@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Nov 23, 2018 at 04:32:31PM -0500, Tom Lane wrote:
> Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp> writes:
> > I was reminded that I was often annoyed with identifying the code
> > that made a word-completion, by hearing the same complaint from a
> > collegue of mine just now.
> > Something like the attached that tweaks completion_matches calls
> > lets psql emit the line number where a word-completion
> > happens. The output can be split out using redirection so that it
> > doesn't break into the conversation on console.
>
> > (make -s COPT=-DTABCOMPLETION_DEBUG install)
> > $ psql postgres 2>~debug.out
> > =# alt[tab]er [tab]t[tab]ab[tab] [tab]
>
> > You can see the following output in another bash session.
> > $ tail -f ~/debug.out
> > [1414][1435][1435][1435][1431]
> > Every number enclosed by brackets is the line number in
> > tab-complete.c, where completion happens.
>
> > Is this useful? Any suggestions, thoughts?
>
> Hm. I can see the value of instrumenting tab-complete when you're trying
> to debug why it did something, but this output format seems pretty terse
> and unreadable. Can we get it to print the completion text as well?
> I'm imagining something more like
>
> 1414: "er "
> 1435: ""
> 1435: "ab"
> 1435: ""
> 1431: ""
>
> Perhaps there's room as well to print the context that the match looked
> at:
>
> 1414: "alt" -> "er "
> 1435: "alter " -> ""
> 1435: "alter t" -> "ab"
>
> etc.
>
> regards, tom lane

Is this something along the lines of what you had in mind?

Best,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

Attachment Content-Type Size
0001-v0002-Surface-tab-completions-for-debugging.patch text/x-diff 1.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2018-11-25 00:53:30 Re: POC for a function trust mechanism
Previous Message Thomas Munro 2018-11-24 23:59:37 Re: pgsql: Add WL_EXIT_ON_PM_DEATH pseudo-event.