1CREATE SCHEMA upgrade_distributed_function_before; 2SET search_path TO upgrade_distributed_function_before, public; 3SET citus.shard_replication_factor TO 1; 4 5CREATE TABLE t1 (a int PRIMARY KEY, b int); 6SELECT create_distributed_table('t1','a'); 7INSERT INTO t1 VALUES (11), (12); 8 9-- create a very simple distributed function colocated with the table 10CREATE FUNCTION count_values(input int) RETURNS int AS 11$$ 12 DECLARE 13 cnt int := 0; 14 BEGIN 15 SELECT count(*) INTO cnt FROM upgrade_distributed_function_before.t1 WHERE a = $1; 16 RETURN cnt; 17 END; 18$$ LANGUAGE plpgsql; 19SELECT create_distributed_function('count_values(int)', '$1', colocate_with:='t1'); 20 21-- make sure that the metadata synced before running the queries 22SELECT wait_until_metadata_sync(5000); 23SELECT bool_and(metadatasynced) FROM pg_dist_node WHERE isactive AND noderole = 'primary'; 24SET client_min_messages TO DEBUG1; 25 26SELECT count_values(11); 27SELECT count_values(12); 28