99 *
1010 *
1111 * IDENTIFICATION
12- * $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.98 2007/02/08 18:37:14 tgl Exp $
12+ * $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.99 2007/02/19 03: 18:51 tgl Exp $
1313 *
1414 *-------------------------------------------------------------------------
1515 */
@@ -1728,9 +1728,7 @@ read_sql_construct(int until,
17281728 {
17291729 parenlevel--;
17301730 if (parenlevel < 0 )
1731- ereport (ERROR,
1732- (errcode (ERRCODE_SYNTAX_ERROR),
1733- errmsg (" mismatched parentheses" )));
1731+ yyerror (" mismatched parentheses" );
17341732 }
17351733 /*
17361734 * End of function definition is an error, and we don't expect to
@@ -1739,11 +1737,9 @@ read_sql_construct(int until,
17391737 */
17401738 if (tok == 0 || tok == ' ;' )
17411739 {
1742- plpgsql_error_lineno = lno;
17431740 if (parenlevel != 0 )
1744- ereport (ERROR,
1745- (errcode (ERRCODE_SYNTAX_ERROR),
1746- errmsg (" mismatched parentheses" )));
1741+ yyerror (" mismatched parentheses" );
1742+ plpgsql_error_lineno = lno;
17471743 if (isexpression)
17481744 ereport (ERROR,
17491745 (errcode (ERRCODE_SYNTAX_ERROR),
@@ -1811,6 +1807,7 @@ read_datatype(int tok)
18111807{
18121808 int lno;
18131809 PLpgSQL_dstring ds;
1810+ char *type_name;
18141811 PLpgSQL_type *result;
18151812 bool needspace = false ;
18161813 int parenlevel = 0 ;
@@ -1833,14 +1830,10 @@ read_datatype(int tok)
18331830 {
18341831 if (tok == 0 )
18351832 {
1836- plpgsql_error_lineno = lno;
18371833 if (parenlevel != 0 )
1838- ereport (ERROR,
1839- (errcode (ERRCODE_SYNTAX_ERROR),
1840- errmsg (" mismatched parentheses" )));
1841- ereport (ERROR,
1842- (errcode (ERRCODE_SYNTAX_ERROR),
1843- errmsg (" incomplete datatype declaration" )));
1834+ yyerror (" mismatched parentheses" );
1835+ else
1836+ yyerror (" incomplete datatype declaration" );
18441837 }
18451838 /* Possible followers for datatype in a declaration */
18461839 if (tok == K_NOT || tok == K_ASSIGN || tok == K_DEFAULT)
@@ -1862,9 +1855,14 @@ read_datatype(int tok)
18621855
18631856 plpgsql_push_back_token (tok);
18641857
1858+ type_name = plpgsql_dstring_get (&ds);
1859+
1860+ if (type_name[0 ] == ' \0 ' )
1861+ yyerror (" missing datatype declaration" );
1862+
18651863 plpgsql_error_lineno = lno; /* in case of error in parse_datatype */
18661864
1867- result = plpgsql_parse_datatype (plpgsql_dstring_get (&ds) );
1865+ result = plpgsql_parse_datatype (type_name );
18681866
18691867 plpgsql_dstring_free (&ds);
18701868
@@ -1895,21 +1893,11 @@ make_execsql_stmt(const char *sqlstart, int lineno)
18951893 if (tok == ' ;' )
18961894 break ;
18971895 if (tok == 0 )
1898- {
1899- plpgsql_error_lineno = plpgsql_scanner_lineno ();
1900- ereport (ERROR,
1901- (errcode (ERRCODE_SYNTAX_ERROR),
1902- errmsg (" unexpected end of function definition" )));
1903- }
1896+ yyerror (" unexpected end of function definition" );
19041897 if (tok == K_INTO)
19051898 {
19061899 if (have_into)
1907- {
1908- plpgsql_error_lineno = plpgsql_scanner_lineno ();
1909- ereport (ERROR,
1910- (errcode (ERRCODE_SYNTAX_ERROR),
1911- errmsg (" INTO specified more than once" )));
1912- }
1900+ yyerror (" INTO specified more than once" );
19131901 have_into = true ;
19141902 read_into_target (&rec, &row, &have_strict);
19151903 continue ;
0 commit comments