/* \i sql/model.sql RESET client_min_messages; RESET log_error_verbosity; SET client_min_messages = notice; SET log_error_verbosity = terse; */ SET search_path TO market; truncate torder; truncate tstack; SELECT setval('tstack_id_seq',1,false); setval -------- 1 (1 row) truncate tmvt; SELECT setval('tmvt_id_seq',1,false); setval -------- 1 (1 row) truncate towner; SELECT setval('towner_id_seq',1,false); setval -------- 1 (1 row) select * from fsubmitbarter(1,'a',NULL,'q2',10,'q1',20,'1 hour'::interval); id | diag ----+------ 1 | 0 (1 row) select * from fproducemvt(); ord | ordp | qtt_requ | qtt_prov | qtt | qtt_reci | qtt_give | err | json | own | type | stackid --------------------------+------------+----------+----------+-----+----------+----------+-----+------+-----+------+--------- (1,1,1,1,10,q2,20,q1,20) | (,,,,,,,,) | 10 | 20 | 20 | 0 | 0 | 0 | | a | 1 | 1 (1 row) select * from fsubmitbarter(1,'b',NULL,'q3',20,'q2',40,'1 hour'::interval); id | diag ----+------ 2 | 0 (1 row) select * from fproducemvt(); ord | ordp | qtt_requ | qtt_prov | qtt | qtt_reci | qtt_give | err | json | own | type | stackid --------------------------+------------+----------+----------+-----+----------+----------+-----+------+-----+------+--------- (1,2,2,2,20,q3,40,q2,40) | (,,,,,,,,) | 20 | 40 | 40 | 0 | 0 | 0 | | b | 1 | 2 (1 row) select * from fsubmitbarter(1,'b',2 ,'q1',20,NULL,40,NULL); id | diag ----+------ 3 | 0 (1 row) select * from fproducemvt(); ord | ordp | qtt_requ | qtt_prov | qtt | qtt_reci | qtt_give | err | json | own | type | stackid --------------------------+--------------------------+----------+----------+-----+----------+----------+-----+------+-----+------+--------- (1,3,2,2,20,q1,40,q2,40) | (1,2,2,2,20,q3,40,q2,40) | 20 | 40 | 40 | 20 | 20 | 0 | | b | 1 | 3 (1 row) -- select * from femptystack(); select id,nbc,nbt,grp,xid,xoid,own_src,own_dst,qtt,nat,ack from tmvt order by id desc limit 2; id | nbc | nbt | grp | xid | xoid | own_src | own_dst | qtt | nat | ack ----+-----+-----+-----+-----+------+---------+---------+-----+-----+----- 2 | 2 | 2 | 1 | 1 | 1 | a | b | 20 | q1 | f 1 | 2 | 2 | 1 | 3 | 2 | b | a | 20 | q2 | f (2 rows) select * from fsubmitbarter(1,'a',NULL,'q2',10,'q1',20,'1 hour'::interval); id | diag ----+------ 4 | 0 (1 row) select * from fproducemvt(); ord | ordp | qtt_requ | qtt_prov | qtt | qtt_reci | qtt_give | err | json | own | type | stackid --------------------------+------------+----------+----------+-----+----------+----------+-----+------+-----+------+--------- (1,4,1,4,10,q2,20,q1,20) | (,,,,,,,,) | 10 | 20 | 20 | 20 | 20 | 0 | | a | 1 | 4 (1 row) select id,nbc,nbt,grp,xid,xoid,own_src,own_dst,qtt,nat,ack from tmvt order by id desc limit 2; id | nbc | nbt | grp | xid | xoid | own_src | own_dst | qtt | nat | ack ----+-----+-----+-----+-----+------+---------+---------+-----+-----+----- 4 | 2 | 2 | 3 | 3 | 2 | b | a | 20 | q2 | f 3 | 2 | 2 | 3 | 4 | 4 | a | b | 20 | q1 | f (2 rows)