我有一个简单的单元测试要在 pgtab https://pgtap.org/documentation.html#is中运行,如下所示
BEGIN;
SELECT plan(12);
-- Run the tests.
do
$$
declare
v_expected varchar(100);;
begin
SELECT has_table('unit_test_expected_results');
end;
$$;
-- Finish the tests and clean up.
SELECT * FROM finish();
ROLLBACK;
END
当我写SELECT has_table('unit_test_expected_results');
里面时begin
,end
我面临以下错误
[2021-06-01 23:50:58] [42601] ERROR: query has no destination for result data
[2021-06-01 23:50:58] Hint: If you want to discard the results of a SELECT, use PERFORM instead.
[2021-06-01 23:50:58] Where: PL/pgSQL function inline_code_block line 5 at SQL statement
任何帮助将不胜感激
这是 pgtab 扩展的功能
create function has_table(name, text) returns text
language sql
as
$$
SELECT ok( _rexists( '{r,p}'::char[], $1 ), $2 );
$$;
alter function has_table(name, text) owner to postgres;
如果我写下面的代码
begin
SELECT has_table('unit_test_expected_results') INTO v_expected;
end;
OR
begin
PERFORM has_table('unit_test_expected_results');
end;
这行得通,但是在输出窗口中没有结果,但是,如果我在开始和结束之外写,一切都可以正常工作