f 如何使用SQL 查詢Postgres RDBMS 系統記錄檔內關鍵字串FATAL 或PANIC或WARNNING ~ 迪貝之家

如何使用SQL 查詢Postgres RDBMS 系統記錄檔內關鍵字串FATAL 或PANIC或WARNNING

select to_tsvector(pg_read_file(current_log,1,size) )  @@ to_tsquery('(FATAL|PANIC|WARNNING)')
from ( 
 select case current_setting('log_directory') when 'pg_log' then current_setting('data_directory')||'/pg_log/'||file
                                              else current_setting('log_directory')||'/'||file end as current_log ,
 (pg_stat_file(current_setting('log_directory')||'/'||file)).modification,(pg_stat_file(current_setting('log_directory')||'/'||file)).size
 FROM  pg_ls_dir(current_setting('log_directory')||'/') as list(file)
  ORDER BY 2 DESC
  LIMIT 1 );