Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit68c521e

Browse files
committed
Improve coverage of pltcl regression tests.
Test composite-type arguments and the argisnull and spi_lastoid Tclcommmands. This stuff was not covered before, but needs to be exercisedsince the upcoming Tcl object-conversion patch changes these code paths(and broke at least one of them).
1 parent9def031 commit68c521e

File tree

5 files changed

+140
-0
lines changed

5 files changed

+140
-0
lines changed

‎src/pl/tcl/expected/pltcl_queries.out

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,50 @@ NOTICE: TG_table_name: trigger_test
256256
NOTICE: TG_table_schema: public
257257
NOTICE: TG_when: BEFORE
258258
NOTICE: args: {23 skidoo}
259+
-- Test composite-type arguments
260+
select tcl_composite_arg_ref1(row('tkey', 42, 'ref2'));
261+
tcl_composite_arg_ref1
262+
------------------------
263+
42
264+
(1 row)
265+
266+
select tcl_composite_arg_ref2(row('tkey', 42, 'ref2'));
267+
tcl_composite_arg_ref2
268+
------------------------
269+
ref2
270+
(1 row)
271+
272+
-- Test argisnull primitive
273+
select tcl_argisnull('foo');
274+
tcl_argisnull
275+
---------------
276+
f
277+
(1 row)
278+
279+
select tcl_argisnull('');
280+
tcl_argisnull
281+
---------------
282+
f
283+
(1 row)
284+
285+
select tcl_argisnull(null);
286+
tcl_argisnull
287+
---------------
288+
t
289+
(1 row)
290+
291+
-- Test spi_lastoid primitive
292+
create temp table t1 (f1 int);
293+
select tcl_lastoid('t1');
294+
tcl_lastoid
295+
-------------
296+
0
297+
(1 row)
298+
299+
create temp table t2 (f1 int) with oids;
300+
select tcl_lastoid('t2') > 0;
301+
?column?
302+
----------
303+
t
304+
(1 row)
305+

‎src/pl/tcl/expected/pltcl_queries_1.out

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,50 @@ NOTICE: TG_table_name: trigger_test
256256
NOTICE: TG_table_schema: public
257257
NOTICE: TG_when: BEFORE
258258
NOTICE: args: {23 skidoo}
259+
-- Test composite-type arguments
260+
select tcl_composite_arg_ref1(row('tkey', 42, 'ref2'));
261+
tcl_composite_arg_ref1
262+
------------------------
263+
42
264+
(1 row)
265+
266+
select tcl_composite_arg_ref2(row('tkey', 42, 'ref2'));
267+
tcl_composite_arg_ref2
268+
------------------------
269+
ref2
270+
(1 row)
271+
272+
-- Test argisnull primitive
273+
select tcl_argisnull('foo');
274+
tcl_argisnull
275+
---------------
276+
f
277+
(1 row)
278+
279+
select tcl_argisnull('');
280+
tcl_argisnull
281+
---------------
282+
f
283+
(1 row)
284+
285+
select tcl_argisnull(null);
286+
tcl_argisnull
287+
---------------
288+
t
289+
(1 row)
290+
291+
-- Test spi_lastoid primitive
292+
create temp table t1 (f1 int);
293+
select tcl_lastoid('t1');
294+
tcl_lastoid
295+
-------------
296+
0
297+
(1 row)
298+
299+
create temp table t2 (f1 int) with oids;
300+
select tcl_lastoid('t2') > 0;
301+
?column?
302+
----------
303+
t
304+
(1 row)
305+

‎src/pl/tcl/expected/pltcl_setup.out

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,19 @@ create trigger dta1_before before insert or update on T_dta1
398398
create trigger dta2_before before insert or update on T_dta2
399399
for each row execute procedure
400400
check_primkey('ref1', 'ref2', 'T_pkey2', 'key1', 'key2');
401+
create function tcl_composite_arg_ref1(T_dta1) returns int as '
402+
return $1(ref1)
403+
' language pltcl;
404+
create function tcl_composite_arg_ref2(T_dta1) returns text as '
405+
return $1(ref2)
406+
' language pltcl;
407+
create function tcl_argisnull(text) returns bool as '
408+
argisnull 1
409+
' language pltcl;
410+
create function tcl_lastoid(tabname text) returns int8 as '
411+
spi_exec "insert into $1 default values"
412+
spi_lastoid
413+
' language pltcl;
401414
create function tcl_int4add(int4,int4) returns int4 as '
402415
return [expr $1 + $2]
403416
' language pltcl;

‎src/pl/tcl/sql/pltcl_queries.sql

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,18 @@ delete from trigger_test_view;
8282

8383
update trigger_testset v='update'where i=1;
8484
deletefrom trigger_test;
85+
86+
-- Test composite-type arguments
87+
select tcl_composite_arg_ref1(row('tkey',42,'ref2'));
88+
select tcl_composite_arg_ref2(row('tkey',42,'ref2'));
89+
90+
-- Test argisnull primitive
91+
select tcl_argisnull('foo');
92+
select tcl_argisnull('');
93+
select tcl_argisnull(null);
94+
95+
-- Test spi_lastoid primitive
96+
create temp table t1 (f1int);
97+
select tcl_lastoid('t1');
98+
create temp table t2 (f1int) with oids;
99+
select tcl_lastoid('t2')>0;

‎src/pl/tcl/sql/pltcl_setup.sql

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,24 @@ create trigger dta2_before before insert or update on T_dta2
429429
check_primkey('ref1','ref2','T_pkey2','key1','key2');
430430

431431

432+
createfunctiontcl_composite_arg_ref1(T_dta1) returnsintas'
433+
return $1(ref1)
434+
' language pltcl;
435+
436+
createfunctiontcl_composite_arg_ref2(T_dta1) returnstextas'
437+
return $1(ref2)
438+
' language pltcl;
439+
440+
createfunctiontcl_argisnull(text) returns boolas'
441+
argisnull 1
442+
' language pltcl;
443+
444+
createfunctiontcl_lastoid(tabnametext) returns int8as'
445+
spi_exec "insert into $1 default values"
446+
spi_lastoid
447+
' language pltcl;
448+
449+
432450
createfunctiontcl_int4add(int4,int4) returns int4as'
433451
return [expr $1 + $2]
434452
' language pltcl;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp