Skip to content

Commit 6b99ed9

Browse files
committed
- fix insert statements in samples #70
1 parent fc22825 commit 6b99ed9

9 files changed

Lines changed: 81 additions & 33 deletions

File tree

samples/Chain.sql

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,17 @@ BEGIN
6464
)
6565
RETURNING chain_id INTO v_chain_id;
6666

67-
INSERT INTO timetable.chain_execution_config VALUES
68-
(
67+
INSERT INTO timetable.chain_execution_config (
68+
chain_execution_config,
69+
chain_id,
70+
chain_name,
71+
run_at,
72+
max_instances,
73+
live,
74+
self_destruct,
75+
exclusive_execution,
76+
excluded_execution_configs
77+
) VALUES (
6978
DEFAULT, -- chain_execution_config,
7079
v_parent_id, -- chain_id,
7180
'chain operation', -- chain_name

samples/ClientMessages.sql

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,20 @@ chain_insert(chain_id) AS (
2424
RETURNING chain_id
2525
),
2626
chain_config(id) as (
27-
INSERT INTO timetable.chain_execution_config VALUES
28-
(
27+
INSERT INTO timetable.chain_execution_config (
28+
chain_execution_config,
29+
chain_id,
30+
chain_name,
31+
run_at,
32+
max_instances,
33+
live,
34+
self_destruct,
35+
exclusive_execution,
36+
excluded_execution_configs
37+
) VALUES (
2938
DEFAULT, -- chain_execution_config,
3039
(SELECT chain_id FROM chain_insert), -- chain_id,
31-
'notify every minute', -- chain_name,
40+
'raise client message every minute', -- chain_name,
3241
'* * * * *', -- run_at,
3342
1, -- max_instances,
3443
TRUE, -- live,

samples/CronStyle.sql

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
21
-- Create a Job with the timetable.job_add function in cron style
32

43
-- In order to demonstrate Cron style schduling of job execution, we will create a table(One time) for inserting of data
5-
CREATE TABLE timetable.dummy_log (
4+
CREATE TABLE IF NOT EXISTS timetable.dummy_log (
65
log_ID BIGSERIAL,
76
event_name TEXT,
87
timestmp TIMESTAMPTZ DEFAULT TRANSACTION_TIMESTAMP(),
@@ -13,12 +12,7 @@ CREATE TABLE timetable.dummy_log (
1312
-- task_function: The function wich will be executed.
1413
-- client_name: The name of worker under which this task will execute
1514
-- task_type: Type of the function SQL,SHELL and BUILTIN
16-
-- by_cron: Time Schedule in Cron Syntax
17-
-- by_minute: This specifies the minutes on which the job is to run
18-
-- by_hour: This specifies the hours on which the job is to run
19-
-- by_day: This specifies the days on which the job is to run.
20-
-- by_month: This specifies the month on which the job is to run
21-
-- by_day_of_week: This specifies the day of week (0,7 is sunday) on which the job is to run
15+
-- run_at: Time Schedule in Cron Syntax
2216
-- max_instances: The amount of instances that this chain may have running at the same time.
2317
-- live: Control if the chain may be executed once it reaches its schedule.
2418
-- self_destruct: Self destruct the chain.
@@ -38,12 +32,7 @@ SELECT timetable.job_add (
3832
task_function => $$INSERT INTO timetable.dummy_log (event_name) VALUES ('Cron test')$$,
3933
client_name => NULL, -- any worker may execute
4034
task_type => 'SQL',
41-
by_cron => '40 */2 27 * *',
42-
by_minute => NULL,
43-
by_hour => NULL,
44-
by_day => NULL,
45-
by_month => NULL,
46-
by_day_of_week => NULL,
35+
run_at => '40 */2 27 * *',
4736
max_instances => 1,
4837
live => TRUE,
4938
self_destruct => FALSE);

samples/Log.sql

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,17 @@ BEGIN
1414
RETURNING chain_id INTO v_chain_id;
1515

1616
-- Create the chain execution configuration
17-
INSERT INTO timetable.chain_execution_config VALUES
18-
(
17+
INSERT INTO timetable.chain_execution_config (
18+
chain_execution_config,
19+
chain_id,
20+
chain_name,
21+
run_at,
22+
max_instances,
23+
live,
24+
self_destruct,
25+
exclusive_execution,
26+
excluded_execution_configs
27+
) VALUES (
1928
DEFAULT, -- chain_execution_config,
2029
v_chain_id, -- chain_id,
2130
'Builtin-in Log', -- chain_name

samples/NoOp.sql

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
INSERT INTO timetable.chain_execution_config VALUES
2-
(
1+
INSERT INTO timetable.chain_execution_config (
2+
chain_execution_config,
3+
chain_id,
4+
chain_name,
5+
run_at,
6+
max_instances,
7+
live,
8+
self_destruct,
9+
exclusive_execution,
10+
excluded_execution_configs
11+
) VALUES (
312
DEFAULT, -- chain_execution_config,
413
timetable.insert_base_task(task_name := 'NoOp', parent_task_id := NULL), -- chain_id,
514
'execute noop every minute', -- chain_name,

samples/RemoteDB.sql

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,18 @@ BEGIN
4545
chain_id INTO v_chain_id;
4646

4747
--chain configuration
48-
INSERT INTO timetable.chain_execution_config
49-
VALUES (DEFAULT, -- chain_execution_config,
48+
INSERT INTO timetable.chain_execution_config (
49+
chain_execution_config,
50+
chain_id,
51+
chain_name,
52+
run_at,
53+
max_instances,
54+
live,
55+
self_destruct,
56+
exclusive_execution,
57+
excluded_execution_configs
58+
) VALUES (
59+
DEFAULT, -- chain_execution_config,
5060
v_chain_id, -- chain_id,
5161
'remote db', -- chain_name
5262
'* * * * *', -- run_at,

samples/SelfDestruct.sql

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,17 @@ chain_insert(chain_id) AS (
1616
RETURNING chain_id
1717
),
1818
chain_config(id) as (
19-
INSERT INTO timetable.chain_execution_config VALUES
20-
(
19+
INSERT INTO timetable.chain_execution_config (
20+
chain_execution_config,
21+
chain_id,
22+
chain_name,
23+
run_at,
24+
max_instances,
25+
live,
26+
self_destruct,
27+
exclusive_execution,
28+
excluded_execution_configs
29+
) VALUES (
2130
DEFAULT, -- chain_execution_config,
2231
(SELECT chain_id FROM chain_insert), -- chain_id,
2332
'notify then destruct', -- chain_name,

samples/Shell.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ BEGIN
88

99
-- Create the base task
1010
INSERT INTO timetable.base_task(name, kind, script)
11-
VALUES ('psql', 'SHELL'::timetable.task_kind, 'psql')
11+
VALUES ('run shell with psql', 'SHELL'::timetable.task_kind, 'psql')
1212
RETURNING task_id INTO v_task_id;
1313

1414
-- Create the chain

samples/Sleep.sql

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,20 @@ chain_insert(chain_id) AS (
1010
RETURNING chain_id
1111
),
1212
chain_config(id) as (
13-
INSERT INTO timetable.chain_execution_config VALUES
14-
(
13+
INSERT INTO timetable.chain_execution_config (
14+
chain_execution_config,
15+
chain_id,
16+
chain_name,
17+
run_at,
18+
max_instances,
19+
live
20+
) VALUES (
1521
DEFAULT, -- chain_execution_config,
1622
(SELECT chain_id FROM chain_insert), -- chain_id,
1723
'sleep every minute', -- chain_name,
1824
'* * * * *', -- run_at,
1925
1, -- max_instances,
20-
TRUE, -- live,
21-
FALSE, -- self_destruct,
22-
FALSE -- exclusive_execution,
26+
TRUE
2327
)
2428
RETURNING chain_execution_config
2529
)

0 commit comments

Comments
 (0)