ERROR: syntax error at or near "EXISTS" LINE 1: ALTER TABLE IF EXISTS event ^ QUERY: ALTER TABLE IF EXISTS event RENAME TO event_s; CONTEXT: PL/pgSQL function "convert_table_to_history" line 60 at EXECUTE statement
As you'll see, in this case the command was issued from a function. But issuing it directly evokes the same error.