Problem
When trying to create a CAST in PostgreSQL, for example:
CREATE CAST (A AS B) WITH FUNCTION function_name(A) AS IMPLICIT;
It returns the following error:
ERROR: must be owner of type A or type B SQL State: 42501.
Environment
- Cloud SQL PostgreSQL
- Executing a CREATE CAST command directly against a database or as part of a data import
Solution
This feature is working as designed. Workarounds have been provided, including using explicit cast or conversion functions within SQL statements that require them.
Cause
CREATE CAST commands require superuser access, which is not available to Cloud SQL users.