snippetsqlMinor
How to create INOUT assignment cast on Amazon RDS PostgreSQL? If not possible, then why?
Viewed 0 times
postgresqlwhycreatecastassignmentamazoninoutpossiblethenhow
Problem
I'm migrating existing application to Amazon RDS PostgreSQL.
The application has cross-database support and for compatibility reasons it includes the following SQL:
On plain PostgreSQL, this requires superuser. On Amazon RDS PostgreSQL this fails with
ERROR: must be owner of type character varying or type numeric
Note: I guess that whether this is assignment or implicit cast is irrelevant, but included this information for completeness.
The application has cross-database support and for compatibility reasons it includes the following SQL:
CREATE CAST (varchar AS numeric) WITH INOUT AS ASSIGNMENTOn plain PostgreSQL, this requires superuser. On Amazon RDS PostgreSQL this fails with
ERROR: must be owner of type character varying or type numeric
- Is there a way to create such a cast in Amazon RDS (perhaps via administrative web interface)?
- If this is not possible, then why? Is this deliberate limitation (e.g. is the cast something dangerous) or just a missing feature?
Note: I guess that whether this is assignment or implicit cast is irrelevant, but included this information for completeness.
Solution
On AWS RDS you must first
To run
When you create a DB instance, the master user system account that you
create is assigned to the
The
(customarily named postgres in local instances) but with some
restrictions.
alter type owner to before create cast since the default owner of all types is the rdsadmin user.To run
alter type you must do so with the master user system account you created for RDS or any other user that you have given the rds_superuser role. From the docs:When you create a DB instance, the master user system account that you
create is assigned to the
rds_superuserrole.The
rds_superuser role is similar to the PostgreSQL superuser role(customarily named postgres in local instances) but with some
restrictions.
Context
StackExchange Database Administrators Q#96960, answer score: 4
Revisions (0)
No revisions yet.