1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>9.26. System Information Functions and Operators</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="functions-srf.html" title="9.25. Set Returning Functions" /><link rel="next" href="functions-admin.html" title="9.27. System Administration Functions" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">9.26. System Information Functions and Operators</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="functions-srf.html" title="9.25. Set Returning Functions">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="functions.html" title="Chapter 9. Functions and Operators">Up</a></td><th width="60%" align="center">Chapter 9. Functions and Operators</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="functions-admin.html" title="9.27. System Administration Functions">Next</a></td></tr></table><hr /></div><div class="sect1" id="FUNCTIONS-INFO"><div class="titlepage"><div><div><h2 class="title" style="clear: both">9.26. System Information Functions and Operators <a href="#FUNCTIONS-INFO" class="id_link">#</a></h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="functions-info.html#FUNCTIONS-INFO-SESSION">9.26.1. Session Information Functions</a></span></dt><dt><span class="sect2"><a href="functions-info.html#FUNCTIONS-INFO-ACCESS">9.26.2. Access Privilege Inquiry Functions</a></span></dt><dt><span class="sect2"><a href="functions-info.html#FUNCTIONS-INFO-SCHEMA">9.26.3. Schema Visibility Inquiry Functions</a></span></dt><dt><span class="sect2"><a href="functions-info.html#FUNCTIONS-INFO-CATALOG">9.26.4. System Catalog Information Functions</a></span></dt><dt><span class="sect2"><a href="functions-info.html#FUNCTIONS-INFO-OBJECT">9.26.5. Object Information and Addressing Functions</a></span></dt><dt><span class="sect2"><a href="functions-info.html#FUNCTIONS-INFO-COMMENT">9.26.6. Comment Information Functions</a></span></dt><dt><span class="sect2"><a href="functions-info.html#FUNCTIONS-INFO-VALIDITY">9.26.7. Data Validity Checking Functions</a></span></dt><dt><span class="sect2"><a href="functions-info.html#FUNCTIONS-INFO-SNAPSHOT">9.26.8. Transaction ID and Snapshot Information Functions</a></span></dt><dt><span class="sect2"><a href="functions-info.html#FUNCTIONS-INFO-COMMIT-TIMESTAMP">9.26.9. Committed Transaction Information Functions</a></span></dt><dt><span class="sect2"><a href="functions-info.html#FUNCTIONS-INFO-CONTROLDATA">9.26.10. Control Data Functions</a></span></dt></dl></div><p>
The functions described in this section are used to obtain various
information about a <span class="productname">PostgreSQL</span> installation.
</p><div class="sect2" id="FUNCTIONS-INFO-SESSION"><div class="titlepage"><div><div><h3 class="title">9.26.1. Session Information Functions <a href="#FUNCTIONS-INFO-SESSION" class="id_link">#</a></h3></div></div></div><p>
<a class="xref" href="functions-info.html#FUNCTIONS-INFO-SESSION-TABLE" title="Table 9.67. Session Information Functions">Table 9.67</a> shows several
functions that extract session and system information.
</p><p>
In addition to the functions listed in this section, there are a number of
functions related to the statistics system that also provide system
information. See <a class="xref" href="monitoring-stats.html#MONITORING-STATS-FUNCTIONS" title="28.2.25. Statistics Functions">Section 28.2.25</a> for more
information.
</p><div class="table" id="FUNCTIONS-INFO-SESSION-TABLE"><p class="title"><strong>Table 9.67. Session Information Functions</strong></p><div class="table-contents"><table class="table" summary="Session Information Functions" border="1"><colgroup><col /></colgroup><thead><tr><th class="func_table_entry"><p class="func_signature">
Function
</p>
<p>
Description
</p></th></tr></thead><tbody><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.1.1.1.1" class="indexterm"></a>
<code class="function">current_catalog</code>
→ <code class="returnvalue">name</code>
</p>
<p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.1.1.2.1" class="indexterm"></a>
<code class="function">current_database</code> ()
→ <code class="returnvalue">name</code>
</p>
<p>
Returns the name of the current database. (Databases are
called <span class="quote">“<span class="quote">catalogs</span>”</span> in the SQL standard,
so <code class="function">current_catalog</code> is the standard's
spelling.)
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.2.1.1.1" class="indexterm"></a>
<code class="function">current_query</code> ()
→ <code class="returnvalue">text</code>
</p>
<p>
Returns the text of the currently executing query, as submitted
by the client (which might contain more than one statement).
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.3.1.1.1" class="indexterm"></a>
<code class="function">current_role</code>
→ <code class="returnvalue">name</code>
</p>
<p>
This is equivalent to <code class="function">current_user</code>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.4.1.1.1" class="indexterm"></a>
<a id="id-1.5.8.32.3.4.2.2.4.1.1.2" class="indexterm"></a>
<code class="function">current_schema</code>
→ <code class="returnvalue">name</code>
</p>
<p class="func_signature">
<code class="function">current_schema</code> ()
→ <code class="returnvalue">name</code>
</p>
<p>
Returns the name of the schema that is first in the search path (or a
null value if the search path is empty). This is the schema that will
be used for any tables or other named objects that are created without
specifying a target schema.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.5.1.1.1" class="indexterm"></a>
<a id="id-1.5.8.32.3.4.2.2.5.1.1.2" class="indexterm"></a>
<code class="function">current_schemas</code> ( <em class="parameter"><code>include_implicit</code></em> <code class="type">boolean</code> )
→ <code class="returnvalue">name[]</code>
</p>
<p>
Returns an array of the names of all schemas presently in the
effective search path, in their priority order. (Items in the current
<a class="xref" href="runtime-config-client.html#GUC-SEARCH-PATH">search_path</a> setting that do not correspond to
existing, searchable schemas are omitted.) If the Boolean argument
is <code class="literal">true</code>, then implicitly-searched system schemas
such as <code class="literal">pg_catalog</code> are included in the result.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.6.1.1.1" class="indexterm"></a>
<a id="id-1.5.8.32.3.4.2.2.6.1.1.2" class="indexterm"></a>
<code class="function">current_user</code>
→ <code class="returnvalue">name</code>
</p>
<p>
Returns the user name of the current execution context.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.7.1.1.1" class="indexterm"></a>
<code class="function">inet_client_addr</code> ()
→ <code class="returnvalue">inet</code>
</p>
<p>
Returns the IP address of the current client,
or <code class="literal">NULL</code> if the current connection is via a
Unix-domain socket.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.8.1.1.1" class="indexterm"></a>
<code class="function">inet_client_port</code> ()
→ <code class="returnvalue">integer</code>
</p>
<p>
Returns the IP port number of the current client,
or <code class="literal">NULL</code> if the current connection is via a
Unix-domain socket.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.9.1.1.1" class="indexterm"></a>
<code class="function">inet_server_addr</code> ()
→ <code class="returnvalue">inet</code>
</p>
<p>
Returns the IP address on which the server accepted the current
connection,
or <code class="literal">NULL</code> if the current connection is via a
Unix-domain socket.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.10.1.1.1" class="indexterm"></a>
<code class="function">inet_server_port</code> ()
→ <code class="returnvalue">integer</code>
</p>
<p>
Returns the IP port number on which the server accepted the current
connection,
or <code class="literal">NULL</code> if the current connection is via a
Unix-domain socket.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.11.1.1.1" class="indexterm"></a>
<code class="function">pg_backend_pid</code> ()
→ <code class="returnvalue">integer</code>
</p>
<p>
Returns the process ID of the server process attached to the current
session.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.12.1.1.1" class="indexterm"></a>
<code class="function">pg_blocking_pids</code> ( <code class="type">integer</code> )
→ <code class="returnvalue">integer[]</code>
</p>
<p>
Returns an array of the process ID(s) of the sessions that are
blocking the server process with the specified process ID from
acquiring a lock, or an empty array if there is no such server process
or it is not blocked.
</p>
<p>
One server process blocks another if it either holds a lock that
conflicts with the blocked process's lock request (hard block), or is
waiting for a lock that would conflict with the blocked process's lock
request and is ahead of it in the wait queue (soft block). When using
parallel queries the result always lists client-visible process IDs
(that is, <code class="function">pg_backend_pid</code> results) even if the
actual lock is held or awaited by a child worker process. As a result
of that, there may be duplicated PIDs in the result. Also note that
when a prepared transaction holds a conflicting lock, it will be
represented by a zero process ID.
</p>
<p>
Frequent calls to this function could have some impact on database
performance, because it needs exclusive access to the lock manager's
shared state for a short time.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.13.1.1.1" class="indexterm"></a>
<code class="function">pg_conf_load_time</code> ()
→ <code class="returnvalue">timestamp with time zone</code>
</p>
<p>
Returns the time when the server configuration files were last loaded.
If the current session was alive at the time, this will be the time
when the session itself re-read the configuration files (so the
reading will vary a little in different sessions). Otherwise it is
the time when the postmaster process re-read the configuration files.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.14.1.1.1" class="indexterm"></a>
<a id="id-1.5.8.32.3.4.2.2.14.1.1.2" class="indexterm"></a>
<a id="id-1.5.8.32.3.4.2.2.14.1.1.3" class="indexterm"></a>
<a id="id-1.5.8.32.3.4.2.2.14.1.1.4" class="indexterm"></a>
<code class="function">pg_current_logfile</code> ( [<span class="optional"> <code class="type">text</code> </span>] )
→ <code class="returnvalue">text</code>
</p>
<p>
Returns the path name of the log file currently in use by the logging
collector. The path includes the <a class="xref" href="runtime-config-logging.html#GUC-LOG-DIRECTORY">log_directory</a>
directory and the individual log file name. The result
is <code class="literal">NULL</code> if the logging collector is disabled.
When multiple log files exist, each in a different
format, <code class="function">pg_current_logfile</code> without an argument
returns the path of the file having the first format found in the
ordered list: <code class="literal">stderr</code>,
<code class="literal">csvlog</code>, <code class="literal">jsonlog</code>.
<code class="literal">NULL</code> is returned if no log file has any of these
formats.
To request information about a specific log file format, supply
either <code class="literal">csvlog</code>, <code class="literal">jsonlog</code> or
<code class="literal">stderr</code> as the
value of the optional parameter. The result is <code class="literal">NULL</code>
if the log format requested is not configured in
<a class="xref" href="runtime-config-logging.html#GUC-LOG-DESTINATION">log_destination</a>.
The result reflects the contents of
the <code class="filename">current_logfiles</code> file.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.15.1.1.1" class="indexterm"></a>
<code class="function">pg_my_temp_schema</code> ()
→ <code class="returnvalue">oid</code>
</p>
<p>
Returns the OID of the current session's temporary schema, or zero if
it has none (because it has not created any temporary tables).
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.16.1.1.1" class="indexterm"></a>
<code class="function">pg_is_other_temp_schema</code> ( <code class="type">oid</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Returns true if the given OID is the OID of another session's
temporary schema. (This can be useful, for example, to exclude other
sessions' temporary tables from a catalog display.)
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.17.1.1.1" class="indexterm"></a>
<code class="function">pg_jit_available</code> ()
→ <code class="returnvalue">boolean</code>
</p>
<p>
Returns true if a <acronym class="acronym">JIT</acronym> compiler extension is
available (see <a class="xref" href="jit.html" title="Chapter 32. Just-in-Time Compilation (JIT)">Chapter 32</a>) and the
<a class="xref" href="runtime-config-query.html#GUC-JIT">jit</a> configuration parameter is set to
<code class="literal">on</code>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.18.1.1.1" class="indexterm"></a>
<code class="function">pg_listening_channels</code> ()
→ <code class="returnvalue">setof text</code>
</p>
<p>
Returns the set of names of asynchronous notification channels that
the current session is listening to.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.19.1.1.1" class="indexterm"></a>
<code class="function">pg_notification_queue_usage</code> ()
→ <code class="returnvalue">double precision</code>
</p>
<p>
Returns the fraction (0–1) of the asynchronous notification
queue's maximum size that is currently occupied by notifications that
are waiting to be processed.
See <a class="xref" href="sql-listen.html" title="LISTEN"><span class="refentrytitle">LISTEN</span></a> and <a class="xref" href="sql-notify.html" title="NOTIFY"><span class="refentrytitle">NOTIFY</span></a>
for more information.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.20.1.1.1" class="indexterm"></a>
<code class="function">pg_postmaster_start_time</code> ()
→ <code class="returnvalue">timestamp with time zone</code>
</p>
<p>
Returns the time when the server started.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.21.1.1.1" class="indexterm"></a>
<code class="function">pg_safe_snapshot_blocking_pids</code> ( <code class="type">integer</code> )
→ <code class="returnvalue">integer[]</code>
</p>
<p>
Returns an array of the process ID(s) of the sessions that are blocking
the server process with the specified process ID from acquiring a safe
snapshot, or an empty array if there is no such server process or it
is not blocked.
</p>
<p>
A session running a <code class="literal">SERIALIZABLE</code> transaction blocks
a <code class="literal">SERIALIZABLE READ ONLY DEFERRABLE</code> transaction
from acquiring a snapshot until the latter determines that it is safe
to avoid taking any predicate locks. See
<a class="xref" href="transaction-iso.html#XACT-SERIALIZABLE" title="13.2.3. Serializable Isolation Level">Section 13.2.3</a> for more information about
serializable and deferrable transactions.
</p>
<p>
Frequent calls to this function could have some impact on database
performance, because it needs access to the predicate lock manager's
shared state for a short time.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.22.1.1.1" class="indexterm"></a>
<code class="function">pg_trigger_depth</code> ()
→ <code class="returnvalue">integer</code>
</p>
<p>
Returns the current nesting level
of <span class="productname">PostgreSQL</span> triggers (0 if not called,
directly or indirectly, from inside a trigger).
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.23.1.1.1" class="indexterm"></a>
<code class="function">session_user</code>
→ <code class="returnvalue">name</code>
</p>
<p>
Returns the session user's name.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.24.1.1.1" class="indexterm"></a>
<code class="function">system_user</code>
→ <code class="returnvalue">text</code>
</p>
<p>
Returns the authentication method and the identity (if any) that the
user presented during the authentication cycle before they were
assigned a database role. It is represented as
<code class="literal">auth_method:identity</code> or
<code class="literal">NULL</code> if the user has not been authenticated (for
example if <a class="link" href="auth-trust.html" title="21.4. Trust Authentication">Trust authentication</a> has
been used).
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.25.1.1.1" class="indexterm"></a>
<code class="function">user</code>
→ <code class="returnvalue">name</code>
</p>
<p>
This is equivalent to <code class="function">current_user</code>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.3.4.2.2.26.1.1.1" class="indexterm"></a>
<code class="function">version</code> ()
→ <code class="returnvalue">text</code>
</p>
<p>
Returns a string describing the <span class="productname">PostgreSQL</span>
server's version. You can also get this information from
<a class="xref" href="runtime-config-preset.html#GUC-SERVER-VERSION">server_version</a>, or for a machine-readable
version use <a class="xref" href="runtime-config-preset.html#GUC-SERVER-VERSION-NUM">server_version_num</a>. Software
developers should use <code class="varname">server_version_num</code> (available
since 8.2) or <a class="xref" href="libpq-status.html#LIBPQ-PQSERVERVERSION"><code class="function">PQserverVersion</code></a> instead of
parsing the text version.
</p></td></tr></tbody></table></div></div><br class="table-break" /><div class="note"><h3 class="title">Note</h3><p>
<code class="function">current_catalog</code>,
<code class="function">current_role</code>,
<code class="function">current_schema</code>,
<code class="function">current_user</code>,
<code class="function">session_user</code>,
and <code class="function">user</code> have special syntactic status
in <acronym class="acronym">SQL</acronym>: they must be called without trailing
parentheses. In PostgreSQL, parentheses can optionally be used with
<code class="function">current_schema</code>, but not with the others.
</p></div><p>
The <code class="function">session_user</code> is normally the user who initiated
the current database connection; but superusers can change this setting
with <a class="xref" href="sql-set-session-authorization.html" title="SET SESSION AUTHORIZATION"><span class="refentrytitle">SET SESSION AUTHORIZATION</span></a>.
The <code class="function">current_user</code> is the user identifier
that is applicable for permission checking. Normally it is equal
to the session user, but it can be changed with
<a class="xref" href="sql-set-role.html" title="SET ROLE"><span class="refentrytitle">SET ROLE</span></a>.
It also changes during the execution of
functions with the attribute <code class="literal">SECURITY DEFINER</code>.
In Unix parlance, the session user is the <span class="quote">“<span class="quote">real user</span>”</span> and
the current user is the <span class="quote">“<span class="quote">effective user</span>”</span>.
<code class="function">current_role</code> and <code class="function">user</code> are
synonyms for <code class="function">current_user</code>. (The SQL standard draws
a distinction between <code class="function">current_role</code>
and <code class="function">current_user</code>, but <span class="productname">PostgreSQL</span>
does not, since it unifies users and roles into a single kind of entity.)
</p></div><div class="sect2" id="FUNCTIONS-INFO-ACCESS"><div class="titlepage"><div><div><h3 class="title">9.26.2. Access Privilege Inquiry Functions <a href="#FUNCTIONS-INFO-ACCESS" class="id_link">#</a></h3></div></div></div><a id="id-1.5.8.32.4.2" class="indexterm"></a><p>
<a class="xref" href="functions-info.html#FUNCTIONS-INFO-ACCESS-TABLE" title="Table 9.68. Access Privilege Inquiry Functions">Table 9.68</a> lists functions that
allow querying object access privileges programmatically.
(See <a class="xref" href="ddl-priv.html" title="5.7. Privileges">Section 5.7</a> for more information about
privileges.)
In these functions, the user whose privileges are being inquired about
can be specified by name or by OID
(<code class="structname">pg_authid</code>.<code class="structfield">oid</code>), or if
the name is given as <code class="literal">public</code> then the privileges of the
PUBLIC pseudo-role are checked. Also, the <em class="parameter"><code>user</code></em>
argument can be omitted entirely, in which case
the <code class="function">current_user</code> is assumed.
The object that is being inquired about can be specified either by name or
by OID, too. When specifying by name, a schema name can be included if
relevant.
The access privilege of interest is specified by a text string, which must
evaluate to one of the appropriate privilege keywords for the object's type
(e.g., <code class="literal">SELECT</code>). Optionally, <code class="literal">WITH GRANT
OPTION</code> can be added to a privilege type to test whether the
privilege is held with grant option. Also, multiple privilege types can be
listed separated by commas, in which case the result will be true if any of
the listed privileges is held. (Case of the privilege string is not
significant, and extra whitespace is allowed between but not within
privilege names.)
Some examples:
</p><pre class="programlisting">
SELECT has_table_privilege('myschema.mytable', 'select');
SELECT has_table_privilege('joe', 'mytable', 'INSERT, SELECT WITH GRANT OPTION');
</pre><p>
</p><div class="table" id="FUNCTIONS-INFO-ACCESS-TABLE"><p class="title"><strong>Table 9.68. Access Privilege Inquiry Functions</strong></p><div class="table-contents"><table class="table" summary="Access Privilege Inquiry Functions" border="1"><colgroup><col /></colgroup><thead><tr><th class="func_table_entry"><p class="func_signature">
Function
</p>
<p>
Description
</p></th></tr></thead><tbody><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.4.4.2.2.1.1.1.1" class="indexterm"></a>
<code class="function">has_any_column_privilege</code> (
[<span class="optional"> <em class="parameter"><code>user</code></em> <code class="type">name</code> or <code class="type">oid</code>, </span>]
<em class="parameter"><code>table</code></em> <code class="type">text</code> or <code class="type">oid</code>,
<em class="parameter"><code>privilege</code></em> <code class="type">text</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Does user have privilege for any column of table?
This succeeds either if the privilege is held for the whole table, or
if there is a column-level grant of the privilege for at least one
column.
Allowable privilege types are
<code class="literal">SELECT</code>, <code class="literal">INSERT</code>,
<code class="literal">UPDATE</code>, and <code class="literal">REFERENCES</code>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.4.4.2.2.2.1.1.1" class="indexterm"></a>
<code class="function">has_column_privilege</code> (
[<span class="optional"> <em class="parameter"><code>user</code></em> <code class="type">name</code> or <code class="type">oid</code>, </span>]
<em class="parameter"><code>table</code></em> <code class="type">text</code> or <code class="type">oid</code>,
<em class="parameter"><code>column</code></em> <code class="type">text</code> or <code class="type">smallint</code>,
<em class="parameter"><code>privilege</code></em> <code class="type">text</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Does user have privilege for the specified table column?
This succeeds either if the privilege is held for the whole table, or
if there is a column-level grant of the privilege for the column.
The column can be specified by name or by attribute number
(<code class="structname">pg_attribute</code>.<code class="structfield">attnum</code>).
Allowable privilege types are
<code class="literal">SELECT</code>, <code class="literal">INSERT</code>,
<code class="literal">UPDATE</code>, and <code class="literal">REFERENCES</code>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.4.4.2.2.3.1.1.1" class="indexterm"></a>
<code class="function">has_database_privilege</code> (
[<span class="optional"> <em class="parameter"><code>user</code></em> <code class="type">name</code> or <code class="type">oid</code>, </span>]
<em class="parameter"><code>database</code></em> <code class="type">text</code> or <code class="type">oid</code>,
<em class="parameter"><code>privilege</code></em> <code class="type">text</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Does user have privilege for database?
Allowable privilege types are
<code class="literal">CREATE</code>,
<code class="literal">CONNECT</code>,
<code class="literal">TEMPORARY</code>, and
<code class="literal">TEMP</code> (which is equivalent to
<code class="literal">TEMPORARY</code>).
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.4.4.2.2.4.1.1.1" class="indexterm"></a>
<code class="function">has_foreign_data_wrapper_privilege</code> (
[<span class="optional"> <em class="parameter"><code>user</code></em> <code class="type">name</code> or <code class="type">oid</code>, </span>]
<em class="parameter"><code>fdw</code></em> <code class="type">text</code> or <code class="type">oid</code>,
<em class="parameter"><code>privilege</code></em> <code class="type">text</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Does user have privilege for foreign-data wrapper?
The only allowable privilege type is <code class="literal">USAGE</code>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.4.4.2.2.5.1.1.1" class="indexterm"></a>
<code class="function">has_function_privilege</code> (
[<span class="optional"> <em class="parameter"><code>user</code></em> <code class="type">name</code> or <code class="type">oid</code>, </span>]
<em class="parameter"><code>function</code></em> <code class="type">text</code> or <code class="type">oid</code>,
<em class="parameter"><code>privilege</code></em> <code class="type">text</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Does user have privilege for function?
The only allowable privilege type is <code class="literal">EXECUTE</code>.
</p>
<p>
When specifying a function by name rather than by OID, the allowed
input is the same as for the <code class="type">regprocedure</code> data type (see
<a class="xref" href="datatype-oid.html" title="8.19. Object Identifier Types">Section 8.19</a>).
An example is:
</p><pre class="programlisting">
SELECT has_function_privilege('joeuser', 'myfunc(int, text)', 'execute');
</pre><p>
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.4.4.2.2.6.1.1.1" class="indexterm"></a>
<code class="function">has_language_privilege</code> (
[<span class="optional"> <em class="parameter"><code>user</code></em> <code class="type">name</code> or <code class="type">oid</code>, </span>]
<em class="parameter"><code>language</code></em> <code class="type">text</code> or <code class="type">oid</code>,
<em class="parameter"><code>privilege</code></em> <code class="type">text</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Does user have privilege for language?
The only allowable privilege type is <code class="literal">USAGE</code>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.4.4.2.2.7.1.1.1" class="indexterm"></a>
<code class="function">has_parameter_privilege</code> (
[<span class="optional"> <em class="parameter"><code>user</code></em> <code class="type">name</code> or <code class="type">oid</code>, </span>]
<em class="parameter"><code>parameter</code></em> <code class="type">text</code>,
<em class="parameter"><code>privilege</code></em> <code class="type">text</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Does user have privilege for configuration parameter?
The parameter name is case-insensitive.
Allowable privilege types are <code class="literal">SET</code>
and <code class="literal">ALTER SYSTEM</code>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.4.4.2.2.8.1.1.1" class="indexterm"></a>
<code class="function">has_schema_privilege</code> (
[<span class="optional"> <em class="parameter"><code>user</code></em> <code class="type">name</code> or <code class="type">oid</code>, </span>]
<em class="parameter"><code>schema</code></em> <code class="type">text</code> or <code class="type">oid</code>,
<em class="parameter"><code>privilege</code></em> <code class="type">text</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Does user have privilege for schema?
Allowable privilege types are
<code class="literal">CREATE</code> and
<code class="literal">USAGE</code>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.4.4.2.2.9.1.1.1" class="indexterm"></a>
<code class="function">has_sequence_privilege</code> (
[<span class="optional"> <em class="parameter"><code>user</code></em> <code class="type">name</code> or <code class="type">oid</code>, </span>]
<em class="parameter"><code>sequence</code></em> <code class="type">text</code> or <code class="type">oid</code>,
<em class="parameter"><code>privilege</code></em> <code class="type">text</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Does user have privilege for sequence?
Allowable privilege types are
<code class="literal">USAGE</code>,
<code class="literal">SELECT</code>, and
<code class="literal">UPDATE</code>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.4.4.2.2.10.1.1.1" class="indexterm"></a>
<code class="function">has_server_privilege</code> (
[<span class="optional"> <em class="parameter"><code>user</code></em> <code class="type">name</code> or <code class="type">oid</code>, </span>]
<em class="parameter"><code>server</code></em> <code class="type">text</code> or <code class="type">oid</code>,
<em class="parameter"><code>privilege</code></em> <code class="type">text</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Does user have privilege for foreign server?
The only allowable privilege type is <code class="literal">USAGE</code>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.4.4.2.2.11.1.1.1" class="indexterm"></a>
<code class="function">has_table_privilege</code> (
[<span class="optional"> <em class="parameter"><code>user</code></em> <code class="type">name</code> or <code class="type">oid</code>, </span>]
<em class="parameter"><code>table</code></em> <code class="type">text</code> or <code class="type">oid</code>,
<em class="parameter"><code>privilege</code></em> <code class="type">text</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Does user have privilege for table?
Allowable privilege types
are <code class="literal">SELECT</code>, <code class="literal">INSERT</code>,
<code class="literal">UPDATE</code>, <code class="literal">DELETE</code>,
<code class="literal">TRUNCATE</code>, <code class="literal">REFERENCES</code>,
and <code class="literal">TRIGGER</code>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.4.4.2.2.12.1.1.1" class="indexterm"></a>
<code class="function">has_tablespace_privilege</code> (
[<span class="optional"> <em class="parameter"><code>user</code></em> <code class="type">name</code> or <code class="type">oid</code>, </span>]
<em class="parameter"><code>tablespace</code></em> <code class="type">text</code> or <code class="type">oid</code>,
<em class="parameter"><code>privilege</code></em> <code class="type">text</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Does user have privilege for tablespace?
The only allowable privilege type is <code class="literal">CREATE</code>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.4.4.2.2.13.1.1.1" class="indexterm"></a>
<code class="function">has_type_privilege</code> (
[<span class="optional"> <em class="parameter"><code>user</code></em> <code class="type">name</code> or <code class="type">oid</code>, </span>]
<em class="parameter"><code>type</code></em> <code class="type">text</code> or <code class="type">oid</code>,
<em class="parameter"><code>privilege</code></em> <code class="type">text</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Does user have privilege for data type?
The only allowable privilege type is <code class="literal">USAGE</code>.
When specifying a type by name rather than by OID, the allowed input
is the same as for the <code class="type">regtype</code> data type (see
<a class="xref" href="datatype-oid.html" title="8.19. Object Identifier Types">Section 8.19</a>).
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.4.4.2.2.14.1.1.1" class="indexterm"></a>
<code class="function">pg_has_role</code> (
[<span class="optional"> <em class="parameter"><code>user</code></em> <code class="type">name</code> or <code class="type">oid</code>, </span>]
<em class="parameter"><code>role</code></em> <code class="type">text</code> or <code class="type">oid</code>,
<em class="parameter"><code>privilege</code></em> <code class="type">text</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Does user have privilege for role?
Allowable privilege types are
<code class="literal">MEMBER</code>, <code class="literal">USAGE</code>,
and <code class="literal">SET</code>.
<code class="literal">MEMBER</code> denotes direct or indirect membership in
the role without regard to what specific privileges may be conferred.
<code class="literal">USAGE</code> denotes whether the privileges of the role
are immediately available without doing <code class="command">SET ROLE</code>,
while <code class="literal">SET</code> denotes whether it is possible to change
to the role using the <code class="literal">SET ROLE</code> command.
This function does not allow the special case of
setting <em class="parameter"><code>user</code></em> to <code class="literal">public</code>,
because the PUBLIC pseudo-role can never be a member of real roles.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.4.4.2.2.15.1.1.1" class="indexterm"></a>
<code class="function">row_security_active</code> (
<em class="parameter"><code>table</code></em> <code class="type">text</code> or <code class="type">oid</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Is row-level security active for the specified table in the context of
the current user and current environment?
</p></td></tr></tbody></table></div></div><br class="table-break" /><p>
<a class="xref" href="functions-info.html#FUNCTIONS-ACLITEM-OP-TABLE" title="Table 9.69. aclitem Operators">Table 9.69</a> shows the operators
available for the <code class="type">aclitem</code> type, which is the catalog
representation of access privileges. See <a class="xref" href="ddl-priv.html" title="5.7. Privileges">Section 5.7</a>
for information about how to read access privilege values.
</p><div class="table" id="FUNCTIONS-ACLITEM-OP-TABLE"><p class="title"><strong>Table 9.69. <code class="type">aclitem</code> Operators</strong></p><div class="table-contents"><table class="table" summary="aclitem Operators" border="1"><colgroup><col /></colgroup><thead><tr><th class="func_table_entry"><p class="func_signature">
Operator
</p>
<p>
Description
</p>
<p>
Example(s)
</p></th></tr></thead><tbody><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.4.6.2.2.1.1.1.1" class="indexterm"></a>
<code class="type">aclitem</code> <code class="literal">=</code> <code class="type">aclitem</code>
→ <code class="returnvalue">boolean</code>
</p>
<p>
Are <code class="type">aclitem</code>s equal? (Notice that
type <code class="type">aclitem</code> lacks the usual set of comparison
operators; it has only equality. In turn, <code class="type">aclitem</code>
arrays can only be compared for equality.)
</p>
<p>
<code class="literal">'calvin=r*w/hobbes'::aclitem = 'calvin=r*w*/hobbes'::aclitem</code>
→ <code class="returnvalue">f</code>
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.4.6.2.2.2.1.1.1" class="indexterm"></a>
<code class="type">aclitem[]</code> <code class="literal">@></code> <code class="type">aclitem</code>
→ <code class="returnvalue">boolean</code>
</p>
<p>
Does array contain the specified privileges? (This is true if there
is an array entry that matches the <code class="type">aclitem</code>'s grantee and
grantor, and has at least the specified set of privileges.)
</p>
<p>
<code class="literal">'{calvin=r*w/hobbes,hobbes=r*w*/postgres}'::aclitem[] @> 'calvin=r*/hobbes'::aclitem</code>
→ <code class="returnvalue">t</code>
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<code class="type">aclitem[]</code> <code class="literal">~</code> <code class="type">aclitem</code>
→ <code class="returnvalue">boolean</code>
</p>
<p>
This is a deprecated alias for <code class="literal">@></code>.
</p>
<p>
<code class="literal">'{calvin=r*w/hobbes,hobbes=r*w*/postgres}'::aclitem[] ~ 'calvin=r*/hobbes'::aclitem</code>
→ <code class="returnvalue">t</code>
</p></td></tr></tbody></table></div></div><br class="table-break" /><p>
<a class="xref" href="functions-info.html#FUNCTIONS-ACLITEM-FN-TABLE" title="Table 9.70. aclitem Functions">Table 9.70</a> shows some additional
functions to manage the <code class="type">aclitem</code> type.
</p><div class="table" id="FUNCTIONS-ACLITEM-FN-TABLE"><p class="title"><strong>Table 9.70. <code class="type">aclitem</code> Functions</strong></p><div class="table-contents"><table class="table" summary="aclitem Functions" border="1"><colgroup><col /></colgroup><thead><tr><th class="func_table_entry"><p class="func_signature">
Function
</p>
<p>
Description
</p></th></tr></thead><tbody><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.4.8.2.2.1.1.1.1" class="indexterm"></a>
<code class="function">acldefault</code> (
<em class="parameter"><code>type</code></em> <code class="type">"char"</code>,
<em class="parameter"><code>ownerId</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">aclitem[]</code>
</p>
<p>
Constructs an <code class="type">aclitem</code> array holding the default access
privileges for an object of type <em class="parameter"><code>type</code></em> belonging
to the role with OID <em class="parameter"><code>ownerId</code></em>. This represents
the access privileges that will be assumed when an object's ACL entry
is null. (The default access privileges are described in
<a class="xref" href="ddl-priv.html" title="5.7. Privileges">Section 5.7</a>.)
The <em class="parameter"><code>type</code></em> parameter must be one of
'c' for <code class="literal">COLUMN</code>,
'r' for <code class="literal">TABLE</code> and table-like objects,
's' for <code class="literal">SEQUENCE</code>,
'd' for <code class="literal">DATABASE</code>,
'f' for <code class="literal">FUNCTION</code> or <code class="literal">PROCEDURE</code>,
'l' for <code class="literal">LANGUAGE</code>,
'L' for <code class="literal">LARGE OBJECT</code>,
'n' for <code class="literal">SCHEMA</code>,
'p' for <code class="literal">PARAMETER</code>,
't' for <code class="literal">TABLESPACE</code>,
'F' for <code class="literal">FOREIGN DATA WRAPPER</code>,
'S' for <code class="literal">FOREIGN SERVER</code>,
or
'T' for <code class="literal">TYPE</code> or <code class="literal">DOMAIN</code>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.4.8.2.2.2.1.1.1" class="indexterm"></a>
<code class="function">aclexplode</code> ( <code class="type">aclitem[]</code> )
→ <code class="returnvalue">setof record</code>
( <em class="parameter"><code>grantor</code></em> <code class="type">oid</code>,
<em class="parameter"><code>grantee</code></em> <code class="type">oid</code>,
<em class="parameter"><code>privilege_type</code></em> <code class="type">text</code>,
<em class="parameter"><code>is_grantable</code></em> <code class="type">boolean</code> )
</p>
<p>
Returns the <code class="type">aclitem</code> array as a set of rows.
If the grantee is the pseudo-role PUBLIC, it is represented by zero in
the <em class="parameter"><code>grantee</code></em> column. Each granted privilege is
represented as <code class="literal">SELECT</code>, <code class="literal">INSERT</code>,
etc (see <a class="xref" href="ddl-priv.html#PRIVILEGE-ABBREVS-TABLE" title="Table 5.1. ACL Privilege Abbreviations">Table 5.1</a> for a full list).
Note that each privilege is broken out as a separate row, so
only one keyword appears in the <em class="parameter"><code>privilege_type</code></em>
column.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.4.8.2.2.3.1.1.1" class="indexterm"></a>
<code class="function">makeaclitem</code> (
<em class="parameter"><code>grantee</code></em> <code class="type">oid</code>,
<em class="parameter"><code>grantor</code></em> <code class="type">oid</code>,
<em class="parameter"><code>privileges</code></em> <code class="type">text</code>,
<em class="parameter"><code>is_grantable</code></em> <code class="type">boolean</code> )
→ <code class="returnvalue">aclitem</code>
</p>
<p>
Constructs an <code class="type">aclitem</code> with the given properties.
<em class="parameter"><code>privileges</code></em> is a comma-separated list of
privilege names such as <code class="literal">SELECT</code>,
<code class="literal">INSERT</code>, etc, all of which are set in the
result. (Case of the privilege string is not significant, and
extra whitespace is allowed between but not within privilege
names.)
</p></td></tr></tbody></table></div></div><br class="table-break" /></div><div class="sect2" id="FUNCTIONS-INFO-SCHEMA"><div class="titlepage"><div><div><h3 class="title">9.26.3. Schema Visibility Inquiry Functions <a href="#FUNCTIONS-INFO-SCHEMA" class="id_link">#</a></h3></div></div></div><p>
<a class="xref" href="functions-info.html#FUNCTIONS-INFO-SCHEMA-TABLE" title="Table 9.71. Schema Visibility Inquiry Functions">Table 9.71</a> shows functions that
determine whether a certain object is <em class="firstterm">visible</em> in the
current schema search path.
For example, a table is said to be visible if its
containing schema is in the search path and no table of the same
name appears earlier in the search path. This is equivalent to the
statement that the table can be referenced by name without explicit
schema qualification. Thus, to list the names of all visible tables:
</p><pre class="programlisting">
SELECT relname FROM pg_class WHERE pg_table_is_visible(oid);
</pre><p>
For functions and operators, an object in the search path is said to be
visible if there is no object of the same name <span class="emphasis"><em>and argument data
type(s)</em></span> earlier in the path. For operator classes and families,
both the name and the associated index access method are considered.
</p><a id="id-1.5.8.32.5.3" class="indexterm"></a><div class="table" id="FUNCTIONS-INFO-SCHEMA-TABLE"><p class="title"><strong>Table 9.71. Schema Visibility Inquiry Functions</strong></p><div class="table-contents"><table class="table" summary="Schema Visibility Inquiry Functions" border="1"><colgroup><col /></colgroup><thead><tr><th class="func_table_entry"><p class="func_signature">
Function
</p>
<p>
Description
</p></th></tr></thead><tbody><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.5.4.2.2.1.1.1.1" class="indexterm"></a>
<code class="function">pg_collation_is_visible</code> ( <em class="parameter"><code>collation</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Is collation visible in search path?
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.5.4.2.2.2.1.1.1" class="indexterm"></a>
<code class="function">pg_conversion_is_visible</code> ( <em class="parameter"><code>conversion</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Is conversion visible in search path?
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.5.4.2.2.3.1.1.1" class="indexterm"></a>
<code class="function">pg_function_is_visible</code> ( <em class="parameter"><code>function</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Is function visible in search path?
(This also works for procedures and aggregates.)
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.5.4.2.2.4.1.1.1" class="indexterm"></a>
<code class="function">pg_opclass_is_visible</code> ( <em class="parameter"><code>opclass</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Is operator class visible in search path?
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.5.4.2.2.5.1.1.1" class="indexterm"></a>
<code class="function">pg_operator_is_visible</code> ( <em class="parameter"><code>operator</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Is operator visible in search path?
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.5.4.2.2.6.1.1.1" class="indexterm"></a>
<code class="function">pg_opfamily_is_visible</code> ( <em class="parameter"><code>opclass</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Is operator family visible in search path?
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.5.4.2.2.7.1.1.1" class="indexterm"></a>
<code class="function">pg_statistics_obj_is_visible</code> ( <em class="parameter"><code>stat</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Is statistics object visible in search path?
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.5.4.2.2.8.1.1.1" class="indexterm"></a>
<code class="function">pg_table_is_visible</code> ( <em class="parameter"><code>table</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Is table visible in search path?
(This works for all types of relations, including views, materialized
views, indexes, sequences and foreign tables.)
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.5.4.2.2.9.1.1.1" class="indexterm"></a>
<code class="function">pg_ts_config_is_visible</code> ( <em class="parameter"><code>config</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Is text search configuration visible in search path?
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.5.4.2.2.10.1.1.1" class="indexterm"></a>
<code class="function">pg_ts_dict_is_visible</code> ( <em class="parameter"><code>dict</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Is text search dictionary visible in search path?
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.5.4.2.2.11.1.1.1" class="indexterm"></a>
<code class="function">pg_ts_parser_is_visible</code> ( <em class="parameter"><code>parser</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Is text search parser visible in search path?
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.5.4.2.2.12.1.1.1" class="indexterm"></a>
<code class="function">pg_ts_template_is_visible</code> ( <em class="parameter"><code>template</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Is text search template visible in search path?
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.5.4.2.2.13.1.1.1" class="indexterm"></a>
<code class="function">pg_type_is_visible</code> ( <em class="parameter"><code>type</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Is type (or domain) visible in search path?
</p></td></tr></tbody></table></div></div><br class="table-break" /><p>
All these functions require object OIDs to identify the object to be
checked. If you want to test an object by name, it is convenient to use
the OID alias types (<code class="type">regclass</code>, <code class="type">regtype</code>,
<code class="type">regprocedure</code>, <code class="type">regoperator</code>, <code class="type">regconfig</code>,
or <code class="type">regdictionary</code>),
for example:
</p><pre class="programlisting">
SELECT pg_type_is_visible('myschema.widget'::regtype);
</pre><p>
Note that it would not make much sense to test a non-schema-qualified
type name in this way — if the name can be recognized at all, it must be visible.
</p></div><div class="sect2" id="FUNCTIONS-INFO-CATALOG"><div class="titlepage"><div><div><h3 class="title">9.26.4. System Catalog Information Functions <a href="#FUNCTIONS-INFO-CATALOG" class="id_link">#</a></h3></div></div></div><p>
<a class="xref" href="functions-info.html#FUNCTIONS-INFO-CATALOG-TABLE" title="Table 9.72. System Catalog Information Functions">Table 9.72</a> lists functions that
extract information from the system catalogs.
</p><div class="table" id="FUNCTIONS-INFO-CATALOG-TABLE"><p class="title"><strong>Table 9.72. System Catalog Information Functions</strong></p><div class="table-contents"><table class="table" summary="System Catalog Information Functions" border="1"><colgroup><col /></colgroup><thead><tr><th class="func_table_entry"><p class="func_signature">
Function
</p>
<p>
Description
</p></th></tr></thead><tbody><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.1.1.1.1" class="indexterm"></a>
<code class="function">format_type</code> ( <em class="parameter"><code>type</code></em> <code class="type">oid</code>, <em class="parameter"><code>typemod</code></em> <code class="type">integer</code> )
→ <code class="returnvalue">text</code>
</p>
<p>
Returns the SQL name for a data type that is identified by its type
OID and possibly a type modifier. Pass NULL for the type modifier if
no specific modifier is known.
</p></td></tr><tr><td id="PG-CHAR-TO-ENCODING" class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.2.1.1.1" class="indexterm"></a>
<code class="function">pg_char_to_encoding</code> ( <em class="parameter"><code>encoding</code></em> <code class="type">name</code> )
→ <code class="returnvalue">integer</code>
</p>
<p>
Converts the supplied encoding name into an integer representing the
internal identifier used in some system catalog tables.
Returns <code class="literal">-1</code> if an unknown encoding name is provided.
</p></td></tr><tr><td id="PG-ENCODING-TO-CHAR" class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.3.1.1.1" class="indexterm"></a>
<code class="function">pg_encoding_to_char</code> ( <em class="parameter"><code>encoding</code></em> <code class="type">integer</code> )
→ <code class="returnvalue">name</code>
</p>
<p>
Converts the integer used as the internal identifier of an encoding in some
system catalog tables into a human-readable string.
Returns an empty string if an invalid encoding number is provided.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.4.1.1.1" class="indexterm"></a>
<code class="function">pg_get_catalog_foreign_keys</code> ()
→ <code class="returnvalue">setof record</code>
( <em class="parameter"><code>fktable</code></em> <code class="type">regclass</code>,
<em class="parameter"><code>fkcols</code></em> <code class="type">text[]</code>,
<em class="parameter"><code>pktable</code></em> <code class="type">regclass</code>,
<em class="parameter"><code>pkcols</code></em> <code class="type">text[]</code>,
<em class="parameter"><code>is_array</code></em> <code class="type">boolean</code>,
<em class="parameter"><code>is_opt</code></em> <code class="type">boolean</code> )
</p>
<p>
Returns a set of records describing the foreign key relationships
that exist within the <span class="productname">PostgreSQL</span> system
catalogs.
The <em class="parameter"><code>fktable</code></em> column contains the name of the
referencing catalog, and the <em class="parameter"><code>fkcols</code></em> column
contains the name(s) of the referencing column(s). Similarly,
the <em class="parameter"><code>pktable</code></em> column contains the name of the
referenced catalog, and the <em class="parameter"><code>pkcols</code></em> column
contains the name(s) of the referenced column(s).
If <em class="parameter"><code>is_array</code></em> is true, the last referencing
column is an array, each of whose elements should match some entry
in the referenced catalog.
If <em class="parameter"><code>is_opt</code></em> is true, the referencing column(s)
are allowed to contain zeroes instead of a valid reference.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.5.1.1.1" class="indexterm"></a>
<code class="function">pg_get_constraintdef</code> ( <em class="parameter"><code>constraint</code></em> <code class="type">oid</code> [<span class="optional">, <em class="parameter"><code>pretty</code></em> <code class="type">boolean</code> </span>] )
→ <code class="returnvalue">text</code>
</p>
<p>
Reconstructs the creating command for a constraint.
(This is a decompiled reconstruction, not the original text
of the command.)
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.6.1.1.1" class="indexterm"></a>
<code class="function">pg_get_expr</code> ( <em class="parameter"><code>expr</code></em> <code class="type">pg_node_tree</code>, <em class="parameter"><code>relation</code></em> <code class="type">oid</code> [<span class="optional">, <em class="parameter"><code>pretty</code></em> <code class="type">boolean</code> </span>] )
→ <code class="returnvalue">text</code>
</p>
<p>
Decompiles the internal form of an expression stored in the system
catalogs, such as the default value for a column. If the expression
might contain Vars, specify the OID of the relation they refer to as
the second parameter; if no Vars are expected, passing zero is
sufficient.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.7.1.1.1" class="indexterm"></a>
<code class="function">pg_get_functiondef</code> ( <em class="parameter"><code>func</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">text</code>
</p>
<p>
Reconstructs the creating command for a function or procedure.
(This is a decompiled reconstruction, not the original text
of the command.)
The result is a complete <code class="command">CREATE OR REPLACE FUNCTION</code>
or <code class="command">CREATE OR REPLACE PROCEDURE</code> statement.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.8.1.1.1" class="indexterm"></a>
<code class="function">pg_get_function_arguments</code> ( <em class="parameter"><code>func</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">text</code>
</p>
<p>
Reconstructs the argument list of a function or procedure, in the form
it would need to appear in within <code class="command">CREATE FUNCTION</code>
(including default values).
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.9.1.1.1" class="indexterm"></a>
<code class="function">pg_get_function_identity_arguments</code> ( <em class="parameter"><code>func</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">text</code>
</p>
<p>
Reconstructs the argument list necessary to identify a function or
procedure, in the form it would need to appear in within commands such
as <code class="command">ALTER FUNCTION</code>. This form omits default values.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.10.1.1.1" class="indexterm"></a>
<code class="function">pg_get_function_result</code> ( <em class="parameter"><code>func</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">text</code>
</p>
<p>
Reconstructs the <code class="literal">RETURNS</code> clause of a function, in
the form it would need to appear in within <code class="command">CREATE
FUNCTION</code>. Returns <code class="literal">NULL</code> for a procedure.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.11.1.1.1" class="indexterm"></a>
<code class="function">pg_get_indexdef</code> ( <em class="parameter"><code>index</code></em> <code class="type">oid</code> [<span class="optional">, <em class="parameter"><code>column</code></em> <code class="type">integer</code>, <em class="parameter"><code>pretty</code></em> <code class="type">boolean</code> </span>] )
→ <code class="returnvalue">text</code>
</p>
<p>
Reconstructs the creating command for an index.
(This is a decompiled reconstruction, not the original text
of the command.) If <em class="parameter"><code>column</code></em> is supplied and is
not zero, only the definition of that column is reconstructed.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.12.1.1.1" class="indexterm"></a>
<code class="function">pg_get_keywords</code> ()
→ <code class="returnvalue">setof record</code>
( <em class="parameter"><code>word</code></em> <code class="type">text</code>,
<em class="parameter"><code>catcode</code></em> <code class="type">"char"</code>,
<em class="parameter"><code>barelabel</code></em> <code class="type">boolean</code>,
<em class="parameter"><code>catdesc</code></em> <code class="type">text</code>,
<em class="parameter"><code>baredesc</code></em> <code class="type">text</code> )
</p>
<p>
Returns a set of records describing the SQL keywords recognized by the
server. The <em class="parameter"><code>word</code></em> column contains the
keyword. The <em class="parameter"><code>catcode</code></em> column contains a
category code: <code class="literal">U</code> for an unreserved
keyword, <code class="literal">C</code> for a keyword that can be a column
name, <code class="literal">T</code> for a keyword that can be a type or
function name, or <code class="literal">R</code> for a fully reserved keyword.
The <em class="parameter"><code>barelabel</code></em> column
contains <code class="literal">true</code> if the keyword can be used as
a <span class="quote">“<span class="quote">bare</span>”</span> column label in <code class="command">SELECT</code> lists,
or <code class="literal">false</code> if it can only be used
after <code class="literal">AS</code>.
The <em class="parameter"><code>catdesc</code></em> column contains a
possibly-localized string describing the keyword's category.
The <em class="parameter"><code>baredesc</code></em> column contains a
possibly-localized string describing the keyword's column label status.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.13.1.1.1" class="indexterm"></a>
<code class="function">pg_get_partkeydef</code> ( <em class="parameter"><code>table</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">text</code>
</p>
<p>
Reconstructs the definition of a partitioned table's partition
key, in the form it would have in the <code class="literal">PARTITION
BY</code> clause of <code class="command">CREATE TABLE</code>.
(This is a decompiled reconstruction, not the original text
of the command.)
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.14.1.1.1" class="indexterm"></a>
<code class="function">pg_get_ruledef</code> ( <em class="parameter"><code>rule</code></em> <code class="type">oid</code> [<span class="optional">, <em class="parameter"><code>pretty</code></em> <code class="type">boolean</code> </span>] )
→ <code class="returnvalue">text</code>
</p>
<p>
Reconstructs the creating command for a rule.
(This is a decompiled reconstruction, not the original text
of the command.)
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.15.1.1.1" class="indexterm"></a>
<code class="function">pg_get_serial_sequence</code> ( <em class="parameter"><code>table</code></em> <code class="type">text</code>, <em class="parameter"><code>column</code></em> <code class="type">text</code> )
→ <code class="returnvalue">text</code>
</p>
<p>
Returns the name of the sequence associated with a column,
or NULL if no sequence is associated with the column.
If the column is an identity column, the associated sequence is the
sequence internally created for that column.
For columns created using one of the serial types
(<code class="type">serial</code>, <code class="type">smallserial</code>, <code class="type">bigserial</code>),
it is the sequence created for that serial column definition.
In the latter case, the association can be modified or removed
with <code class="command">ALTER SEQUENCE OWNED BY</code>.
(This function probably should have been
called <code class="function">pg_get_owned_sequence</code>; its current name
reflects the fact that it has historically been used with serial-type
columns.) The first parameter is a table name with optional
schema, and the second parameter is a column name. Because the first
parameter potentially contains both schema and table names, it is
parsed per usual SQL rules, meaning it is lower-cased by default.
The second parameter, being just a column name, is treated literally
and so has its case preserved. The result is suitably formatted
for passing to the sequence functions (see
<a class="xref" href="functions-sequence.html" title="9.17. Sequence Manipulation Functions">Section 9.17</a>).
</p>
<p>
A typical use is in reading the current value of the sequence for an
identity or serial column, for example:
</p><pre class="programlisting">
SELECT currval(pg_get_serial_sequence('sometable', 'id'));
</pre><p>
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.16.1.1.1" class="indexterm"></a>
<code class="function">pg_get_statisticsobjdef</code> ( <em class="parameter"><code>statobj</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">text</code>
</p>
<p>
Reconstructs the creating command for an extended statistics object.
(This is a decompiled reconstruction, not the original text
of the command.)
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.17.1.1.1" class="indexterm"></a>
<code class="function">pg_get_triggerdef</code> ( <em class="parameter"><code>trigger</code></em> <code class="type">oid</code> [<span class="optional">, <em class="parameter"><code>pretty</code></em> <code class="type">boolean</code> </span>] )
→ <code class="returnvalue">text</code>
</p>
<p>
Reconstructs the creating command for a trigger.
(This is a decompiled reconstruction, not the original text
of the command.)
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.18.1.1.1" class="indexterm"></a>
<code class="function">pg_get_userbyid</code> ( <em class="parameter"><code>role</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">name</code>
</p>
<p>
Returns a role's name given its OID.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.19.1.1.1" class="indexterm"></a>
<code class="function">pg_get_viewdef</code> ( <em class="parameter"><code>view</code></em> <code class="type">oid</code> [<span class="optional">, <em class="parameter"><code>pretty</code></em> <code class="type">boolean</code> </span>] )
→ <code class="returnvalue">text</code>
</p>
<p>
Reconstructs the underlying <code class="command">SELECT</code> command for a
view or materialized view. (This is a decompiled reconstruction, not
the original text of the command.)
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<code class="function">pg_get_viewdef</code> ( <em class="parameter"><code>view</code></em> <code class="type">oid</code>, <em class="parameter"><code>wrap_column</code></em> <code class="type">integer</code> )
→ <code class="returnvalue">text</code>
</p>
<p>
Reconstructs the underlying <code class="command">SELECT</code> command for a
view or materialized view. (This is a decompiled reconstruction, not
the original text of the command.) In this form of the function,
pretty-printing is always enabled, and long lines are wrapped to try
to keep them shorter than the specified number of columns.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<code class="function">pg_get_viewdef</code> ( <em class="parameter"><code>view</code></em> <code class="type">text</code> [<span class="optional">, <em class="parameter"><code>pretty</code></em> <code class="type">boolean</code> </span>] )
→ <code class="returnvalue">text</code>
</p>
<p>
Reconstructs the underlying <code class="command">SELECT</code> command for a
view or materialized view, working from a textual name for the view
rather than its OID. (This is deprecated; use the OID variant
instead.)
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.22.1.1.1" class="indexterm"></a>
<code class="function">pg_index_column_has_property</code> ( <em class="parameter"><code>index</code></em> <code class="type">regclass</code>, <em class="parameter"><code>column</code></em> <code class="type">integer</code>, <em class="parameter"><code>property</code></em> <code class="type">text</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Tests whether an index column has the named property.
Common index column properties are listed in
<a class="xref" href="functions-info.html#FUNCTIONS-INFO-INDEX-COLUMN-PROPS" title="Table 9.73. Index Column Properties">Table 9.73</a>.
(Note that extension access methods can define additional property
names for their indexes.)
<code class="literal">NULL</code> is returned if the property name is not known
or does not apply to the particular object, or if the OID or column
number does not identify a valid object.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.23.1.1.1" class="indexterm"></a>
<code class="function">pg_index_has_property</code> ( <em class="parameter"><code>index</code></em> <code class="type">regclass</code>, <em class="parameter"><code>property</code></em> <code class="type">text</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Tests whether an index has the named property.
Common index properties are listed in
<a class="xref" href="functions-info.html#FUNCTIONS-INFO-INDEX-PROPS" title="Table 9.74. Index Properties">Table 9.74</a>.
(Note that extension access methods can define additional property
names for their indexes.)
<code class="literal">NULL</code> is returned if the property name is not known
or does not apply to the particular object, or if the OID does not
identify a valid object.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.24.1.1.1" class="indexterm"></a>
<code class="function">pg_indexam_has_property</code> ( <em class="parameter"><code>am</code></em> <code class="type">oid</code>, <em class="parameter"><code>property</code></em> <code class="type">text</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Tests whether an index access method has the named property.
Access method properties are listed in
<a class="xref" href="functions-info.html#FUNCTIONS-INFO-INDEXAM-PROPS" title="Table 9.75. Index Access Method Properties">Table 9.75</a>.
<code class="literal">NULL</code> is returned if the property name is not known
or does not apply to the particular object, or if the OID does not
identify a valid object.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.25.1.1.1" class="indexterm"></a>
<code class="function">pg_options_to_table</code> ( <em class="parameter"><code>options_array</code></em> <code class="type">text[]</code> )
→ <code class="returnvalue">setof record</code>
( <em class="parameter"><code>option_name</code></em> <code class="type">text</code>,
<em class="parameter"><code>option_value</code></em> <code class="type">text</code> )
</p>
<p>
Returns the set of storage options represented by a value from
<code class="structname">pg_class</code>.<code class="structfield">reloptions</code> or
<code class="structname">pg_attribute</code>.<code class="structfield">attoptions</code>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.26.1.1.1" class="indexterm"></a>
<code class="function">pg_settings_get_flags</code> ( <em class="parameter"><code>guc</code></em> <code class="type">text</code> )
→ <code class="returnvalue">text[]</code>
</p>
<p>
Returns an array of the flags associated with the given GUC, or
<code class="literal">NULL</code> if it does not exist. The result is
an empty array if the GUC exists but there are no flags to show.
Only the most useful flags listed in
<a class="xref" href="functions-info.html#FUNCTIONS-PG-SETTINGS-FLAGS" title="Table 9.76. GUC Flags">Table 9.76</a> are exposed.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.27.1.1.1" class="indexterm"></a>
<code class="function">pg_tablespace_databases</code> ( <em class="parameter"><code>tablespace</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">setof oid</code>
</p>
<p>
Returns the set of OIDs of databases that have objects stored in the
specified tablespace. If this function returns any rows, the
tablespace is not empty and cannot be dropped. To identify the specific
objects populating the tablespace, you will need to connect to the
database(s) identified by <code class="function">pg_tablespace_databases</code>
and query their <code class="structname">pg_class</code> catalogs.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.28.1.1.1" class="indexterm"></a>
<code class="function">pg_tablespace_location</code> ( <em class="parameter"><code>tablespace</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">text</code>
</p>
<p>
Returns the file system path that this tablespace is located in.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.29.1.1.1" class="indexterm"></a>
<code class="function">pg_typeof</code> ( <code class="type">"any"</code> )
→ <code class="returnvalue">regtype</code>
</p>
<p>
Returns the OID of the data type of the value that is passed to it.
This can be helpful for troubleshooting or dynamically constructing
SQL queries. The function is declared as
returning <code class="type">regtype</code>, which is an OID alias type (see
<a class="xref" href="datatype-oid.html" title="8.19. Object Identifier Types">Section 8.19</a>); this means that it is the same as an
OID for comparison purposes but displays as a type name.
</p>
<p>
For example:
</p><pre class="programlisting">
SELECT pg_typeof(33);
pg_typeof
-----------
integer
SELECT typlen FROM pg_type WHERE oid = pg_typeof(33);
typlen
--------
4
</pre><p>
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.30.1.1.1" class="indexterm"></a>
<code class="function">COLLATION FOR</code> ( <code class="type">"any"</code> )
→ <code class="returnvalue">text</code>
</p>
<p>
Returns the name of the collation of the value that is passed to it.
The value is quoted and schema-qualified if necessary. If no
collation was derived for the argument expression,
then <code class="literal">NULL</code> is returned. If the argument is not of a
collatable data type, then an error is raised.
</p>
<p>
For example:
</p><pre class="programlisting">
SELECT collation for (description) FROM pg_description LIMIT 1;
pg_collation_for
------------------
"default"
SELECT collation for ('foo' COLLATE "de_DE");
pg_collation_for
------------------
"de_DE"
</pre><p>
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.31.1.1.1" class="indexterm"></a>
<code class="function">to_regclass</code> ( <code class="type">text</code> )
→ <code class="returnvalue">regclass</code>
</p>
<p>
Translates a textual relation name to its OID. A similar result is
obtained by casting the string to type <code class="type">regclass</code> (see
<a class="xref" href="datatype-oid.html" title="8.19. Object Identifier Types">Section 8.19</a>); however, this function will return
<code class="literal">NULL</code> rather than throwing an error if the name is
not found.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.32.1.1.1" class="indexterm"></a>
<code class="function">to_regcollation</code> ( <code class="type">text</code> )
→ <code class="returnvalue">regcollation</code>
</p>
<p>
Translates a textual collation name to its OID. A similar result is
obtained by casting the string to type <code class="type">regcollation</code> (see
<a class="xref" href="datatype-oid.html" title="8.19. Object Identifier Types">Section 8.19</a>); however, this function will return
<code class="literal">NULL</code> rather than throwing an error if the name is
not found.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.33.1.1.1" class="indexterm"></a>
<code class="function">to_regnamespace</code> ( <code class="type">text</code> )
→ <code class="returnvalue">regnamespace</code>
</p>
<p>
Translates a textual schema name to its OID. A similar result is
obtained by casting the string to type <code class="type">regnamespace</code> (see
<a class="xref" href="datatype-oid.html" title="8.19. Object Identifier Types">Section 8.19</a>); however, this function will return
<code class="literal">NULL</code> rather than throwing an error if the name is
not found.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.34.1.1.1" class="indexterm"></a>
<code class="function">to_regoper</code> ( <code class="type">text</code> )
→ <code class="returnvalue">regoper</code>
</p>
<p>
Translates a textual operator name to its OID. A similar result is
obtained by casting the string to type <code class="type">regoper</code> (see
<a class="xref" href="datatype-oid.html" title="8.19. Object Identifier Types">Section 8.19</a>); however, this function will return
<code class="literal">NULL</code> rather than throwing an error if the name is
not found or is ambiguous.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.35.1.1.1" class="indexterm"></a>
<code class="function">to_regoperator</code> ( <code class="type">text</code> )
→ <code class="returnvalue">regoperator</code>
</p>
<p>
Translates a textual operator name (with parameter types) to its OID. A similar result is
obtained by casting the string to type <code class="type">regoperator</code> (see
<a class="xref" href="datatype-oid.html" title="8.19. Object Identifier Types">Section 8.19</a>); however, this function will return
<code class="literal">NULL</code> rather than throwing an error if the name is
not found.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.36.1.1.1" class="indexterm"></a>
<code class="function">to_regproc</code> ( <code class="type">text</code> )
→ <code class="returnvalue">regproc</code>
</p>
<p>
Translates a textual function or procedure name to its OID. A similar result is
obtained by casting the string to type <code class="type">regproc</code> (see
<a class="xref" href="datatype-oid.html" title="8.19. Object Identifier Types">Section 8.19</a>); however, this function will return
<code class="literal">NULL</code> rather than throwing an error if the name is
not found or is ambiguous.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.37.1.1.1" class="indexterm"></a>
<code class="function">to_regprocedure</code> ( <code class="type">text</code> )
→ <code class="returnvalue">regprocedure</code>
</p>
<p>
Translates a textual function or procedure name (with argument types) to its OID. A similar result is
obtained by casting the string to type <code class="type">regprocedure</code> (see
<a class="xref" href="datatype-oid.html" title="8.19. Object Identifier Types">Section 8.19</a>); however, this function will return
<code class="literal">NULL</code> rather than throwing an error if the name is
not found.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.38.1.1.1" class="indexterm"></a>
<code class="function">to_regrole</code> ( <code class="type">text</code> )
→ <code class="returnvalue">regrole</code>
</p>
<p>
Translates a textual role name to its OID. A similar result is
obtained by casting the string to type <code class="type">regrole</code> (see
<a class="xref" href="datatype-oid.html" title="8.19. Object Identifier Types">Section 8.19</a>); however, this function will return
<code class="literal">NULL</code> rather than throwing an error if the name is
not found.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.6.3.2.2.39.1.1.1" class="indexterm"></a>
<code class="function">to_regtype</code> ( <code class="type">text</code> )
→ <code class="returnvalue">regtype</code>
</p>
<p>
Translates a textual type name to its OID. A similar result is
obtained by casting the string to type <code class="type">regtype</code> (see
<a class="xref" href="datatype-oid.html" title="8.19. Object Identifier Types">Section 8.19</a>); however, this function will return
<code class="literal">NULL</code> rather than throwing an error if the name is
not found.
</p></td></tr></tbody></table></div></div><br class="table-break" /><p>
Most of the functions that reconstruct (decompile) database objects
have an optional <em class="parameter"><code>pretty</code></em> flag, which
if <code class="literal">true</code> causes the result to
be <span class="quote">“<span class="quote">pretty-printed</span>”</span>. Pretty-printing suppresses unnecessary
parentheses and adds whitespace for legibility.
The pretty-printed format is more readable, but the default format
is more likely to be interpreted the same way by future versions of
<span class="productname">PostgreSQL</span>; so avoid using pretty-printed output
for dump purposes. Passing <code class="literal">false</code> for
the <em class="parameter"><code>pretty</code></em> parameter yields the same result as
omitting the parameter.
</p><div class="table" id="FUNCTIONS-INFO-INDEX-COLUMN-PROPS"><p class="title"><strong>Table 9.73. Index Column Properties</strong></p><div class="table-contents"><table class="table" summary="Index Column Properties" border="1"><colgroup><col /><col /></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><code class="literal">asc</code></td><td>Does the column sort in ascending order on a forward scan?
</td></tr><tr><td><code class="literal">desc</code></td><td>Does the column sort in descending order on a forward scan?
</td></tr><tr><td><code class="literal">nulls_first</code></td><td>Does the column sort with nulls first on a forward scan?
</td></tr><tr><td><code class="literal">nulls_last</code></td><td>Does the column sort with nulls last on a forward scan?
</td></tr><tr><td><code class="literal">orderable</code></td><td>Does the column possess any defined sort ordering?
</td></tr><tr><td><code class="literal">distance_orderable</code></td><td>Can the column be scanned in order by a <span class="quote">“<span class="quote">distance</span>”</span>
operator, for example <code class="literal">ORDER BY col <-> constant</code> ?
</td></tr><tr><td><code class="literal">returnable</code></td><td>Can the column value be returned by an index-only scan?
</td></tr><tr><td><code class="literal">search_array</code></td><td>Does the column natively support <code class="literal">col = ANY(array)</code>
searches?
</td></tr><tr><td><code class="literal">search_nulls</code></td><td>Does the column support <code class="literal">IS NULL</code> and
<code class="literal">IS NOT NULL</code> searches?
</td></tr></tbody></table></div></div><br class="table-break" /><div class="table" id="FUNCTIONS-INFO-INDEX-PROPS"><p class="title"><strong>Table 9.74. Index Properties</strong></p><div class="table-contents"><table class="table" summary="Index Properties" border="1"><colgroup><col /><col /></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><code class="literal">clusterable</code></td><td>Can the index be used in a <code class="literal">CLUSTER</code> command?
</td></tr><tr><td><code class="literal">index_scan</code></td><td>Does the index support plain (non-bitmap) scans?
</td></tr><tr><td><code class="literal">bitmap_scan</code></td><td>Does the index support bitmap scans?
</td></tr><tr><td><code class="literal">backward_scan</code></td><td>Can the scan direction be changed in mid-scan (to
support <code class="literal">FETCH BACKWARD</code> on a cursor without
needing materialization)?
</td></tr></tbody></table></div></div><br class="table-break" /><div class="table" id="FUNCTIONS-INFO-INDEXAM-PROPS"><p class="title"><strong>Table 9.75. Index Access Method Properties</strong></p><div class="table-contents"><table class="table" summary="Index Access Method Properties" border="1"><colgroup><col /><col /></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><code class="literal">can_order</code></td><td>Does the access method support <code class="literal">ASC</code>,
<code class="literal">DESC</code> and related keywords in
<code class="literal">CREATE INDEX</code>?
</td></tr><tr><td><code class="literal">can_unique</code></td><td>Does the access method support unique indexes?
</td></tr><tr><td><code class="literal">can_multi_col</code></td><td>Does the access method support indexes with multiple columns?
</td></tr><tr><td><code class="literal">can_exclude</code></td><td>Does the access method support exclusion constraints?
</td></tr><tr><td><code class="literal">can_include</code></td><td>Does the access method support the <code class="literal">INCLUDE</code>
clause of <code class="literal">CREATE INDEX</code>?
</td></tr></tbody></table></div></div><br class="table-break" /><div class="table" id="FUNCTIONS-PG-SETTINGS-FLAGS"><p class="title"><strong>Table 9.76. GUC Flags</strong></p><div class="table-contents"><table class="table" summary="GUC Flags" border="1"><colgroup><col /><col /></colgroup><thead><tr><th>Flag</th><th>Description</th></tr></thead><tbody><tr><td><code class="literal">EXPLAIN</code></td><td>Parameters with this flag are included in
<code class="command">EXPLAIN (SETTINGS)</code> commands.
</td></tr><tr><td><code class="literal">NO_SHOW_ALL</code></td><td>Parameters with this flag are excluded from
<code class="command">SHOW ALL</code> commands.
</td></tr><tr><td><code class="literal">NO_RESET</code></td><td>Parameters with this flag do not support
<code class="command">RESET</code> commands.
</td></tr><tr><td><code class="literal">NO_RESET_ALL</code></td><td>Parameters with this flag are excluded from
<code class="command">RESET ALL</code> commands.
</td></tr><tr><td><code class="literal">NOT_IN_SAMPLE</code></td><td>Parameters with this flag are not included in
<code class="filename">postgresql.conf</code> by default.
</td></tr><tr><td><code class="literal">RUNTIME_COMPUTED</code></td><td>Parameters with this flag are runtime-computed ones.
</td></tr></tbody></table></div></div><br class="table-break" /></div><div class="sect2" id="FUNCTIONS-INFO-OBJECT"><div class="titlepage"><div><div><h3 class="title">9.26.5. Object Information and Addressing Functions <a href="#FUNCTIONS-INFO-OBJECT" class="id_link">#</a></h3></div></div></div><p>
<a class="xref" href="functions-info.html#FUNCTIONS-INFO-OBJECT-TABLE" title="Table 9.77. Object Information and Addressing Functions">Table 9.77</a> lists functions related to
database object identification and addressing.
</p><div class="table" id="FUNCTIONS-INFO-OBJECT-TABLE"><p class="title"><strong>Table 9.77. Object Information and Addressing Functions</strong></p><div class="table-contents"><table class="table" summary="Object Information and Addressing Functions" border="1"><colgroup><col /></colgroup><thead><tr><th class="func_table_entry"><p class="func_signature">
Function
</p>
<p>
Description
</p></th></tr></thead><tbody><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.7.3.2.2.1.1.1.1" class="indexterm"></a>
<code class="function">pg_describe_object</code> ( <em class="parameter"><code>classid</code></em> <code class="type">oid</code>, <em class="parameter"><code>objid</code></em> <code class="type">oid</code>, <em class="parameter"><code>objsubid</code></em> <code class="type">integer</code> )
→ <code class="returnvalue">text</code>
</p>
<p>
Returns a textual description of a database object identified by
catalog OID, object OID, and sub-object ID (such as a column number
within a table; the sub-object ID is zero when referring to a whole
object). This description is intended to be human-readable, and might
be translated, depending on server configuration. This is especially
useful to determine the identity of an object referenced in the
<code class="structname">pg_depend</code> catalog. This function returns
<code class="literal">NULL</code> values for undefined objects.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.7.3.2.2.2.1.1.1" class="indexterm"></a>
<code class="function">pg_identify_object</code> ( <em class="parameter"><code>classid</code></em> <code class="type">oid</code>, <em class="parameter"><code>objid</code></em> <code class="type">oid</code>, <em class="parameter"><code>objsubid</code></em> <code class="type">integer</code> )
→ <code class="returnvalue">record</code>
( <em class="parameter"><code>type</code></em> <code class="type">text</code>,
<em class="parameter"><code>schema</code></em> <code class="type">text</code>,
<em class="parameter"><code>name</code></em> <code class="type">text</code>,
<em class="parameter"><code>identity</code></em> <code class="type">text</code> )
</p>
<p>
Returns a row containing enough information to uniquely identify the
database object specified by catalog OID, object OID and sub-object
ID.
This information is intended to be machine-readable, and is never
translated.
<em class="parameter"><code>type</code></em> identifies the type of database object;
<em class="parameter"><code>schema</code></em> is the schema name that the object
belongs in, or <code class="literal">NULL</code> for object types that do not
belong to schemas;
<em class="parameter"><code>name</code></em> is the name of the object, quoted if
necessary, if the name (along with schema name, if pertinent) is
sufficient to uniquely identify the object,
otherwise <code class="literal">NULL</code>;
<em class="parameter"><code>identity</code></em> is the complete object identity, with
the precise format depending on object type, and each name within the
format being schema-qualified and quoted as necessary. Undefined
objects are identified with <code class="literal">NULL</code> values.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.7.3.2.2.3.1.1.1" class="indexterm"></a>
<code class="function">pg_identify_object_as_address</code> ( <em class="parameter"><code>classid</code></em> <code class="type">oid</code>, <em class="parameter"><code>objid</code></em> <code class="type">oid</code>, <em class="parameter"><code>objsubid</code></em> <code class="type">integer</code> )
→ <code class="returnvalue">record</code>
( <em class="parameter"><code>type</code></em> <code class="type">text</code>,
<em class="parameter"><code>object_names</code></em> <code class="type">text[]</code>,
<em class="parameter"><code>object_args</code></em> <code class="type">text[]</code> )
</p>
<p>
Returns a row containing enough information to uniquely identify the
database object specified by catalog OID, object OID and sub-object
ID.
The returned information is independent of the current server, that
is, it could be used to identify an identically named object in
another server.
<em class="parameter"><code>type</code></em> identifies the type of database object;
<em class="parameter"><code>object_names</code></em> and
<em class="parameter"><code>object_args</code></em>
are text arrays that together form a reference to the object.
These three values can be passed
to <code class="function">pg_get_object_address</code> to obtain the internal
address of the object.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.7.3.2.2.4.1.1.1" class="indexterm"></a>
<code class="function">pg_get_object_address</code> ( <em class="parameter"><code>type</code></em> <code class="type">text</code>, <em class="parameter"><code>object_names</code></em> <code class="type">text[]</code>, <em class="parameter"><code>object_args</code></em> <code class="type">text[]</code> )
→ <code class="returnvalue">record</code>
( <em class="parameter"><code>classid</code></em> <code class="type">oid</code>,
<em class="parameter"><code>objid</code></em> <code class="type">oid</code>,
<em class="parameter"><code>objsubid</code></em> <code class="type">integer</code> )
</p>
<p>
Returns a row containing enough information to uniquely identify the
database object specified by a type code and object name and argument
arrays.
The returned values are the ones that would be used in system catalogs
such as <code class="structname">pg_depend</code>; they can be passed to
other system functions such as <code class="function">pg_describe_object</code>
or <code class="function">pg_identify_object</code>.
<em class="parameter"><code>classid</code></em> is the OID of the system catalog
containing the object;
<em class="parameter"><code>objid</code></em> is the OID of the object itself, and
<em class="parameter"><code>objsubid</code></em> is the sub-object ID, or zero if none.
This function is the inverse
of <code class="function">pg_identify_object_as_address</code>.
Undefined objects are identified with <code class="literal">NULL</code> values.
</p></td></tr></tbody></table></div></div><br class="table-break" /></div><div class="sect2" id="FUNCTIONS-INFO-COMMENT"><div class="titlepage"><div><div><h3 class="title">9.26.6. Comment Information Functions <a href="#FUNCTIONS-INFO-COMMENT" class="id_link">#</a></h3></div></div></div><a id="id-1.5.8.32.8.2" class="indexterm"></a><p>
The functions shown in <a class="xref" href="functions-info.html#FUNCTIONS-INFO-COMMENT-TABLE" title="Table 9.78. Comment Information Functions">Table 9.78</a>
extract comments previously stored with the <a class="xref" href="sql-comment.html" title="COMMENT"><span class="refentrytitle">COMMENT</span></a>
command. A null value is returned if no
comment could be found for the specified parameters.
</p><div class="table" id="FUNCTIONS-INFO-COMMENT-TABLE"><p class="title"><strong>Table 9.78. Comment Information Functions</strong></p><div class="table-contents"><table class="table" summary="Comment Information Functions" border="1"><colgroup><col /></colgroup><thead><tr><th class="func_table_entry"><p class="func_signature">
Function
</p>
<p>
Description
</p></th></tr></thead><tbody><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.8.4.2.2.1.1.1.1" class="indexterm"></a>
<code class="function">col_description</code> ( <em class="parameter"><code>table</code></em> <code class="type">oid</code>, <em class="parameter"><code>column</code></em> <code class="type">integer</code> )
→ <code class="returnvalue">text</code>
</p>
<p>
Returns the comment for a table column, which is specified by the OID
of its table and its column number.
(<code class="function">obj_description</code> cannot be used for table
columns, since columns do not have OIDs of their own.)
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.8.4.2.2.2.1.1.1" class="indexterm"></a>
<code class="function">obj_description</code> ( <em class="parameter"><code>object</code></em> <code class="type">oid</code>, <em class="parameter"><code>catalog</code></em> <code class="type">name</code> )
→ <code class="returnvalue">text</code>
</p>
<p>
Returns the comment for a database object specified by its OID and the
name of the containing system catalog. For
example, <code class="literal">obj_description(123456, 'pg_class')</code> would
retrieve the comment for the table with OID 123456.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<code class="function">obj_description</code> ( <em class="parameter"><code>object</code></em> <code class="type">oid</code> )
→ <code class="returnvalue">text</code>
</p>
<p>
Returns the comment for a database object specified by its OID alone.
This is <span class="emphasis"><em>deprecated</em></span> since there is no guarantee
that OIDs are unique across different system catalogs; therefore, the
wrong comment might be returned.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.8.4.2.2.4.1.1.1" class="indexterm"></a>
<code class="function">shobj_description</code> ( <em class="parameter"><code>object</code></em> <code class="type">oid</code>, <em class="parameter"><code>catalog</code></em> <code class="type">name</code> )
→ <code class="returnvalue">text</code>
</p>
<p>
Returns the comment for a shared database object specified by its OID
and the name of the containing system catalog. This is just
like <code class="function">obj_description</code> except that it is used for
retrieving comments on shared objects (that is, databases, roles, and
tablespaces). Some system catalogs are global to all databases within
each cluster, and the descriptions for objects in them are stored
globally as well.
</p></td></tr></tbody></table></div></div><br class="table-break" /></div><div class="sect2" id="FUNCTIONS-INFO-VALIDITY"><div class="titlepage"><div><div><h3 class="title">9.26.7. Data Validity Checking Functions <a href="#FUNCTIONS-INFO-VALIDITY" class="id_link">#</a></h3></div></div></div><p>
The functions shown in <a class="xref" href="functions-info.html#FUNCTIONS-INFO-VALIDITY-TABLE" title="Table 9.79. Data Validity Checking Functions">Table 9.79</a>
can be helpful for checking validity of proposed input data.
</p><div class="table" id="FUNCTIONS-INFO-VALIDITY-TABLE"><p class="title"><strong>Table 9.79. Data Validity Checking Functions</strong></p><div class="table-contents"><table class="table" summary="Data Validity Checking Functions" border="1"><colgroup><col /></colgroup><thead><tr><th class="func_table_entry"><p class="func_signature">
Function
</p>
<p>
Description
</p>
<p>
Example(s)
</p></th></tr></thead><tbody><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.9.3.2.2.1.1.1.1" class="indexterm"></a>
<code class="function">pg_input_is_valid</code> (
<em class="parameter"><code>string</code></em> <code class="type">text</code>,
<em class="parameter"><code>type</code></em> <code class="type">text</code>
)
→ <code class="returnvalue">boolean</code>
</p>
<p>
Tests whether the given <em class="parameter"><code>string</code></em> is valid
input for the specified data type, returning true or false.
</p>
<p>
This function will only work as desired if the data type's input
function has been updated to report invalid input as
a <span class="quote">“<span class="quote">soft</span>”</span> error. Otherwise, invalid input will abort
the transaction, just as if the string had been cast to the type
directly.
</p>
<p>
<code class="literal">pg_input_is_valid('42', 'integer')</code>
→ <code class="returnvalue">t</code>
</p>
<p>
<code class="literal">pg_input_is_valid('42000000000', 'integer')</code>
→ <code class="returnvalue">f</code>
</p>
<p>
<code class="literal">pg_input_is_valid('1234.567', 'numeric(7,4)')</code>
→ <code class="returnvalue">f</code>
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.9.3.2.2.2.1.1.1" class="indexterm"></a>
<code class="function">pg_input_error_info</code> (
<em class="parameter"><code>string</code></em> <code class="type">text</code>,
<em class="parameter"><code>type</code></em> <code class="type">text</code>
)
→ <code class="returnvalue">record</code>
( <em class="parameter"><code>message</code></em> <code class="type">text</code>,
<em class="parameter"><code>detail</code></em> <code class="type">text</code>,
<em class="parameter"><code>hint</code></em> <code class="type">text</code>,
<em class="parameter"><code>sql_error_code</code></em> <code class="type">text</code> )
</p>
<p>
Tests whether the given <em class="parameter"><code>string</code></em> is valid
input for the specified data type; if not, return the details of
the error that would have been thrown. If the input is valid, the
results are NULL. The inputs are the same as
for <code class="function">pg_input_is_valid</code>.
</p>
<p>
This function will only work as desired if the data type's input
function has been updated to report invalid input as
a <span class="quote">“<span class="quote">soft</span>”</span> error. Otherwise, invalid input will abort
the transaction, just as if the string had been cast to the type
directly.
</p>
<p>
<code class="literal">select * from pg_input_error_info('42000000000', 'integer')</code>
→ <code class="returnvalue"></code>
</p><pre class="programlisting">
message | detail | hint | sql_error_code
------------------------------------------------------+--------+------+----------------
value "42000000000" is out of range for type integer | | | 22003
</pre><p>
</p>
<p>
<code class="literal">select message, detail from pg_input_error_info('1234.567', 'numeric(7,4)')</code>
→ <code class="returnvalue"></code>
</p><pre class="programlisting">
message | detail
------------------------+-----------------------------------------------------------------------------------
numeric field overflow | A field with precision 7, scale 4 must round to an absolute value less than 10^3.
</pre><p>
</p></td></tr></tbody></table></div></div><br class="table-break" /></div><div class="sect2" id="FUNCTIONS-INFO-SNAPSHOT"><div class="titlepage"><div><div><h3 class="title">9.26.8. Transaction ID and Snapshot Information Functions <a href="#FUNCTIONS-INFO-SNAPSHOT" class="id_link">#</a></h3></div></div></div><p>
The functions shown in <a class="xref" href="functions-info.html#FUNCTIONS-PG-SNAPSHOT" title="Table 9.80. Transaction ID and Snapshot Information Functions">Table 9.80</a>
provide server transaction information in an exportable form. The main
use of these functions is to determine which transactions were committed
between two snapshots.
</p><div class="table" id="FUNCTIONS-PG-SNAPSHOT"><p class="title"><strong>Table 9.80. Transaction ID and Snapshot Information Functions</strong></p><div class="table-contents"><table class="table" summary="Transaction ID and Snapshot Information Functions" border="1"><colgroup><col /></colgroup><thead><tr><th class="func_table_entry"><p class="func_signature">
Function
</p>
<p>
Description
</p></th></tr></thead><tbody><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.10.3.2.2.1.1.1.1" class="indexterm"></a>
<code class="function">pg_current_xact_id</code> ()
→ <code class="returnvalue">xid8</code>
</p>
<p>
Returns the current transaction's ID. It will assign a new one if the
current transaction does not have one already (because it has not
performed any database updates); see <a class="xref" href="transaction-id.html" title="74.1. Transactions and Identifiers">Section 74.1</a> for details. If executed in a
subtransaction, this will return the top-level transaction ID;
see <a class="xref" href="subxacts.html" title="74.3. Subtransactions">Section 74.3</a> for details.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.10.3.2.2.2.1.1.1" class="indexterm"></a>
<code class="function">pg_current_xact_id_if_assigned</code> ()
→ <code class="returnvalue">xid8</code>
</p>
<p>
Returns the current transaction's ID, or <code class="literal">NULL</code> if no
ID is assigned yet. (It's best to use this variant if the transaction
might otherwise be read-only, to avoid unnecessary consumption of an
XID.)
If executed in a subtransaction, this will return the top-level
transaction ID.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.10.3.2.2.3.1.1.1" class="indexterm"></a>
<code class="function">pg_xact_status</code> ( <code class="type">xid8</code> )
→ <code class="returnvalue">text</code>
</p>
<p>
Reports the commit status of a recent transaction.
The result is one of <code class="literal">in progress</code>,
<code class="literal">committed</code>, or <code class="literal">aborted</code>,
provided that the transaction is recent enough that the system retains
the commit status of that transaction.
If it is old enough that no references to the transaction survive in
the system and the commit status information has been discarded, the
result is <code class="literal">NULL</code>.
Applications might use this function, for example, to determine
whether their transaction committed or aborted after the application
and database server become disconnected while
a <code class="literal">COMMIT</code> is in progress.
Note that prepared transactions are reported as <code class="literal">in
progress</code>; applications must check <a class="link" href="view-pg-prepared-xacts.html" title="54.16. pg_prepared_xacts"><code class="structname">pg_prepared_xacts</code></a>
if they need to determine whether a transaction ID belongs to a
prepared transaction.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.10.3.2.2.4.1.1.1" class="indexterm"></a>
<code class="function">pg_current_snapshot</code> ()
→ <code class="returnvalue">pg_snapshot</code>
</p>
<p>
Returns a current <em class="firstterm">snapshot</em>, a data structure
showing which transaction IDs are now in-progress.
Only top-level transaction IDs are included in the snapshot;
subtransaction IDs are not shown; see <a class="xref" href="subxacts.html" title="74.3. Subtransactions">Section 74.3</a>
for details.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.10.3.2.2.5.1.1.1" class="indexterm"></a>
<code class="function">pg_snapshot_xip</code> ( <code class="type">pg_snapshot</code> )
→ <code class="returnvalue">setof xid8</code>
</p>
<p>
Returns the set of in-progress transaction IDs contained in a snapshot.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.10.3.2.2.6.1.1.1" class="indexterm"></a>
<code class="function">pg_snapshot_xmax</code> ( <code class="type">pg_snapshot</code> )
→ <code class="returnvalue">xid8</code>
</p>
<p>
Returns the <code class="structfield">xmax</code> of a snapshot.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.10.3.2.2.7.1.1.1" class="indexterm"></a>
<code class="function">pg_snapshot_xmin</code> ( <code class="type">pg_snapshot</code> )
→ <code class="returnvalue">xid8</code>
</p>
<p>
Returns the <code class="structfield">xmin</code> of a snapshot.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.10.3.2.2.8.1.1.1" class="indexterm"></a>
<code class="function">pg_visible_in_snapshot</code> ( <code class="type">xid8</code>, <code class="type">pg_snapshot</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
Is the given transaction ID <em class="firstterm">visible</em> according
to this snapshot (that is, was it completed before the snapshot was
taken)? Note that this function will not give the correct answer for
a subtransaction ID (subxid); see <a class="xref" href="subxacts.html" title="74.3. Subtransactions">Section 74.3</a> for
details.
</p></td></tr></tbody></table></div></div><br class="table-break" /><p>
The internal transaction ID type <code class="type">xid</code> is 32 bits wide and
wraps around every 4 billion transactions. However,
the functions shown in <a class="xref" href="functions-info.html#FUNCTIONS-PG-SNAPSHOT" title="Table 9.80. Transaction ID and Snapshot Information Functions">Table 9.80</a> use a
64-bit type <code class="type">xid8</code> that does not wrap around during the life
of an installation and can be converted to <code class="type">xid</code> by casting if
required; see <a class="xref" href="transaction-id.html" title="74.1. Transactions and Identifiers">Section 74.1</a> for details.
The data type <code class="type">pg_snapshot</code> stores information about
transaction ID visibility at a particular moment in time. Its components
are described in <a class="xref" href="functions-info.html#FUNCTIONS-PG-SNAPSHOT-PARTS" title="Table 9.81. Snapshot Components">Table 9.81</a>.
<code class="type">pg_snapshot</code>'s textual representation is
<code class="literal"><em class="replaceable"><code>xmin</code></em>:<em class="replaceable"><code>xmax</code></em>:<em class="replaceable"><code>xip_list</code></em></code>.
For example <code class="literal">10:20:10,14,15</code> means
<code class="literal">xmin=10, xmax=20, xip_list=10, 14, 15</code>.
</p><div class="table" id="FUNCTIONS-PG-SNAPSHOT-PARTS"><p class="title"><strong>Table 9.81. Snapshot Components</strong></p><div class="table-contents"><table class="table" summary="Snapshot Components" border="1"><colgroup><col /><col /></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><code class="structfield">xmin</code></td><td>
Lowest transaction ID that was still active. All transaction IDs
less than <code class="structfield">xmin</code> are either committed and visible,
or rolled back and dead.
</td></tr><tr><td><code class="structfield">xmax</code></td><td>
One past the highest completed transaction ID. All transaction IDs
greater than or equal to <code class="structfield">xmax</code> had not yet
completed as of the time of the snapshot, and thus are invisible.
</td></tr><tr><td><code class="structfield">xip_list</code></td><td>
Transactions in progress at the time of the snapshot. A transaction
ID that is <code class="literal">xmin <= <em class="replaceable"><code>X</code></em> <
xmax</code> and not in this list was already completed at the time
of the snapshot, and thus is either visible or dead according to its
commit status. This list does not include the transaction IDs of
subtransactions (subxids).
</td></tr></tbody></table></div></div><br class="table-break" /><p>
In releases of <span class="productname">PostgreSQL</span> before 13 there was
no <code class="type">xid8</code> type, so variants of these functions were provided
that used <code class="type">bigint</code> to represent a 64-bit XID, with a
correspondingly distinct snapshot data type <code class="type">txid_snapshot</code>.
These older functions have <code class="literal">txid</code> in their names. They
are still supported for backward compatibility, but may be removed from a
future release. See <a class="xref" href="functions-info.html#FUNCTIONS-TXID-SNAPSHOT" title="Table 9.82. Deprecated Transaction ID and Snapshot Information Functions">Table 9.82</a>.
</p><div class="table" id="FUNCTIONS-TXID-SNAPSHOT"><p class="title"><strong>Table 9.82. Deprecated Transaction ID and Snapshot Information Functions</strong></p><div class="table-contents"><table class="table" summary="Deprecated Transaction ID and Snapshot Information Functions" border="1"><colgroup><col /></colgroup><thead><tr><th class="func_table_entry"><p class="func_signature">
Function
</p>
<p>
Description
</p></th></tr></thead><tbody><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.10.7.2.2.1.1.1.1" class="indexterm"></a>
<code class="function">txid_current</code> ()
→ <code class="returnvalue">bigint</code>
</p>
<p>
See <code class="function">pg_current_xact_id()</code>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.10.7.2.2.2.1.1.1" class="indexterm"></a>
<code class="function">txid_current_if_assigned</code> ()
→ <code class="returnvalue">bigint</code>
</p>
<p>
See <code class="function">pg_current_xact_id_if_assigned()</code>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.10.7.2.2.3.1.1.1" class="indexterm"></a>
<code class="function">txid_current_snapshot</code> ()
→ <code class="returnvalue">txid_snapshot</code>
</p>
<p>
See <code class="function">pg_current_snapshot()</code>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.10.7.2.2.4.1.1.1" class="indexterm"></a>
<code class="function">txid_snapshot_xip</code> ( <code class="type">txid_snapshot</code> )
→ <code class="returnvalue">setof bigint</code>
</p>
<p>
See <code class="function">pg_snapshot_xip()</code>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.10.7.2.2.5.1.1.1" class="indexterm"></a>
<code class="function">txid_snapshot_xmax</code> ( <code class="type">txid_snapshot</code> )
→ <code class="returnvalue">bigint</code>
</p>
<p>
See <code class="function">pg_snapshot_xmax()</code>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.10.7.2.2.6.1.1.1" class="indexterm"></a>
<code class="function">txid_snapshot_xmin</code> ( <code class="type">txid_snapshot</code> )
→ <code class="returnvalue">bigint</code>
</p>
<p>
See <code class="function">pg_snapshot_xmin()</code>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.10.7.2.2.7.1.1.1" class="indexterm"></a>
<code class="function">txid_visible_in_snapshot</code> ( <code class="type">bigint</code>, <code class="type">txid_snapshot</code> )
→ <code class="returnvalue">boolean</code>
</p>
<p>
See <code class="function">pg_visible_in_snapshot()</code>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.10.7.2.2.8.1.1.1" class="indexterm"></a>
<code class="function">txid_status</code> ( <code class="type">bigint</code> )
→ <code class="returnvalue">text</code>
</p>
<p>
See <code class="function">pg_xact_status()</code>.
</p></td></tr></tbody></table></div></div><br class="table-break" /></div><div class="sect2" id="FUNCTIONS-INFO-COMMIT-TIMESTAMP"><div class="titlepage"><div><div><h3 class="title">9.26.9. Committed Transaction Information Functions <a href="#FUNCTIONS-INFO-COMMIT-TIMESTAMP" class="id_link">#</a></h3></div></div></div><p>
The functions shown in <a class="xref" href="functions-info.html#FUNCTIONS-COMMIT-TIMESTAMP" title="Table 9.83. Committed Transaction Information Functions">Table 9.83</a>
provide information about when past transactions were committed.
They only provide useful data when the
<a class="xref" href="runtime-config-replication.html#GUC-TRACK-COMMIT-TIMESTAMP">track_commit_timestamp</a> configuration option is
enabled, and only for transactions that were committed after it was
enabled. Commit timestamp information is routinely removed during
vacuum.
</p><div class="table" id="FUNCTIONS-COMMIT-TIMESTAMP"><p class="title"><strong>Table 9.83. Committed Transaction Information Functions</strong></p><div class="table-contents"><table class="table" summary="Committed Transaction Information Functions" border="1"><colgroup><col /></colgroup><thead><tr><th class="func_table_entry"><p class="func_signature">
Function
</p>
<p>
Description
</p></th></tr></thead><tbody><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.11.3.2.2.1.1.1.1" class="indexterm"></a>
<code class="function">pg_xact_commit_timestamp</code> ( <code class="type">xid</code> )
→ <code class="returnvalue">timestamp with time zone</code>
</p>
<p>
Returns the commit timestamp of a transaction.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.11.3.2.2.2.1.1.1" class="indexterm"></a>
<code class="function">pg_xact_commit_timestamp_origin</code> ( <code class="type">xid</code> )
→ <code class="returnvalue">record</code>
( <em class="parameter"><code>timestamp</code></em> <code class="type">timestamp with time zone</code>,
<em class="parameter"><code>roident</code></em> <code class="type">oid</code>)
</p>
<p>
Returns the commit timestamp and replication origin of a transaction.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.11.3.2.2.3.1.1.1" class="indexterm"></a>
<code class="function">pg_last_committed_xact</code> ()
→ <code class="returnvalue">record</code>
( <em class="parameter"><code>xid</code></em> <code class="type">xid</code>,
<em class="parameter"><code>timestamp</code></em> <code class="type">timestamp with time zone</code>,
<em class="parameter"><code>roident</code></em> <code class="type">oid</code> )
</p>
<p>
Returns the transaction ID, commit timestamp and replication origin
of the latest committed transaction.
</p></td></tr></tbody></table></div></div><br class="table-break" /></div><div class="sect2" id="FUNCTIONS-INFO-CONTROLDATA"><div class="titlepage"><div><div><h3 class="title">9.26.10. Control Data Functions <a href="#FUNCTIONS-INFO-CONTROLDATA" class="id_link">#</a></h3></div></div></div><p>
The functions shown in <a class="xref" href="functions-info.html#FUNCTIONS-CONTROLDATA" title="Table 9.84. Control Data Functions">Table 9.84</a>
print information initialized during <code class="command">initdb</code>, such
as the catalog version. They also show information about write-ahead
logging and checkpoint processing. This information is cluster-wide,
not specific to any one database. These functions provide most of the same
information, from the same source, as the
<a class="xref" href="app-pgcontroldata.html" title="pg_controldata"><span class="refentrytitle"><span class="application">pg_controldata</span></span></a> application.
</p><div class="table" id="FUNCTIONS-CONTROLDATA"><p class="title"><strong>Table 9.84. Control Data Functions</strong></p><div class="table-contents"><table class="table" summary="Control Data Functions" border="1"><colgroup><col /></colgroup><thead><tr><th class="func_table_entry"><p class="func_signature">
Function
</p>
<p>
Description
</p></th></tr></thead><tbody><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.12.3.2.2.1.1.1.1" class="indexterm"></a>
<code class="function">age</code> ( <code class="type">xid</code> )
→ <code class="returnvalue">integer</code>
</p>
<p>
Returns the number of transactions between the supplied
transaction id and the current transaction counter.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.12.3.2.2.2.1.1.1" class="indexterm"></a>
<code class="function">mxid_age</code> ( <code class="type">xid</code> )
→ <code class="returnvalue">integer</code>
</p>
<p>
Returns the number of multixacts IDs between the supplied
multixact ID and the current multixacts counter.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.12.3.2.2.3.1.1.1" class="indexterm"></a>
<code class="function">pg_control_checkpoint</code> ()
→ <code class="returnvalue">record</code>
</p>
<p>
Returns information about current checkpoint state, as shown in
<a class="xref" href="functions-info.html#FUNCTIONS-PG-CONTROL-CHECKPOINT" title="Table 9.85. pg_control_checkpoint Output Columns">Table 9.85</a>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.12.3.2.2.4.1.1.1" class="indexterm"></a>
<code class="function">pg_control_system</code> ()
→ <code class="returnvalue">record</code>
</p>
<p>
Returns information about current control file state, as shown in
<a class="xref" href="functions-info.html#FUNCTIONS-PG-CONTROL-SYSTEM" title="Table 9.86. pg_control_system Output Columns">Table 9.86</a>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.12.3.2.2.5.1.1.1" class="indexterm"></a>
<code class="function">pg_control_init</code> ()
→ <code class="returnvalue">record</code>
</p>
<p>
Returns information about cluster initialization state, as shown in
<a class="xref" href="functions-info.html#FUNCTIONS-PG-CONTROL-INIT" title="Table 9.87. pg_control_init Output Columns">Table 9.87</a>.
</p></td></tr><tr><td class="func_table_entry"><p class="func_signature">
<a id="id-1.5.8.32.12.3.2.2.6.1.1.1" class="indexterm"></a>
<code class="function">pg_control_recovery</code> ()
→ <code class="returnvalue">record</code>
</p>
<p>
Returns information about recovery state, as shown in
<a class="xref" href="functions-info.html#FUNCTIONS-PG-CONTROL-RECOVERY" title="Table 9.88. pg_control_recovery Output Columns">Table 9.88</a>.
</p></td></tr></tbody></table></div></div><br class="table-break" /><div class="table" id="FUNCTIONS-PG-CONTROL-CHECKPOINT"><p class="title"><strong>Table 9.85. <code class="function">pg_control_checkpoint</code> Output Columns</strong></p><div class="table-contents"><table class="table" summary="pg_control_checkpoint Output Columns" border="1"><colgroup><col /><col /></colgroup><thead><tr><th>Column Name</th><th>Data Type</th></tr></thead><tbody><tr><td><code class="structfield">checkpoint_lsn</code></td><td><code class="type">pg_lsn</code></td></tr><tr><td><code class="structfield">redo_lsn</code></td><td><code class="type">pg_lsn</code></td></tr><tr><td><code class="structfield">redo_wal_file</code></td><td><code class="type">text</code></td></tr><tr><td><code class="structfield">timeline_id</code></td><td><code class="type">integer</code></td></tr><tr><td><code class="structfield">prev_timeline_id</code></td><td><code class="type">integer</code></td></tr><tr><td><code class="structfield">full_page_writes</code></td><td><code class="type">boolean</code></td></tr><tr><td><code class="structfield">next_xid</code></td><td><code class="type">text</code></td></tr><tr><td><code class="structfield">next_oid</code></td><td><code class="type">oid</code></td></tr><tr><td><code class="structfield">next_multixact_id</code></td><td><code class="type">xid</code></td></tr><tr><td><code class="structfield">next_multi_offset</code></td><td><code class="type">xid</code></td></tr><tr><td><code class="structfield">oldest_xid</code></td><td><code class="type">xid</code></td></tr><tr><td><code class="structfield">oldest_xid_dbid</code></td><td><code class="type">oid</code></td></tr><tr><td><code class="structfield">oldest_active_xid</code></td><td><code class="type">xid</code></td></tr><tr><td><code class="structfield">oldest_multi_xid</code></td><td><code class="type">xid</code></td></tr><tr><td><code class="structfield">oldest_multi_dbid</code></td><td><code class="type">oid</code></td></tr><tr><td><code class="structfield">oldest_commit_ts_xid</code></td><td><code class="type">xid</code></td></tr><tr><td><code class="structfield">newest_commit_ts_xid</code></td><td><code class="type">xid</code></td></tr><tr><td><code class="structfield">checkpoint_time</code></td><td><code class="type">timestamp with time zone</code></td></tr></tbody></table></div></div><br class="table-break" /><div class="table" id="FUNCTIONS-PG-CONTROL-SYSTEM"><p class="title"><strong>Table 9.86. <code class="function">pg_control_system</code> Output Columns</strong></p><div class="table-contents"><table class="table" summary="pg_control_system Output Columns" border="1"><colgroup><col /><col /></colgroup><thead><tr><th>Column Name</th><th>Data Type</th></tr></thead><tbody><tr><td><code class="structfield">pg_control_version</code></td><td><code class="type">integer</code></td></tr><tr><td><code class="structfield">catalog_version_no</code></td><td><code class="type">integer</code></td></tr><tr><td><code class="structfield">system_identifier</code></td><td><code class="type">bigint</code></td></tr><tr><td><code class="structfield">pg_control_last_modified</code></td><td><code class="type">timestamp with time zone</code></td></tr></tbody></table></div></div><br class="table-break" /><div class="table" id="FUNCTIONS-PG-CONTROL-INIT"><p class="title"><strong>Table 9.87. <code class="function">pg_control_init</code> Output Columns</strong></p><div class="table-contents"><table class="table" summary="pg_control_init Output Columns" border="1"><colgroup><col /><col /></colgroup><thead><tr><th>Column Name</th><th>Data Type</th></tr></thead><tbody><tr><td><code class="structfield">max_data_alignment</code></td><td><code class="type">integer</code></td></tr><tr><td><code class="structfield">database_block_size</code></td><td><code class="type">integer</code></td></tr><tr><td><code class="structfield">blocks_per_segment</code></td><td><code class="type">integer</code></td></tr><tr><td><code class="structfield">wal_block_size</code></td><td><code class="type">integer</code></td></tr><tr><td><code class="structfield">bytes_per_wal_segment</code></td><td><code class="type">integer</code></td></tr><tr><td><code class="structfield">max_identifier_length</code></td><td><code class="type">integer</code></td></tr><tr><td><code class="structfield">max_index_columns</code></td><td><code class="type">integer</code></td></tr><tr><td><code class="structfield">max_toast_chunk_size</code></td><td><code class="type">integer</code></td></tr><tr><td><code class="structfield">large_object_chunk_size</code></td><td><code class="type">integer</code></td></tr><tr><td><code class="structfield">float8_pass_by_value</code></td><td><code class="type">boolean</code></td></tr><tr><td><code class="structfield">data_page_checksum_version</code></td><td><code class="type">integer</code></td></tr></tbody></table></div></div><br class="table-break" /><div class="table" id="FUNCTIONS-PG-CONTROL-RECOVERY"><p class="title"><strong>Table 9.88. <code class="function">pg_control_recovery</code> Output Columns</strong></p><div class="table-contents"><table class="table" summary="pg_control_recovery Output Columns" border="1"><colgroup><col /><col /></colgroup><thead><tr><th>Column Name</th><th>Data Type</th></tr></thead><tbody><tr><td><code class="structfield">min_recovery_end_lsn</code></td><td><code class="type">pg_lsn</code></td></tr><tr><td><code class="structfield">min_recovery_end_timeline</code></td><td><code class="type">integer</code></td></tr><tr><td><code class="structfield">backup_start_lsn</code></td><td><code class="type">pg_lsn</code></td></tr><tr><td><code class="structfield">backup_end_lsn</code></td><td><code class="type">pg_lsn</code></td></tr><tr><td><code class="structfield">end_of_backup_record_required</code></td><td><code class="type">boolean</code></td></tr></tbody></table></div></div><br class="table-break" /></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="functions-srf.html" title="9.25. Set Returning Functions">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="functions.html" title="Chapter 9. Functions and Operators">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="functions-admin.html" title="9.27. System Administration Functions">Next</a></td></tr><tr><td width="40%" align="left" valign="top">9.25. Set Returning Functions </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 9.27. System Administration Functions</td></tr></table></div></body></html>
|