44 * procedural language
55 *
66 * IDENTIFICATION
7- * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.42 2003/04/27 22:21:22 tgl Exp $
7+ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/gram.y,v 1.43 2003/05/05 16:46:27 tgl Exp $
88 *
99 * This software is copyrighted by Jan Wieck - Hamburg.
1010 *
@@ -334,7 +334,7 @@ decl_statement: decl_varname decl_const decl_datatype decl_notnull decl_defval
334334/* Composite type --- treat as rowtype*/
335335PLpgSQL_row *row;
336336
337- row =build_rowtype ($3 ->typrelid);
337+ row =plpgsql_build_rowtype ($3 ->typrelid);
338338row->dtype= PLPGSQL_DTYPE_ROW;
339339row->refname=$1 .name;
340340row->lineno=$1 .lineno;
@@ -486,7 +486,7 @@ decl_cursor_arglist : decl_cursor_arg
486486
487487new ->dtype = PLPGSQL_DTYPE_ROW;
488488new ->refname = strdup(" *internal*" );
489- new ->lineno =yylineno ;
489+ new ->lineno =plpgsql_scanner_lineno() ;
490490new ->rowtypeclass = InvalidOid;
491491/*
492492 * We make temporary fieldnames/varnos arrays that
@@ -553,7 +553,7 @@ decl_aliasitem: T_WORD
553553nsi = plpgsql_ns_lookup(name,NULL );
554554if (nsi ==NULL )
555555{
556- plpgsql_error_lineno =yylineno ;
556+ plpgsql_error_lineno =plpgsql_scanner_lineno() ;
557557elog (ERROR," function has no parameter %s" , name);
558558}
559559
@@ -578,7 +578,7 @@ decl_varname: T_WORD
578578plpgsql_convert_ident (yytext, &name,1 );
579579/* name should be malloc'd for use as varname*/
580580$$ .name = strdup(name);
581- $$ .lineno =yylineno ;
581+ $$ .lineno =plpgsql_scanner_lineno() ;
582582pfree (name);
583583}
584584;
@@ -625,7 +625,7 @@ decl_defval: ';'
625625PLpgSQL_dstring ds;
626626PLpgSQL_expr*expr;
627627
628- lno =yylineno ;
628+ lno =plpgsql_scanner_lineno() ;
629629expr = malloc(sizeof (PLpgSQL_expr));
630630plpgsql_dstring_init (&ds);
631631plpgsql_dstring_append (&ds," SELECT" );
@@ -1034,7 +1034,7 @@ fori_varname: T_VARIABLE
10341034plpgsql_convert_ident (yytext, &name,1 );
10351035/* name should be malloc'd for use as varname*/
10361036$$ .name = strdup(name);
1037- $$ .lineno =yylineno ;
1037+ $$ .lineno =plpgsql_scanner_lineno() ;
10381038pfree (name);
10391039}
10401040| T_WORD
@@ -1044,7 +1044,7 @@ fori_varname: T_VARIABLE
10441044plpgsql_convert_ident (yytext, &name,1 );
10451045/* name should be malloc'd for use as varname*/
10461046$$ .name = strdup(name);
1047- $$ .lineno =yylineno ;
1047+ $$ .lineno =plpgsql_scanner_lineno() ;
10481048pfree (name);
10491049}
10501050;
@@ -1405,7 +1405,7 @@ stmt_open: K_OPEN lno cursor_varptr
14051405
14061406if (tok !=' (' )
14071407{
1408- plpgsql_error_lineno =yylineno ;
1408+ plpgsql_error_lineno =plpgsql_scanner_lineno() ;
14091409elog (ERROR," cursor %s has arguments" ,
14101410 $3 ->refname);
14111411}
@@ -1427,7 +1427,7 @@ stmt_open: K_OPEN lno cursor_varptr
14271427
14281428if (strncmp(cp," SELECT" ,6 ) !=0 )
14291429{
1430- plpgsql_error_lineno =yylineno ;
1430+ plpgsql_error_lineno =plpgsql_scanner_lineno() ;
14311431elog (ERROR," expected 'SELECT (', got '%s' (internal error)" ,
14321432new ->argquery->query);
14331433}
@@ -1436,7 +1436,7 @@ stmt_open: K_OPEN lno cursor_varptr
14361436cp++;
14371437if (*cp !=' (' )
14381438{
1439- plpgsql_error_lineno =yylineno ;
1439+ plpgsql_error_lineno =plpgsql_scanner_lineno() ;
14401440elog (ERROR," expected 'SELECT (', got '%s' (internal error)" ,
14411441new ->argquery->query);
14421442}
@@ -1454,13 +1454,13 @@ stmt_open: K_OPEN lno cursor_varptr
14541454
14551455if (tok ==' (' )
14561456{
1457- plpgsql_error_lineno =yylineno ;
1457+ plpgsql_error_lineno =plpgsql_scanner_lineno() ;
14581458elog (ERROR," cursor %s has no arguments" , $3 ->refname);
14591459}
14601460
14611461if (tok !=' ;' )
14621462{
1463- plpgsql_error_lineno =yylineno ;
1463+ plpgsql_error_lineno =plpgsql_scanner_lineno() ;
14641464elog (ERROR," syntax error at\" %s\" " , yytext);
14651465}
14661466}
@@ -1502,7 +1502,7 @@ cursor_varptr: T_VARIABLE
15021502
15031503if (((PLpgSQL_var *) yylval.variable)->datatype->typoid != REFCURSOROID)
15041504{
1505- plpgsql_error_lineno =yylineno ;
1505+ plpgsql_error_lineno =plpgsql_scanner_lineno() ;
15061506elog (ERROR," %s must be of type cursor or refcursor" ,
15071507 ((PLpgSQL_var *) yylval.variable)->refname);
15081508}
@@ -1517,7 +1517,7 @@ cursor_variable: T_VARIABLE
15171517
15181518if (((PLpgSQL_var *) yylval.variable)->datatype->typoid != REFCURSOROID)
15191519{
1520- plpgsql_error_lineno =yylineno ;
1520+ plpgsql_error_lineno =plpgsql_scanner_lineno() ;
15211521elog (ERROR," %s must be of type refcursor" ,
15221522 ((PLpgSQL_var *) yylval.variable)->refname);
15231523}
@@ -1583,8 +1583,7 @@ opt_lblname: T_WORD
15831583
15841584lno :
15851585{
1586- plpgsql_error_lineno = yylineno;
1587- $$ = yylineno;
1586+ $$ = plpgsql_error_lineno = plpgsql_scanner_lineno();
15881587}
15891588;
15901589
@@ -1618,7 +1617,7 @@ read_sql_construct(int until,
16181617char buf[32 ];
16191618PLpgSQL_expr*expr;
16201619
1621- lno =yylineno ;
1620+ lno =plpgsql_scanner_lineno () ;
16221621plpgsql_dstring_init (&ds);
16231622plpgsql_dstring_append (&ds, (char *) sqlstart);
16241623
@@ -1690,7 +1689,7 @@ read_datatype(int tok)
16901689bool needspace =false ;
16911690int parenlevel =0 ;
16921691
1693- lno =yylineno ;
1692+ lno =plpgsql_scanner_lineno () ;
16941693
16951694/* Often there will be a lookahead token, but if not, get one*/
16961695if (tok == YYEMPTY)
@@ -1769,14 +1768,14 @@ make_select_stmt(void)
17691768break ;
17701769if (tok ==0 )
17711770{
1772- plpgsql_error_lineno =yylineno ;
1771+ plpgsql_error_lineno =plpgsql_scanner_lineno () ;
17731772elog (ERROR," unexpected end of file" );
17741773}
17751774if (tok == K_INTO)
17761775{
17771776if (have_into)
17781777{
1779- plpgsql_error_lineno =yylineno ;
1778+ plpgsql_error_lineno =plpgsql_scanner_lineno () ;
17801779elog (ERROR," INTO specified more than once" );
17811780}
17821781tok =yylex ();
@@ -1814,7 +1813,7 @@ make_select_stmt(void)
18141813break ;
18151814
18161815default :
1817- plpgsql_error_lineno =yylineno ;
1816+ plpgsql_error_lineno =plpgsql_scanner_lineno () ;
18181817elog (ERROR," plpgsql: %s is not a variable" ,
18191818 yytext);
18201819}
@@ -1824,7 +1823,7 @@ make_select_stmt(void)
18241823row =malloc (sizeof (PLpgSQL_row));
18251824row->dtype = PLPGSQL_DTYPE_ROW;
18261825row->refname =strdup (" *internal*" );
1827- row->lineno =yylineno ;
1826+ row->lineno =plpgsql_scanner_lineno () ;
18281827row->rowtypeclass = InvalidOid;
18291828row->nfields = nfields;
18301829row->fieldnames =malloc (sizeof (char *) * nfields);
@@ -1945,7 +1944,7 @@ make_fetch_stmt(void)
19451944break ;
19461945
19471946default :
1948- plpgsql_error_lineno =yylineno ;
1947+ plpgsql_error_lineno =plpgsql_scanner_lineno () ;
19491948elog (ERROR," plpgsql: %s is not a variable" ,
19501949 yytext);
19511950}
@@ -1955,7 +1954,7 @@ make_fetch_stmt(void)
19551954row =malloc (sizeof (PLpgSQL_row));
19561955row->dtype = PLPGSQL_DTYPE_ROW;
19571956row->refname =strdup (" *internal*" );
1958- row->lineno =yylineno ;
1957+ row->lineno =plpgsql_scanner_lineno () ;
19591958row->rowtypeclass = InvalidOid;
19601959row->nfields = nfields;
19611960row->fieldnames =malloc (sizeof (char *) * nfields);
@@ -2028,7 +2027,7 @@ check_assignable(PLpgSQL_datum *datum)
20282027case PLPGSQL_DTYPE_VAR:
20292028if (((PLpgSQL_var *) datum)->isconst )
20302029{
2031- plpgsql_error_lineno =yylineno ;
2030+ plpgsql_error_lineno =plpgsql_scanner_lineno () ;
20322031elog (ERROR," %s is declared CONSTANT" ,
20332032 ((PLpgSQL_var *) datum)->refname );
20342033}