Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5a37050

Browse files
author
Vladimir Ershov
committed
fix tests && func names
1 parent bc54115 commit 5a37050

File tree

3 files changed

+58
-8
lines changed

3 files changed

+58
-8
lines changed

expected/cron_string.out

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
create user __temp_robot;
2+
create user __temp_root WITH SUPERUSER;
3+
SET SESSION AUTHORIZATION __temp_root;
24
select schedule.create_job(
35
'{
46
"name": "Test @reboot",
@@ -52,12 +54,14 @@ select schedule.create_job(
5254
(1 row)
5355

5456
select * from schedule.cron order by id;
55-
id | node | name | comments | rule | next_time_statement | do_sql | same_transaction | onrollback_statement | active | broken | executor | owner | postpone | retry | max_run_time | max_instances | start_date | end_date | reason | _next_exec_time
56-
----+--------+----------------------+----------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+---------------------------------------+------------------+----------------------+--------+--------+--------------+----------+-----------+-------+--------------+---------------+------------+----------+--------+-----------------
57-
1 | master | Test @reboot | | {"crontab": "@reboot", "onstart": 1} | | {"show all"} | f | | t | f | __temp_robot | postgres | | 0 | | 1 | | | |
58-
2 | master | Test 1 | | {"days": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31], "hours": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23], "wdays": [0, 1, 2, 3, 4, 5, 6], "months": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], "crontab": "* * * * *", "minutes": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]} | | {"select 'this is every minute job'"} | f | | t | f | __temp_robot | postgres | @ 2 hours | 0 | | 1 | | | |
59-
3 | master | Test 2 4/4 2/4 * * * | | {"days": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31], "hours": [2, 6, 10, 14, 18, 22], "wdays": [0, 1, 2, 3, 4, 5, 6], "months": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], "crontab": "4/4 2/4 * * *", "minutes": [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56]} | | {"select pg_sleep(10)"} | f | | t | f | __temp_robot | postgres | | 0 | | 1 | | | |
60-
4 | master | Test 3 | | {"days": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31], "hours": [1], "wdays": [0, 4], "months": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], "crontab": "23 1 * * THU,SUN", "minutes": [23]} | | {"select 'ok' as ok"} | f | | t | f | postgres | postgres | | 0 | | 1 | | | |
57+
id | node | name | comments | rule | next_time_statement | do_sql | same_transaction | onrollback_statement | active | broken | executor | owner | postpone | retry | max_run_time | max_instances | start_date | end_date | reason | _next_exec_time
58+
----+--------+----------------------+----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+---------------------------------------+------------------+----------------------+--------+--------+--------------+-------------+-----------+-------+--------------+---------------+------------+----------+--------+-----------------
59+
1 | master | Test @reboot | | {"crontab": "@reboot", "onstart": 1} | | {"show all"} | f | | t | f | __temp_robot | __temp_root | | 0 | | 1 | | | |
60+
2 | master | Test 1 | | {"days": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31], "hours": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23], "wdays": [0, 1, 2, 3, 4, 5, 6], "crontab": "* * * * *", "minutes": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59]} | | {"select 'this is every minute job'"} | f | | t | f | __temp_robot | __temp_root | @ 2 hours | 0 | | 1 | | | |
61+
3 | master | Test 2 4/4 2/4 * * * | | {"days": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31], "hours": [2, 6, 10, 14, 18, 22], "wdays": [0, 1, 2, 3, 4, 5, 6], "crontab": "4/4 2/4 * * *", "minutes": [4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56]} | | {"select pg_sleep(10)"} | f | | t | f | __temp_robot | __temp_root | | 0 | | 1 | | | |
62+
4 | master | Test 3 | | {"days": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31], "hours": [1], "wdays": [0, 4], "crontab": "23 1 * * THU,SUN", "minutes": [23]} | | {"select 'ok' as ok"} | f | | t | f | __temp_root | __temp_root | | 0 | | 1 | | | |
6163
(4 rows)
6264

65+
RESET SESSION AUTHORIZATION;
66+
drop user __temp_root;
6367
drop user __temp_robot;

pgpro_scheduler--1.0.sql

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ $BODY$
804804
LANGUAGE plpgsql
805805
SECURITY DEFINER;
806806

807-
CREATE FUNCTION schedule.get_user_owned_cron() RETURNS SETOF schedule.cron_rec AS
807+
CREATE FUNCTION schedule.get_owned_cron() RETURNS SETOF schedule.cron_rec AS
808808
$BODY$
809809
DECLARE
810810
ii schedule.cron;
@@ -820,7 +820,8 @@ $BODY$
820820
LANGUAGE plpgsql
821821
SECURITY DEFINER;
822822

823-
CREATE FUNCTION schedule.get_user_owned_cron(usename text) RETURNS SETOF schedule.cron_rec AS
823+
824+
CREATE FUNCTION schedule.get_owned_cron(usename text) RETURNS SETOF schedule.cron_rec AS
824825
$BODY$
825826
DECLARE
826827
ii schedule.cron;
@@ -840,6 +841,26 @@ $BODY$
840841
LANGUAGE plpgsql
841842
SECURITY DEFINER;
842843

844+
CREATE FUNCTION schedule.get_user_owned_cron() RETURNS SETOF schedule.cron_rec AS
845+
$BODY$
846+
BEGIN
847+
RETURN QUERY SELECT * from schedule.get_owned_cron();
848+
END
849+
$BODY$
850+
LANGUAGE plpgsql
851+
SECURITY DEFINER;
852+
853+
CREATE FUNCTION schedule.get_user_owned_cron(usename text) RETURNS SETOF schedule.cron_rec AS
854+
$BODY$
855+
BEGIN
856+
RETURN QUERY SELECT * from schedule.get_owned_cron(usename);
857+
END
858+
$BODY$
859+
LANGUAGE plpgsql
860+
SECURITY DEFINER;
861+
862+
863+
843864
CREATE FUNCTION schedule.get_user_cron() RETURNS SETOF schedule.cron_rec AS
844865
$BODY$
845866
DECLARE
@@ -910,6 +931,16 @@ $BODY$
910931
LANGUAGE plpgsql
911932
SECURITY DEFINER;
912933

934+
CREATE FUNCTION schedule.get_active_jobs(usename text) RETURNS SETOF schedule.cron_job AS
935+
$BODY$
936+
DECLARE
937+
BEGIN
938+
RETURN QUERY SELECT * FROM schedule.get_user_active_jobs(usename);
939+
END
940+
$BODY$
941+
LANGUAGE plpgsql
942+
SECURITY DEFINER;
943+
913944
CREATE FUNCTION schedule.get_active_jobs() RETURNS SETOF schedule.cron_job AS
914945
$BODY$
915946
DECLARE
@@ -983,6 +1014,15 @@ $BODY$
9831014
LANGUAGE plpgsql
9841015
SECURITY DEFINER;
9851016

1017+
CREATE FUNCTION schedule.get_log(usename text) RETURNS SETOF schedule.cron_job AS
1018+
$BODY$
1019+
BEGIN
1020+
RETURN QUERY SELECT * FROM schedule.get_user_log(usename);
1021+
END
1022+
$BODY$
1023+
LANGUAGE plpgsql
1024+
SECURITY DEFINER;
1025+
9861026
CREATE FUNCTION schedule.get_log() RETURNS SETOF schedule.cron_job AS
9871027
$BODY$
9881028
BEGIN

sql/cron_string.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
create user __temp_robot;
2+
create user __temp_root WITH SUPERUSER;
3+
4+
SET SESSION AUTHORIZATION __temp_root;
5+
26
select schedule.create_job(
37
'{
48
"name": "Test @reboot",
@@ -37,4 +41,6 @@ select schedule.create_job(
3741

3842
select * from schedule.cron order by id;
3943

44+
RESET SESSION AUTHORIZATION;
45+
drop user __temp_root;
4046
drop user __temp_robot;

0 commit comments

Comments
 (0)