4
4
* procedural language
5
5
*
6
6
* IDENTIFICATION
7
- * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.26 2001/10/09 04: 15:38 tgl Exp $
7
+ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.27 2001/10/09 15:59:56 tgl Exp $
8
8
*
9
9
* This software is copyrighted by Jan Wieck - Hamburg.
10
10
*
@@ -507,10 +507,16 @@ decl_aliasitem : T_WORD
507
507
plpgsql_ns_setlocal (false );
508
508
name = plpgsql_tolower(yytext);
509
509
if (name[0 ] != ' $' )
510
+ {
511
+ plpgsql_error_lineno = yylineno;
510
512
elog (ERROR, " can only alias positional parameters" );
513
+ }
511
514
nsi = plpgsql_ns_lookup(name, NULL );
512
515
if (nsi == NULL )
516
+ {
517
+ plpgsql_error_lineno = yylineno;
513
518
elog (ERROR, " function has no parameter %s" , name);
519
+ }
514
520
515
521
plpgsql_ns_setlocal (true );
516
522
@@ -585,14 +591,12 @@ decl_defval : ';'
585
591
{
586
592
case 0 :
587
593
plpgsql_error_lineno = lno;
588
- plpgsql_comperrinfo ();
589
594
elog (ERROR, " unexpected end of file" );
590
595
case K_NULL:
591
596
if (yylex () != ' ;' )
592
597
{
593
598
plpgsql_error_lineno = lno;
594
- plpgsql_comperrinfo ();
595
- elog (ERROR, " expectec ; after NULL" );
599
+ elog (ERROR, " expected ; after NULL" );
596
600
}
597
601
free (expr);
598
602
plpgsql_dstring_free (&ds);
@@ -607,7 +611,6 @@ decl_defval : ';'
607
611
if (tok == 0 )
608
612
{
609
613
plpgsql_error_lineno = lno;
610
- plpgsql_comperrinfo ();
611
614
elog (ERROR, " unterminated default value" );
612
615
}
613
616
if (plpgsql_SpaceScanned)
@@ -793,7 +796,7 @@ getdiag_target : T_VARIABLE
793
796
{
794
797
if (yylval.var->isconst)
795
798
{
796
- plpgsql_comperrinfo () ;
799
+ plpgsql_error_lineno = yylineno ;
797
800
elog (ERROR, " %s is declared CONSTANT; can not receive diagnostics" , yylval.var->refname);
798
801
}
799
802
$$ = yylval.var->varno;
@@ -809,7 +812,7 @@ assign_var : T_VARIABLE
809
812
{
810
813
if (yylval.var->isconst)
811
814
{
812
- plpgsql_comperrinfo () ;
815
+ plpgsql_error_lineno = yylineno ;
813
816
elog (ERROR, " %s is declared CONSTANT" , yylval.var->refname);
814
817
}
815
818
$$ = yylval.var->varno;
@@ -1045,7 +1048,6 @@ fori_lower :
1045
1048
if (tok == 0 )
1046
1049
{
1047
1050
plpgsql_error_lineno = lno;
1048
- plpgsql_comperrinfo ();
1049
1051
elog (ERROR, " missing .. to terminate lower bound of for loop" );
1050
1052
}
1051
1053
plpgsql_dstring_append (&ds, yytext);
@@ -1083,7 +1085,6 @@ stmt_fors : opt_label K_FOR lno fors_target K_IN K_SELECT expr_until_loop loop_
1083
1085
new ->row = (PLpgSQL_row *)$4 ;
1084
1086
break ;
1085
1087
default :
1086
- plpgsql_comperrinfo ();
1087
1088
elog (ERROR, " unknown dtype %d in stmt_fors" , $4 ->dtype);
1088
1089
}
1089
1090
new ->query = $7 ;
@@ -1113,7 +1114,6 @@ stmt_dynfors : opt_label K_FOR lno fors_target K_IN K_EXECUTE expr_until_loop lo
1113
1114
new ->row = (PLpgSQL_row *)$4 ;
1114
1115
break ;
1115
1116
default :
1116
- plpgsql_comperrinfo ();
1117
1117
elog (ERROR, " unknown dtype %d in stmt_dynfors" , $4 ->dtype);
1118
1118
}
1119
1119
new ->query = $7 ;
@@ -1339,7 +1339,7 @@ stmt_open : K_OPEN lno cursor_varptr
1339
1339
1340
1340
if (tok != K_FOR)
1341
1341
{
1342
- plpgsql_comperrinfo () ;
1342
+ plpgsql_error_lineno = $2 ;
1343
1343
elog (ERROR, " syntax error at \" %s\" - expected FOR to open a reference cursor" , yytext);
1344
1344
}
1345
1345
@@ -1355,7 +1355,7 @@ stmt_open : K_OPEN lno cursor_varptr
1355
1355
break ;
1356
1356
1357
1357
default :
1358
- plpgsql_comperrinfo () ;
1358
+ plpgsql_error_lineno = $2 ;
1359
1359
elog (ERROR, " syntax error at \" %s\" " , yytext);
1360
1360
}
1361
1361
@@ -1370,7 +1370,7 @@ stmt_open : K_OPEN lno cursor_varptr
1370
1370
1371
1371
if (tok != ' (' )
1372
1372
{
1373
- plpgsql_comperrinfo () ;
1373
+ plpgsql_error_lineno = yylineno ;
1374
1374
elog (ERROR, " cursor %s has arguments" , $3 ->refname);
1375
1375
}
1376
1376
@@ -1384,7 +1384,7 @@ stmt_open : K_OPEN lno cursor_varptr
1384
1384
--cp;
1385
1385
if (*cp != ' )' )
1386
1386
{
1387
- plpgsql_comperrinfo () ;
1387
+ plpgsql_error_lineno = yylineno ;
1388
1388
elog (ERROR, " missing )" );
1389
1389
}
1390
1390
*cp = ' \0 ' ;
@@ -1395,13 +1395,13 @@ stmt_open : K_OPEN lno cursor_varptr
1395
1395
1396
1396
if (tok == ' (' )
1397
1397
{
1398
- plpgsql_comperrinfo () ;
1398
+ plpgsql_error_lineno = yylineno ;
1399
1399
elog (ERROR, " cursor %s has no arguments" , $3 ->refname);
1400
1400
}
1401
1401
1402
1402
if (tok != ' ;' )
1403
1403
{
1404
- plpgsql_comperrinfo () ;
1404
+ plpgsql_error_lineno = yylineno ;
1405
1405
elog (ERROR, " syntax error at \" %s\" " , yytext);
1406
1406
}
1407
1407
}
@@ -1440,7 +1440,7 @@ cursor_varptr : T_VARIABLE
1440
1440
{
1441
1441
if (yylval.var->datatype->typoid != REFCURSOROID)
1442
1442
{
1443
- plpgsql_comperrinfo () ;
1443
+ plpgsql_error_lineno = yylineno ;
1444
1444
elog (ERROR, " %s must be of type cursor or refcursor" , yylval.var->refname);
1445
1445
}
1446
1446
$$ = yylval.var;
@@ -1451,7 +1451,7 @@ cursor_variable : T_VARIABLE
1451
1451
{
1452
1452
if (yylval.var->datatype->typoid != REFCURSOROID)
1453
1453
{
1454
- plpgsql_comperrinfo () ;
1454
+ plpgsql_error_lineno = yylineno ;
1455
1455
elog (ERROR, " %s must be of type refcursor" , yylval.var->refname);
1456
1456
}
1457
1457
$$ = yylval.var->varno;
@@ -1545,7 +1545,6 @@ read_sqlstmt (int until, char *s, char *sqlstart)
1545
1545
{
1546
1546
case 0 :
1547
1547
plpgsql_error_lineno = lno;
1548
- plpgsql_comperrinfo ();
1549
1548
elog (ERROR, " missing %s at end of SQL statement" , s);
1550
1549
break ;
1551
1550
@@ -1613,7 +1612,6 @@ read_datatype(int tok)
1613
1612
if (tok == 0 )
1614
1613
{
1615
1614
plpgsql_error_lineno = lno;
1616
- plpgsql_comperrinfo ();
1617
1615
elog (ERROR, " incomplete datatype declaration" );
1618
1616
}
1619
1617
/* Possible followers for datatype in a declaration */
@@ -1636,6 +1634,8 @@ read_datatype(int tok)
1636
1634
1637
1635
plpgsql_push_back_token (tok);
1638
1636
1637
+ plpgsql_error_lineno = lno; /* in case of error in parse_datatype */
1638
+
1639
1639
result = plpgsql_parse_datatype (plpgsql_dstring_get (&ds));
1640
1640
1641
1641
plpgsql_dstring_free (&ds);
@@ -1711,7 +1711,6 @@ make_select_stmt()
1711
1711
if (tok == 0 )
1712
1712
{
1713
1713
plpgsql_error_lineno = yylineno;
1714
- plpgsql_comperrinfo ();
1715
1714
elog (ERROR, " unexpected end of file" );
1716
1715
}
1717
1716
plpgsql_dstring_append (&ds, yytext);
@@ -1772,6 +1771,7 @@ make_select_stmt()
1772
1771
break ;
1773
1772
1774
1773
default :
1774
+ plpgsql_error_lineno = yylineno;
1775
1775
elog (ERROR, " plpgsql: %s is not a variable or record field" , yytext);
1776
1776
}
1777
1777
}
@@ -1850,7 +1850,6 @@ make_select_stmt()
1850
1850
if (tok == 0 )
1851
1851
{
1852
1852
plpgsql_error_lineno = yylineno;
1853
- plpgsql_comperrinfo ();
1854
1853
elog (ERROR, " unexpected end of file" );
1855
1854
}
1856
1855
plpgsql_dstring_append (&ds, yytext);
@@ -1899,7 +1898,6 @@ make_select_stmt()
1899
1898
if (tok == 0 )
1900
1899
{
1901
1900
plpgsql_error_lineno = yylineno;
1902
- plpgsql_comperrinfo ();
1903
1901
elog (ERROR, " unexpected end of file" );
1904
1902
}
1905
1903
plpgsql_dstring_append (&ds, yytext);
@@ -1989,6 +1987,7 @@ make_fetch_stmt()
1989
1987
break ;
1990
1988
1991
1989
default :
1990
+ plpgsql_error_lineno = yylineno;
1992
1991
elog (ERROR, " plpgsql: %s is not a variable or record field" , yytext);
1993
1992
}
1994
1993
}
@@ -2013,16 +2012,18 @@ make_fetch_stmt()
2013
2012
break ;
2014
2013
2015
2014
default :
2016
- {
2017
- elog (ERROR, " syntax error at '%s'" , yytext);
2018
- }
2015
+ plpgsql_error_lineno = yylineno;
2016
+ elog (ERROR, " syntax error at '%s'" , yytext);
2019
2017
}
2020
2018
2021
2019
if (!have_nexttok)
2022
2020
tok = yylex ();
2023
2021
2024
2022
if (tok != ' ;' )
2023
+ {
2024
+ plpgsql_error_lineno = yylineno;
2025
2025
elog (ERROR, " syntax error at '%s'" , yytext);
2026
+ }
2026
2027
2027
2028
fetch = malloc (sizeof (PLpgSQL_stmt_select));
2028
2029
memset (fetch, 0 , sizeof (PLpgSQL_stmt_fetch));
0 commit comments