Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2719905

Browse files
committed
Convert psql's flex lexer to be re-entrant, and make it compile standalone.
Change psqlscan.l to specify '%option reentrant', adjust internal APIsto match, and get rid of its internal static variables. While this isgood cleanup in an abstract sense, the reason to do it right now is thatit seems the only practical way to support use of separate flex lexerswith common PsqlScanState infrastructure. If we build two non-reentrantlexers then we are going to have problems with dangling buffer pointersin whichever lexer isn't active when we transition from one buffer toanother, as well as curious side-effects if we try to share any codebetween the files. (Horiguchi-san had a different solution to that in hispending patch, but I find it ugly and probably broken for corner cases.)Depending on which version of flex you're using, this may result in gettinga "warning: unused variable 'yyg'" warning from psqlscan, similar to theone you'd have seen for a long time in backend/parser/scan.l. I put alocal -Wno-error into CFLAGS for the file, for the convenience of thosewho compile with -Werror.Also, stop compiling psqlscan as part of mainloop.c, and make it astandalone build target instead. This is a lot cleaner than before, thoughit doesn't really change much in practice as of this commit. (I'm not surewhether the MSVC build scripts will need some help with this part, but thebuildfarm will soon tell us.)
1 parentb555ed8 commit2719905

File tree

3 files changed

+176
-118
lines changed

3 files changed

+176
-118
lines changed

‎src/bin/psql/Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ override CPPFLAGS := -I. -I$(srcdir) -I$(libpq_srcdir) -I$(top_srcdir)/src/bin/p
2323
OBJS=command.o common.o help.o input.o stringutils.o mainloop.o copy.o\
2424
startup.o prompt.o variables.o large_obj.o print.o describe.o\
2525
tab-complete.o mbprint.o dumputils.o keywords.o kwlookup.o\
26-
sql_help.o\
26+
sql_help.opsqlscan.o\
2727
$(WIN32RES)
2828

2929

@@ -44,12 +44,14 @@ sql_help.c: sql_help.h ;
4444
sql_help.h: create_help.pl$(wildcard$(REFDOCDIR)/*.sgml)
4545
$(PERL)$<$(REFDOCDIR)$*
4646

47-
# psqlscan is compiled as part of mainloop
48-
mainloop.o: psqlscan.c
49-
5047
psqlscan.c: FLEXFLAGS = -Cfe -p -p
5148
psqlscan.c: FLEX_NO_BACKUP=yes
5249

50+
# Latest flex causes warnings in this file.
51+
ifeq ($(GCC),yes)
52+
psqlscan.o: CFLAGS += -Wno-error
53+
endif
54+
5355
distprep: sql_help.h psqlscan.c
5456

5557
install: all installdirs

‎src/bin/psql/mainloop.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -458,13 +458,3 @@ MainLoop(FILE *source)
458458

459459
returnsuccessResult;
460460
}/* MainLoop() */
461-
462-
463-
/*
464-
* psqlscan.c is #include'd here instead of being compiled on its own.
465-
* This is because we need postgres_fe.h to be read before any system
466-
* include files, else things tend to break on platforms that have
467-
* multiple infrastructures for stdio.h and so on. flex is absolutely
468-
* uncooperative about that, so we can't compile psqlscan.c on its own.
469-
*/
470-
#include"psqlscan.c"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp