Skip to content

Commit 24f8524

Browse files
authored
Merge pull request #3120 from masatake/sql-fix-wrong-promise-area
SQL: fix a typo in the code deciding a promise area
2 parents e7acc5e + d4bdaa5 commit 24f8524

3 files changed

Lines changed: 8 additions & 1 deletion

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
fun1 input.sql /^CREATE OR REPLACE FUNCTION fun1() RETURNS VARCHAR AS '$/;" f
22
fun2 input.sql /^CREATE OR REPLACE FUNCTION fun2() RETURNS VARCHAR LANGUAGE plpgsql AS $\$$/;" f
33
test input.sql /^CREATE FUNCTION test(keys text[], vals text[]) RETURNS text AS$/;" f
4+
test2 input.sql /^CREATE FUNCTION test2(keys text[], vals text[]) RETURNS text AS $ABCDEFGHIJKLMNOPQRSTUVWXYZ\$$/;" f
45
test1_var1 input.sql /^ test1_var1 VARCHAR(64) := $$ABC$$;$/;" v
56
test1_var2 input.sql /^ test1_var2 VARCHAR(64) := $xyz$XYZ$xyz$;$/;" v
67
test1_var3 input.sql /^ test1_var3 INTEGER := 1;$/;" v
78
test2_var1 input.sql /^ test2_var1 VARCHAR(64) := 'ABC2';$/;" v
89
test2_var2 input.sql /^ test2_var2 VARCHAR(64) := 'XYZ2';$/;" v
910
test2_var3 input.sql /^ test2_var3 INTEGER := 2;$/;" v
1011
o input.sql /^ var o = {};$/;" v
12+
q input.sql /^var q={}; return "{}";$/;" v

Units/parser-sql.r/sql_pgSQL_guest.d/input.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,8 @@ $$
3131
return JSON.stringify(o);
3232
$$
3333
LANGUAGE plv8 IMMUTABLE STRICT;
34+
35+
CREATE FUNCTION test2(keys text[], vals text[]) RETURNS text AS $ABCDEFGHIJKLMNOPQRSTUVWXYZ$
36+
var q={}; return "{}";
37+
$ABCDEFGHIJKLMNOPQRSTUVWXYZ$ LANGUAGE plv8 IMMUTABLE STRICT;
38+
-- The fist whitespace is needed to trigger the original bug.

parsers/sql.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ static tokenType parseDollarQuote (vString *const string, const int delimiter, i
797797
linenum[END] = getInputLineNumber ();
798798
offset[END] = getInputLineOffset ();
799799
if (offset[END] > len)
800-
offset[END] =- len;
800+
offset[END] -= len;
801801
*promise = makePromise (NULL,
802802
linenum [START], offset [START],
803803
linenum [END], offset [END],

0 commit comments

Comments
 (0)