UNPKG

bc-code-intelligence-mcp

Version:

BC Code Intelligence MCP Server - Complete Specialist Bundle with AI-driven expert consultation, seamless handoffs, and context-preserving workflows

79 lines (57 loc) 4.06 kB
--- title: "IsTemporary Table Safeguard Pattern for Data Protection" domain: "seth-security" difficulty: "intermediate" bc_versions: "14+" tags: ["data-protection", "temporary-tables", "safeguards", "data-integrity", "error-prevention"] prerequisites: ["al-tables", "data-access-patterns"] --- # IsTemporary Table Safeguard Pattern for Data Protection ## Overview The IsTemporary table safeguard pattern prevents accidental data modifications to permanent database tables by validating table state before performing destructive operations, protecting against data corruption and unintended database changes. **Safety Principle**: Always verify table temporariness before bulk operations, modifications without keys, or destructive actions to prevent permanent data loss. ## Strategic Framework ### Data Protection Strategy - **Validation gates**: Check IsTemporary before bulk insert/modify/delete operations - **Operation scoping**: Restrict dangerous operations to temporary tables only - **Error prevention**: Fail fast when permanent tables are used inappropriately - **Developer safety**: Provide clear feedback for incorrect table usage patterns ### Risk Mitigation Approach - **Bulk operation safety**: Prevent mass data changes to production tables - **Development protection**: Guard against test code affecting live data - **Integration safety**: Validate table state in data import/export routines - **Maintenance protection**: Ensure cleanup operations target appropriate tables ## Architecture Patterns ### Precondition Validation Implement validation checks that verify table temporariness before executing operations that could affect large data sets or bypass normal business logic constraints. ### Defensive Programming Pattern Build safeguards into reusable procedures and functions that work with table data, ensuring they cannot accidentally corrupt permanent database tables. ### Operation Context Awareness Design data manipulation routines that understand whether they're working with temporary or permanent data and adjust their behavior accordingly. ## Implementation Guidelines ### Validation Implementation - **Early validation**: Check IsTemporary at procedure entry points - **Clear error messages**: Provide specific feedback about safeguard violations - **Conditional operations**: Use IsTemporary state to determine operation safety - **Logging integration**: Record safeguard violations for debugging and auditing ### Bulk Operation Protection Implement mandatory IsTemporary checks before DeleteAll, ModifyAll, and other bulk operations that could affect large numbers of records without individual validation. ### Development Workflow Safety Build IsTemporary validation into development and testing procedures to prevent test code from accidentally targeting production tables. ## Best Practices ### Safeguard Implementation - **Consistent application**: Apply safeguards uniformly across similar operations - **Performance consideration**: Balance safety checks with execution efficiency - **Clear documentation**: Document why and when safeguards are required - **Team training**: Ensure developers understand safeguard importance and usage ### Error Handling Strategy Provide clear, actionable error messages when safeguard violations occur, helping developers understand both the problem and the correct solution. ### Code Review Integration Include IsTemporary safeguard checks in code review checklists, especially for procedures that manipulate table data in bulk. ## Anti-Patterns ### Avoid These Approaches - **Skipping validation**: Bypassing IsTemporary checks for "performance" reasons - **Silent failures**: Not providing clear error messages when safeguards trigger - **Inconsistent application**: Using safeguards in some functions but not others - **Late validation**: Checking IsTemporary after beginning data modifications - **Generic error handling**: Non-specific error messages that don't help debugging