mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-23 15:16:29 +00:00
Initial commit
This commit is contained in:
19
sql_utils/Makefile
Normal file
19
sql_utils/Makefile
Normal file
@@ -0,0 +1,19 @@
|
||||
#
|
||||
# Makefile
|
||||
# Copyright (c) 2ndQuadrant, 2010
|
||||
#
|
||||
|
||||
MODULE_big = repmgr_wrapper_funcs
|
||||
DATA_built=repmgr_wrapper_funcs.sql
|
||||
DATA=uninstall_repmgr_wrapper_funcs.sql
|
||||
OBJS=repmgr_wrapper_funcs.o
|
||||
|
||||
ifdef USE_PGXS
|
||||
PGXS := $(shell pg_config --pgxs)
|
||||
include $(PGXS)
|
||||
else
|
||||
subdir = contrib/repmgr/sql_utils
|
||||
top_builddir = ../../..
|
||||
include $(top_builddir)/src/Makefile.global
|
||||
include $(top_srcdir)/contrib/contrib-global.mk
|
||||
endif
|
||||
36
sql_utils/repmgr_wrapper_funcs.c
Normal file
36
sql_utils/repmgr_wrapper_funcs.c
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* repmgr_wrapper_funcs.c
|
||||
* Copyright (c) 2ndQuadrant, 2010
|
||||
*
|
||||
* Expose some backend functions in SQL
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
#include "fmgr.h"
|
||||
#include "access/xlog.h"
|
||||
#include "storage/procarray.h"
|
||||
|
||||
PG_MODULE_MAGIC;
|
||||
|
||||
Datum last_xlog_replay_timestamp(PG_FUNCTION_ARGS);
|
||||
Datum oldest_xmin(PG_FUNCTION_ARGS);
|
||||
|
||||
PG_FUNCTION_INFO_V1(last_xlog_replay_timestamp);
|
||||
|
||||
Datum
|
||||
last_xlog_replay_timestamp(PG_FUNCTION_ARGS)
|
||||
{
|
||||
if (!InRecovery)
|
||||
PG_RETURN_NULL();
|
||||
else
|
||||
PG_RETURN_TIMESTAMPTZ(GetLatestXLogTime());
|
||||
}
|
||||
|
||||
|
||||
PG_FUNCTION_INFO_V1(oldest_xmin);
|
||||
|
||||
Datum
|
||||
oldest_xmin(PG_FUNCTION_ARGS)
|
||||
{
|
||||
PG_RETURN_INT64(GetOldestXmin(false, false));
|
||||
}
|
||||
13
sql_utils/repmgr_wrapper_funcs.sql.in
Normal file
13
sql_utils/repmgr_wrapper_funcs.sql.in
Normal file
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* repmgr_wrapper_function.sql
|
||||
* Copyright (c) 2ndQuadrant, 2010
|
||||
*
|
||||
*/
|
||||
|
||||
CREATE FUNCTION get_last_xlog_replay_timestamp() RETURNS timestamp with time zone
|
||||
AS 'MODULE_PATHNAME', 'last_xlog_replay_timestamp'
|
||||
LANGUAGE C STRICT;
|
||||
|
||||
CREATE FUNCTION get_oldest_xmin() RETURNS bigint
|
||||
AS 'MODULE_PATHNAME', 'oldest_xmin'
|
||||
LANGUAGE C STRICT;
|
||||
2
sql_utils/uninstall_repmgr_wrapper_funcs.sql
Normal file
2
sql_utils/uninstall_repmgr_wrapper_funcs.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
DROP FUNCTION get_last_xlog_replay_timestamp();
|
||||
DROP FUNCTION get_oldest_xmin();
|
||||
Reference in New Issue
Block a user