*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.142 2010/03/03 01:53:17 tgl Exp $
+ * $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.143 2010/06/25 16:40:13 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* match composite names (hence an unreserved word followed by "."
* will not be recognized).
*/
- if (!lval->word.quoted && lval->word.ident != NULL &&
- strcmp(lval->word.ident, kw_str) == 0)
+ if (!lval->wdatum.quoted && lval->wdatum.ident != NULL &&
+ strcmp(lval->wdatum.ident, kw_str) == 0)
return true;
}
return false; /* not the keyword */
select raise_test();
ERROR: RAISE without parameters cannot be used outside an exception handler
CONTEXT: PL/pgSQL function "raise_test"
+-- check cases where implicit SQLSTATE variable could be confused with
+-- SQLSTATE as a keyword, cf bug #5524
+create or replace function raise_test() returns void as $$
+begin
+ perform 1/0;
+exception
+ when sqlstate '22012' then
+ raise notice using message = sqlstate;
+ raise sqlstate '22012' using message = 'substitute message';
+end;
+$$ language plpgsql;
+select raise_test();
+NOTICE: 22012
+ERROR: substitute message
drop function raise_test();
-- test CASE statement
create or replace function case_test(bigint) returns text as $$
select raise_test();
+-- check cases where implicit SQLSTATE variable could be confused with
+-- SQLSTATE as a keyword, cf bug #5524
+create or replace function raise_test() returns void as $$
+begin
+ perform 1/0;
+exception
+ when sqlstate '22012' then
+ raise notice using message = sqlstate;
+ raise sqlstate '22012' using message = 'substitute message';
+end;
+$$ language plpgsql;
+
+select raise_test();
+
drop function raise_test();
-- test CASE statement