Skip to content

Commit

Permalink
Fix a bug in the _estimate_rollback_groups() function. It returned NU…
Browse files Browse the repository at this point in the history
…LL when there was no update to rollback.
  • Loading branch information
beaud76 committed Mar 20, 2013
1 parent 181286d commit 3bcc339
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 16 deletions.
4 changes: 2 additions & 2 deletions sql/emaj--next_version.sql
Expand Up @@ -4907,7 +4907,7 @@ r record;
BEGIN
-- check supplied group names and mark parameters
SELECT emaj._rlbk_check(v_groupNames,v_mark) INTO v_markName;
-- compute a random negative rollback-id
-- compute a random negative rollback-id (not to interfere with ids of real rollbacks)
SELECT (random() * -10000000000)::bigint INTO v_rlbkId;
--
-- simulate a rollback planning
Expand All @@ -4919,7 +4919,7 @@ r record;
-- call the _rlbk_planning function
PERFORM emaj._rlbk_planning(v_rlbkId);
-- compute the sum of the duration estimates of all elementary steps
SELECT sum(rlbp_estimated_duration) INTO v_estimDuration
SELECT coalesce(sum(rlbp_estimated_duration), '0 SECONDS'::INTERVAL) INTO v_estimDuration
FROM emaj.emaj_rlbk_plan
WHERE rlbp_rlbk_id = v_rlbkId;
-- cancel the effect of the rollback planning
Expand Down
4 changes: 2 additions & 2 deletions sql/emaj.sql
Expand Up @@ -4983,7 +4983,7 @@ r record;
BEGIN
-- check supplied group names and mark parameters
SELECT emaj._rlbk_check(v_groupNames,v_mark) INTO v_markName;
-- compute a random negative rollback-id
-- compute a random negative rollback-id (not to interfere with ids of real rollbacks)
SELECT (random() * -10000000000)::bigint INTO v_rlbkId;
--
-- simulate a rollback planning
Expand All @@ -4995,7 +4995,7 @@ r record;
-- call the _rlbk_planning function
PERFORM emaj._rlbk_planning(v_rlbkId);
-- compute the sum of the duration estimates of all elementary steps
SELECT sum(rlbp_estimated_duration) INTO v_estimDuration
SELECT coalesce(sum(rlbp_estimated_duration), '0 SECONDS'::INTERVAL) INTO v_estimDuration
FROM emaj.emaj_rlbk_plan
WHERE rlbp_rlbk_id = v_rlbkId;
-- cancel the effect of the rollback planning
Expand Down
4 changes: 2 additions & 2 deletions sql/emaj_src.sql
Expand Up @@ -5006,7 +5006,7 @@ r record;
BEGIN
-- check supplied group names and mark parameters
SELECT emaj._rlbk_check(v_groupNames,v_mark) INTO v_markName;
-- compute a random negative rollback-id
-- compute a random negative rollback-id (not to interfere with ids of real rollbacks)
SELECT (random() * -10000000000)::bigint INTO v_rlbkId;
--
-- simulate a rollback planning
Expand All @@ -5018,7 +5018,7 @@ r record;
-- call the _rlbk_planning function
PERFORM emaj._rlbk_planning(v_rlbkId);
-- compute the sum of the duration estimates of all elementary steps
SELECT sum(rlbp_estimated_duration) INTO v_estimDuration
SELECT coalesce(sum(rlbp_estimated_duration), '0 SECONDS'::INTERVAL) INTO v_estimDuration
FROM emaj.emaj_rlbk_plan
WHERE rlbp_rlbk_id = v_rlbkId;
-- cancel the effect of the rollback planning
Expand Down
4 changes: 2 additions & 2 deletions test/83/expected/instPsql.out
Expand Up @@ -5075,7 +5075,7 @@ r record;
BEGIN
-- check supplied group names and mark parameters
SELECT emaj._rlbk_check(v_groupNames,v_mark) INTO v_markName;
-- compute a random negative rollback-id
-- compute a random negative rollback-id (not to interfere with ids of real rollbacks)
SELECT (random() * -10000000000)::bigint INTO v_rlbkId;
--
-- simulate a rollback planning
Expand All @@ -5087,7 +5087,7 @@ r record;
-- call the _rlbk_planning function
PERFORM emaj._rlbk_planning(v_rlbkId);
-- compute the sum of the duration estimates of all elementary steps
SELECT sum(rlbp_estimated_duration) INTO v_estimDuration
SELECT coalesce(sum(rlbp_estimated_duration), '0 SECONDS'::INTERVAL) INTO v_estimDuration
FROM emaj.emaj_rlbk_plan
WHERE rlbp_rlbk_id = v_rlbkId;
-- cancel the effect of the rollback planning
Expand Down
7 changes: 7 additions & 0 deletions test/83/expected/misc.out
Expand Up @@ -457,6 +457,13 @@ select reltuples from pg_class, pg_namespace where relnamespace=pg_namespace.oid

