Advertisement
Guest User

Untitled

a guest
Sep 20th, 2024
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. begin;
  2.  
  3. CREATE OR REPLACE FUNCTION evergreen.redact_value_anyelement(
  4. input_data anyelement,
  5. skip_redaction BOOLEAN DEFAULT FALSE, -- pass TRUE for "I passed the test!" and avoid redaction
  6. redact_with anyelement DEFAULT NULL
  7. ) RETURNS anyelement AS $f$
  8. DECLARE
  9. result ALIAS FOR $0;
  10. BEGIN
  11. IF skip_redaction THEN
  12. result := input_data;
  13. ELSE
  14. result := redact_with;
  15. END IF;
  16.  
  17. RETURN result;
  18. END;
  19. $f$ STABLE LANGUAGE PLPGSQL;
  20.  
  21. select 1 as expected, evergreen.redact_value_anyelement(id,true,'3') from actor.usr where id=1;
  22. select 3 as expected, evergreen.redact_value_anyelement(id,false,'3') from actor.usr where id=1;
  23.  
  24. rollback;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement