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

Commit 14ffdd8

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 fda3e65 commit 14ffdd8

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/test/isolation/specscanner.l

Lines changed: 14 additions & 5 deletions
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

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

4042
%%
4143

44+
%{
45+
litbuf = pg_malloc(LITBUF_INIT);
46+
litbufsize = LITBUF_INIT;
47+
%}
48+
4249
permutation { return(PERMUTATION); }
4350
session { return(SESSION); }
4451
setup { return(SETUP); }
@@ -96,10 +103,12 @@ teardown { return(TEARDOWN); }
96103
static void
97104
addlitchar(char c)
98105
{
99-
if (litbufpos >= sizeof(litbuf) - 1)
106+
/* We must always leave room to add a trailing \0 */
107+
if (litbufpos >= litbufsize - 1)
100108
{
101-
fprintf(stderr, "SQL step too long\n");
102-
exit(1);
109+
/* Double the size of litbuf if it gets full */
110+
litbufsize += litbufsize;
111+
litbuf = pg_realloc(litbuf, litbufsize);
103112
}
104113
litbuf[litbufpos++] = c;
105114
}

0 commit comments

Comments
 (0)