CREATE TABLE test_data (
  test_name TEXT PRIMARY KEY,
  test_length INT GENERATED ALWAYS AS (length(test_data)) STORED,
  test_data BYTEA
);

CREATE OR REPLACE FUNCTION import_bytea(p_path text, p_result out bytea) 
                   language plpgsql as $$
DECLARE
  l_oid oid;
BEGIN
  SELECT lo_import(p_path) INTO l_oid;
  SELECT lo_get(l_oid) INTO p_result;
  PERFORM lo_unlink(l_oid);
END;$$;

INSERT INTO test_data (test_name, test_data) VALUES ('000000010000000000000001', import_bytea('/tmp/pglz/000000010000000000000001'));
INSERT INTO test_data (test_name, test_data) VALUES ('000000010000000000000006', import_bytea('/tmp/pglz/000000010000000000000006'));
INSERT INTO test_data (test_name, test_data) VALUES ('000000010000000000000008', import_bytea('/tmp/pglz/000000010000000000000008'));
INSERT INTO test_data (test_name, test_data) VALUES ('16398', import_bytea('/tmp/pglz/16398'));
INSERT INTO test_data (test_name, test_data) VALUES ('shakespeare.txt', import_bytea('/tmp/pglz/shakespeare.txt'));
INSERT INTO test_data (test_name, test_data) VALUES ('mr', import_bytea('/tmp/pglz/mr'));
INSERT INTO test_data (test_name, test_data) VALUES ('dickens', import_bytea('/tmp/pglz/dickens'));
INSERT INTO test_data (test_name, test_data) VALUES ('mozilla', import_bytea('/tmp/pglz/mozilla'));
INSERT INTO test_data (test_name, test_data) VALUES ('nci', import_bytea('/tmp/pglz/nci'));
INSERT INTO test_data (test_name, test_data) VALUES ('ooffice', import_bytea('/tmp/pglz/ooffice'));
INSERT INTO test_data (test_name, test_data) VALUES ('osdb', import_bytea('/tmp/pglz/osdb'));
INSERT INTO test_data (test_name, test_data) VALUES ('reymont', import_bytea('/tmp/pglz/reymont'));
INSERT INTO test_data (test_name, test_data) VALUES ('samba', import_bytea('/tmp/pglz/samba'));
INSERT INTO test_data (test_name, test_data) VALUES ('sao', import_bytea('/tmp/pglz/sao'));
INSERT INTO test_data (test_name, test_data) VALUES ('webster', import_bytea('/tmp/pglz/webster'));
INSERT INTO test_data (test_name, test_data) VALUES ('x-ray', import_bytea('/tmp/pglz/x-ray'));
INSERT INTO test_data (test_name, test_data) VALUES ('xml', import_bytea('/tmp/pglz/xml'));
