Commit 68c521eb authored by Tom Lane's avatar Tom Lane

Improve coverage of pltcl regression tests.

Test composite-type arguments and the argisnull and spi_lastoid Tcl
commmands.  This stuff was not covered before, but needs to be exercised
since the upcoming Tcl object-conversion patch changes these code paths
(and broke at least one of them).
parent 9def031b
......@@ -256,3 +256,50 @@ NOTICE: TG_table_name: trigger_test
NOTICE: TG_table_schema: public
NOTICE: TG_when: BEFORE
NOTICE: args: {23 skidoo}
-- Test composite-type arguments
select tcl_composite_arg_ref1(row('tkey', 42, 'ref2'));
tcl_composite_arg_ref1
------------------------
42
(1 row)
select tcl_composite_arg_ref2(row('tkey', 42, 'ref2'));
tcl_composite_arg_ref2
------------------------
ref2
(1 row)
-- Test argisnull primitive
select tcl_argisnull('foo');
tcl_argisnull
---------------
f
(1 row)
select tcl_argisnull('');
tcl_argisnull
---------------
f
(1 row)
select tcl_argisnull(null);
tcl_argisnull
---------------
t
(1 row)
-- Test spi_lastoid primitive
create temp table t1 (f1 int);
select tcl_lastoid('t1');
tcl_lastoid
-------------
0
(1 row)
create temp table t2 (f1 int) with oids;
select tcl_lastoid('t2') > 0;
?column?
----------
t
(1 row)
......@@ -256,3 +256,50 @@ NOTICE: TG_table_name: trigger_test
NOTICE: TG_table_schema: public
NOTICE: TG_when: BEFORE
NOTICE: args: {23 skidoo}
-- Test composite-type arguments
select tcl_composite_arg_ref1(row('tkey', 42, 'ref2'));
tcl_composite_arg_ref1
------------------------
42
(1 row)
select tcl_composite_arg_ref2(row('tkey', 42, 'ref2'));
tcl_composite_arg_ref2
------------------------
ref2
(1 row)
-- Test argisnull primitive
select tcl_argisnull('foo');
tcl_argisnull
---------------
f
(1 row)
select tcl_argisnull('');
tcl_argisnull
---------------
f
(1 row)
select tcl_argisnull(null);
tcl_argisnull
---------------
t
(1 row)
-- Test spi_lastoid primitive
create temp table t1 (f1 int);
select tcl_lastoid('t1');
tcl_lastoid
-------------
0
(1 row)
create temp table t2 (f1 int) with oids;
select tcl_lastoid('t2') > 0;
?column?
----------
t
(1 row)
......@@ -398,6 +398,19 @@ create trigger dta1_before before insert or update on T_dta1
create trigger dta2_before before insert or update on T_dta2
for each row execute procedure
check_primkey('ref1', 'ref2', 'T_pkey2', 'key1', 'key2');
create function tcl_composite_arg_ref1(T_dta1) returns int as '
return $1(ref1)
' language pltcl;
create function tcl_composite_arg_ref2(T_dta1) returns text as '
return $1(ref2)
' language pltcl;
create function tcl_argisnull(text) returns bool as '
argisnull 1
' language pltcl;
create function tcl_lastoid(tabname text) returns int8 as '
spi_exec "insert into $1 default values"
spi_lastoid
' language pltcl;
create function tcl_int4add(int4,int4) returns int4 as '
return [expr $1 + $2]
' language pltcl;
......
......@@ -82,3 +82,18 @@ delete from trigger_test_view;
update trigger_test set v = 'update' where i = 1;
delete from trigger_test;
-- Test composite-type arguments
select tcl_composite_arg_ref1(row('tkey', 42, 'ref2'));
select tcl_composite_arg_ref2(row('tkey', 42, 'ref2'));
-- Test argisnull primitive
select tcl_argisnull('foo');
select tcl_argisnull('');
select tcl_argisnull(null);
-- Test spi_lastoid primitive
create temp table t1 (f1 int);
select tcl_lastoid('t1');
create temp table t2 (f1 int) with oids;
select tcl_lastoid('t2') > 0;
......@@ -429,6 +429,24 @@ create trigger dta2_before before insert or update on T_dta2
check_primkey('ref1', 'ref2', 'T_pkey2', 'key1', 'key2');
create function tcl_composite_arg_ref1(T_dta1) returns int as '
return $1(ref1)
' language pltcl;
create function tcl_composite_arg_ref2(T_dta1) returns text as '
return $1(ref2)
' language pltcl;
create function tcl_argisnull(text) returns bool as '
argisnull 1
' language pltcl;
create function tcl_lastoid(tabname text) returns int8 as '
spi_exec "insert into $1 default values"
spi_lastoid
' language pltcl;
create function tcl_int4add(int4,int4) returns int4 as '
return [expr $1 + $2]
' language pltcl;
......
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