Commit 0cd78780 authored by Tom Lane's avatar Tom Lane

Rename a function to avoid naming conflict in parallel regression tests.

Commit 31a89185 added some tests in
plpgsql.sql that used a function rather unthinkingly named "foo()".
However, rangefuncs.sql has some much older tests that create a function
of that name, and since these test scripts run in parallel, there is a
chance of failures if the timing is just right.  Use another name to
avoid that.  Per buildfarm (failure seen today on "hamerkop", but
probably it's happened before and not been noticed).
parent 7919398b
...@@ -3627,24 +3627,24 @@ drop table tabwithcols; ...@@ -3627,24 +3627,24 @@ drop table tabwithcols;
-- --
-- Tests for composite-type results -- Tests for composite-type results
-- --
create type footype as (x int, y varchar); create type compostype as (x int, y varchar);
-- test: use of variable of composite type in return statement -- test: use of variable of composite type in return statement
create or replace function foo() returns footype as $$ create or replace function compos() returns compostype as $$
declare declare
v footype; v compostype;
begin begin
v := (1, 'hello'); v := (1, 'hello');
return v; return v;
end; end;
$$ language plpgsql; $$ language plpgsql;
select foo(); select compos();
foo compos
----------- -----------
(1,hello) (1,hello)
(1 row) (1 row)
-- test: use of variable of record type in return statement -- test: use of variable of record type in return statement
create or replace function foo() returns footype as $$ create or replace function compos() returns compostype as $$
declare declare
v record; v record;
begin begin
...@@ -3652,49 +3652,49 @@ begin ...@@ -3652,49 +3652,49 @@ begin
return v; return v;
end; end;
$$ language plpgsql; $$ language plpgsql;
select foo(); select compos();
foo compos
----------- -----------
(1,hello) (1,hello)
(1 row) (1 row)
-- test: use of row expr in return statement -- test: use of row expr in return statement
create or replace function foo() returns footype as $$ create or replace function compos() returns compostype as $$
begin begin
return (1, 'hello'::varchar); return (1, 'hello'::varchar);
end; end;
$$ language plpgsql; $$ language plpgsql;
select foo(); select compos();
foo compos
----------- -----------
(1,hello) (1,hello)
(1 row) (1 row)
-- this does not work currently (no implicit casting) -- this does not work currently (no implicit casting)
create or replace function foo() returns footype as $$ create or replace function compos() returns compostype as $$
begin begin
return (1, 'hello'); return (1, 'hello');
end; end;
$$ language plpgsql; $$ language plpgsql;
select foo(); select compos();
ERROR: returned record type does not match expected record type ERROR: returned record type does not match expected record type
DETAIL: Returned type unknown does not match expected type character varying in column 2. DETAIL: Returned type unknown does not match expected type character varying in column 2.
CONTEXT: PL/pgSQL function foo() while casting return value to function's return type CONTEXT: PL/pgSQL function compos() while casting return value to function's return type
-- ... but this does -- ... but this does
create or replace function foo() returns footype as $$ create or replace function compos() returns compostype as $$
begin begin
return (1, 'hello')::footype; return (1, 'hello')::compostype;
end; end;
$$ language plpgsql; $$ language plpgsql;
select foo(); select compos();
foo compos
----------- -----------
(1,hello) (1,hello)
(1 row) (1 row)
drop function foo(); drop function compos();
-- test: return a row expr as record. -- test: return a row expr as record.
create or replace function foorec() returns record as $$ create or replace function composrec() returns record as $$
declare declare
v record; v record;
begin begin
...@@ -3702,37 +3702,37 @@ begin ...@@ -3702,37 +3702,37 @@ begin
return v; return v;
end; end;
$$ language plpgsql; $$ language plpgsql;
select foorec(); select composrec();
foorec composrec
----------- -----------
(1,hello) (1,hello)
(1 row) (1 row)
-- test: return row expr in return statement. -- test: return row expr in return statement.
create or replace function foorec() returns record as $$ create or replace function composrec() returns record as $$
begin begin
return (1, 'hello'); return (1, 'hello');
end; end;
$$ language plpgsql; $$ language plpgsql;
select foorec(); select composrec();
foorec composrec
----------- -----------
(1,hello) (1,hello)
(1 row) (1 row)
drop function foorec(); drop function composrec();
-- test: row expr in RETURN NEXT statement. -- test: row expr in RETURN NEXT statement.
create or replace function foo() returns setof footype as $$ create or replace function compos() returns setof compostype as $$
begin begin
for i in 1..3 for i in 1..3
loop loop
return next (1, 'hello'::varchar); return next (1, 'hello'::varchar);
end loop; end loop;
return next null::footype; return next null::compostype;
return next (2, 'goodbye')::footype; return next (2, 'goodbye')::compostype;
end; end;
$$ language plpgsql; $$ language plpgsql;
select * from foo(); select * from compos();
x | y x | y
---+--------- ---+---------
1 | hello 1 | hello
...@@ -3742,18 +3742,18 @@ select * from foo(); ...@@ -3742,18 +3742,18 @@ select * from foo();
2 | goodbye 2 | goodbye
(5 rows) (5 rows)
drop function foo(); drop function compos();
-- test: use invalid expr in return statement. -- test: use invalid expr in return statement.
create or replace function foo() returns footype as $$ create or replace function compos() returns compostype as $$
begin begin
return 1 + 1; return 1 + 1;
end; end;
$$ language plpgsql; $$ language plpgsql;
select foo(); select compos();
ERROR: cannot return non-composite value from function returning composite type ERROR: cannot return non-composite value from function returning composite type
CONTEXT: PL/pgSQL function foo() line 3 at RETURN CONTEXT: PL/pgSQL function compos() line 3 at RETURN
drop function foo(); drop function compos();
drop type footype; drop type compostype;
-- --
-- Tests for 8.4's new RAISE features -- Tests for 8.4's new RAISE features
-- --
......
...@@ -2941,22 +2941,22 @@ drop table tabwithcols; ...@@ -2941,22 +2941,22 @@ drop table tabwithcols;
-- Tests for composite-type results -- Tests for composite-type results
-- --
create type footype as (x int, y varchar); create type compostype as (x int, y varchar);
-- test: use of variable of composite type in return statement -- test: use of variable of composite type in return statement
create or replace function foo() returns footype as $$ create or replace function compos() returns compostype as $$
declare declare
v footype; v compostype;
begin begin
v := (1, 'hello'); v := (1, 'hello');
return v; return v;
end; end;
$$ language plpgsql; $$ language plpgsql;
select foo(); select compos();
-- test: use of variable of record type in return statement -- test: use of variable of record type in return statement
create or replace function foo() returns footype as $$ create or replace function compos() returns compostype as $$
declare declare
v record; v record;
begin begin
...@@ -2965,39 +2965,39 @@ begin ...@@ -2965,39 +2965,39 @@ begin
end; end;
$$ language plpgsql; $$ language plpgsql;
select foo(); select compos();
-- test: use of row expr in return statement -- test: use of row expr in return statement
create or replace function foo() returns footype as $$ create or replace function compos() returns compostype as $$
begin begin
return (1, 'hello'::varchar); return (1, 'hello'::varchar);
end; end;
$$ language plpgsql; $$ language plpgsql;
select foo(); select compos();
-- this does not work currently (no implicit casting) -- this does not work currently (no implicit casting)
create or replace function foo() returns footype as $$ create or replace function compos() returns compostype as $$
begin begin
return (1, 'hello'); return (1, 'hello');
end; end;
$$ language plpgsql; $$ language plpgsql;
select foo(); select compos();
-- ... but this does -- ... but this does
create or replace function foo() returns footype as $$ create or replace function compos() returns compostype as $$
begin begin
return (1, 'hello')::footype; return (1, 'hello')::compostype;
end; end;
$$ language plpgsql; $$ language plpgsql;
select foo(); select compos();
drop function foo(); drop function compos();
-- test: return a row expr as record. -- test: return a row expr as record.
create or replace function foorec() returns record as $$ create or replace function composrec() returns record as $$
declare declare
v record; v record;
begin begin
...@@ -3006,46 +3006,46 @@ begin ...@@ -3006,46 +3006,46 @@ begin
end; end;
$$ language plpgsql; $$ language plpgsql;
select foorec(); select composrec();
-- test: return row expr in return statement. -- test: return row expr in return statement.
create or replace function foorec() returns record as $$ create or replace function composrec() returns record as $$
begin begin
return (1, 'hello'); return (1, 'hello');
end; end;
$$ language plpgsql; $$ language plpgsql;
select foorec(); select composrec();
drop function foorec(); drop function composrec();
-- test: row expr in RETURN NEXT statement. -- test: row expr in RETURN NEXT statement.
create or replace function foo() returns setof footype as $$ create or replace function compos() returns setof compostype as $$
begin begin
for i in 1..3 for i in 1..3
loop loop
return next (1, 'hello'::varchar); return next (1, 'hello'::varchar);
end loop; end loop;
return next null::footype; return next null::compostype;
return next (2, 'goodbye')::footype; return next (2, 'goodbye')::compostype;
end; end;
$$ language plpgsql; $$ language plpgsql;
select * from foo(); select * from compos();
drop function foo(); drop function compos();
-- test: use invalid expr in return statement. -- test: use invalid expr in return statement.
create or replace function foo() returns footype as $$ create or replace function compos() returns compostype as $$
begin begin
return 1 + 1; return 1 + 1;
end; end;
$$ language plpgsql; $$ language plpgsql;
select foo(); select compos();
drop function foo(); drop function compos();
drop type footype; drop type compostype;
-- --
-- Tests for 8.4's new RAISE features -- Tests for 8.4's new RAISE features
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment