postgresql-pg_is_in_backup-patch-v3.diff
text/x-patch
Filename: postgresql-pg_is_in_backup-patch-v3.diff
Type: text/x-patch
Part: 2
Message:
Re: Patch pg_is_in_backup()
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
Series: patch v3
| File | + | − |
|---|---|---|
| doc/src/sgml/func.sgml | 10 | 0 |
| src/backend/access/transam/xlogfuncs.c | 9 | 0 |
| src/include/access/xlog_internal.h | 1 | 0 |
| src/include/catalog/pg_proc.h | 2 | 0 |
diff -ru postgresql-head/doc/src/sgml/func.sgml postgresql/doc/src/sgml/func.sgml
--- postgresql-head/doc/src/sgml/func.sgml 2012-04-03 10:44:43.979702643 +0200
+++ postgresql/doc/src/sgml/func.sgml 2012-04-03 11:24:41.427701474 +0200
@@ -14467,6 +14467,9 @@
<primary>pg_stop_backup</primary>
</indexterm>
<indexterm>
+ <primary>pg_is_in_backup</primary>
+ </indexterm>
+ <indexterm>
<primary>pg_switch_xlog</primary>
</indexterm>
<indexterm>
@@ -14532,6 +14535,13 @@
</row>
<row>
<entry>
+ <literal><function>pg_is_in_backup()</function></literal>
+ </entry>
+ <entry><type>bool</type></entry>
+ <entry>True if an on-line exclusive backup is still in progress.</entry>
+ </row>
+ <row>
+ <entry>
<literal><function>pg_switch_xlog()</function></literal>
</entry>
<entry><type>text</type></entry>
diff -ru postgresql-head/src/backend/access/transam/xlogfuncs.c postgresql/src/backend/access/transam/xlogfuncs.c
--- postgresql-head/src/backend/access/transam/xlogfuncs.c 2012-04-03 10:44:44.227702645 +0200
+++ postgresql/src/backend/access/transam/xlogfuncs.c 2012-04-03 11:24:41.427701474 +0200
@@ -563,3 +563,12 @@
PG_RETURN_NUMERIC(result);
}
+
+/*
+ * Returns bool with current on-line backup mode, a global state.
+ */
+Datum
+pg_is_in_backup(PG_FUNCTION_ARGS)
+{
+ PG_RETURN_BOOL(BackupInProgress());
+}
diff -ru postgresql-head/src/include/access/xlog_internal.h postgresql/src/include/access/xlog_internal.h
--- postgresql-head/src/include/access/xlog_internal.h 2012-04-03 10:44:45.051702642 +0200
+++ postgresql/src/include/access/xlog_internal.h 2012-04-03 11:24:41.427701474 +0200
@@ -282,5 +282,6 @@
extern Datum pg_xlog_replay_resume(PG_FUNCTION_ARGS);
extern Datum pg_is_xlog_replay_paused(PG_FUNCTION_ARGS);
extern Datum pg_xlog_location_diff(PG_FUNCTION_ARGS);
+extern Datum pg_is_in_backup(PG_FUNCTION_ARGS);
#endif /* XLOG_INTERNAL_H */
diff -ru postgresql-head/src/include/catalog/pg_proc.h postgresql/src/include/catalog/pg_proc.h
--- postgresql-head/src/include/catalog/pg_proc.h 2012-04-03 10:44:45.051702642 +0200
+++ postgresql/src/include/catalog/pg_proc.h 2012-04-03 11:24:41.427701474 +0200
@@ -2924,6 +2924,8 @@
DESCR("prepare for taking an online backup");
DATA(insert OID = 2173 ( pg_stop_backup PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 25 "" _null_ _null_ _null_ _null_ pg_stop_backup _null_ _null_ _null_ ));
DESCR("finish taking an online backup");
+DATA(insert OID = 3882 ( pg_is_in_backup PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 16 "" _null_ _null_ _null_ _null_ pg_is_in_backup _null_ _null_ _null_ ));
+DESCR("true if server is in online backup");
DATA(insert OID = 2848 ( pg_switch_xlog PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 25 "" _null_ _null_ _null_ _null_ pg_switch_xlog _null_ _null_ _null_ ));
DESCR("switch to new xlog file");
DATA(insert OID = 3098 ( pg_create_restore_point PGNSP PGUID 12 1 0 0 0 f f f f t f v 1 0 25 "25" _null_ _null_ _null_ _null_ pg_create_restore_point _null_ _null_ _null_ ));