Project

General

Profile

« Previous | Next » 

Revision 7294

include parameter for deleting system metadata records (or not). Intending to also use this for https://redmine.dataone.org/issues/3055

View differences:

src/delete_all_by_pid.sql
2 2
 * This function removes all traces of an object identified by the given {pid}.
3 3
 * NOTE: for complete removal, the object should also be deleted from the filesystem.
4 4
 */
5
CREATE OR REPLACE FUNCTION delete_all(pid text) RETURNS VOID AS $$ 
5
CREATE OR REPLACE FUNCTION delete_all(pid text, deleteSystemMetadata boolean default true) RETURNS VOID AS $$ 
6 6
DECLARE 
7 7
	v_docid text; 
8 8
	v_rev integer; 
......
63 63
		END IF;
64 64
	END IF;
65 65

  
66
	-- do we want to remove the SM records too?
67
	IF deleteSystemMetadata THEN
68
		DELETE FROM systemMetadataReplicationPolicy WHERE guid = pid;
69
		GET DIAGNOSTICS deleted_count = ROW_COUNT;
70
		RAISE NOTICE 'Deleted % rows from systemMetadataReplicationPolicy', deleted_count;
71
		
72
		DELETE FROM systemMetadataReplicationStatus WHERE guid = pid;
73
		GET DIAGNOSTICS deleted_count = ROW_COUNT;
74
		RAISE NOTICE 'Deleted % rows from systemMetadataReplicationStatus', deleted_count;
75
		
76
		DELETE FROM systemMetadata WHERE guid = pid;
77
		GET DIAGNOSTICS deleted_count = ROW_COUNT;
78
		RAISE NOTICE 'Deleted % rows from systemMetadata', deleted_count;
66 79
	
67
	DELETE FROM systemMetadataReplicationPolicy WHERE guid = pid;
68
	GET DIAGNOSTICS deleted_count = ROW_COUNT;
69
	RAISE NOTICE 'Deleted % rows from systemMetadataReplicationPolicy', deleted_count;
80
		DELETE FROM xml_access WHERE guid = pid;
81
		GET DIAGNOSTICS deleted_count = ROW_COUNT;
82
		RAISE NOTICE 'Deleted % rows from xml_access', deleted_count;
70 83
	
71
	DELETE FROM systemMetadataReplicationStatus WHERE guid = pid;
72
	GET DIAGNOSTICS deleted_count = ROW_COUNT;
73
	RAISE NOTICE 'Deleted % rows from systemMetadataReplicationStatus', deleted_count;
84
		DELETE FROM identifier WHERE guid = pid;
85
		GET DIAGNOSTICS deleted_count = ROW_COUNT;
86
		RAISE NOTICE 'Deleted % rows from identifier', deleted_count;
87
	END IF;
74 88
	
75
	DELETE FROM systemMetadata WHERE guid = pid;
76
	GET DIAGNOSTICS deleted_count = ROW_COUNT;
77
	RAISE NOTICE 'Deleted % rows from systemMetadata', deleted_count;
78

  
79
	DELETE FROM xml_access WHERE guid = pid;
80
	GET DIAGNOSTICS deleted_count = ROW_COUNT;
81
	RAISE NOTICE 'Deleted % rows from xml_access', deleted_count;
82

  
83
	DELETE FROM identifier WHERE guid = pid;
84
	GET DIAGNOSTICS deleted_count = ROW_COUNT;
85
	RAISE NOTICE 'Deleted % rows from identifier', deleted_count;
86
	
87 89
END;
88 90
$$ 
89 91
LANGUAGE plpgsql;

Also available in: Unified diff