comparison PostgreSQL/Plugins/SQL/PrepareIndex.sql @ 572:6667bd31beaf find-refactoring

ReadOnly mode continued
author Alain Mazy <am@orthanc.team>
date Thu, 26 Sep 2024 17:24:29 +0200
parents 11c6bcc9d1f2
children
comparison
equal deleted inserted replaced
568:77c8544bbd7d 572:6667bd31beaf
543 IF is_new_instance > 0 THEN 543 IF is_new_instance > 0 THEN
544 -- Move the patient to the end of the recycling order. 544 -- Move the patient to the end of the recycling order.
545 PERFORM PatientAddedOrUpdated(patient_internal_id, 1); 545 PERFORM PatientAddedOrUpdated(patient_internal_id, 1);
546 END IF; 546 END IF;
547 END; 547 END;
548 548 $body$ LANGUAGE plpgsql;
549
550 -- function to compute a statistic in a ReadOnly transaction
551 CREATE OR REPLACE FUNCTION ComputeStatisticsReadOnly(
552 IN statistics_key INTEGER,
553 OUT accumulated_value BIGINT
554 ) RETURNS BIGINT AS $body$
555
556 DECLARE
557 current_value BIGINT;
558
559 BEGIN
560
561 SELECT VALUE from GlobalIntegers
562 INTO current_value
563 WHERE key = statistics_key;
564
565 SELECT sum(value) + current_value FROM GlobalIntegersChanges
566 INTO accumulated_value
567 WHERE key = statistics_key;
568
569 END;
549 $body$ LANGUAGE plpgsql; 570 $body$ LANGUAGE plpgsql;
550 571
551 572
552 573
553 -- set the global properties that actually documents the DB version, revision and some of the capabilities 574 -- set the global properties that actually documents the DB version, revision and some of the capabilities
557 INSERT INTO GlobalProperties VALUES (6, 1); -- GlobalProperty_GetTotalSizeIsFast 578 INSERT INTO GlobalProperties VALUES (6, 1); -- GlobalProperty_GetTotalSizeIsFast
558 INSERT INTO GlobalProperties VALUES (10, 1); -- GlobalProperty_HasTrigramIndex 579 INSERT INTO GlobalProperties VALUES (10, 1); -- GlobalProperty_HasTrigramIndex
559 INSERT INTO GlobalProperties VALUES (11, 3); -- GlobalProperty_HasCreateInstance -- this is actually the 3rd version of HasCreateInstance 580 INSERT INTO GlobalProperties VALUES (11, 3); -- GlobalProperty_HasCreateInstance -- this is actually the 3rd version of HasCreateInstance
560 INSERT INTO GlobalProperties VALUES (12, 1); -- GlobalProperty_HasFastCountResources 581 INSERT INTO GlobalProperties VALUES (12, 1); -- GlobalProperty_HasFastCountResources
561 INSERT INTO GlobalProperties VALUES (13, 1); -- GlobalProperty_GetLastChangeIndex 582 INSERT INTO GlobalProperties VALUES (13, 1); -- GlobalProperty_GetLastChangeIndex
583 INSERT INTO GlobalProperties VALUES (14, 1); -- GlobalProperty_HasComputeStatisticsReadOnly