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)
+
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)
+
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;
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;
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;