59 lignes
1,6 Kio
SQL
59 lignes
1,6 Kio
SQL
CREATE EXTENSION slim;
|
|
CREATE EXTENSION pacs;
|
|
|
|
SELECT pacs_reset_all_measures();
|
|
|
|
-- create a measure
|
|
SELECT pacs_create_measure('A');
|
|
-- increment it 3 times
|
|
SELECT pacs_increment_measure('A');
|
|
SELECT pacs_increment_measure('A');
|
|
SELECT pacs_increment_measure('A');
|
|
-- check measure value is 3
|
|
SELECT pacs_get_measure('A');
|
|
-- reset the measure
|
|
SELECT pacs_reset_measure('A');
|
|
-- should be 0 now
|
|
SELECT pacs_get_measure('A');
|
|
-- increment again
|
|
SELECT pacs_increment_measure('A');
|
|
-- should be 1
|
|
SELECT pacs_get_measure('A');
|
|
-- and drop the measure
|
|
SELECT pacs_drop_measure('A');
|
|
|
|
-- get stats from pacs (empty)
|
|
-- SELECT * FROM pacs_get_stats();
|
|
-- create 2 measures
|
|
SELECT pacs_create_measure('B');
|
|
SELECT pacs_create_measure('C');
|
|
-- expect 2 measures
|
|
-- SELECT * FROM pacs_get_stats();
|
|
-- drop one
|
|
SELECT pacs_drop_measure('B');
|
|
-- so result now is 1
|
|
-- SELECT * FROM pacs_get_stats();
|
|
|
|
--
|
|
-- SPECIAL CASES
|
|
--
|
|
-- measure A has been dropped already.
|
|
-- but it's not erroing, as expected.
|
|
SELECT pacs_drop_measure('A');
|
|
|
|
-- trying to get value for an inexisting measure
|
|
-- should ERROR
|
|
SELECT pacs_get_measure('absent');
|
|
|
|
-- reseting an inexsting measure
|
|
-- but it's not erroing, as expected
|
|
SELECT pacs_reset_measure('absent');
|
|
-- the measure still does not exist
|
|
-- so we have an error
|
|
SELECT pacs_get_measure('absent');
|
|
-- however increment always create the measure if it does not exists
|
|
SELECT pacs_increment_measure('absent');
|
|
-- and now we can fetch value (should be 1)
|
|
SELECT pacs_get_measure('absent');
|
|
-- and we drop the "absent" measure (yeah, it's confusing)
|
|
SELECT pacs_drop_measure('absent');
|