There's no point in checking a global policy for every single value decoding, not for every row decoded.
Please adjust the code to only check it once per recv_results_rows() call - decode_row() should be defined either as is today with column_encryption_policy enabled, or much simpler without all those extra checks.