RDS Crosstab – Fixing ‘Permission Denied for Language C’ Error

amazon-rdsawspivotpostgresqlpostgresql-9.4

We're currently using PostgreSQL 9.2 in our production database, we want to migrate to a new RDS instance, using PostgreSQL 9.4. However, we need to have permission to create a function, but only superuser can create functions on RDS and my user can't be granted as superuser.

CREATE FUNCTION crosstab50(text, OUT rownumber integer, OUT c1 text,...) 
    RETURNS SETOF record 
    LANGUAGE c 
    STABLE STRICT 
    AS '$libdir/tablefunc', 'crosstab';

But we're getting this error during our restore operation:

ERROR:  permission denied for language c

Best Answer

RDS doesn't let you install arbitrary C functions. It's a restricted environment.

crosstab is part of the tablefunc extension. You may be able to CREATE EXTENSION tablefunc if it's on the whitelist but you won't be able to add new variants, even if the underlying C function is already loaded and approved.