Hi, This patch (psql_remove_include.patch) eliminates the #include of psqlscan.c at the bottom of mainloop.c.
The attached patch uses the %top{} flex feature introduced in flex 2.5.30 released 2003-4-1. (See the NEWS file for flex.) The good news is that config/programs.m4 requires flex >= 2.5.31. The bad news is that RHEL 5 (released 2007-03-14 with a 13 year (10+3 years) support lifecycle) has a flex (2.5.4a) that is too old for this patch. :-( (At least this is what the changelog in flex from the RHEL 5 srpm repo tells me.) I don't know what this means. The flex docs on my box, fwiw, don't mention %top{} in the section describing Posix (in)compatibility. The patch is against git head. All the tests pass, fwiw. Because this depends on the toolchain it wouldn't hurt to build on other architectures/ operating systems. I'm thinking of exposing enough of the psql parser, moving it to libpq, that any client-side app can do what libpq does; given a bunch of sql separated by semi-colons get the results of all the statements. This should also allow the "statement separation" to be done on the client side in libpq. Although I don't imagine that this will have a performance impact on the server side it sounds like a first step toward pushing more of the parsing onto the client. Regards, Karl <k...@meme.com> Free Software: "You don't pay back, you pay forward." -- Robert A. Heinlein P.S. Sent this patch to the list at Sep 27 00:43:28 Central time and it never showed up so I'm sending again with a different subject. Info on the previous message: Subject: Remove #include psqlscan.c from psql message-id=<1348724599.28442.0@mofo>
diff --git a/src/bin/psql/Makefile b/src/bin/psql/Makefile index 771fd71..e05b1cf 100644 --- a/src/bin/psql/Makefile +++ b/src/bin/psql/Makefile @@ -23,7 +23,7 @@ override CPPFLAGS := -I. -I$(srcdir) -I$(libpq_srcdir) -I$(top_srcdir)/src/bin/p OBJS= command.o common.o help.o input.o stringutils.o mainloop.o copy.o \ startup.o prompt.o variables.o large_obj.o print.o describe.o \ tab-complete.o mbprint.o dumputils.o keywords.o kwlookup.o \ - sql_help.o \ + sql_help.o psqlscan.o \ $(WIN32RES) FLEXFLAGS = -Cfe -b -p -p @@ -46,9 +46,6 @@ sql_help.c: sql_help.h ; sql_help.h: create_help.pl $(wildcard $(REFDOCDIR)/*.sgml) $(PERL) $< $(REFDOCDIR) $* -# psqlscan is compiled as part of mainloop -mainloop.o: psqlscan.c - psqlscan.c: psqlscan.l ifdef FLEX $(FLEX) $(FLEXFLAGS) -o'$@' $< diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c index 16c65ec..3f55813 100644 --- a/src/bin/psql/mainloop.c +++ b/src/bin/psql/mainloop.c @@ -413,13 +413,3 @@ MainLoop(FILE *source) return successResult; } /* MainLoop() */ - - -/* - * psqlscan.c is #include'd here instead of being compiled on its own. - * This is because we need postgres_fe.h to be read before any system - * include files, else things tend to break on platforms that have - * multiple infrastructures for stdio.h and so on. flex is absolutely - * uncooperative about that, so we can't compile psqlscan.c on its own. - */ -#include "psqlscan.c" diff --git a/src/bin/psql/mainloop.h b/src/bin/psql/mainloop.h index 134987a..1557187 100644 --- a/src/bin/psql/mainloop.h +++ b/src/bin/psql/mainloop.h @@ -9,6 +9,7 @@ #define MAINLOOP_H #include "postgres_fe.h" +#include "psqlscan.h" int MainLoop(FILE *source); diff --git a/src/bin/psql/psqlscan.l b/src/bin/psql/psqlscan.l index 1208c8f..069c46f 100644 --- a/src/bin/psql/psqlscan.l +++ b/src/bin/psql/psqlscan.l @@ -37,8 +37,17 @@ * *------------------------------------------------------------------------- */ +%} + /* + * postgres_fe.h must be read before any system include files, else + * things tend to break on platforms that have multiple + * infrastructures for stdio.h and so on. + */ +%top{ #include "postgres_fe.h" +} +%{ #include "psqlscan.h" #include <ctype.h>
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers