summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorBruce Momjian2002-09-12 00:24:10 +0000
committerBruce Momjian2002-09-12 00:24:10 +0000
commitb3f52320f6cb8374f3db5397e63b82f595c90681 (patch)
tree838a5b8f866b54fce0996e9b7a433bc10a119b3c /src/test
parent81186865fec2e39a6a66e9435b32d7048c03dd32 (diff)
> Sean Chittenden <sean@chittenden.org> writes:
> >>::sigh:: Is it me or does it look like all >>of pl/pgsql is schema un-aware (ie, all of the declarations). -sc > > > Yeah. The group of routines parse_word, parse_dblword, etc that are > called by the lexer certainly all need work. There are some > definitional issues to think about, too --- plpgsql presently relies on > the number of names to give it some idea of what to look for, and those > rules are probably all toast now. Please come up with a sketch of what > you think the behavior should be before you start hacking code. Attached is a diff -c format proposal to fix this. I've also attached a short test script. Seems to work OK and passes all regression tests. Here's a breakdown of how I understand plpgsql's "Special word rules" -- I think it illustrates the behavior reasonably well. New functions added by this patch are plpgsql_parse_tripwordtype and plpgsql_parse_dblwordrowtype: Joe Conway
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/sql/plpgsql-nsp-testing.sql47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/test/regress/sql/plpgsql-nsp-testing.sql b/src/test/regress/sql/plpgsql-nsp-testing.sql
new file mode 100644
index 00000000000..8694b8db649
--- /dev/null
+++ b/src/test/regress/sql/plpgsql-nsp-testing.sql
@@ -0,0 +1,47 @@
+-- nspname.relname.attname%TYPE
+DROP FUNCTION t();
+CREATE OR REPLACE FUNCTION t() RETURNS TEXT AS '
+DECLARE
+ col_name pg_catalog.pg_attribute.attname%TYPE;
+BEGIN
+ col_name := ''uga'';
+ RETURN col_name;
+END;
+' LANGUAGE 'plpgsql';
+SELECT t();
+
+-- nspname.relname%ROWTYPE
+DROP FUNCTION t();
+CREATE OR REPLACE FUNCTION t() RETURNS pg_catalog.pg_attribute AS '
+DECLARE
+ rec pg_catalog.pg_attribute%ROWTYPE;
+BEGIN
+ SELECT INTO rec * FROM pg_catalog.pg_attribute WHERE attrelid = 1247 AND attname = ''typname'';
+ RETURN rec;
+END;
+' LANGUAGE 'plpgsql';
+SELECT * FROM t();
+
+-- nspname.relname.attname%TYPE
+DROP FUNCTION t();
+CREATE OR REPLACE FUNCTION t() RETURNS pg_catalog.pg_attribute.attname%TYPE AS '
+DECLARE
+ rec pg_catalog.pg_attribute.attname%TYPE;
+BEGIN
+ SELECT INTO rec pg_catalog.pg_attribute.attname FROM pg_catalog.pg_attribute WHERE attrelid = 1247 AND attname = ''typname'';
+ RETURN rec;
+END;
+' LANGUAGE 'plpgsql';
+SELECT t();
+
+-- nspname.relname%ROWTYPE
+DROP FUNCTION t();
+CREATE OR REPLACE FUNCTION t() RETURNS pg_catalog.pg_attribute AS '
+DECLARE
+ rec pg_catalog.pg_attribute%ROWTYPE;
+BEGIN
+ SELECT INTO rec * FROM pg_catalog.pg_attribute WHERE attrelid = 1247 AND attname = ''typname'';
+ RETURN rec;
+END;
+' LANGUAGE 'plpgsql';
+SELECT * FROM t();