When I run the following code in psql the following error appears:
Code
CREATE OR REPLACE FUNCTION fct_isslave ()
RETURNS SETOF character varying AS
$ BODY $
BEGIN
RETURN QUERY SELECT CASE pg_is_in_recovery () FALSE THEN WHEN '0' :: varchar ELSE '1' :: varchar END;
END;
$ BODY $
LANGUAGE plpgsql VOLATILE
COST 100
ROWS 1000;
ALTER FUNCTION fct_isslave ()
OWNER TO usr_aplicacao;
CREATE OR REPLACE VIEW THE v_isslave
SELECT fct_isslave () AS fct_isslave;
ALTER TABLE v_isslave
OWNER TO usr_aplicacao;
CREATE OR REPLACE VIEW THE v_statusreplica
SELECT 'Last updated' :: text AS tx_tipo,
pg_last_xact_replay_timestamp () :: text AS tx_metrica
UNION
SELECT 'Delay' :: text AS tx_tipo,
CASE
WHEN pg_last_xlog_receive_location () = pg_last_xlog_replay_location () 0 THEN text ::
ELSE date_part ('epoch' :: text, now () - pg_last_xact_replay_timestamp ()) :: text
END THE tx_metrica
UNION
SELECT 'Working' :: text AS tx_tipo,
CASE
WHEN pg_is_in_recovery () THEN Yes :: text
ELSE 'False' :: text
END THE tx_metrica
UNION
SELECT 'Last xlog received' :: text AS tx_tipo,
pg_last_xlog_receive_location () :: text AS tx_metrica;
ALTER TABLE v_statusreplica
OWNER TO usr_aplicacao;
Error:
ERROR: syntax error at or near "$"
LINE 3: $
^
ERROR: syntax error at or near "RETURN"
LINE 2: RETURN QUERY SELECT CASE pg_is_in_recovery () FALSE WHEN ...
^
WARNING: there is the transaction in progress
COMMIT
ERROR: syntax error at or near "$"
LINE 1: $
^
ERROR: function fct_isslave () does not exist
ERROR: function fct_isslave () does not exist
LINE 2: SELECT fct_isslave () AS fct_isslave;
^
HINT: No function matches the given name and argument types. You might need to
add explicit type casts.
ERROR: relation "v_isslave" does not exist
CREATE VIEW
ALTER TABLE