Conditionally delete temporary table in Redshift

We use http://aws.amazon.com/redshift/ and I create / delete temporary tables in reports. Sometimes we encounter cases when someone created a temporary table and could not delete it.

In other databases, such as PostgreSQL, on which Redshift is based, I could simply:

DROP TEMP TABLE IF EXISTS tblfoo;

But this is a syntax error in Redshift. I can check for temporary tables using http://docs.aws.amazon.com/redshift/latest/dg/r_STV_TBL_PERM.html , but this only works if I am a superuser and I do not work as a superuser, I I could go and learn the exceptions, but with my reporting structure, I would rather go the wrong way.

So, how do I, as a regular user and without generating database errors, conditionally delete a temporary table, if it exists?

+4
source share
1 answer

The test I ran showed that I can see the temporary tables of other users in stv_tbl_perm using a non-super-user id. The cluster testing I tested is 1.0.797. Note that no user can see the temporary tables of other users in pg_class.

+2
source

Source: https://habr.com/ru/post/1547069/


All Articles