[CalendarServer-changes] [15687] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Tue Jun 21 12:54:06 PDT 2016
Revision: 15687
http://trac.calendarserver.org//changeset/15687
Author: cdaboo at apple.com
Date: 2016-06-21 12:54:06 -0700 (Tue, 21 Jun 2016)
Log Message:
-----------
Oracle PL/SQL function change.
Modified Paths:
--------------
CalendarServer/trunk/requirements-cs.txt
CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect-extras.sql
CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect.sql
CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_62_to_63.sql
Modified: CalendarServer/trunk/requirements-cs.txt
===================================================================
--- CalendarServer/trunk/requirements-cs.txt 2016-06-21 19:53:25 UTC (rev 15686)
+++ CalendarServer/trunk/requirements-cs.txt 2016-06-21 19:54:06 UTC (rev 15687)
@@ -7,7 +7,7 @@
zope.interface==4.1.3
setuptools==18.5
- --editable svn+http://svn.calendarserver.org/repository/calendarserver/twext/trunk@15653#egg=twextpy
+ --editable svn+http://svn.calendarserver.org/repository/calendarserver/twext/trunk@15686#egg=twextpy
cffi==1.3.0
pycparser==2.14
#twisted
Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect-extras.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect-extras.sql 2016-06-21 19:53:25 UTC (rev 15686)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect-extras.sql 2016-06-21 19:54:06 UTC (rev 15687)
@@ -16,54 +16,31 @@
-- Extra schema to add to current-oracle-dialect.sql
-create or replace function next_job_all(now timestamp)
+create or replace function next_job(now in timestamp, min_priority in integer)
return integer is
- cursor c1 is
- select JOB_ID from JOB
- where ASSIGNED is NULL and PAUSE = 0 and NOT_BEFORE <= now
- order by PRIORITY desc
- for update skip locked;
- result integer;
-begin
- open c1;
- fetch c1 into result;
- close c1;
- return result;
-end;
-/
-
-create or replace function next_job_medium_high(now timestamp)
- return integer is
- cursor c1 is
+ cursor c (priority number) is
select JOB_ID from JOB
- where PRIORITY != 0 and ASSIGNED is NULL and PAUSE = 0 and NOT_BEFORE <= now
- order by PRIORITY desc
- for update skip locked;
+ where PRIORITY = priority AND ASSIGNED is NULL and PAUSE = 0 and NOT_BEFORE <= now
+ for update skip locked;
result integer;
begin
- open c1;
- fetch c1 into result;
- close c1;
+ open c(2);
+ fetch c into result;
+ close c;
+ if result is null and min_priority != 2 then
+ open c(1);
+ fetch c into result;
+ close c;
+ if result is null and min_priority = 0 then
+ open c(0);
+ fetch c into result;
+ close c;
+ end if;
+ end if;
return result;
end;
/
-create or replace function next_job_high(now timestamp)
- return integer is
- cursor c1 is
- select JOB_ID from JOB
- where PRIORITY = 2 and ASSIGNED is NULL and PAUSE = 0 and NOT_BEFORE <= now
- order by PRIORITY desc
- for update skip locked;
- result integer;
-begin
- open c1;
- fetch c1 into result;
- close c1;
- return result;
-end;
-/
-
create or replace function overdue_job(now timestamp)
return integer is
cursor c1 is
Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect.sql 2016-06-21 19:53:25 UTC (rev 15686)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/current-oracle-dialect.sql 2016-06-21 19:54:06 UTC (rev 15687)
@@ -1095,54 +1095,31 @@
-- Extra schema to add to current-oracle-dialect.sql
-create or replace function next_job_all(now timestamp)
+create or replace function next_job(now in timestamp, min_priority in integer)
return integer is
- cursor c1 is
- select JOB_ID from JOB
- where ASSIGNED is NULL and PAUSE = 0 and NOT_BEFORE <= now
- order by PRIORITY desc
- for update skip locked;
- result integer;
-begin
- open c1;
- fetch c1 into result;
- close c1;
- return result;
-end;
-/
-
-create or replace function next_job_medium_high(now timestamp)
- return integer is
- cursor c1 is
+ cursor c (priority number) is
select JOB_ID from JOB
- where PRIORITY != 0 and ASSIGNED is NULL and PAUSE = 0 and NOT_BEFORE <= now
- order by PRIORITY desc
- for update skip locked;
+ where PRIORITY = priority AND ASSIGNED is NULL and PAUSE = 0 and NOT_BEFORE <= now
+ for update skip locked;
result integer;
begin
- open c1;
- fetch c1 into result;
- close c1;
+ open c(2);
+ fetch c into result;
+ close c;
+ if result is null and min_priority != 2 then
+ open c(1);
+ fetch c into result;
+ close c;
+ if result is null and min_priority = 0 then
+ open c(0);
+ fetch c into result;
+ close c;
+ end if;
+ end if;
return result;
end;
/
-create or replace function next_job_high(now timestamp)
- return integer is
- cursor c1 is
- select JOB_ID from JOB
- where PRIORITY = 2 and ASSIGNED is NULL and PAUSE = 0 and NOT_BEFORE <= now
- order by PRIORITY desc
- for update skip locked;
- result integer;
-begin
- open c1;
- fetch c1 into result;
- close c1;
- return result;
-end;
-/
-
create or replace function overdue_job(now timestamp)
return integer is
cursor c1 is
Modified: CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_62_to_63.sql
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_62_to_63.sql 2016-06-21 19:53:25 UTC (rev 15686)
+++ CalendarServer/trunk/txdav/common/datastore/sql_schema/upgrades/oracle-dialect/upgrade_from_62_to_63.sql 2016-06-21 19:54:06 UTC (rev 15687)
@@ -23,5 +23,35 @@
"TRASHED"
);
+-- Replace three stored procedures with one new one
+drop function next_job_all;
+drop function next_job_medium_high;
+drop function next_job_high;
+
+create or replace function next_job(now in timestamp, min_priority in integer)
+ return integer is
+ cursor c (priority number) is
+ select JOB_ID from JOB
+ where PRIORITY = priority AND ASSIGNED is NULL and PAUSE = 0 and NOT_BEFORE <= now
+ for update skip locked;
+ result integer;
+begin
+ open c(2);
+ fetch c into result;
+ close c;
+ if result is null and min_priority != 2 then
+ open c(1);
+ fetch c into result;
+ close c;
+ if result is null and min_priority = 0 then
+ open c(0);
+ fetch c into result;
+ close c;
+ end if;
+ end if;
+ return result;
+end;
+/
+
-- update the version
update CALENDARSERVER set VALUE = '63' where NAME = 'VERSION';
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20160621/ff8d8acd/attachment-0001.html>
More information about the calendarserver-changes
mailing list