-- Test argisnull primitive select tcl_argisnull('foo'); select tcl_argisnull(''); select tcl_argisnull(null);
-- test some error cases create function tcl_error(out a int, out b int) as $$returm 1$$ language pltcl; select tcl_error();
create function bad_record(out a text, out b text) as $$return [list a]$$ language pltcl; select bad_record();
create function bad_field(out a text, out b text) as $$return [list a 1 b 2 cow 3]$$ language pltcl; select bad_field();
-- test compound return select * from tcl_test_cube_squared(5);
-- test SRF select * from tcl_test_squared_rows(0,5);
select * from tcl_test_sequence(0,5) as a;
select1, tcl_test_sequence(0,5);
create function non_srf() returns intas $$return_next 1$$ language pltcl; select non_srf();
create function bad_record_srf(out a text, out b text) returns setof record as $$
return_next [list a]
$$ language pltcl; select bad_record_srf();
create function bad_field_srf(out a text, out b text) returns setof record as $$
return_next [list a 1 b 2 cow 3]
$$ language pltcl; select bad_field_srf();
-- test composite and domain-over-composite results create function tcl_composite_result(int) returns T_comp1 as $$ return [list tkey tkey1 ref1 $1 ref2 ref22]
$$ language pltcl; select tcl_composite_result(1001); select * from tcl_composite_result(1002);
create function tcl_dcomposite_result(int) returns d_comp1 as $$ return [list tkey tkey2 ref1 $1 ref2 ref42]
$$ language pltcl; select tcl_dcomposite_result(1001); select * from tcl_dcomposite_result(1002); select * from tcl_dcomposite_result(-1); -- fail
create function tcl_record_result(int) returns record as $$ return [list q1 sometext q2 $1 q3 moretext]
$$ language pltcl; select tcl_record_result(42); -- fail select * from tcl_record_result(42); -- fail select * from tcl_record_result(42) as (q1 text, q2 int, q3 text); select * from tcl_record_result(42) as (q1 text, q2 int, q3 text, q4 int); select * from tcl_record_result(42) as (q1 text, q2 int, q4 int); -- fail
-- test elog select tcl_eval('elog'); select tcl_eval('elog foo bar');
-- test forced error select tcl_eval('error "forced error"');
-- test loop control in spi_exec[p] select tcl_spi_exec(true, 'break'); select tcl_spi_exec(true, 'continue'); select tcl_spi_exec(true, 'error'); select tcl_spi_exec(true, 'return'); select tcl_spi_exec(false, 'break'); select tcl_spi_exec(false, 'continue'); select tcl_spi_exec(false, 'error'); select tcl_spi_exec(false, 'return');
-- test that we don't get confused by multiple funcs with same SQL name createschema tcls1; create function tcls1.somefunc(int) returns intas $$ return [expr $1 * 2]
$$ language pltcl;
createschema tcls2; create function tcls2.somefunc(int) returns intas $$ return [expr $1 * 3]
$$ language pltcl;
set search_path = tcls1; select tcls1.somefunc(11); set search_path = tcls2; select tcls2.somefunc(12); set search_path = tcls1; select tcls1.somefunc(13);
reset search_path;
-- test that it works to replace a function that's being executed create function replaceme(text) returns text as $p$
spi_exec { createorreplace function replaceme(text) returns text as $$ return"$1 fum"
$$ language pltcl;
}
spi_exec {select replaceme('foe') asinner} return"fee $1 $inner"
$p$ language pltcl;
select replaceme('fie'); select replaceme('fie');
-- forcibly run the Tcl event loop for awhile, to check that we have not -- messed things up too badly by disabling the Tcl notifier subsystem select tcl_eval($$
unset -nocomplain ::tcl_vwait
after 100 {set ::tcl_vwait 1}
vwait ::tcl_vwait
unset -nocomplain ::tcl_vwait$$);
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.1 Sekunden
(vorverarbeitet am 2026-08-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.