Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc3a0588

Browse files
committed
Remove ancient PL/pgsql line numbering hack.
While this hack arguably has some benefit in terms of making PL/pgsql'sline numbering match the programmer's expectations, it also makesPL/pgsql inconsistent with the remaining PLs, making it difficult forclients to reliably determine where the error actually is. On balance,it seems better to be consistent.Pavel Stehule
1 parente621037 commitc3a0588

File tree

5 files changed

+31
-44
lines changed

5 files changed

+31
-44
lines changed

‎src/pl/plpgsql/src/pl_scanner.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_scanner.c,v 1.5 2010/02/26 02:01:35 momjian Exp $
12+
* $PostgreSQL: pgsql/src/pl/plpgsql/src/pl_scanner.c,v 1.6 2010/08/02 03:46:54 rhaas Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -519,19 +519,6 @@ location_lineno_init(void)
519519
cur_line_start=scanorig;
520520
cur_line_num=1;
521521

522-
/*----------
523-
* Hack: skip any initial newline, so that in the common coding layout
524-
*CREATE FUNCTION ... AS $$
525-
*code body
526-
*$$ LANGUAGE plpgsql;
527-
* we will think "line 1" is what the programmer thinks of as line 1.
528-
*----------
529-
*/
530-
if (*cur_line_start=='\r')
531-
cur_line_start++;
532-
if (*cur_line_start=='\n')
533-
cur_line_start++;
534-
535522
cur_line_end=strchr(cur_line_start,'\n');
536523
}
537524

‎src/test/regress/expected/domain.out

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,15 +436,15 @@ begin
436436
end$$ language plpgsql;
437437
select doubledecrement(3); -- fail because of implicit null assignment
438438
ERROR: domain pos_int does not allow null values
439-
CONTEXT: PL/pgSQL function "doubledecrement" line2 during statement block local variable initialization
439+
CONTEXT: PL/pgSQL function "doubledecrement" line3 during statement block local variable initialization
440440
create or replace function doubledecrement(p1 pos_int) returns pos_int as $$
441441
declare v pos_int := 0;
442442
begin
443443
return p1;
444444
end$$ language plpgsql;
445445
select doubledecrement(3); -- fail at initialization assignment
446446
ERROR: value for domain pos_int violates check constraint "pos_int_check"
447-
CONTEXT: PL/pgSQL function "doubledecrement" line2 during statement block local variable initialization
447+
CONTEXT: PL/pgSQL function "doubledecrement" line3 during statement block local variable initialization
448448
create or replace function doubledecrement(p1 pos_int) returns pos_int as $$
449449
declare v pos_int := 1;
450450
begin
@@ -457,7 +457,7 @@ select doubledecrement(0); -- fail before call
457457
ERROR: value for domain pos_int violates check constraint "pos_int_check"
458458
select doubledecrement(1); -- fail at assignment to v
459459
ERROR: value for domain pos_int violates check constraint "pos_int_check"
460-
CONTEXT: PL/pgSQL function "doubledecrement" line3 at assignment
460+
CONTEXT: PL/pgSQL function "doubledecrement" line4 at assignment
461461
select doubledecrement(2); -- fail at return
462462
ERROR: value for domain pos_int violates check constraint "pos_int_check"
463463
CONTEXT: PL/pgSQL function "doubledecrement" while casting return value to function's return type

‎src/test/regress/expected/guc.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ set work_mem = '1MB';
686686
select myfunc(0);
687687
ERROR: division by zero
688688
CONTEXT: SQL statement "SELECT 1/$1"
689-
PL/pgSQL function "myfunc" line3 at PERFORM
689+
PL/pgSQL function "myfunc" line4 at PERFORM
690690
select current_setting('work_mem');
691691
current_setting
692692
-----------------