-- estimate with empty rollback statistics and default parameters
delete from emaj.emaj_rlbk_stat;
select emaj.emaj_estimate_rollback_group('myGroup2','EMAJ_LAST_MARK',FALSE);
emaj_estimate_rollback_group
------------------------------
@ 0.00 secs
(1 row)

-- should return 0.004000 sec (nothing to rollback => only the fixed costs)
select emaj.emaj_estimate_rollback_group('myGroup2','Mark21',FALSE);
emaj_estimate_rollback_group
------------------------------
Expand Down
4 changes: 2 additions & 2 deletions test/84/expected/instPsql.out
Expand Up @@ -5075,7 +5075,7 @@ r record;
BEGIN
-- check supplied group names and mark parameters
SELECT emaj._rlbk_check(v_groupNames,v_mark) INTO v_markName;
-- compute a random negative rollback-id
-- compute a random negative rollback-id (not to interfere with ids of real rollbacks)
SELECT (random() * -10000000000)::bigint INTO v_rlbkId;
--
-- simulate a rollback planning
Expand All @@ -5087,7 +5087,7 @@ r record;
-- call the _rlbk_planning function
PERFORM emaj._rlbk_planning(v_rlbkId);
-- compute the sum of the duration estimates of all elementary steps
SELECT sum(rlbp_estimated_duration) INTO v_estimDuration
SELECT coalesce(sum(rlbp_estimated_duration), '0 SECONDS'::INTERVAL) INTO v_estimDuration
FROM emaj.emaj_rlbk_plan
WHERE rlbp_rlbk_id = v_rlbkId;
-- cancel the effect of the rollback planning
Expand Down
7 changes: 7 additions & 0 deletions test/84/expected/misc.out
Expand Up @@ -457,6 +457,13 @@ select reltuples from pg_class, pg_namespace where relnamespace=pg_namespace.oid

-- estimate with empty rollback statistics and default parameters
delete from emaj.emaj_rlbk_stat;
select emaj.emaj_estimate_rollback_group('myGroup2','EMAJ_LAST_MARK',FALSE);
emaj_estimate_rollback_group
------------------------------
@ 0.004 secs
(1 row)

-- should return 0.004000 sec (nothing to rollback => only the fixed costs)
select emaj.emaj_estimate_rollback_group('myGroup2','Mark21',FALSE);
emaj_estimate_rollback_group
------------------------------
Expand Down
4 changes: 2 additions & 2 deletions test/90/expected/instPsql.out
Expand Up @@ -5075,7 +5075,7 @@ r record;
BEGIN
-- check supplied group names and mark parameters
SELECT emaj._rlbk_check(v_groupNames,v_mark) INTO v_markName;
-- compute a random negative rollback-id
-- compute a random negative rollback-id (not to interfere with ids of real rollbacks)
SELECT (random() * -10000000000)::bigint INTO v_rlbkId;
--
-- simulate a rollback planning
Expand All @@ -5087,7 +5087,7 @@ r record;
-- call the _rlbk_planning function
PERFORM emaj._rlbk_planning(v_rlbkId);
-- compute the sum of the duration estimates of all elementary steps
SELECT sum(rlbp_estimated_duration) INTO v_estimDuration
SELECT coalesce(sum(rlbp_estimated_duration), '0 SECONDS'::INTERVAL) INTO v_estimDuration
FROM emaj.emaj_rlbk_plan
WHERE rlbp_rlbk_id = v_rlbkId;
-- cancel the effect of the rollback planning
Expand Down
7 changes: 7 additions & 0 deletions test/90/expected/misc.out
Expand Up @@ -457,6 +457,13 @@ select reltuples from pg_class, pg_namespace where relnamespace=pg_namespace.oid

-- estimate with empty rollback statistics and default parameters
delete from emaj.emaj_rlbk_stat;
select emaj.emaj_estimate_rollback_group('myGroup2','EMAJ_LAST_MARK',FALSE);
emaj_estimate_rollback_group
------------------------------
@ 0.004 secs
(1 row)

-- should return 0.004000 sec (nothing to rollback => only the fixed costs)
select emaj.emaj_estimate_rollback_group('myGroup2','Mark21',FALSE);
emaj_estimate_rollback_group
------------------------------
Expand Down
4 changes: 2 additions & 2 deletions test/91/expected/instPsql.out
Expand Up @@ -5075,7 +5075,7 @@ r record;
BEGIN
-- check supplied group names and mark parameters
SELECT emaj._rlbk_check(v_groupNames,v_mark) INTO v_markName;
-- compute a random negative rollback-id
-- compute a random negative rollback-id (not to interfere with ids of real rollbacks)
SELECT (random() * -10000000000)::bigint INTO v_rlbkId;
--
-- simulate a rollback planning
Expand All @@ -5087,7 +5087,7 @@ r record;
-- call the _rlbk_planning function
PERFORM emaj._rlbk_planning(v_rlbkId);
-- compute the sum of the duration estimates of all elementary steps
SELECT sum(rlbp_estimated_duration) INTO v_estimDuration
SELECT coalesce(sum(rlbp_estimated_duration), '0 SECONDS'::INTERVAL) INTO v_estimDuration
FROM emaj.emaj_rlbk_plan
WHERE rlbp_rlbk_id = v_rlbkId;
-- cancel the effect of the rollback planning
Expand Down
7 changes: 7 additions & 0 deletions test/91/expected/misc.out
Expand Up @@ -457,6 +457,13 @@ select reltuples from pg_class, pg_namespace where relnamespace=pg_namespace.oid

-- estimate with empty rollback statistics and default parameters
delete from emaj.emaj_rlbk_stat;
select emaj.emaj_estimate_rollback_group('myGroup2','EMAJ_LAST_MARK',FALSE);
emaj_estimate_rollback_group
------------------------------
@ 0.004 secs
(1 row)

-- should return 0.004000 sec (nothing to rollback => only the fixed costs)
select emaj.emaj_estimate_rollback_group('myGroup2','Mark21',FALSE);
emaj_estimate_rollback_group
------------------------------
Expand Down
4 changes: 2 additions & 2 deletions test/92/expected/instPsql.out
Expand Up @@ -5075,7 +5075,7 @@ r record;
BEGIN
-- check supplied group names and mark parameters
SELECT emaj._rlbk_check(v_groupNames,v_mark) INTO v_markName;
-- compute a random negative rollback-id
-- compute a random negative rollback-id (not to interfere with ids of real rollbacks)
SELECT (random() * -10000000000)::bigint INTO v_rlbkId;
--
-- simulate a rollback planning
Expand All @@ -5087,7 +5087,7 @@ r record;
-- call the _rlbk_planning function
PERFORM emaj._rlbk_planning(v_rlbkId);
-- compute the sum of the duration estimates of all elementary steps
SELECT sum(rlbp_estimated_duration) INTO v_estimDuration
SELECT coalesce(sum(rlbp_estimated_duration), '0 SECONDS'::INTERVAL) INTO v_estimDuration
FROM emaj.emaj_rlbk_plan
WHERE rlbp_rlbk_id = v_rlbkId;
-- cancel the effect of the rollback planning
Expand Down
7 changes: 7 additions & 0 deletions test/92/expected/misc.out
Expand Up @@ -457,6 +457,13 @@ select reltuples from pg_class, pg_namespace where relnamespace=pg_namespace.oid

-- estimate with empty rollback statistics and default parameters
delete from emaj.emaj_rlbk_stat;
select emaj.emaj_estimate_rollback_group('myGroup2','EMAJ_LAST_MARK',FALSE);
emaj_estimate_rollback_group
------------------------------
@ 0.004 secs
(1 row)

-- should return 0.004000 sec (nothing to rollback => only the fixed costs)
select emaj.emaj_estimate_rollback_group('myGroup2','Mark21',FALSE);
emaj_estimate_rollback_group
------------------------------
Expand Down
3 changes: 3 additions & 0 deletions test/sql/misc.sql
Expand Up @@ -164,6 +164,9 @@ select reltuples from pg_class, pg_namespace where relnamespace=pg_namespace.oid
-- estimate with empty rollback statistics and default parameters
delete from emaj.emaj_rlbk_stat;

select emaj.emaj_estimate_rollback_group('myGroup2','EMAJ_LAST_MARK',FALSE);
-- should return 0.004000 sec (nothing to rollback => only the fixed costs)

select emaj.emaj_estimate_rollback_group('myGroup2','Mark21',FALSE);
-- should return 1.436620 sec

Expand Down

0 comments on commit 3bcc339

Please sign in to comment.