aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-02-28 16:57:37 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2018-02-28 16:57:37 -0500
commit14ffdd8cf88f6ef2dbfe0df542ef43e30f06b479 (patch)
treea3aa4730f3652d86cd957e72838e66443964f151 /src
parentfda3e65786763bd43abc576a23035a4cd24ed138 (diff)
downloadpostgresql-14ffdd8cf88f6ef2dbfe0df542ef43e30f06b479.tar.gz
postgresql-14ffdd8cf88f6ef2dbfe0df542ef43e30f06b479.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/test/isolation/specscanner.l19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/test/isolation/specscanner.l b/src/test/isolation/specscanner.l
index aed9269c63b..1b56d86d2e2 100644
--- a/src/test/isolation/specscanner.l
+++ b/src/test/isolation/specscanner.l
@@ -12,8 +12,10 @@
static int yyline = 1; /* line number for error reporting */
-static char litbuf[1024];
-static int litbufpos = 0;
+#define LITBUF_INIT 1024 /* initial size of litbuf */
+static char *litbuf = NULL;
+static size_t litbufsize = 0;
+static size_t litbufpos = 0;
static void addlitchar(char c);
@@ -39,6 +41,11 @@ comment ("#"{non_newline}*)
%%
+%{
+ litbuf = pg_malloc(LITBUF_INIT);
+ litbufsize = LITBUF_INIT;
+%}
+
permutation { return(PERMUTATION); }
session { return(SESSION); }
setup { return(SETUP); }
@@ -96,10 +103,12 @@ teardown { return(TEARDOWN); }
static void
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");
- exit(1);
+ /* Double the size of litbuf if it gets full */
+ litbufsize += litbufsize;
+ litbuf = pg_realloc(litbuf, litbufsize);
}
litbuf[litbufpos++] = c;
}