whitelist for allowed user queries in postgres
Looking for a way to limited a user to a specific set of queries (i.e. a whitelist).


Wrap all of your queries in a plpgsql function that takes a SQL command and executes dynamic SQL.

SELECT * FROM mystupidwrapper('SELECT * FROM foo');


It will have to return a specific type, SETOF jsonb sounds great. You can write mystupidwrapper in perl, or plv8 and it'll even be trusted. If you want to write it in plperl, you can even use SQL::Statement::Structure to do basic SQL Statement processing. That said, SQL is a query language it provides READ permissions on both table and columns but the goal is still a declarative language that provides the ability to query abstractly.

Perhaps you want something more like pg-promise which natively supports a QueryFile