--
--  User-defined functions for file-size and file-modification-time
--

CREATE OR REPLACE FUNCTION bacula_lstat_size (varchar)
  RETURNS BIGINT LANGUAGE 'C' IMMUTABLE STRICT
  AS 'pgbacula.so','bacula_lstat_size'; 

CREATE OR REPLACE FUNCTION bacula_lstat_mtime (varchar)
  RETURNS TIMESTAMPTZ LANGUAGE 'C' IMMUTABLE STRICT
  AS 'pgbacula.so','bacula_lstat_mtime'; 

--
--  Extra indexes
--

CREATE INDEX filename_name_ci_idx
  ON filename (( upper(name) ));

CREATE INDEX path_name_ci_idx 
  ON path (( upper(path) ));

CREATE INDEX file_size_idx
  ON file (( bacula_lstat_size(lstat) ));

CREATE INDEX file_mtime_idx 
  ON file (( bacula_lstat_mtime(lstat) ));

