Search code examples
postgresqlgoogle-cloud-platformpostgisgoogle-cloud-sql

Google Cloud SQL: how to enable GDAL drivers with PostGIS?


My goal is to is to run PostGIS' ST_AsGDALRaster function. With no configuration, PostGIS 2.2+ will error out:

ERROR: rt_raster_to_gdal: Could not load the output GDAL driver

This is all fine and expected. However with GCP's Cloud SQL, I'm unable to set the PostGIS flags that properly enable the drivers. I've attempted the following:

Setting via gcloud:

gcloud instances patch $instance \
    --database-flags 'postgis.gdal_enabled_drivers=ENABLE_ALL'

which errors out with the following:

ERROR: (gcloud.sql.instances.patch) HTTPError 404: Flag requested cannot be set.

Attempting to set it via SQL set via

SET postgis.gdal_enabled_drivers = 'ENABLE_ALL';

which shows the following in Cloud SQL's error log:

WARNING: permission denied to set parameter "postgis.gdal_enabled_drivers"

Is there a recommended way to proceed with generating raster images from Cloud SQL + PostGIS?


Solution

  • Google now supports the GDAL driver in Cloud SQL (as of May 2024).