Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dc7d70e

Browse filesBrowse files
committed
Expose control file data via SQL accessible functions.
Add four new SQL accessible functions: pg_control_system(), pg_control_checkpoint(), pg_control_recovery(), and pg_control_init() which expose a subset of the control file data. Along the way move the code to read and validate the control file to src/common, where it can be shared by the new backend functions and the original pg_controldata frontend program. Patch by me, significant input, testing, and review by Michael Paquier.
1 parent d34794f commit dc7d70e
Copy full SHA for dc7d70e

File tree

11 files changed

+900
-105
lines changed
Filter options

11 files changed

+900
-105
lines changed

‎doc/src/sgml/func.sgml

Copy file name to clipboardExpand all lines: doc/src/sgml/func.sgml
+356Lines changed: 356 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16703,6 +16703,362 @@ SELECT collation for ('foo' COLLATE "de_DE");
1670316703
</tgroup>
1670416704
</table>
1670516705

16706+
<para>
16707+
The functions shown in <xref linkend="functions-controldata">
16708+
print information initialized during <command>initdb</>, such
16709+
as the catalog version. They also show information about write-ahead
16710+
logging and checkpoint processing. This information is cluster-wide,
16711+
and not specific to any one database. They provide most of the same
16712+
information, from the same source, as
16713+
<xref linkend="APP-PGCONTROLDATA">, although in a form better suited
16714+
to <acronym>SQL</acronym> functions.
16715+
</para>
16716+
16717+
<table id="functions-controldata">
16718+
<title>Control Data Functions</title>
16719+
<tgroup cols="3">
16720+
<thead>
16721+
<row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry></row>
16722+
</thead>
16723+
16724+
<tbody>
16725+
<row>
16726+
<entry>
16727+
<indexterm><primary>pg_control_checkpoint</primary></indexterm>
16728+
<literal><function>pg_control_checkpoint()</function></literal>
16729+
</entry>
16730+
<entry><type>record</type></entry>
16731+
<entry>
16732+
Returns information about current checkpoint state.
16733+
</entry>
16734+
</row>
16735+
16736+
<row>
16737+
<entry>
16738+
<indexterm><primary>pg_control_system</primary></indexterm>
16739+
<literal><function>pg_control_system()</function></literal>
16740+
</entry>
16741+
<entry><type>record</type></entry>
16742+
<entry>
16743+
Returns information about current controldata file state.
16744+
</entry>
16745+
</row>
16746+
16747+
<row>
16748+
<entry>
16749+
<indexterm><primary>pg_control_init</primary></indexterm>
16750+
<literal><function>pg_control_init()</function></literal>
16751+
</entry>
16752+
<entry><type>record</type></entry>
16753+
<entry>
16754+
Returns information about cluster initialization state.
16755+
</entry>
16756+
</row>
16757+
16758+
<row>
16759+
<entry>
16760+
<indexterm><primary>pg_control_recovery</primary></indexterm>
16761+
<literal><function>pg_control_recovery()</function></literal>
16762+
</entry>
16763+
<entry><type>record</type></entry>
16764+
<entry>
16765+
Returns information about recovery state.
16766+
</entry>
16767+
</row>
16768+
16769+
</tbody>
16770+
</tgroup>
16771+
</table>
16772+
16773+
<para>
16774+
<function>pg_control_checkpoint</> returns a record, shown in
16775+
<xref linkend="functions-pg-control-checkpoint">
16776+
</para>
16777+
16778+
<table id="functions-pg-control-checkpoint">
16779+
<title><function>pg_control_checkpoint</> Columns</title>
16780+
<tgroup cols="2">
16781+
<thead>
16782+
<row>
16783+
<entry>Column Name</entry>
16784+
<entry>Data Type</entry>
16785+
</row>
16786+
</thead>
16787+
16788+
<tbody>
16789+
16790+
<row>
16791+
<entry>checkpoint_location</entry>
16792+
<entry><type>pg_lsn</type></entry>
16793+
</row>
16794+
16795+
<row>
16796+
<entry>prior_location</entry>
16797+
<entry><type>pg_lsn</type></entry>
16798+
</row>
16799+
16800+
<row>
16801+
<entry>redo_location</entry>
16802+
<entry><type>pg_lsn</type></entry>
16803+
</row>
16804+
16805+
<row>
16806+
<entry>redo_wal_file</entry>
16807+
<entry><type>text</type></entry>
16808+
</row>
16809+
16810+
<row>
16811+
<entry>timeline_id</entry>
16812+
<entry><type>integer</type></entry>
16813+
</row>
16814+
16815+
<row>
16816+
<entry>prev_timeline_id</entry>
16817+
<entry><type>integer</type></entry>
16818+
</row>
16819+
16820+
<row>
16821+
<entry>full_page_writes</entry>
16822+
<entry><type>boolean</type></entry>
16823+
</row>
16824+
16825+
<row>
16826+
<entry>next_xid</entry>
16827+
<entry><type>text</type></entry>
16828+
</row>
16829+
16830+
<row>
16831+
<entry>next_oid</entry>
16832+
<entry><type>oid</type></entry>
16833+
</row>
16834+
16835+
<row>
16836+
<entry>next_multixact_id</entry>
16837+
<entry><type>xid</type></entry>
16838+
</row>
16839+
16840+
<row>
16841+
<entry>next_multi_offset</entry>
16842+
<entry><type>xid</type></entry>
16843+
</row>
16844+
16845+
<row>
16846+
<entry>oldest_xid</entry>
16847+
<entry><type>xid</type></entry>
16848+
</row>
16849+
16850+
<row>
16851+
<entry>oldest_xid_dbid</entry>
16852+
<entry><type>oid</type></entry>
16853+
</row>
16854+
16855+
<row>
16856+
<entry>oldest_active_xid</entry>
16857+
<entry><type>xid</type></entry>
16858+
</row>
16859+
16860+
<row>
16861+
<entry>oldest_multi_xid</entry>
16862+
<entry><type>xid</type></entry>
16863+
</row>
16864+
16865+
<row>
16866+
<entry>oldest_multi_dbid</entry>
16867+
<entry><type>oid</type></entry>
16868+
</row>
16869+
16870+
<row>
16871+
<entry>oldest_commit_ts_xid</entry>
16872+
<entry><type>xid</type></entry>
16873+
</row>
16874+
16875+
<row>
16876+
<entry>newest_commit_ts_xid</entry>
16877+
<entry><type>xid</type></entry>
16878+
</row>
16879+
16880+
<row>
16881+
<entry>checkpoint_time</entry>
16882+
<entry><type>timestamp with time zone</type></entry>
16883+
</row>
16884+
16885+
</tbody>
16886+
</tgroup>
16887+
</table>
16888+
16889+
<para>
16890+
<function>pg_control_system</> returns a record, shown in
16891+
<xref linkend="functions-pg-control-system">
16892+
</para>
16893+
16894+
<table id="functions-pg-control-system">
16895+
<title><function>pg_control_system</> Columns</title>
16896+
<tgroup cols="2">
16897+
<thead>
16898+
<row>
16899+
<entry>Column Name</entry>
16900+
<entry>Data Type</entry>
16901+
</row>
16902+
</thead>
16903+
16904+
<tbody>
16905+
16906+
<row>
16907+
<entry>pg_control_version</entry>
16908+
<entry><type>integer</type></entry>
16909+
</row>
16910+
16911+
<row>
16912+
<entry>catalog_version_no</entry>
16913+
<entry><type>integer</type></entry>
16914+
</row>
16915+
16916+
<row>
16917+
<entry>system_identifier</entry>
16918+
<entry><type>bigint</type></entry>
16919+
</row>
16920+
16921+
<row>
16922+
<entry>pg_control_last_modified</entry>
16923+
<entry><type>timestamp with time zone</type></entry>
16924+
</row>
16925+
16926+
</tbody>
16927+
</tgroup>
16928+
</table>
16929+
16930+
<para>
16931+
<function>pg_control_init</> returns a record, shown in
16932+
<xref linkend="functions-pg-control-init">
16933+
</para>
16934+
16935+
<table id="functions-pg-control-init">
16936+
<title><function>pg_control_init</> Columns</title>
16937+
<tgroup cols="2">
16938+
<thead>
16939+
<row>
16940+
<entry>Column Name</entry>
16941+
<entry>Data Type</entry>
16942+
</row>
16943+
</thead>
16944+
16945+
<tbody>
16946+
16947+
<row>
16948+
<entry>max_data_alignment</entry>
16949+
<entry><type>integer</type></entry>
16950+
</row>
16951+
16952+
<row>
16953+
<entry>database_block_size</entry>
16954+
<entry><type>integer</type></entry>
16955+
</row>
16956+
16957+
<row>
16958+
<entry>blocks_per_segment</entry>
16959+
<entry><type>integer</type></entry>
16960+
</row>
16961+
16962+
<row>
16963+
<entry>wal_block_size</entry>
16964+
<entry><type>integer</type></entry>
16965+
</row>
16966+
16967+
<row>
16968+
<entry>bytes_per_wal_segment</entry>
16969+
<entry><type>integer</type></entry>
16970+
</row>
16971+
16972+
<row>
16973+
<entry>max_identifier_length</entry>
16974+
<entry><type>integer</type></entry>
16975+
</row>
16976+
16977+
<row>
16978+
<entry>max_index_columns</entry>
16979+
<entry><type>integer</type></entry>
16980+
</row>
16981+
16982+
<row>
16983+
<entry>max_toast_chunk_size</entry>
16984+
<entry><type>integer</type></entry>
16985+
</row>
16986+
16987+
<row>
16988+
<entry>large_object_chunk_size</entry>
16989+
<entry><type>integer</type></entry>
16990+
</row>
16991+
16992+
<row>
16993+
<entry>bigint_timestamps</entry>
16994+
<entry><type>boolean</type></entry>
16995+
</row>
16996+
16997+
<row>
16998+
<entry>float4_pass_by_value</entry>
16999+
<entry><type>boolean</type></entry>
17000+
</row>
17001+
17002+
<row>
17003+
<entry>float8_pass_by_value</entry>
17004+
<entry><type>boolean</type></entry>
17005+
</row>
17006+
17007+
<row>
17008+
<entry>data_page_checksum_version</entry>
17009+
<entry><type>integer</type></entry>
17010+
</row>
17011+
17012+
</tbody>
17013+
</tgroup>
17014+
</table>
17015+
17016+
<para>
17017+
<function>pg_control_recovery</> returns a record, shown in
17018+
<xref linkend="functions-pg-control-recovery">
17019+
</para>
17020+
17021+
<table id="functions-pg-control-recovery">
17022+
<title><function>pg_control_recovery</> Columns</title>
17023+
<tgroup cols="2">
17024+
<thead>
17025+
<row>
17026+
<entry>Column Name</entry>
17027+
<entry>Data Type</entry>
17028+
</row>
17029+
</thead>
17030+
17031+
<tbody>
17032+
17033+
<row>
17034+
<entry>min_recovery_end_location</entry>
17035+
<entry><type>pg_lsn</type></entry>
17036+
</row>
17037+
17038+
<row>
17039+
<entry>min_recovery_end_timeline</entry>
17040+
<entry><type>integer</type></entry>
17041+
</row>
17042+
17043+
<row>
17044+
<entry>backup_start_location</entry>
17045+
<entry><type>pg_lsn</type></entry>
17046+
</row>
17047+
17048+
<row>
17049+
<entry>backup_end_location</entry>
17050+
<entry><type>pg_lsn</type></entry>
17051+
</row>
17052+
17053+
<row>
17054+
<entry>end_of_backup_record_required</entry>
17055+
<entry><type>boolean</type></entry>
17056+
</row>
17057+
17058+
</tbody>
17059+
</tgroup>
17060+
</table>
17061+
1670617062
</sect1>
1670717063

1670817064
<sect1 id="functions-admin">

‎src/backend/utils/misc/Makefile

Copy file name to clipboardExpand all lines: src/backend/utils/misc/Makefile
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ include $(top_builddir)/src/Makefile.global
1414

1515
override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS)
1616

17-
OBJS = guc.o help_config.o pg_config.o pg_rusage.o \
17+
OBJS = guc.o help_config.o pg_config.o pg_controldata.o pg_rusage.o \
1818
ps_status.o rls.o sampling.o superuser.o timeout.o tzparser.o
1919

2020
# This location might depend on the installation directories. Therefore

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.