‎src/test/regress/expected/plancache.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ end$$ language plpgsql;
235235
select cachebug();
236236
NOTICE: table "temptable" does not exist, skipping
237237
CONTEXT: SQL statement "drop table if exists temptable cascade"
238-
PL/pgSQL function "cachebug" line3 at SQL statement
238+
PL/pgSQL function "cachebug" line4 at SQL statement
239239
NOTICE: 1
240240
NOTICE: 2
241241
NOTICE: 3
@@ -247,7 +247,7 @@ NOTICE: 3
247247
select cachebug();
248248
NOTICE: drop cascades to view vv
249249
CONTEXT: SQL statement "drop table if exists temptable cascade"
250-
PL/pgSQL function "cachebug" line3 at SQL statement
250+
PL/pgSQL function "cachebug" line4 at SQL statement
251251
NOTICE: 1
252252
NOTICE: 2
253253
NOTICE: 3

‎src/test/regress/expected/plpgsql.out

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,16 +1518,16 @@ ERROR: duplicate key value violates unique constraint "pfield_name"
15181518
DETAIL: Key (name)=(PF1_1) already exists.
15191519
update PSlot set backlink = 'WS.not.there' where slotname = 'PS.base.a1';
15201520
ERROR: WS.not.there does not exist
1521-
CONTEXT: PL/pgSQL function "tg_backlink_a" line16 at assignment
1521+
CONTEXT: PL/pgSQL function "tg_backlink_a" line17 at assignment
15221522
update PSlot set backlink = 'XX.illegal' where slotname = 'PS.base.a1';
15231523
ERROR: illegal backlink beginning with XX
1524-
CONTEXT: PL/pgSQL function "tg_backlink_a" line16 at assignment
1524+
CONTEXT: PL/pgSQL function "tg_backlink_a" line17 at assignment
15251525
update PSlot set slotlink = 'PS.not.there' where slotname = 'PS.base.a1';
15261526
ERROR: PS.not.there does not exist
1527-
CONTEXT: PL/pgSQL function "tg_slotlink_a" line16 at assignment
1527+
CONTEXT: PL/pgSQL function "tg_slotlink_a" line17 at assignment
15281528
update PSlot set slotlink = 'XX.illegal' where slotname = 'PS.base.a1';
15291529
ERROR: illegal slotlink beginning with XX
1530-
CONTEXT: PL/pgSQL function "tg_slotlink_a" line16 at assignment
1530+
CONTEXT: PL/pgSQL function "tg_slotlink_a" line17 at assignment
15311531
insert into HSlot values ('HS', 'base.hub1', 1, '');
15321532
ERROR: duplicate key value violates unique constraint "hslot_name"
15331533
DETAIL: Key (slotname)=(HS.base.hub1.1 ) already exists.
@@ -2067,13 +2067,13 @@ end$$ language plpgsql;
20672067
select test_variable_storage();
20682068
NOTICE: should see this
20692069
CONTEXT: SQL statement "SELECT trap_zero_divide(-100)"
2070-
PL/pgSQL function "test_variable_storage" line7 at PERFORM
2070+
PL/pgSQL function "test_variable_storage" line8 at PERFORM
20712071
NOTICE: should see this only if -100 <> 0
20722072
CONTEXT: SQL statement "SELECT trap_zero_divide(-100)"
2073-
PL/pgSQL function "test_variable_storage" line7 at PERFORM
2073+
PL/pgSQL function "test_variable_storage" line8 at PERFORM
20742074
NOTICE: should see this only if -100 fits in smallint
20752075
CONTEXT: SQL statement "SELECT trap_zero_divide(-100)"
2076-
PL/pgSQL function "test_variable_storage" line7 at PERFORM
2076+
PL/pgSQL function "test_variable_storage" line8 at PERFORM
20772077
test_variable_storage
20782078
-----------------------
20792079
123456789012
@@ -2302,7 +2302,7 @@ end;
23022302
$$ language plpgsql;
23032303
select raise_test1(5);
23042304
ERROR: too many parameters specified for RAISE
2305-
CONTEXT: PL/pgSQL function "raise_test1" line2 at RAISE
2305+
CONTEXT: PL/pgSQL function "raise_test1" line3 at RAISE
23062306
create function raise_test2(int) returns int as $$
23072307
begin
23082308
raise notice 'This message has too few parameters: %, %, %', $1, $1;
@@ -2311,7 +2311,7 @@ end;
23112311
$$ language plpgsql;
23122312
select raise_test2(10);
23132313
ERROR: too few parameters specified for RAISE
2314-
CONTEXT: PL/pgSQL function "raise_test2" line2 at RAISE
2314+
CONTEXT: PL/pgSQL function "raise_test2" line3 at RAISE
23152315
--
23162316
-- reject function definitions that contain malformed SQL queries at
23172317
-- compile-time, where possible
@@ -2424,7 +2424,7 @@ ERROR: column "sqlstate" does not exist
24242424
LINE 1: SELECT sqlstate
24252425
^
24262426
QUERY: SELECT sqlstate
2427-
CONTEXT: PL/pgSQL function "excpt_test1" line2 at RAISE
2427+
CONTEXT: PL/pgSQL function "excpt_test1" line3 at RAISE
24282428
create function excpt_test2() returns void as $$
24292429
begin
24302430
begin
@@ -2439,7 +2439,7 @@ ERROR: column "sqlstate" does not exist
24392439
LINE 1: SELECT sqlstate
24402440
^
24412441
QUERY: SELECT sqlstate
2442-
CONTEXT: PL/pgSQL function "excpt_test2" line4 at RAISE
2442+
CONTEXT: PL/pgSQL function "excpt_test2" line5 at RAISE
24432443
create function excpt_test3() returns void as $$
24442444
begin
24452445
begin
@@ -2821,7 +2821,7 @@ begin
28212821
end$$ language plpgsql;
28222822
select footest();
28232823
ERROR: query returned more than one row
2824-
CONTEXT: PL/pgSQL function "footest" line4 at SQL statement
2824+
CONTEXT: PL/pgSQL function "footest" line5 at SQL statement
28252825
create or replace function footest() returns void as $$
28262826
declare x record;
28272827
begin
@@ -2884,7 +2884,7 @@ begin
28842884
end$$ language plpgsql;
28852885
select footest();
28862886
ERROR: query returned no rows
2887-
CONTEXT: PL/pgSQL function "footest" line4 at SQL statement
2887+
CONTEXT: PL/pgSQL function "footest" line5 at SQL statement
28882888
create or replace function footest() returns void as $$
28892889
declare x record;
28902890
begin
@@ -2894,7 +2894,7 @@ begin
28942894
end$$ language plpgsql;
28952895
select footest();
28962896
ERROR: query returned more than one row
2897-
CONTEXT: PL/pgSQL function "footest" line4 at SQL statement
2897+
CONTEXT: PL/pgSQL function "footest" line5 at SQL statement
28982898
create or replace function footest() returns void as $$
28992899
declare x record;
29002900
begin
@@ -2918,7 +2918,7 @@ begin
29182918
end$$ language plpgsql;
29192919
select footest();
29202920
ERROR: query returned no rows
2921-
CONTEXT: PL/pgSQL function "footest" line4 at EXECUTE statement
2921+
CONTEXT: PL/pgSQL function "footest" line5 at EXECUTE statement
29222922
create or replace function footest() returns void as $$
29232923
declare x record;
29242924
begin
@@ -2928,7 +2928,7 @@ begin
29282928
end$$ language plpgsql;
29292929
select footest();
29302930
ERROR: query returned more than one row
2931-
CONTEXT: PL/pgSQL function "footest" line4 at EXECUTE statement
2931+
CONTEXT: PL/pgSQL function "footest" line5 at EXECUTE statement
29322932
drop function footest();
29332933
-- test scrollable cursor support
29342934
create function sc_test() returns setof integer as $$
@@ -2972,7 +2972,7 @@ $$ language plpgsql;
29722972
select * from sc_test(); -- fails because of NO SCROLL specification
29732973
ERROR: cursor can only scan forward
29742974
HINT: Declare it with SCROLL option to enable backward scan.
2975-
CONTEXT: PL/pgSQL function "sc_test" line6 at FETCH
2975+
CONTEXT: PL/pgSQL function "sc_test" line7 at FETCH
29762976
create or replace function sc_test() returns setof integer as $$
29772977
declare
29782978
c refcursor;
@@ -3559,7 +3559,7 @@ end;
35593559
$$ language plpgsql;
35603560
select raise_test();
35613561
ERROR: RAISE option already specified: MESSAGE
3562-
CONTEXT: PL/pgSQL function "raise_test" line2 at RAISE
3562+
CONTEXT: PL/pgSQL function "raise_test" line3 at RAISE
35633563
-- conflict on errcode
35643564
create or replace function raise_test() returns void as $$
35653565
begin
@@ -3568,7 +3568,7 @@ end;
35683568
$$ language plpgsql;
35693569
select raise_test();
35703570
ERROR: RAISE option already specified: ERRCODE
3571-
CONTEXT: PL/pgSQL function "raise_test" line2 at RAISE
3571+
CONTEXT: PL/pgSQL function "raise_test" line3 at RAISE
35723572
-- nothing to re-RAISE
35733573
create or replace function raise_test() returns void as $$
35743574
begin
@@ -3639,7 +3639,7 @@ select case_test(4);
36393639
select case_test(5); -- fails
36403640
ERROR: case not found
36413641
HINT: CASE statement is missing ELSE part.
3642-
CONTEXT: PL/pgSQL function "case_test" line4 at CASE
3642+
CONTEXT: PL/pgSQL function "case_test" line5 at CASE
36433643
select case_test(8);
36443644
case_test
36453645
----------------------
@@ -3667,7 +3667,7 @@ select case_test(12);
36673667
select case_test(13); -- fails
36683668
ERROR: case not found
36693669
HINT: CASE statement is missing ELSE part.
3670-
CONTEXT: PL/pgSQL function "case_test" line4 at CASE
3670+
CONTEXT: PL/pgSQL function "case_test" line5 at CASE
36713671
create or replace function catch() returns void as $$
36723672
begin
36733673
raise notice '%', case_test(6);
@@ -3943,7 +3943,7 @@ LINE 1: SELECT 'foo\\bar\041baz'
39433943
^
39443944
HINT: Use the escape string syntax for backslashes, e.g., E'\\'.
39453945
QUERY: SELECT 'foo\\bar\041baz'
3946-
CONTEXT: PL/pgSQL function "strtest" line3 at RETURN
3946+
CONTEXT: PL/pgSQL function "strtest" line4 at RETURN
39473947
strtest
39483948
-------------
39493949
foo\bar!baz
@@ -4026,7 +4026,7 @@ ERROR: column "foo" does not exist
40264026
LINE 1: SELECT rtrim(roomno) AS roomno, foo FROM Room ORDER BY roomn...
40274027
^
40284028
QUERY: SELECT rtrim(roomno) AS roomno, foo FROM Room ORDER BY roomno
4029-
CONTEXT: PL/pgSQL function "inline_code_block" line3 at FOR over SELECT rows
4029+
CONTEXT: PL/pgSQL function "inline_code_block" line4 at FOR over SELECT rows
40304030
-- Check variable scoping -- a var is not available in its own or prior
40314031
-- default expressions.
40324032
create function scope_test() returns int as $$
@@ -4063,7 +4063,7 @@ LINE 1: select q1,q2 from int8_tbl
40634063
^
40644064
DETAIL: It could refer to either a PL/pgSQL variable or a table column.
40654065
QUERY: select q1,q2 from int8_tbl
4066-
CONTEXT: PL/pgSQL function "conflict_test" line4 at FOR over SELECT rows
4066+
CONTEXT: PL/pgSQL function "conflict_test" line5 at FOR over SELECT rows
40674067
create or replace function conflict_test() returns setof int8_tbl as $$
40684068
#variable_conflict use_variable
40694069
declare r record;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp