Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 38a1144

Browse files
committed
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
1 parent 2af28e6 commit 38a1144

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/test/isolation/specscanner.l

+14-5
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212

1313
static int yyline = 1; /* line number for error reporting */
1414

15-
static char litbuf[1024];
16-
static int litbufpos = 0;
15+
#define LITBUF_INIT 1024 /* initial size of litbuf */
16+
static char *litbuf = NULL;
17+
static size_t litbufsize = 0;
18+
static size_t litbufpos = 0;
1719

1820
static void addlitchar(char c);
1921

@@ -41,6 +43,11 @@ comment ("#"{non_newline}*)
4143

4244
%%
4345

46+
%{
47+
litbuf = pg_malloc(LITBUF_INIT);
48+
litbufsize = LITBUF_INIT;
49+
%}
50+
4451
permutation { return PERMUTATION; }
4552
session { return SESSION; }
4653
setup { return SETUP; }
@@ -100,10 +107,12 @@ teardown { return TEARDOWN; }
100107
static void
101108
addlitchar(char c)
102109
{
103-
if (litbufpos >= sizeof(litbuf) - 1)
110+
/* We must always leave room to add a trailing \0 */
111+
if (litbufpos >= litbufsize - 1)
104112
{
105-
fprintf(stderr, "SQL step too long\n");
106-
exit(1);
113+
/* Double the size of litbuf if it gets full */
114+
litbufsize += litbufsize;
115+
litbuf = pg_realloc(litbuf, litbufsize);
107116
}
108117
litbuf[litbufpos++] = c;
109118
}

0 commit comments

Comments
 (0)