-- Add Test data for vacuumlo contrib

-- Insert single large object
CREATE OR REPLACE FUNCTION Create_LargeObject_p()
RETURNS void
AS $$
DECLARE
	strRetValue varchar(100);
	loid	oid;
	fd	integer;
BEGIN
	SELECT lo_creat(42) INTO loid;
	SELECT lo_open(loid, CAST(x'20000' | x'40000' AS integer)) INTO fd;
	SELECT lowrite(fd, 'Test Value1') INTO strRetValue;
	SELECT lo_close(fd) INTO strRetValue;
END;
$$ LANGUAGE plpgsql;

-- Insert multiple (13000) large objects
CREATE OR REPLACE FUNCTION Create_ManyLargeObjects()
RETURNS void
AS $$

DECLARE
	strRetValue varchar(100);
BEGIN
	FOR iRunNo in 0..13000 LOOP
		SELECT Create_LargeObject_p() INTO strRetValue;
	END LOOP;
END;
$$ LANGUAGE plpgsql;

select * from Create_ManyLargeObjects();

select count(*) from pg_largeobject;

