Re: Converting tab-complete.c's else-if chain to a switch

2024-10-10 Thread Tom Lane
Jacob Champion writes: > Meson's coverage generation is unhappy with the new hardcoded #line > references emitted by gen_tabcomplete.pl: > genhtml: ERROR: cannot read > /home/jacob/src/postgres/worktree-oauth/build-dev/tab-complete.in.c > I've attached a potential fix which references $ARGV[0]

Re: Converting tab-complete.c's else-if chain to a switch

2024-10-10 Thread Jacob Champion
Hi Tom, Meson's coverage generation is unhappy with the new hardcoded #line references emitted by gen_tabcomplete.pl: genhtml: ERROR: cannot read /home/jacob/src/postgres/worktree-oauth/build-dev/tab-complete.in.c I've attached a potential fix which references $ARGV[0] instead, but it's not

Re: Converting tab-complete.c's else-if chain to a switch

2024-10-10 Thread Tom Lane
Anthonin Bonnefoy writes: > bd1276a3c9 seems to have introduced a segfault when trying to complete > a word that doesn't have any match. For example, 'postgres=# z\t' will > yield the following backtrace: Interesting --- it seems to depend on which readline version you're using, because I see a c

Re: Converting tab-complete.c's else-if chain to a switch

2024-10-10 Thread Daniel Gustafsson
> On 10 Oct 2024, at 09:22, Anthonin Bonnefoy > wrote: > psql tries to read the previous word when matches are NULL. However, > there's no previous word set here, leading to the segfault. > > I've attached a patch that checks if the previous word does exist > before trying to use it, along with

Re: Converting tab-complete.c's else-if chain to a switch

2024-10-10 Thread Anthonin Bonnefoy
Hi, bd1276a3c9 seems to have introduced a segfault when trying to complete a word that doesn't have any match. For example, 'postgres=# z\t' will yield the following backtrace: #0: psql`pg_strcasecmp(s1="", s2="ACCESS METHOD") at pgstrcasecmp.c:40:39 #1: psql`psql_completion(text=":pgss-", start=

Re: Converting tab-complete.c's else-if chain to a switch

2024-10-07 Thread Tom Lane
Thomas Munro writes: > On Mon, Oct 7, 2024 at 12:11 PM Tom Lane wrote: >> Hmm, I should think that if you break anything in tab-complete.in.c, >> the breakage would propagate to tab-complete.c without difficulty. >> Do you have an example of something that the preprocessor would mask? > Fair poi

Re: Converting tab-complete.c's else-if chain to a switch

2024-10-06 Thread Thomas Munro
On Mon, Oct 7, 2024 at 12:11 PM Tom Lane wrote: > Hmm, I should think that if you break anything in tab-complete.in.c, > the breakage would propagate to tab-complete.c without difficulty. > Do you have an example of something that the preprocessor would mask? Fair point, and nope. Thought withdr

Re: Converting tab-complete.c's else-if chain to a switch

2024-10-06 Thread Tom Lane
Thomas Munro writes: > On Sat, Jul 27, 2024 at 8:03 AM Tom Lane wrote: >> I thought this version of the patch would be less subject to merge >> conflicts than v1, but it didn't take long for somebody to break it. >> Rebased v3 attached -- no nontrivial changes from v2. > +1 Thanks for looking a

Re: Converting tab-complete.c's else-if chain to a switch

2024-10-06 Thread Thomas Munro
On Sat, Jul 27, 2024 at 8:03 AM Tom Lane wrote: > I wrote: > > I modified the preprocessor to work like that, and I like the results > > better than what I had. > > I thought this version of the patch would be less subject to merge > conflicts than v1, but it didn't take long for somebody to break

Re: Converting tab-complete.c's else-if chain to a switch

2024-07-26 Thread Tom Lane
I wrote: > I modified the preprocessor to work like that, and I like the results > better than what I had. I thought this version of the patch would be less subject to merge conflicts than v1, but it didn't take long for somebody to break it. Rebased v3 attached -- no nontrivial changes from v2.

Re: Converting tab-complete.c's else-if chain to a switch

2024-07-16 Thread Tom Lane
I wrote: > Andres Freund writes: >> Hm, the fact that we are continuing to use the same macros in the switch >> makes >> it a bit painful to edit the .in.c in an editor with compiler-warnings >> integration - I see a lot of reported errors ("Expression is not an integer >> constant expression") d

Re: Converting tab-complete.c's else-if chain to a switch

2024-07-15 Thread Tom Lane
Andres Freund writes: > On 2024-07-13 13:16:14 -0400, Tom Lane wrote: >> Of course the main point is the hope that it will work at all with MSVC, but >> I'm not in a position to test that. > It does work with just your patches applied - very nice. Thanks for testing! > The only obvious thing th

Re: Converting tab-complete.c's else-if chain to a switch

2024-07-15 Thread Andres Freund
Hi, On 2024-07-13 13:16:14 -0400, Tom Lane wrote: > I wrote: > > Per discussion elsewhere [1], I've been looking at $SUBJECT. > > Here's a finished patchset to perform this change. Awesome! > With gcc 8.5.0 I see the time drop from about 3 seconds to about 0.7. The > win is less noticeable with

Converting tab-complete.c's else-if chain to a switch

2024-07-11 Thread Tom Lane
Per discussion elsewhere [1], I've been looking at $SUBJECT. I have a very crude Perl hack (too ugly to show yet ;-)) that produces output along the lines of Existing code: /* CREATE STATISTICS */ else if (Matches("CREATE", "STATISTICS", MatchAny)) COMPLETE_WITH("(", "ON"); else