Sometimes a RLS Policy subquery can have a name co...
# sql
q
Sometimes a RLS Policy subquery can have a name conflict and silently use the wrong context! FUN. Like, I have a table that has column
t1.blah_blah
and I wanted to use that column in a subquery who also had a column of the same name (
... where foo.blah_blah = blah_blah
). Instead of warning me, it just used the unqualified name from
foo
.. which is always true, and really tripped me up.
b
We need to think about how to set up a debugging environment for SQL (or more importantly, IMHO, functions).
I've been writing a lot of PLPGSQL functions and they're not fun to debug.
My SupaScript library handles debugging much better -- I've abstracted the
console.log
stuff so you can use the standard logging stuff.
It writes the log messages to a table, which I put a realtime listener on, then show them in my browser console. That's a much better environment for debugging.
q
oh that would be just wonderful
Though, it may not work if the transaction fails? Unless it can queue up the log writes in a bg thread
b
I dunno. It writes to the log table as it goes so I assume it’s still work. I’ll have to see how it goes - I have someone using it a lot this weekend and I’ll ask him what he finds under stress load.