Commit 38a1144a authored by Tom Lane's avatar Tom Lane

Remove restriction on SQL block length in isolationtester scanner.

specscanner.l had a fixed limit of 1024 bytes on the length of
individual SQL stanzas in an isolation test script.  People are
starting to run into that, so fix it by making the buffer resizable.

Once we allow this in HEAD, it seems inevitable that somebody will
try to back-patch a test that exceeds the old limit, so back-patch
this change as a preventive measure.

Daniel Gustafsson

Discussion: https://postgr.es/m/8D628BE4-6606-4FF6-A3FF-8B2B0E9B43D0@yesql.se
parent 2af28e60
...@@ -12,8 +12,10 @@ ...@@ -12,8 +12,10 @@
static int yyline = 1; /* line number for error reporting */ static int yyline = 1; /* line number for error reporting */
static char litbuf[1024]; #define LITBUF_INIT 1024 /* initial size of litbuf */
static int litbufpos = 0; static char *litbuf = NULL;
static size_t litbufsize = 0;
static size_t litbufpos = 0;
static void addlitchar(char c); static void addlitchar(char c);
...@@ -41,6 +43,11 @@ comment ("#"{non_newline}*) ...@@ -41,6 +43,11 @@ comment ("#"{non_newline}*)
%% %%
%{
litbuf = pg_malloc(LITBUF_INIT);
litbufsize = LITBUF_INIT;
%}
permutation { return PERMUTATION; } permutation { return PERMUTATION; }
session { return SESSION; } session { return SESSION; }
setup { return SETUP; } setup { return SETUP; }
...@@ -100,10 +107,12 @@ teardown { return TEARDOWN; } ...@@ -100,10 +107,12 @@ teardown { return TEARDOWN; }
static void static void
addlitchar(char c) addlitchar(char c)
{ {
if (litbufpos >= sizeof(litbuf) - 1) /* We must always leave room to add a trailing \0 */
if (litbufpos >= litbufsize - 1)
{ {
fprintf(stderr, "SQL step too long\n"); /* Double the size of litbuf if it gets full */
exit(1); litbufsize += litbufsize;
litbuf = pg_realloc(litbuf, litbufsize);
} }
litbuf[litbufpos++] = c; litbuf[litbufpos++] = c;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment