Files
alfresco-community-repo/config/alfresco/dbscripts/upgrade/4.1/org.hibernate.dialect.Dialect/update-activiti-nullable-columns.sql
Alan Davis 2b5e64a359 Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
84121: Merged V4.2-BUG-FIX (4.2.4) to HEAD-BUG-FIX (5.0/Cloud)
      82508: Merged V4.1-BUG-FIX (4.1.10) to V4.2-BUG-FIX (4.2.4)
         82319: Merged DEV to V4.1-BUG-FIX (4.1.10)
            81073 : MNT-9532 : SQL performance issue - WHERE ... IS NULL statements
               - Initial commit to revert fixes for MNT-8527 (r48757) and MNT-9483 (r56137) as this fixes causes performance issue for Oracle.
            81966 : MNT-9532 : SQL performance issue - WHERE ... IS NULL statements
               - Default value for feed_user_id and site_network is now @@NULL@@.
               - IS NULL clause was completly removed from activities queries.
               - Upgrade sql script was added to replace nulls for Oracle (empty strings for other dialect) with @@NULL@@.
               - Version schema was incremented by 1.
            82278 : MNT-9532 : SQL performance issue - WHERE ... IS NULL statements
               - Fixed unit test failure. 
      83431: MNT-9532 : SQL performance issue - WHERE ... IS NULL statements
         - Fixed build failure
      84115: MNT-9532/MNT-11871: with the revert of MNT-11871 patch, MNT-9532 should be using a lower schema number.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@84632 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2014-09-18 17:26:23 +00:00

48 lines
2.4 KiB
SQL

--
-- Title: Update ALF_ACTIVITY_FEED and ALF_ACTIVITY_FEED_CONTROL tables by setting special @@NULL@@ value for nullable columns feed_user_id and site_network.
-- Database: Generic
-- Since: V4.1 Schema 5149
-- Author: Pavel Yurkevich
--
-- Please contact support@alfresco.com if you need assistance with the upgrade.
--
-- MNT-9532: SQL performance issue - WHERE ... IS NULL statements
--
-- Record script finish
--
-- Since oracle treats empty strings as NULLs, we have to use following format in where clause
-- ((feed_user_id IS NULL AND '' IS NULL) OR feed_user_id = '')
-- (feed_user_id IS NULL AND '' IS NULL) is Oracle specific part
--FOREACH alf_activity_feed.id system.upgrade.alf_activity_feed.batchsize
UPDATE alf_activity_feed af
SET feed_user_id = '@@NULL@@'
WHERE
((feed_user_id IS NULL AND '' IS NULL) OR feed_user_id = '') AND af.id >= ${LOWERBOUND} AND af.id <= ${UPPERBOUND};
--FOREACH alf_activity_feed.id system.upgrade.alf_activity_feed.batchsize
UPDATE alf_activity_feed af
SET site_network = '@@NULL@@'
WHERE
((site_network IS NULL AND '' IS NULL) OR site_network = '') AND af.id >= ${LOWERBOUND} AND af.id <= ${UPPERBOUND};
--FOREACH alf_activity_feed_control.id system.upgrade.alf_activity_feed_control.batchsize
UPDATE alf_activity_feed_control afc
SET feed_user_id = '@@NULL@@'
WHERE
((feed_user_id IS NULL AND '' IS NULL) OR feed_user_id = '') AND afc.id >= ${LOWERBOUND} AND afc.id <= ${UPPERBOUND};
--FOREACH alf_activity_feed_control.id system.upgrade.alf_activity_feed_control.batchsize
UPDATE alf_activity_feed_control afc
SET site_network = '@@NULL@@'
WHERE
((site_network IS NULL AND '' IS NULL) OR site_network = '') AND afc.id >= ${LOWERBOUND} AND afc.id <= ${UPPERBOUND};
DELETE FROM alf_applied_patch WHERE id = 'patch.db-V4.1-update-activiti-nullable-columns';
INSERT INTO alf_applied_patch
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
VALUES
(
'patch.db-V4.1-update-activiti-nullable-columns', 'Manually executed script upgrade V4.1: ALF_ACTIVITY_FEED and ALF_ACTIVITY_FEED_CONTROL tables. Updates feed_user_id and site_network columns with @@NULL@@ value',
0, 5149, -1, 5150, null, 'UNKNOWN', ${TRUE}, ${TRUE}, 'Script completed'
);