Skip to main content

DB Function - Sanitize App Backup Content

Function: sanitize_backup_content()

Code:

    CREATE OR REPLACE FUNCTION sanitize_backup_content()
RETURNS TRIGGER AS $$
BEGIN
NEW.backup_content = REGEXP_REPLACE(NEW.backup_content, '(?:\\+)u0000', '','g');
RETURN NEW;
END;
$$ LANGUAGE plpgsql;

Environment:

  • ✅ Production
  • ✅ Staging
  • ❌ Development

Description: The sanitize_backup_content() function is responsible for sanitizing the backup_content field by removing any null characters ('\u0000') from the input string.

Parameters:

  • None

Returns:

  • The modified NEW record.

Purpose:

  • Ensures that the backup_content field does not contain null characters.

Usage:

  • This function is called by the trigger_sanitize_app_backup_content trigger before inserting or updating records in the apps table.

Removal: If this function needs to be removed for any reason, execute the following in the necessary environment. This will also remove the corresponding trigger:

DROP FUNCTION sanitize_backup_content CASCADE;

Related Documentation: