These are chat archives for ged/ruby-pg

17th
May 2017
Caleb Sayre
@DrSayre
May 17 18:01

I am having an issue calling plpgsql functions that does a RAISE. The function appears to be executed twice. For example if I have this plpgsql function

CREATE OR REPLACE FUNCTION public.spike_foo()
    RETURNS void AS
$BODY$
    DECLARE
    BEGIN
        RAISE LOG '-------- Spike Foo ----------';
        RAISE '============ This is an error! ==============';
        RETURN;
    END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100;

Then if I call this function by doing this:

ActiveRecord::Base.connection.execute('SELECT * FROM spike_foo();')

Then I will see in the logs both messages being displayed twice. However if I remove the RAISE, leaving only the RAISE LOG, I will see the log message only once. I am seeing this using Rails 4.1 using PG 0.20.0

Caleb Sayre
@DrSayre
May 17 18:06
I can probably put together a small rails app or something demonstrating this if that would help.
Caleb Sayre
@DrSayre
May 17 18:24
@ged