Commit 6f289c2b authored by Robert Haas's avatar Robert Haas

Switch various builtin functions to use pg_lsn instead of text.

The functions in slotfuncs.c don't exist in any released version,
but the changes to xlogfuncs.c represent backward-incompatibilities.
Per discussion, we're hoping that the queries using these functions
are few enough and simple enough that this won't cause too much
breakage for users.

Michael Paquier, reviewed by Andres Freund and further modified
by me.
parent 694e3d13
...@@ -5244,7 +5244,7 @@ ...@@ -5244,7 +5244,7 @@
<row> <row>
<entry><structfield>restart_lsn</structfield></entry> <entry><structfield>restart_lsn</structfield></entry>
<entry><type>text</type></entry> <entry><type>pg_lsn</type></entry>
<entry></entry> <entry></entry>
<entry>The address (<literal>LSN</literal>) of oldest WAL which still <entry>The address (<literal>LSN</literal>) of oldest WAL which still
might be required by the consumer of this slot and thus won't be might be required by the consumer of this slot and thus won't be
......
...@@ -15884,35 +15884,35 @@ SELECT set_config('log_statement_stats', 'off', false); ...@@ -15884,35 +15884,35 @@ SELECT set_config('log_statement_stats', 'off', false);
<entry> <entry>
<literal><function>pg_create_restore_point(<parameter>name</> <type>text</>)</function></literal> <literal><function>pg_create_restore_point(<parameter>name</> <type>text</>)</function></literal>
</entry> </entry>
<entry><type>text</type></entry> <entry><type>pg_lsn</type></entry>
<entry>Create a named point for performing restore (restricted to superusers)</entry> <entry>Create a named point for performing restore (restricted to superusers)</entry>
</row> </row>
<row> <row>
<entry> <entry>
<literal><function>pg_current_xlog_insert_location()</function></literal> <literal><function>pg_current_xlog_insert_location()</function></literal>
</entry> </entry>
<entry><type>text</type></entry> <entry><type>pg_lsn</type></entry>
<entry>Get current transaction log insert location</entry> <entry>Get current transaction log insert location</entry>
</row> </row>
<row> <row>
<entry> <entry>
<literal><function>pg_current_xlog_location()</function></literal> <literal><function>pg_current_xlog_location()</function></literal>
</entry> </entry>
<entry><type>text</type></entry> <entry><type>pg_lsn</type></entry>
<entry>Get current transaction log write location</entry> <entry>Get current transaction log write location</entry>
</row> </row>
<row> <row>
<entry> <entry>
<literal><function>pg_start_backup(<parameter>label</> <type>text</> <optional>, <parameter>fast</> <type>boolean</> </optional>)</function></literal> <literal><function>pg_start_backup(<parameter>label</> <type>text</> <optional>, <parameter>fast</> <type>boolean</> </optional>)</function></literal>
</entry> </entry>
<entry><type>text</type></entry> <entry><type>pg_lsn</type></entry>
<entry>Prepare for performing on-line backup (restricted to superusers or replication roles)</entry> <entry>Prepare for performing on-line backup (restricted to superusers or replication roles)</entry>
</row> </row>
<row> <row>
<entry> <entry>
<literal><function>pg_stop_backup()</function></literal> <literal><function>pg_stop_backup()</function></literal>
</entry> </entry>
<entry><type>text</type></entry> <entry><type>pg_lsn</type></entry>
<entry>Finish performing on-line backup (restricted to superusers or replication roles)</entry> <entry>Finish performing on-line backup (restricted to superusers or replication roles)</entry>
</row> </row>
<row> <row>
...@@ -15933,26 +15933,26 @@ SELECT set_config('log_statement_stats', 'off', false); ...@@ -15933,26 +15933,26 @@ SELECT set_config('log_statement_stats', 'off', false);
<entry> <entry>
<literal><function>pg_switch_xlog()</function></literal> <literal><function>pg_switch_xlog()</function></literal>
</entry> </entry>
<entry><type>text</type></entry> <entry><type>pg_lsn</type></entry>
<entry>Force switch to a new transaction log file (restricted to superusers)</entry> <entry>Force switch to a new transaction log file (restricted to superusers)</entry>
</row> </row>
<row> <row>
<entry> <entry>
<literal><function>pg_xlogfile_name(<parameter>location</> <type>text</>)</function></literal> <literal><function>pg_xlogfile_name(<parameter>location</> <type>pg_lsn</>)</function></literal>
</entry> </entry>
<entry><type>text</type></entry> <entry><type>text</type></entry>
<entry>Convert transaction log location string to file name</entry> <entry>Convert transaction log location string to file name</entry>
</row> </row>
<row> <row>
<entry> <entry>
<literal><function>pg_xlogfile_name_offset(<parameter>location</> <type>text</>)</function></literal> <literal><function>pg_xlogfile_name_offset(<parameter>location</> <type>pg_lsn</>)</function></literal>
</entry> </entry>
<entry><type>text</>, <type>integer</></entry> <entry><type>text</>, <type>integer</></entry>
<entry>Convert transaction log location string to file name and decimal byte offset within file</entry> <entry>Convert transaction log location string to file name and decimal byte offset within file</entry>
</row> </row>
<row> <row>
<entry> <entry>
<literal><function>pg_xlog_location_diff(<parameter>location</> <type>text</>, <parameter>location</> <type>text</>)</function></literal> <literal><function>pg_xlog_location_diff(<parameter>location</> <type>pg_lsn</>, <parameter>location</> <type>pg_lsn</>)</function></literal>
</entry> </entry>
<entry><type>numeric</></entry> <entry><type>numeric</></entry>
<entry>Calculate the difference between two transaction log locations</entry> <entry>Calculate the difference between two transaction log locations</entry>
...@@ -16107,7 +16107,7 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup()); ...@@ -16107,7 +16107,7 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
<entry> <entry>
<literal><function>pg_last_xlog_receive_location()</function></literal> <literal><function>pg_last_xlog_receive_location()</function></literal>
</entry> </entry>
<entry><type>text</type></entry> <entry><type>pg_lsn</type></entry>
<entry>Get last transaction log location received and synced to disk by <entry>Get last transaction log location received and synced to disk by
streaming replication. While streaming replication is in progress streaming replication. While streaming replication is in progress
this will increase monotonically. If recovery has completed this will this will increase monotonically. If recovery has completed this will
...@@ -16121,7 +16121,7 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup()); ...@@ -16121,7 +16121,7 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
<entry> <entry>
<literal><function>pg_last_xlog_replay_location()</function></literal> <literal><function>pg_last_xlog_replay_location()</function></literal>
</entry> </entry>
<entry><type>text</type></entry> <entry><type>pg_lsn</type></entry>
<entry>Get last transaction log location replayed during recovery. <entry>Get last transaction log location replayed during recovery.
If recovery is still in progress this will increase monotonically. If recovery is still in progress this will increase monotonically.
If recovery has completed then this value will remain static at If recovery has completed then this value will remain static at
...@@ -16335,7 +16335,7 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup()); ...@@ -16335,7 +16335,7 @@ postgres=# SELECT * FROM pg_xlogfile_name_offset(pg_stop_backup());
<literal><function>pg_create_physical_replication_slot(<parameter>slotname</parameter> <type>text</type>, <parameter>plugin</parameter> <type>text</type>)</function></literal> <literal><function>pg_create_physical_replication_slot(<parameter>slotname</parameter> <type>text</type>, <parameter>plugin</parameter> <type>text</type>)</function></literal>
</entry> </entry>
<entry> <entry>
(<parameter>slotname</parameter> <type>text</type>, <parameter>xlog_position</parameter> <type>text</type>) (<parameter>slotname</parameter> <type>text</type>, <parameter>xlog_position</parameter> <type>pg_lsn</type>)
</entry> </entry>
<entry> <entry>
Creates a new physical replication slot named Creates a new physical replication slot named
......
...@@ -30,11 +30,10 @@ ...@@ -30,11 +30,10 @@
#include "utils/builtins.h" #include "utils/builtins.h"
#include "utils/numeric.h" #include "utils/numeric.h"
#include "utils/guc.h" #include "utils/guc.h"
#include "utils/pg_lsn.h"
#include "utils/timestamp.h" #include "utils/timestamp.h"
#include "storage/fd.h" #include "storage/fd.h"
static void validate_xlog_location(char *str);
/* /*
* pg_start_backup: set up for taking an on-line backup dump * pg_start_backup: set up for taking an on-line backup dump
...@@ -52,7 +51,6 @@ pg_start_backup(PG_FUNCTION_ARGS) ...@@ -52,7 +51,6 @@ pg_start_backup(PG_FUNCTION_ARGS)
bool fast = PG_GETARG_BOOL(1); bool fast = PG_GETARG_BOOL(1);
char *backupidstr; char *backupidstr;
XLogRecPtr startpoint; XLogRecPtr startpoint;
char startxlogstr[MAXFNAMELEN];
backupidstr = text_to_cstring(backupid); backupidstr = text_to_cstring(backupid);
...@@ -63,9 +61,7 @@ pg_start_backup(PG_FUNCTION_ARGS) ...@@ -63,9 +61,7 @@ pg_start_backup(PG_FUNCTION_ARGS)
startpoint = do_pg_start_backup(backupidstr, fast, NULL, NULL); startpoint = do_pg_start_backup(backupidstr, fast, NULL, NULL);
snprintf(startxlogstr, sizeof(startxlogstr), "%X/%X", PG_RETURN_LSN(startpoint);
(uint32) (startpoint >> 32), (uint32) startpoint);
PG_RETURN_TEXT_P(cstring_to_text(startxlogstr));
} }
/* /*
...@@ -85,7 +81,6 @@ Datum ...@@ -85,7 +81,6 @@ Datum
pg_stop_backup(PG_FUNCTION_ARGS) pg_stop_backup(PG_FUNCTION_ARGS)
{ {
XLogRecPtr stoppoint; XLogRecPtr stoppoint;
char stopxlogstr[MAXFNAMELEN];
if (!superuser() && !has_rolreplication(GetUserId())) if (!superuser() && !has_rolreplication(GetUserId()))
ereport(ERROR, ereport(ERROR,
...@@ -94,9 +89,7 @@ pg_stop_backup(PG_FUNCTION_ARGS) ...@@ -94,9 +89,7 @@ pg_stop_backup(PG_FUNCTION_ARGS)
stoppoint = do_pg_stop_backup(NULL, true, NULL); stoppoint = do_pg_stop_backup(NULL, true, NULL);
snprintf(stopxlogstr, sizeof(stopxlogstr), "%X/%X", PG_RETURN_LSN(stoppoint);
(uint32) (stoppoint >> 32), (uint32) stoppoint);
PG_RETURN_TEXT_P(cstring_to_text(stopxlogstr));
} }
/* /*
...@@ -106,7 +99,6 @@ Datum ...@@ -106,7 +99,6 @@ Datum
pg_switch_xlog(PG_FUNCTION_ARGS) pg_switch_xlog(PG_FUNCTION_ARGS)
{ {
XLogRecPtr switchpoint; XLogRecPtr switchpoint;
char location[MAXFNAMELEN];
if (!superuser()) if (!superuser())
ereport(ERROR, ereport(ERROR,
...@@ -124,9 +116,7 @@ pg_switch_xlog(PG_FUNCTION_ARGS) ...@@ -124,9 +116,7 @@ pg_switch_xlog(PG_FUNCTION_ARGS)
/* /*
* As a convenience, return the WAL location of the switch record * As a convenience, return the WAL location of the switch record
*/ */
snprintf(location, sizeof(location), "%X/%X", PG_RETURN_LSN(switchpoint);
(uint32) (switchpoint >> 32), (uint32) switchpoint);
PG_RETURN_TEXT_P(cstring_to_text(location));
} }
/* /*
...@@ -138,7 +128,6 @@ pg_create_restore_point(PG_FUNCTION_ARGS) ...@@ -138,7 +128,6 @@ pg_create_restore_point(PG_FUNCTION_ARGS)
text *restore_name = PG_GETARG_TEXT_P(0); text *restore_name = PG_GETARG_TEXT_P(0);
char *restore_name_str; char *restore_name_str;
XLogRecPtr restorepoint; XLogRecPtr restorepoint;
char location[MAXFNAMELEN];
if (!superuser()) if (!superuser())
ereport(ERROR, ereport(ERROR,
...@@ -169,9 +158,7 @@ pg_create_restore_point(PG_FUNCTION_ARGS) ...@@ -169,9 +158,7 @@ pg_create_restore_point(PG_FUNCTION_ARGS)
/* /*
* As a convenience, return the WAL location of the restore point record * As a convenience, return the WAL location of the restore point record
*/ */
snprintf(location, sizeof(location), "%X/%X", PG_RETURN_LSN(restorepoint);
(uint32) (restorepoint >> 32), (uint32) restorepoint);
PG_RETURN_TEXT_P(cstring_to_text(location));
} }
/* /*
...@@ -185,7 +172,6 @@ Datum ...@@ -185,7 +172,6 @@ Datum
pg_current_xlog_location(PG_FUNCTION_ARGS) pg_current_xlog_location(PG_FUNCTION_ARGS)
{ {
XLogRecPtr current_recptr; XLogRecPtr current_recptr;
char location[MAXFNAMELEN];
if (RecoveryInProgress()) if (RecoveryInProgress())
ereport(ERROR, ereport(ERROR,
...@@ -195,9 +181,7 @@ pg_current_xlog_location(PG_FUNCTION_ARGS) ...@@ -195,9 +181,7 @@ pg_current_xlog_location(PG_FUNCTION_ARGS)
current_recptr = GetXLogWriteRecPtr(); current_recptr = GetXLogWriteRecPtr();
snprintf(location, sizeof(location), "%X/%X", PG_RETURN_LSN(current_recptr);
(uint32) (current_recptr >> 32), (uint32) current_recptr);
PG_RETURN_TEXT_P(cstring_to_text(location));
} }
/* /*
...@@ -209,7 +193,6 @@ Datum ...@@ -209,7 +193,6 @@ Datum
pg_current_xlog_insert_location(PG_FUNCTION_ARGS) pg_current_xlog_insert_location(PG_FUNCTION_ARGS)
{ {
XLogRecPtr current_recptr; XLogRecPtr current_recptr;
char location[MAXFNAMELEN];
if (RecoveryInProgress()) if (RecoveryInProgress())
ereport(ERROR, ereport(ERROR,
...@@ -219,9 +202,7 @@ pg_current_xlog_insert_location(PG_FUNCTION_ARGS) ...@@ -219,9 +202,7 @@ pg_current_xlog_insert_location(PG_FUNCTION_ARGS)
current_recptr = GetXLogInsertRecPtr(); current_recptr = GetXLogInsertRecPtr();
snprintf(location, sizeof(location), "%X/%X", PG_RETURN_LSN(current_recptr);
(uint32) (current_recptr >> 32), (uint32) current_recptr);
PG_RETURN_TEXT_P(cstring_to_text(location));
} }
/* /*
...@@ -234,16 +215,13 @@ Datum ...@@ -234,16 +215,13 @@ Datum
pg_last_xlog_receive_location(PG_FUNCTION_ARGS) pg_last_xlog_receive_location(PG_FUNCTION_ARGS)
{ {
XLogRecPtr recptr; XLogRecPtr recptr;
char location[MAXFNAMELEN];
recptr = GetWalRcvWriteRecPtr(NULL, NULL); recptr = GetWalRcvWriteRecPtr(NULL, NULL);
if (recptr == 0) if (recptr == 0)
PG_RETURN_NULL(); PG_RETURN_NULL();
snprintf(location, sizeof(location), "%X/%X", PG_RETURN_LSN(recptr);
(uint32) (recptr >> 32), (uint32) recptr);
PG_RETURN_TEXT_P(cstring_to_text(location));
} }
/* /*
...@@ -256,16 +234,13 @@ Datum ...@@ -256,16 +234,13 @@ Datum
pg_last_xlog_replay_location(PG_FUNCTION_ARGS) pg_last_xlog_replay_location(PG_FUNCTION_ARGS)
{ {
XLogRecPtr recptr; XLogRecPtr recptr;
char location[MAXFNAMELEN];
recptr = GetXLogReplayRecPtr(NULL); recptr = GetXLogReplayRecPtr(NULL);
if (recptr == 0) if (recptr == 0)
PG_RETURN_NULL(); PG_RETURN_NULL();
snprintf(location, sizeof(location), "%X/%X", PG_RETURN_LSN(recptr);
(uint32) (recptr >> 32), (uint32) recptr);
PG_RETURN_TEXT_P(cstring_to_text(location));
} }
/* /*
...@@ -279,13 +254,9 @@ pg_last_xlog_replay_location(PG_FUNCTION_ARGS) ...@@ -279,13 +254,9 @@ pg_last_xlog_replay_location(PG_FUNCTION_ARGS)
Datum Datum
pg_xlogfile_name_offset(PG_FUNCTION_ARGS) pg_xlogfile_name_offset(PG_FUNCTION_ARGS)
{ {
text *location = PG_GETARG_TEXT_P(0);
char *locationstr;
uint32 hi,
lo;
XLogSegNo xlogsegno; XLogSegNo xlogsegno;
uint32 xrecoff; uint32 xrecoff;
XLogRecPtr locationpoint; XLogRecPtr locationpoint = PG_GETARG_LSN(0);
char xlogfilename[MAXFNAMELEN]; char xlogfilename[MAXFNAMELEN];
Datum values[2]; Datum values[2];
bool isnull[2]; bool isnull[2];
...@@ -299,20 +270,6 @@ pg_xlogfile_name_offset(PG_FUNCTION_ARGS) ...@@ -299,20 +270,6 @@ pg_xlogfile_name_offset(PG_FUNCTION_ARGS)
errmsg("recovery is in progress"), errmsg("recovery is in progress"),
errhint("pg_xlogfile_name_offset() cannot be executed during recovery."))); errhint("pg_xlogfile_name_offset() cannot be executed during recovery.")));
/*
* Read input and parse
*/
locationstr = text_to_cstring(location);
validate_xlog_location(locationstr);
if (sscanf(locationstr, "%X/%X", &hi, &lo) != 2)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("could not parse transaction log location \"%s\"",
locationstr)));
locationpoint = ((uint64) hi) << 32 | lo;
/* /*
* Construct a tuple descriptor for the result row. This must match this * Construct a tuple descriptor for the result row. This must match this
* function's pg_proc entry! * function's pg_proc entry!
...@@ -359,12 +316,8 @@ pg_xlogfile_name_offset(PG_FUNCTION_ARGS) ...@@ -359,12 +316,8 @@ pg_xlogfile_name_offset(PG_FUNCTION_ARGS)
Datum Datum
pg_xlogfile_name(PG_FUNCTION_ARGS) pg_xlogfile_name(PG_FUNCTION_ARGS)
{ {
text *location = PG_GETARG_TEXT_P(0);
char *locationstr;
uint32 hi,
lo;
XLogSegNo xlogsegno; XLogSegNo xlogsegno;
XLogRecPtr locationpoint; XLogRecPtr locationpoint = PG_GETARG_LSN(0);
char xlogfilename[MAXFNAMELEN]; char xlogfilename[MAXFNAMELEN];
if (RecoveryInProgress()) if (RecoveryInProgress())
...@@ -373,17 +326,6 @@ pg_xlogfile_name(PG_FUNCTION_ARGS) ...@@ -373,17 +326,6 @@ pg_xlogfile_name(PG_FUNCTION_ARGS)
errmsg("recovery is in progress"), errmsg("recovery is in progress"),
errhint("pg_xlogfile_name() cannot be executed during recovery."))); errhint("pg_xlogfile_name() cannot be executed during recovery.")));
locationstr = text_to_cstring(location);
validate_xlog_location(locationstr);
if (sscanf(locationstr, "%X/%X", &hi, &lo) != 2)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("could not parse transaction log location \"%s\"",
locationstr)));
locationpoint = ((uint64) hi) << 32 | lo;
XLByteToPrevSeg(locationpoint, xlogsegno); XLByteToPrevSeg(locationpoint, xlogsegno);
XLogFileName(xlogfilename, ThisTimeLineID, xlogsegno); XLogFileName(xlogfilename, ThisTimeLineID, xlogsegno);
...@@ -481,82 +423,17 @@ pg_is_in_recovery(PG_FUNCTION_ARGS) ...@@ -481,82 +423,17 @@ pg_is_in_recovery(PG_FUNCTION_ARGS)
PG_RETURN_BOOL(RecoveryInProgress()); PG_RETURN_BOOL(RecoveryInProgress());
} }
/*
* Validate the text form of a transaction log location.
* (Just using sscanf() input allows incorrect values such as
* negatives, so we have to be a bit more careful about that).
*/
static void
validate_xlog_location(char *str)
{
#define MAXLSNCOMPONENT 8
int len1,
len2;
len1 = strspn(str, "0123456789abcdefABCDEF");
if (len1 < 1 || len1 > MAXLSNCOMPONENT || str[len1] != '/')
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for transaction log location: \"%s\"", str)));
len2 = strspn(str + len1 + 1, "0123456789abcdefABCDEF");
if (len2 < 1 || len2 > MAXLSNCOMPONENT || str[len1 + 1 + len2] != '\0')
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("invalid input syntax for transaction log location: \"%s\"", str)));
}
/* /*
* Compute the difference in bytes between two WAL locations. * Compute the difference in bytes between two WAL locations.
*/ */
Datum Datum
pg_xlog_location_diff(PG_FUNCTION_ARGS) pg_xlog_location_diff(PG_FUNCTION_ARGS)
{ {
text *location1 = PG_GETARG_TEXT_P(0); Datum result;
text *location2 = PG_GETARG_TEXT_P(1);
char *str1,
*str2;
XLogRecPtr loc1,
loc2;
Numeric result;
uint64 bytes1,
bytes2;
uint32 hi,
lo;
/*
* Read and parse input
*/
str1 = text_to_cstring(location1);
str2 = text_to_cstring(location2);
validate_xlog_location(str1);
validate_xlog_location(str2);
if (sscanf(str1, "%X/%X", &hi, &lo) != 2)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("could not parse transaction log location \"%s\"", str1)));
loc1 = ((uint64) hi) << 32 | lo;
if (sscanf(str2, "%X/%X", &hi, &lo) != 2)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("could not parse transaction log location \"%s\"", str2)));
loc2 = ((uint64) hi) << 32 | lo;
bytes1 = (uint64) loc1;
bytes2 = (uint64) loc2;
/* result = DirectFunctionCall2(pg_lsn_mi,
* result = bytes1 - bytes2. PG_GETARG_DATUM(0),
* PG_GETARG_DATUM(1));
* XXX: this won't handle values higher than 2^63 correctly.
*/
result = DatumGetNumeric(DirectFunctionCall2(numeric_sub,
DirectFunctionCall1(int8_numeric, Int64GetDatum((int64) bytes1)),
DirectFunctionCall1(int8_numeric, Int64GetDatum((int64) bytes2))));
PG_RETURN_NUMERIC(result); PG_RETURN_NUMERIC(result);
} }
......
...@@ -810,7 +810,7 @@ COMMENT ON FUNCTION ts_debug(text) IS ...@@ -810,7 +810,7 @@ COMMENT ON FUNCTION ts_debug(text) IS
CREATE OR REPLACE FUNCTION CREATE OR REPLACE FUNCTION
pg_start_backup(label text, fast boolean DEFAULT false) pg_start_backup(label text, fast boolean DEFAULT false)
RETURNS text STRICT VOLATILE LANGUAGE internal AS 'pg_start_backup'; RETURNS pg_lsn STRICT VOLATILE LANGUAGE internal AS 'pg_start_backup';
CREATE OR REPLACE FUNCTION CREATE OR REPLACE FUNCTION
json_populate_record(base anyelement, from_json json, use_json_as_text boolean DEFAULT false) json_populate_record(base anyelement, from_json json, use_json_as_text boolean DEFAULT false)
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "miscadmin.h" #include "miscadmin.h"
#include "access/htup_details.h" #include "access/htup_details.h"
#include "utils/builtins.h" #include "utils/builtins.h"
#include "utils/pg_lsn.h"
#include "replication/slot.h" #include "replication/slot.h"
Datum pg_create_physical_replication_slot(PG_FUNCTION_ARGS); Datum pg_create_physical_replication_slot(PG_FUNCTION_ARGS);
...@@ -141,8 +142,6 @@ pg_get_replication_slots(PG_FUNCTION_ARGS) ...@@ -141,8 +142,6 @@ pg_get_replication_slots(PG_FUNCTION_ARGS)
bool active; bool active;
Oid database; Oid database;
const char *slot_name; const char *slot_name;
char restart_lsn_s[MAXFNAMELEN];
int i; int i;
SpinLockAcquire(&slot->mutex); SpinLockAcquire(&slot->mutex);
...@@ -164,9 +163,6 @@ pg_get_replication_slots(PG_FUNCTION_ARGS) ...@@ -164,9 +163,6 @@ pg_get_replication_slots(PG_FUNCTION_ARGS)
memset(nulls, 0, sizeof(nulls)); memset(nulls, 0, sizeof(nulls));
snprintf(restart_lsn_s, sizeof(restart_lsn_s), "%X/%X",
(uint32) (restart_lsn >> 32), (uint32) restart_lsn);
i = 0; i = 0;
values[i++] = CStringGetTextDatum(slot_name); values[i++] = CStringGetTextDatum(slot_name);
if (database == InvalidOid) if (database == InvalidOid)
...@@ -180,7 +176,7 @@ pg_get_replication_slots(PG_FUNCTION_ARGS) ...@@ -180,7 +176,7 @@ pg_get_replication_slots(PG_FUNCTION_ARGS)
else else
nulls[i++] = true; nulls[i++] = true;
if (restart_lsn != InvalidTransactionId) if (restart_lsn != InvalidTransactionId)
values[i++] = CStringGetTextDatum(restart_lsn_s); values[i++] = LSNGetDatum(restart_lsn);
else else
nulls[i++] = true; nulls[i++] = true;
......
...@@ -53,6 +53,6 @@ ...@@ -53,6 +53,6 @@
*/ */
/* yyyymmddN */ /* yyyymmddN */
#define CATALOG_VERSION_NO 201402191 #define CATALOG_VERSION_NO 201402192
#endif #endif
...@@ -2971,28 +2971,28 @@ DATA(insert OID = 2171 ( pg_cancel_backend PGNSP PGUID 12 1 0 0 0 f f f f t f v ...@@ -2971,28 +2971,28 @@ DATA(insert OID = 2171 ( pg_cancel_backend PGNSP PGUID 12 1 0 0 0 f f f f t f v
DESCR("cancel a server process' current query"); DESCR("cancel a server process' current query");
DATA(insert OID = 2096 ( pg_terminate_backend PGNSP PGUID 12 1 0 0 0 f f f f t f v 1 0 16 "23" _null_ _null_ _null_ _null_ pg_terminate_backend _null_ _null_ _null_ )); DATA(insert OID = 2096 ( pg_terminate_backend PGNSP PGUID 12 1 0 0 0 f f f f t f v 1 0 16 "23" _null_ _null_ _null_ _null_ pg_terminate_backend _null_ _null_ _null_ ));
DESCR("terminate a server process"); DESCR("terminate a server process");
DATA(insert OID = 2172 ( pg_start_backup PGNSP PGUID 12 1 0 0 0 f f f f t f v 2 0 25 "25 16" _null_ _null_ _null_ _null_ pg_start_backup _null_ _null_ _null_ )); DATA(insert OID = 2172 ( pg_start_backup PGNSP PGUID 12 1 0 0 0 f f f f t f v 2 0 3220 "25 16" _null_ _null_ _null_ _null_ pg_start_backup _null_ _null_ _null_ ));
DESCR("prepare for taking an online backup"); 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_ )); DATA(insert OID = 2173 ( pg_stop_backup PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 3220 "" _null_ _null_ _null_ _null_ pg_stop_backup _null_ _null_ _null_ ));
DESCR("finish taking an online backup"); DESCR("finish taking an online backup");
DATA(insert OID = 3813 ( 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_ )); DATA(insert OID = 3813 ( 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"); DESCR("true if server is in online backup");
DATA(insert OID = 3814 ( pg_backup_start_time PGNSP PGUID 12 1 0 0 0 f f f f t f s 0 0 1184 "" _null_ _null_ _null_ _null_ pg_backup_start_time _null_ _null_ _null_ )); DATA(insert OID = 3814 ( pg_backup_start_time PGNSP PGUID 12 1 0 0 0 f f f f t f s 0 0 1184 "" _null_ _null_ _null_ _null_ pg_backup_start_time _null_ _null_ _null_ ));
DESCR("start time of an online backup"); DESCR("start time of an 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_ )); DATA(insert OID = 2848 ( pg_switch_xlog PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 3220 "" _null_ _null_ _null_ _null_ pg_switch_xlog _null_ _null_ _null_ ));
DESCR("switch to new xlog file"); 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_ )); DATA(insert OID = 3098 ( pg_create_restore_point PGNSP PGUID 12 1 0 0 0 f f f f t f v 1 0 3220 "25" _null_ _null_ _null_ _null_ pg_create_restore_point _null_ _null_ _null_ ));
DESCR("create a named restore point"); DESCR("create a named restore point");
DATA(insert OID = 2849 ( pg_current_xlog_location PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 25 "" _null_ _null_ _null_ _null_ pg_current_xlog_location _null_ _null_ _null_ )); DATA(insert OID = 2849 ( pg_current_xlog_location PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 3220 "" _null_ _null_ _null_ _null_ pg_current_xlog_location _null_ _null_ _null_ ));
DESCR("current xlog write location"); DESCR("current xlog write location");
DATA(insert OID = 2852 ( pg_current_xlog_insert_location PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 25 "" _null_ _null_ _null_ _null_ pg_current_xlog_insert_location _null_ _null_ _null_ )); DATA(insert OID = 2852 ( pg_current_xlog_insert_location PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 3220 "" _null_ _null_ _null_ _null_ pg_current_xlog_insert_location _null_ _null_ _null_ ));
DESCR("current xlog insert location"); DESCR("current xlog insert location");
DATA(insert OID = 2850 ( pg_xlogfile_name_offset PGNSP PGUID 12 1 0 0 0 f f f f t f i 1 0 2249 "25" "{25,25,23}" "{i,o,o}" "{wal_location,file_name,file_offset}" _null_ pg_xlogfile_name_offset _null_ _null_ _null_ )); DATA(insert OID = 2850 ( pg_xlogfile_name_offset PGNSP PGUID 12 1 0 0 0 f f f f t f i 1 0 2249 "3220" "{3220,25,23}" "{i,o,o}" "{wal_location,file_name,file_offset}" _null_ pg_xlogfile_name_offset _null_ _null_ _null_ ));
DESCR("xlog filename and byte offset, given an xlog location"); DESCR("xlog filename and byte offset, given an xlog location");
DATA(insert OID = 2851 ( pg_xlogfile_name PGNSP PGUID 12 1 0 0 0 f f f f t f i 1 0 25 "25" _null_ _null_ _null_ _null_ pg_xlogfile_name _null_ _null_ _null_ )); DATA(insert OID = 2851 ( pg_xlogfile_name PGNSP PGUID 12 1 0 0 0 f f f f t f i 1 0 25 "3220" _null_ _null_ _null_ _null_ pg_xlogfile_name _null_ _null_ _null_ ));
DESCR("xlog filename, given an xlog location"); DESCR("xlog filename, given an xlog location");
DATA(insert OID = 3165 ( pg_xlog_location_diff PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 1700 "25 25" _null_ _null_ _null_ _null_ pg_xlog_location_diff _null_ _null_ _null_ )); DATA(insert OID = 3165 ( pg_xlog_location_diff PGNSP PGUID 12 1 0 0 0 f f f f t f i 2 0 1700 "3220 3220" _null_ _null_ _null_ _null_ pg_xlog_location_diff _null_ _null_ _null_ ));
DESCR("difference in bytes, given two xlog locations"); DESCR("difference in bytes, given two xlog locations");
DATA(insert OID = 3809 ( pg_export_snapshot PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 25 "" _null_ _null_ _null_ _null_ pg_export_snapshot _null_ _null_ _null_ )); DATA(insert OID = 3809 ( pg_export_snapshot PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 25 "" _null_ _null_ _null_ _null_ pg_export_snapshot _null_ _null_ _null_ ));
...@@ -3001,9 +3001,9 @@ DESCR("export a snapshot"); ...@@ -3001,9 +3001,9 @@ DESCR("export a snapshot");
DATA(insert OID = 3810 ( pg_is_in_recovery PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 16 "" _null_ _null_ _null_ _null_ pg_is_in_recovery _null_ _null_ _null_ )); DATA(insert OID = 3810 ( pg_is_in_recovery PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 16 "" _null_ _null_ _null_ _null_ pg_is_in_recovery _null_ _null_ _null_ ));
DESCR("true if server is in recovery"); DESCR("true if server is in recovery");
DATA(insert OID = 3820 ( pg_last_xlog_receive_location PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 25 "" _null_ _null_ _null_ _null_ pg_last_xlog_receive_location _null_ _null_ _null_ )); DATA(insert OID = 3820 ( pg_last_xlog_receive_location PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 3220 "" _null_ _null_ _null_ _null_ pg_last_xlog_receive_location _null_ _null_ _null_ ));
DESCR("current xlog flush location"); DESCR("current xlog flush location");
DATA(insert OID = 3821 ( pg_last_xlog_replay_location PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 25 "" _null_ _null_ _null_ _null_ pg_last_xlog_replay_location _null_ _null_ _null_ )); DATA(insert OID = 3821 ( pg_last_xlog_replay_location PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 3220 "" _null_ _null_ _null_ _null_ pg_last_xlog_replay_location _null_ _null_ _null_ ));
DESCR("last xlog replay location"); DESCR("last xlog replay location");
DATA(insert OID = 3830 ( pg_last_xact_replay_timestamp PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 1184 "" _null_ _null_ _null_ _null_ pg_last_xact_replay_timestamp _null_ _null_ _null_ )); DATA(insert OID = 3830 ( pg_last_xact_replay_timestamp PGNSP PGUID 12 1 0 0 0 f f f f t f v 0 0 1184 "" _null_ _null_ _null_ _null_ pg_last_xact_replay_timestamp _null_ _null_ _null_ ));
DESCR("timestamp of last replay xact"); DESCR("timestamp of last replay xact");
...@@ -4800,11 +4800,11 @@ DATA(insert OID = 3473 ( spg_range_quad_leaf_consistent PGNSP PGUID 12 1 0 0 0 ...@@ -4800,11 +4800,11 @@ DATA(insert OID = 3473 ( spg_range_quad_leaf_consistent PGNSP PGUID 12 1 0 0 0
DESCR("SP-GiST support for quad tree over range"); DESCR("SP-GiST support for quad tree over range");
/* replication slots */ /* replication slots */
DATA(insert OID = 3779 ( pg_create_physical_replication_slot PGNSP PGUID 12 1 0 0 0 f f f f f f v 1 0 2249 "19" "{19,25,25}" "{i,o,o}" "{slotname,slotname,xlog_position}" _null_ pg_create_physical_replication_slot _null_ _null_ _null_ )); DATA(insert OID = 3779 ( pg_create_physical_replication_slot PGNSP PGUID 12 1 0 0 0 f f f f f f v 1 0 2249 "19" "{19,25,3220}" "{i,o,o}" "{slotname,slotname,xlog_position}" _null_ pg_create_physical_replication_slot _null_ _null_ _null_ ));
DESCR("create a physical replication slot"); DESCR("create a physical replication slot");
DATA(insert OID = 3780 ( pg_drop_replication_slot PGNSP PGUID 12 1 0 0 0 f f f f f f v 1 0 2278 "19" _null_ _null_ _null_ _null_ pg_drop_replication_slot _null_ _null_ _null_ )); DATA(insert OID = 3780 ( pg_drop_replication_slot PGNSP PGUID 12 1 0 0 0 f f f f f f v 1 0 2278 "19" _null_ _null_ _null_ _null_ pg_drop_replication_slot _null_ _null_ _null_ ));
DESCR("drop a replication slot"); DESCR("drop a replication slot");
DATA(insert OID = 3781 ( pg_get_replication_slots PGNSP PGUID 12 1 10 0 0 f f f f f t s 0 0 2249 "" "{25,25,26,16,28,25}" "{o,o,o,o,o,o}" "{slot_name,slot_type,datoid,active,xmin,restart_lsn}" _null_ pg_get_replication_slots _null_ _null_ _null_ )); DATA(insert OID = 3781 ( pg_get_replication_slots PGNSP PGUID 12 1 10 0 0 f f f f f t s 0 0 2249 "" "{25,25,26,16,28,3220}" "{o,o,o,o,o,o}" "{slot_name,slot_type,datoid,active,xmin,restart_lsn}" _null_ pg_get_replication_slots _null_ _null_ _null_ ));
DESCR("information about replication slots currently in use"); DESCR("information about replication slots currently in use");
/* event triggers */ /* event triggers */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment