postgresql/src/bin/psql
Tom Lane f391d9dc93 Convert tab-complete's long else-if chain to a switch statement.
Rename tab-complete.c to tab-complete.in.c, create the preprocessor
script gen_tabcomplete.pl, and install Makefile/meson.build rules
to create tab-complete.c from tab-complete.in.c.  The preprocessor
converts match_previous_words' else-if chain into a switch and
populates tcpatterns[] with the data needed by the driver loop.

The initial HeadMatches/TailMatches/Matches test in each else-if arm
is now performed in a table-driven loop.  Where we get a match, the
corresponding switch case is invoked to see if the match succeeds.
(It might not, if there were additional conditions in the original
else-if test.)

The total number of string comparisons done is just about the
same as it was in the previous coding; however, now that we
have table-driven logic underlying the handmade rules, there
is room to improve that.  For now I haven't bothered because
tab completion is still plenty fast enough for human use.
If the number of rules keeps increasing, we might someday
need to do more in that area.

The immediate benefit of all this thrashing is that C compilers
frequently don't deal well with long else-if chains.  On gcc 8.5.0,
this reduces the compile time of tab-complete.c by about a factor of
four, while MSVC is reported to crash outright with the previous
coding.

Discussion: https://postgr.es/m/2208466.1720729502@sss.pgh.pa.us
2024-10-07 12:22:10 -04:00
..
po Translation updates 2024-06-24 13:11:27 +02:00
t Remove test-case workarounds for ancient libedit versions. 2024-09-04 16:25:28 -04:00
.gitignore Convert tab-complete's long else-if chain to a switch statement. 2024-10-07 12:22:10 -04:00
command.c psql: Clean up more aggressively state of \bind[_named], \parse and \close 2024-09-19 15:39:01 +09:00
command.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
common.c psql: Clean up more aggressively state of \bind[_named], \parse and \close 2024-09-19 15:39:01 +09:00
common.h psql: Clean up more aggressively state of \bind[_named], \parse and \close 2024-09-19 15:39:01 +09:00
copy.c Do not treat \. as an EOF marker in CSV mode for COPY IN. 2024-09-30 17:57:12 -04:00
copy.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
create_help.pl Update copyright for 2024 2024-01-03 20:49:05 -05:00
crosstabview.c Use new overflow-safe integer comparison functions. 2024-02-16 14:05:36 -06:00
crosstabview.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
describe.c Fix psql describe commands' handling of ACL columns for old servers. 2024-09-24 17:21:38 -04:00
describe.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
gen_tabcomplete.pl Convert tab-complete's long else-if chain to a switch statement. 2024-10-07 12:22:10 -04:00
help.c psql: Add more meta-commands able to use the extended protocol 2024-08-22 16:25:57 +09:00
help.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
input.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
input.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
large_obj.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
large_obj.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
mainloop.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
mainloop.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
Makefile Convert tab-complete's long else-if chain to a switch statement. 2024-10-07 12:22:10 -04:00
meson.build Convert tab-complete's long else-if chain to a switch statement. 2024-10-07 12:22:10 -04:00
nls.mk More use of getpwuid_r() directly 2024-09-02 09:04:30 +02:00
prompt.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
prompt.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
psqlrc.sample Improve FILES section of psql reference page. 2014-01-14 19:27:57 -05:00
psqlscanslash.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
psqlscanslash.l Allow noise semicolons ending psql \sf, \ef, \sv, \ev commands. 2024-01-10 14:20:09 -05:00
settings.h psql: Add more meta-commands able to use the extended protocol 2024-08-22 16:25:57 +09:00
startup.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
stringutils.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
stringutils.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
tab-complete.h Update copyright for 2024 2024-01-03 20:49:05 -05:00
tab-complete.in.c Convert tab-complete's long else-if chain to a switch statement. 2024-10-07 12:22:10 -04:00
variables.c Update copyright for 2024 2024-01-03 20:49:05 -05:00
variables.h Update copyright for 2024 2024-01-03 20:49:05 -05:00