git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3bdd239)
Fix thinko in tok_is_keyword(): it was looking at the wrong union variant
2010年6月25日 16:40:13 +0000 (16:40 +0000)
2010年6月25日 16:40:13 +0000 (16:40 +0000)
of YYSTYPE, and hence returning the wrong answer for cases where a plpgsql
"unreserved keyword" really does conflict with a variable name. Obviously
I didn't test this enough :-(. Per bug #5524 from Peter Gagarinov.


diff --git a/src/pl/plpgsql/src/gram.y b/src/pl/plpgsql/src/gram.y
index e866d10a65ab4dbf7bce525aff02bc2f5f4d9408..3a78fe69c7556461862d18a546041efa80bee520 100644 (file)
--- a/src/pl/plpgsql/src/gram.y
+++ b/src/pl/plpgsql/src/gram.y
@@ -8,7 +8,7 @@
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
@@ -2080,8 +2080,8 @@ tok_is_keyword(int token, union YYSTYPE *lval,
* 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 */
diff --git a/src/test/regress/expected/plpgsql.out b/src/test/regress/expected/plpgsql.out
index 619939ffa380fc39f7fdb93aa0e30ea72a083c2e..a22e2bfd0f1b348ebcde2ea89f6cdf6d9bb5a931 100644 (file)
--- a/src/test/regress/expected/plpgsql.out
+++ b/src/test/regress/expected/plpgsql.out
@@ -3578,6 +3578,20 @@ $$ language plpgsql;
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 $$
diff --git a/src/test/regress/sql/plpgsql.sql b/src/test/regress/sql/plpgsql.sql
index e181b10898ec5b15fda6430e5a7729f6add73166..612e92d21be4ecf3d02870add23a9e4e3cda7be7 100644 (file)
--- a/src/test/regress/sql/plpgsql.sql
+++ b/src/test/regress/sql/plpgsql.sql
@@ -2916,6 +2916,20 @@ $$ language plpgsql;
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
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /