1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-25 20:23:07 +03:00

Make postgres.bki use the same literal-string syntax as postgresql.conf.

The BKI file's string quoting conventions were previously quite weird,
perhaps as a result of repurposing a function built to scan
single-quoted strings to scan double-quoted ones.  Change to use the
same rules as we use in GUC files, allowing some simplifications in
genbki.pl and initdb.c.

While at it, completely remove the backend's scanstr() function, which
was essentially a duplicate of the string dequoting code in guc-file.l.
Instead export that one (under a less generic name than it had) and let
bootscanner.l use it.  Now we can clarify that scansup.c exists only to
support the main lexer. We could alternatively have removed GUC_scanstr,
but this way seems better since the previous arrangement could mislead
a reader into thinking that scanstr() had something to do with the main
lexer's handling of string literals.  Maybe it did once, but if so it
was a long time ago.

This patch does not bump catversion, since the initially-installed
catalog contents don't change.  Note however that successful initdb
after applying this patch will require up-to-date postgres.bki as well
as postgres and initdb executables.

In passing, remove a bunch of very-long-obsolete #include's in
bootparse.y and bootscanner.l.

John Naylor

Discussion: https://postgr.es/m/CACPNZCtDpd18T0KATTmCggO2GdVC4ow86ypiq5ENff1VnauL8g@mail.gmail.com
This commit is contained in:
Tom Lane
2020-10-04 16:09:55 -04:00
parent 9081bddbd7
commit 97b6144826
9 changed files with 31 additions and 182 deletions

View File

@@ -18,16 +18,10 @@
#include <unistd.h>
#include "access/attnum.h"
#include "access/htup.h"
#include "access/itup.h"
#include "access/tupdesc.h"
#include "bootstrap/bootstrap.h"
#include "catalog/catalog.h"
#include "catalog/heap.h"
#include "catalog/namespace.h"
#include "catalog/pg_am.h"
#include "catalog/pg_attribute.h"
#include "catalog/pg_authid.h"
#include "catalog/pg_class.h"
#include "catalog/pg_namespace.h"
@@ -36,20 +30,7 @@
#include "commands/defrem.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "nodes/nodes.h"
#include "nodes/parsenodes.h"
#include "nodes/pg_list.h"
#include "nodes/primnodes.h"
#include "rewrite/prs2lock.h"
#include "storage/block.h"
#include "storage/fd.h"
#include "storage/ipc.h"
#include "storage/itemptr.h"
#include "storage/off.h"
#include "storage/smgr.h"
#include "tcop/dest.h"
#include "utils/memutils.h"
#include "utils/rel.h"
/*

View File

@@ -15,25 +15,8 @@
*/
#include "postgres.h"
#include "access/attnum.h"
#include "access/htup.h"
#include "access/itup.h"
#include "access/tupdesc.h"
#include "bootstrap/bootstrap.h"
#include "catalog/pg_am.h"
#include "catalog/pg_attribute.h"
#include "catalog/pg_class.h"
#include "nodes/nodes.h"
#include "nodes/parsenodes.h"
#include "nodes/pg_list.h"
#include "nodes/primnodes.h"
#include "parser/scansup.h"
#include "rewrite/prs2lock.h"
#include "storage/block.h"
#include "storage/fd.h"
#include "storage/itemptr.h"
#include "storage/off.h"
#include "utils/rel.h"
#include "utils/guc.h"
/* Not needed now that this file is compiled as part of bootparse. */
/* #include "bootparse.h" */
@@ -66,7 +49,7 @@ static int yyline = 1; /* line number for error reporting */
id [-A-Za-z0-9_]+
sid \"([^\"])*\"
sid \'([^']|\'\')*\'
/*
* Keyword tokens return the keyword text (as a constant string) in yylval.kw,
@@ -120,14 +103,12 @@ NOT { yylval.kw = "NOT"; return XNOT; }
NULL { yylval.kw = "NULL"; return XNULL; }
{id} {
yylval.str = scanstr(yytext);
yylval.str = pstrdup(yytext);
return ID;
}
{sid} {
/* leading and trailing quotes are not passed to scanstr */
yytext[strlen(yytext) - 1] = '\0';
yylval.str = scanstr(yytext+1);
yytext[strlen(yytext)] = '"'; /* restore yytext */
/* strip quotes and escapes */
yylval.str = DeescapeQuotedString(yytext);
return ID;
}