# HG changeset patch # User jbe # Date 1462391365 -7200 # Node ID 2f1c06608defd190417598c1d8706f5073a3b64c # Parent 65bd17395c28702dae3e2108bcba8dd201cb1b7c Fixed functions "delete_member" and "delete_private_data" to properly handle NULL constraints of "member" table diff -r 65bd17395c28 -r 2f1c06608def core.sql --- a/core.sql Wed May 04 21:47:29 2016 +0200 +++ b/core.sql Wed May 04 21:49:25 2016 +0200 @@ -5097,9 +5097,9 @@ "notify_email_secret" = NULL, "notify_email_secret_expiry" = NULL, "notify_email_lock_expiry" = NULL, - "disable_notifications" = NULL, - "notification_counter" = NULL, - "notification_sample_size" = NULL, + "disable_notifications" = TRUE, + "notification_counter" = DEFAULT, + "notification_sample_size" = 0, "notification_dow" = NULL, "notification_hour" = NULL, "login_recovery_expiry" = NULL, @@ -5170,9 +5170,9 @@ "notify_email_secret" = NULL, "notify_email_secret_expiry" = NULL, "notify_email_lock_expiry" = NULL, - "disable_notifications" = NULL, - "notification_counter" = NULL, - "notification_sample_size" = NULL, + "disable_notifications" = TRUE, + "notification_counter" = DEFAULT, + "notification_sample_size" = 0, "notification_dow" = NULL, "notification_hour" = NULL, "login_recovery_expiry" = NULL, diff -r 65bd17395c28 -r 2f1c06608def update/core-update.v3.2.1-v3.2.2.sql --- a/update/core-update.v3.2.1-v3.2.2.sql Wed May 04 21:47:29 2016 +0200 +++ b/update/core-update.v3.2.1-v3.2.2.sql Wed May 04 21:49:25 2016 +0200 @@ -137,4 +137,137 @@ ) AS "subquery2" WHERE "pending" > '0'::INTERVAL; +CREATE OR REPLACE FUNCTION "delete_member"("member_id_p" "member"."id"%TYPE) + RETURNS VOID + LANGUAGE 'plpgsql' VOLATILE AS $$ + BEGIN + UPDATE "member" SET + "last_login" = NULL, + "last_delegation_check" = NULL, + "login" = NULL, + "password" = NULL, + "authority" = NULL, + "authority_uid" = NULL, + "authority_login" = NULL, + "locked" = TRUE, + "active" = FALSE, + "notify_email" = NULL, + "notify_email_unconfirmed" = NULL, + "notify_email_secret" = NULL, + "notify_email_secret_expiry" = NULL, + "notify_email_lock_expiry" = NULL, + "disable_notifications" = TRUE, + "notification_counter" = DEFAULT, + "notification_sample_size" = 0, + "notification_dow" = NULL, + "notification_hour" = NULL, + "login_recovery_expiry" = NULL, + "password_reset_secret" = NULL, + "password_reset_secret_expiry" = NULL, + "organizational_unit" = NULL, + "internal_posts" = NULL, + "realname" = NULL, + "birthday" = NULL, + "address" = NULL, + "email" = NULL, + "xmpp_address" = NULL, + "website" = NULL, + "phone" = NULL, + "mobile_phone" = NULL, + "profession" = NULL, + "external_memberships" = NULL, + "external_posts" = NULL, + "statement" = NULL + WHERE "id" = "member_id_p"; + -- "text_search_data" is updated by triggers + DELETE FROM "setting" WHERE "member_id" = "member_id_p"; + DELETE FROM "setting_map" WHERE "member_id" = "member_id_p"; + DELETE FROM "member_relation_setting" WHERE "member_id" = "member_id_p"; + DELETE FROM "member_image" WHERE "member_id" = "member_id_p"; + DELETE FROM "contact" WHERE "member_id" = "member_id_p"; + DELETE FROM "ignored_member" WHERE "member_id" = "member_id_p"; + DELETE FROM "session" WHERE "member_id" = "member_id_p"; + DELETE FROM "area_setting" WHERE "member_id" = "member_id_p"; + DELETE FROM "issue_setting" WHERE "member_id" = "member_id_p"; + DELETE FROM "ignored_initiative" WHERE "member_id" = "member_id_p"; + DELETE FROM "initiative_setting" WHERE "member_id" = "member_id_p"; + DELETE FROM "suggestion_setting" WHERE "member_id" = "member_id_p"; + DELETE FROM "membership" WHERE "member_id" = "member_id_p"; + DELETE FROM "delegation" WHERE "truster_id" = "member_id_p"; + DELETE FROM "non_voter" WHERE "member_id" = "member_id_p"; + DELETE FROM "direct_voter" USING "issue" + WHERE "direct_voter"."issue_id" = "issue"."id" + AND "issue"."closed" ISNULL + AND "member_id" = "member_id_p"; + RETURN; + END; + $$; + +CREATE OR REPLACE FUNCTION "delete_private_data"() + RETURNS VOID + LANGUAGE 'plpgsql' VOLATILE AS $$ + BEGIN + DELETE FROM "temporary_transaction_data"; + DELETE FROM "member" WHERE "activated" ISNULL; + UPDATE "member" SET + "invite_code" = NULL, + "invite_code_expiry" = NULL, + "admin_comment" = NULL, + "last_login" = NULL, + "last_delegation_check" = NULL, + "login" = NULL, + "password" = NULL, + "authority" = NULL, + "authority_uid" = NULL, + "authority_login" = NULL, + "lang" = NULL, + "notify_email" = NULL, + "notify_email_unconfirmed" = NULL, + "notify_email_secret" = NULL, + "notify_email_secret_expiry" = NULL, + "notify_email_lock_expiry" = NULL, + "disable_notifications" = TRUE, + "notification_counter" = DEFAULT, + "notification_sample_size" = 0, + "notification_dow" = NULL, + "notification_hour" = NULL, + "login_recovery_expiry" = NULL, + "password_reset_secret" = NULL, + "password_reset_secret_expiry" = NULL, + "organizational_unit" = NULL, + "internal_posts" = NULL, + "realname" = NULL, + "birthday" = NULL, + "address" = NULL, + "email" = NULL, + "xmpp_address" = NULL, + "website" = NULL, + "phone" = NULL, + "mobile_phone" = NULL, + "profession" = NULL, + "external_memberships" = NULL, + "external_posts" = NULL, + "formatting_engine" = NULL, + "statement" = NULL; + -- "text_search_data" is updated by triggers + DELETE FROM "setting"; + DELETE FROM "setting_map"; + DELETE FROM "member_relation_setting"; + DELETE FROM "member_image"; + DELETE FROM "contact"; + DELETE FROM "ignored_member"; + DELETE FROM "session"; + DELETE FROM "area_setting"; + DELETE FROM "issue_setting"; + DELETE FROM "ignored_initiative"; + DELETE FROM "initiative_setting"; + DELETE FROM "suggestion_setting"; + DELETE FROM "non_voter"; + DELETE FROM "direct_voter" USING "issue" + WHERE "direct_voter"."issue_id" = "issue"."id" + AND "issue"."closed" ISNULL; + RETURN; + END; + $$; + COMMIT;