0

I am wondering if there is a better way to write a test function in Postgresql 8. The following sniped code works fine under AWS Redshift in my tests so maybe someone can share a shorter implementation in the aforementioned AWS service.

-- The simplest function that I wrote in Postgresql
CREATE FUNCTION TEST_FUNCTION()
    RETURNS INTEGER
STABLE
AS $$
    return 1
$$ LANGUAGE plpythonu;

-- Testing the simplest function
SELECT TEST_FUNCTION();

-- Dropping the simplest function out
DROP FUNCTION TEST_FUNCTION();
R. Ilma
  • 156
  • 1
  • 9
  • No need for an untrusted language: `CREATE FUNCTION TEST_FUNCTION() RETURNS INTEGER AS $$ select 1 $$ LANGUAGE sql;` –  Jul 17 '17 at 18:46
  • Sadly your suggestion does not work in AWS. – R. Ilma Jul 18 '17 at 09:32
  • Since you can not create a *temporary* function, then that's pretty much the way you already have. There is [suggested once](https://stackoverflow.com/questions/4990622/how-to-create-a-temporary-function-in-postgresql/9981540#9981540) (with some risks) to use `pg_temp` scheme, but not sure will it work with redshift. – Kristo Mägi Jul 19 '17 at 13:43

0 Answers0