diff options
author | Tom Lane | 2018-04-17 22:29:11 +0000 |
---|---|---|
committer | Tom Lane | 2018-04-17 22:29:11 +0000 |
commit | 9ffcccdb958d38db5051bf64143330ff445a26cc (patch) | |
tree | d1d6cac61239dca001ceb56afa086af5bb8e8849 /src/backend/bootstrap | |
parent | e90d4ddc639aac7a7217ebc670ad6e49eaeddbf9 (diff) |
Rationalize handling of array type names in bootstrap data.
Formerly, Catalog.pm turned a C array type declaration in the catalog
header files into a SQL type, e.g., 'foo[]'. Along the way, genbki.pl
turned this into '_foo' for the purpose of type lookups, but wrote 'foo[]'
to postgres.bki. During bootstrap, bootscanner.l had to have a special
case rule to tokenize this, and then MapArrayTypeName() would turn 'foo[]'
into '_foo' one more time.
This seems unnecessarily complicated, especially since nobody cares that
much about the readability of postgres.bki. Instead, make Catalog.pm
convert the C declaration into '_foo' to start with, and preserve that
representation of the type name throughout bootstrap data processing.
Then rip out the special-case code in bootscanner.l and bootstrap.c.
This changes postgres.bki to the extent that array fields are now
declared like
proconfig = _text ,
rather than
proconfig = text[] ,
No documentation update, since the SGML docs didn't mention any of this
in the first place, and it's all pretty transparent to writers of
catalog header files anyway.
John Naylor
Discussion: https://postgr.es/m/CAJVSVGUNao=-Q2-vAN3PYcdF5tnL5JAHwGwzZGuYHtq+Mk_9ng@mail.gmail.com
Diffstat (limited to 'src/backend/bootstrap')
-rw-r--r-- | src/backend/bootstrap/bootscanner.l | 6 | ||||
-rw-r--r-- | src/backend/bootstrap/bootstrap.c | 30 |
2 files changed, 0 insertions, 36 deletions
diff --git a/src/backend/bootstrap/bootscanner.l b/src/backend/bootstrap/bootscanner.l index 91d73d713f0..1799757da20 100644 --- a/src/backend/bootstrap/bootscanner.l +++ b/src/backend/bootstrap/bootscanner.l @@ -65,10 +65,8 @@ static int yyline = 1; /* line number for error reporting */ %option prefix="boot_yy" -D [0-9] id [-A-Za-z0-9_]+ sid \"([^\"])*\" -arrayid [A-Za-z0-9_]+\[{D}*\] %% @@ -111,10 +109,6 @@ insert { return INSERT_TUPLE; } "NOT" { return XNOT; } "NULL" { return XNULL; } -{arrayid} { - yylval.str = MapArrayTypeName(yytext); - return ID; - } {id} { yylval.str = scanstr(yytext); return ID; diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index 59cd4b17f32..a148bdc9fd3 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -1037,36 +1037,6 @@ AllocateAttribute(void) } /* - * MapArrayTypeName - * - * Given a type name, produce the corresponding array type name by prepending - * '_' and truncating as needed to fit in NAMEDATALEN-1 bytes. This is only - * used in bootstrap mode, so we can get away with assuming that the input is - * ASCII and we don't need multibyte-aware truncation. - * - * The given string normally ends with '[]' or '[digits]'; we discard that. - * - * The result is a palloc'd string. - */ -char * -MapArrayTypeName(const char *s) -{ - int i, - j; - char newStr[NAMEDATALEN]; - - newStr[0] = '_'; - j = 1; - for (i = 0; i < NAMEDATALEN - 2 && s[i] != '['; i++, j++) - newStr[j] = s[i]; - - newStr[j] = '\0'; - - return pstrdup(newStr); -} - - -/* * index_register() -- record an index that has been set up for building * later. * |