From 0144eb92bbffe25945e57b1c153ddaae93b9f196 Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Fri, 21 Jul 2006 20:51:33 +0000
Subject: [PATCH] Add the full set of comparison functions for type TID,
 including a btree opclass.  This is not so much because anyone's likely to
 create an index on TID, as that sorting TIDs can be useful.  Also added max
 and min aggregates while at it, so that one can investigate the clusteredness
 of a table with queries like SELECT min(ctid), max(ctid) FROM tab WHERE ...
 Greg Stark and Tom Lane

---
 src/backend/utils/adt/tid.c        | 104 +++++++++++++++++++++++++----
 src/include/catalog/catversion.h   |   4 +-
 src/include/catalog/pg_aggregate.h |   4 +-
 src/include/catalog/pg_amop.h      |  12 +++-
 src/include/catalog/pg_amproc.h    |   3 +-
 src/include/catalog/pg_opclass.h   |   3 +-
 src/include/catalog/pg_operator.h  |  13 +++-
 src/include/catalog/pg_proc.h      |  66 ++++++++++--------
 src/include/utils/builtins.h       |   9 ++-
 9 files changed, 167 insertions(+), 51 deletions(-)

diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c
index 658108f56c2..814670521ea 100644
--- a/src/backend/utils/adt/tid.c
+++ b/src/backend/utils/adt/tid.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/utils/adt/tid.c,v 1.53 2006/07/14 05:28:28 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/utils/adt/tid.c,v 1.54 2006/07/21 20:51:32 tgl Exp $
  *
  * NOTES
  *	  input routine largely stolen from boxin().
@@ -98,16 +98,11 @@ Datum
 tidout(PG_FUNCTION_ARGS)
 {
 	ItemPointer itemPtr = PG_GETARG_ITEMPOINTER(0);
-	BlockId		blockId;
 	BlockNumber blockNumber;
 	OffsetNumber offsetNumber;
 	char		buf[32];
 
-	if (!ItemPointerIsValid(itemPtr))
-		PG_RETURN_CSTRING(pstrdup("()"));
-
-	blockId = &(itemPtr->ip_blkid);
-	blockNumber = BlockIdGetBlockNumber(blockId);
+	blockNumber = BlockIdGetBlockNumber(&(itemPtr->ip_blkid));
 	offsetNumber = itemPtr->ip_posid;
 
 	/* Perhaps someday we should output this as a record. */
@@ -163,15 +158,36 @@ tidsend(PG_FUNCTION_ARGS)
  *	 PUBLIC ROUTINES														 *
  *****************************************************************************/
 
+static int32
+tid_cmp_internal(ItemPointer arg1, ItemPointer arg2)
+{
+	/*
+	 * Don't use ItemPointerGetBlockNumber or ItemPointerGetOffsetNumber here,
+	 * because they assert ip_posid != 0 which might not be true for a
+	 * user-supplied TID.
+	 */
+	BlockNumber b1 = BlockIdGetBlockNumber(&(arg1->ip_blkid));
+	BlockNumber b2 = BlockIdGetBlockNumber(&(arg2->ip_blkid));
+	
+	if (b1 < b2)
+		return -1;
+	else if (b1 > b2)
+		return 1;
+	else if (arg1->ip_posid < arg2->ip_posid)
+		return -1;
+	else if (arg1->ip_posid > arg2->ip_posid)
+		return 1;
+	else
+		return 0;
+}
+
 Datum
 tideq(PG_FUNCTION_ARGS)
 {
 	ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0);
 	ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1);
 
-	PG_RETURN_BOOL(BlockIdGetBlockNumber(&(arg1->ip_blkid)) ==
-				   BlockIdGetBlockNumber(&(arg2->ip_blkid)) &&
-				   arg1->ip_posid == arg2->ip_posid);
+	PG_RETURN_BOOL(tid_cmp_internal(arg1,arg2) == 0);
 }
 
 Datum
@@ -180,11 +196,73 @@ tidne(PG_FUNCTION_ARGS)
 	ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0);
 	ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1);
 
-	PG_RETURN_BOOL(BlockIdGetBlockNumber(&(arg1->ip_blkid)) !=
-				   BlockIdGetBlockNumber(&(arg2->ip_blkid)) ||
-				   arg1->ip_posid != arg2->ip_posid);
+	PG_RETURN_BOOL(tid_cmp_internal(arg1,arg2) != 0);
 }
 
+Datum
+tidlt(PG_FUNCTION_ARGS)
+{
+	ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0);
+	ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1);
+
+	PG_RETURN_BOOL(tid_cmp_internal(arg1,arg2) < 0);
+}
+
+Datum
+tidle(PG_FUNCTION_ARGS)
+{
+	ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0);
+	ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1);
+
+	PG_RETURN_BOOL(tid_cmp_internal(arg1,arg2) <= 0);
+}
+
+Datum
+tidgt(PG_FUNCTION_ARGS)
+{
+	ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0);
+	ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1);
+
+	PG_RETURN_BOOL(tid_cmp_internal(arg1,arg2) > 0);
+}
+
+Datum
+tidge(PG_FUNCTION_ARGS)
+{
+	ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0);
+	ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1);
+
+	PG_RETURN_BOOL(tid_cmp_internal(arg1,arg2) >= 0);
+}
+
+Datum
+bttidcmp(PG_FUNCTION_ARGS)
+{
+	ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0);
+	ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1);
+
+	PG_RETURN_INT32(tid_cmp_internal(arg1, arg2));
+}
+
+Datum
+tidlarger(PG_FUNCTION_ARGS)
+{
+	ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0);
+	ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1);
+
+	PG_RETURN_ITEMPOINTER(tid_cmp_internal(arg1,arg2) >= 0 ? arg1 : arg2);
+}
+
+Datum
+tidsmaller(PG_FUNCTION_ARGS)
+{
+	ItemPointer arg1 = PG_GETARG_ITEMPOINTER(0);
+	ItemPointer arg2 = PG_GETARG_ITEMPOINTER(1);
+
+	PG_RETURN_ITEMPOINTER(tid_cmp_internal(arg1,arg2) <= 0 ? arg1 : arg2);
+}
+
+
 /*
  *	Functions to get latest tid of a specified tuple.
  *
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 6edcacc0f54..ce03edd0b16 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -37,7 +37,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.338 2006/07/11 19:49:13 teodor Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.339 2006/07/21 20:51:33 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -53,6 +53,6 @@
  */
 
 /*							yyyymmddN */
-#define CATALOG_VERSION_NO	200607111
+#define CATALOG_VERSION_NO	200607211
 
 #endif
diff --git a/src/include/catalog/pg_aggregate.h b/src/include/catalog/pg_aggregate.h
index 9f3c1ed9c34..e9d5c5151ab 100644
--- a/src/include/catalog/pg_aggregate.h
+++ b/src/include/catalog/pg_aggregate.h
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/pg_aggregate.h,v 1.54 2006/03/10 20:15:26 neilc Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_aggregate.h,v 1.55 2006/07/21 20:51:33 tgl Exp $
  *
  * NOTES
  *	  the genbki.sh script reads this file and generates .bki
@@ -117,6 +117,7 @@ DATA(insert ( 2129	text_larger		-				666		25		_null_ ));
 DATA(insert ( 2130	numeric_larger	-				1756	1700	_null_ ));
 DATA(insert ( 2050	array_larger	-				1073	2277	_null_ ));
 DATA(insert ( 2244	bpchar_larger	-				1060	1042	_null_ ));
+DATA(insert ( 2797	tidlarger		-				2800	27		_null_ ));
 
 /* min */
 DATA(insert ( 2131	int8smaller		-				412		20		_null_ ));
@@ -137,6 +138,7 @@ DATA(insert ( 2145	text_smaller	-				664		25		_null_ ));
 DATA(insert ( 2146	numeric_smaller -				1754	1700	_null_ ));
 DATA(insert ( 2051	array_smaller	-				1072	2277	_null_ ));
 DATA(insert ( 2245	bpchar_smaller	-				1058	1042	_null_ ));
+DATA(insert ( 2798	tidsmaller		-				2799	27		_null_ ));
 
 /*
  * Using int8inc for count() is cheating a little, since it really only
diff --git a/src/include/catalog/pg_amop.h b/src/include/catalog/pg_amop.h
index 27aed661ea6..0bbf6b01275 100644
--- a/src/include/catalog/pg_amop.h
+++ b/src/include/catalog/pg_amop.h
@@ -23,7 +23,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/pg_amop.h,v 1.72 2006/07/11 19:49:13 teodor Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_amop.h,v 1.73 2006/07/21 20:51:33 tgl Exp $
  *
  * NOTES
  *	 the genbki.sh script reads this file and generates .bki
@@ -156,6 +156,16 @@ DATA(insert (	1989	0 3 f  607 ));
 DATA(insert (	1989	0 4 f  612 ));
 DATA(insert (	1989	0 5 f  610 ));
 
+/*
+ * btree tid_ops
+ */
+
+DATA(insert (	2789	0 1 f 2799 ));
+DATA(insert (	2789	0 2 f 2801 ));
+DATA(insert (	2789	0 3 f 387  ));
+DATA(insert (	2789	0 4 f 2802 ));
+DATA(insert (	2789	0 5 f 2800 ));
+
 /*
  *	btree oidvector_ops
  */
diff --git a/src/include/catalog/pg_amproc.h b/src/include/catalog/pg_amproc.h
index 2c6a440aee2..17884fa4194 100644
--- a/src/include/catalog/pg_amproc.h
+++ b/src/include/catalog/pg_amproc.h
@@ -19,7 +19,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/pg_amproc.h,v 1.58 2006/05/02 15:23:16 teodor Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_amproc.h,v 1.59 2006/07/21 20:51:33 tgl Exp $
  *
  * NOTES
  *	  the genbki.sh script reads this file and generates .bki
@@ -124,6 +124,7 @@ DATA(insert (	2098	0 1 2187 ));
 DATA(insert (	2099	0 1  377 ));
 DATA(insert (	2233	0 1  380 ));
 DATA(insert (	2234	0 1  381 ));
+DATA(insert (	2789    0 1 2794 ));
 
 
 /* hash */
diff --git a/src/include/catalog/pg_opclass.h b/src/include/catalog/pg_opclass.h
index 5c86da4c5d6..cee9f752bf0 100644
--- a/src/include/catalog/pg_opclass.h
+++ b/src/include/catalog/pg_opclass.h
@@ -27,7 +27,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/pg_opclass.h,v 1.70 2006/05/02 15:23:16 teodor Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_opclass.h,v 1.71 2006/07/21 20:51:33 tgl Exp $
  *
  * NOTES
  *	  the genbki.sh script reads this file and generates .bki
@@ -162,6 +162,7 @@ DATA(insert OID = 2222 (	405		bool_ops		PGNSP PGUID   16 t 0 ));
 #define BOOL_HASH_OPS_OID 2222
 DATA(insert OID = 2223 (	405		bytea_ops		PGNSP PGUID   17 t 0 ));
 DATA(insert OID = 2224 (	405		int2vector_ops	PGNSP PGUID   22 t 0 ));
+DATA(insert OID = 2789 (	403		tid_ops			PGNSP PGUID   27 t 0 ));
 DATA(insert OID = 2225 (	405		xid_ops			PGNSP PGUID   28 t 0 ));
 DATA(insert OID = 2226 (	405		cid_ops			PGNSP PGUID   29 t 0 ));
 DATA(insert OID = 2227 (	405		abstime_ops		PGNSP PGUID  702 t 0 ));
diff --git a/src/include/catalog/pg_operator.h b/src/include/catalog/pg_operator.h
index a296bf3e41c..95349b2bf56 100644
--- a/src/include/catalog/pg_operator.h
+++ b/src/include/catalog/pg_operator.h
@@ -8,7 +8,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/pg_operator.h,v 1.143 2006/05/02 11:28:55 teodor Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_operator.h,v 1.144 2006/07/21 20:51:33 tgl Exp $
  *
  * NOTES
  *	  the genbki.sh script reads this file and generates .bki
@@ -128,9 +128,15 @@ DATA(insert OID = 388 (  "!"	   PGNSP PGUID r f	20	 0	1700   0   0   0   0  0
 DATA(insert OID = 389 (  "!!"	   PGNSP PGUID l f	 0	20	1700   0   0   0   0  0   0 numeric_fac - - ));
 DATA(insert OID = 385 (  "="	   PGNSP PGUID b t	29	29	16 385	 0	 0	 0	 0	 0 cideq eqsel eqjoinsel ));
 DATA(insert OID = 386 (  "="	   PGNSP PGUID b t	22	22	16 386	 0	 0	 0	 0	 0 int2vectoreq eqsel eqjoinsel ));
-DATA(insert OID = 387 (  "="	   PGNSP PGUID b f	27	27	16 387 402	 0	 0	 0	 0 tideq eqsel eqjoinsel ));
+
+DATA(insert OID = 387 (  "="	   PGNSP PGUID b f	27	27	16 387 402 2799 2799 2799 2800 tideq eqsel eqjoinsel ));
 #define TIDEqualOperator   387
-DATA(insert OID = 402 (  "<>"	   PGNSP PGUID b f	27	27	16 402 387	 0	 0	 0	 0 tidne neqsel neqjoinsel ));
+DATA(insert OID = 402 (  "<>"	   PGNSP PGUID b f	27	27	16 402 387 0 0 0 0 tidne neqsel neqjoinsel ));
+DATA(insert OID = 2799 (  "<"      PGNSP PGUID b f  27  27  16 2800 2802 0 0 0 0 tidlt scalarltsel scalarltjoinsel ));
+#define TIDLessOperator    2799
+DATA(insert OID = 2800 (  ">"      PGNSP PGUID b f  27  27  16 2799 2801 0 0 0 0 tidgt scalargtsel scalargtjoinsel ));
+DATA(insert OID = 2801 (  "<="     PGNSP PGUID b f  27  27  16 2802 2800 0 0 0 0 tidle scalarltsel scalarltjoinsel ));
+DATA(insert OID = 2802 (  ">="     PGNSP PGUID b f  27  27  16 2801 2799 0 0 0 0 tidge scalargtsel scalargtjoinsel ));
 
 DATA(insert OID = 410 ( "="		   PGNSP PGUID b t	20	20	16 410 411 412 412 412 413 int8eq eqsel eqjoinsel ));
 DATA(insert OID = 411 ( "<>"	   PGNSP PGUID b f	20	20	16 411 410 0 0 0 0 int8ne neqsel neqjoinsel ));
@@ -262,6 +268,7 @@ DATA(insert OID = 596 (  "|/"	   PGNSP PGUID l f	 0 701 701	 0	 0	 0	 0	 0	 0 ds
 DATA(insert OID = 597 (  "||/"	   PGNSP PGUID l f	 0 701 701	 0	 0	 0	 0	 0	 0 dcbrt - - ));
 DATA(insert OID = 1284 (  "|"	   PGNSP PGUID l f	 0 704 702	0  0   0   0   0   0 tintervalstart - - ));
 DATA(insert OID = 606 (  "<#>"	   PGNSP PGUID b f 702 702 704	0  0   0   0   0   0 mktinterval - - ));
+
 DATA(insert OID = 607 (  "="	   PGNSP PGUID b t	26	26	16 607 608 609 609 609 610 oideq eqsel eqjoinsel ));
 #define MIN_OIDCMP 607			/* used by cache code */
 DATA(insert OID = 608 (  "<>"	   PGNSP PGUID b f	26	26	16 608 607	0  0   0   0 oidne neqsel neqjoinsel ));
diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h
index efa54141536..9743d6c4a8f 100644
--- a/src/include/catalog/pg_proc.h
+++ b/src/include/catalog/pg_proc.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.415 2006/07/03 22:45:40 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.416 2006/07/21 20:51:33 tgl Exp $
  *
  * NOTES
  *	  The script catalog/genbki.sh reads this file and generates .bki
@@ -1551,11 +1551,6 @@ DESCR("matches regex., case-insensitive");
 DATA(insert OID = 1241 (  nameicregexne    PGNSP PGUID 12 f f t f i 2 16 "19 25" _null_ _null_ _null_ nameicregexne - _null_ ));
 DESCR("does not match regex., case-insensitive");
 
-DATA(insert OID = 2322 ( pg_tablespace_size		PGNSP PGUID 12 f f t f v 1 20 "26" _null_ _null_ _null_ pg_tablespace_size_oid - _null_ ));
-DESCR("Calculate total disk space usage for the specified tablespace");
-DATA(insert OID = 2323 ( pg_tablespace_size		PGNSP PGUID 12 f f t f v 1 20 "19" _null_ _null_ _null_ pg_tablespace_size_name - _null_ ));
-DESCR("Calculate total disk space usage for the specified tablespace");
-
 DATA(insert OID = 1251 (  int4abs		   PGNSP PGUID 12 f f t f i 1 23 "23" _null_ _null_ _null_	int4abs - _null_ ));
 DESCR("absolute value");
 DATA(insert OID = 1253 (  int2abs		   PGNSP PGUID 12 f f t f i 1 21 "21" _null_ _null_ _null_	int2abs - _null_ ));
@@ -1564,9 +1559,6 @@ DESCR("absolute value");
 DATA(insert OID = 1263 (  interval		   PGNSP PGUID 12 f f t f s 1 1186 "25" _null_ _null_ _null_	text_interval - _null_ ));
 DESCR("convert text to interval");
 
-DATA(insert OID = 2324 ( pg_database_size		PGNSP PGUID 12 f f t f v 1 20 "26" _null_ _null_ _null_ pg_database_size_oid - _null_ ));
-DESCR("Calculate total disk space usage for the specified database");
-
 DATA(insert OID = 1271 (  overlaps		   PGNSP PGUID 12 f f f f i 4 16 "1266 1266 1266 1266" _null_ _null_ _null_ overlaps_timetz - _null_ ));
 DESCR("SQL92 interval comparison");
 DATA(insert OID = 1272 (  datetime_pl	   PGNSP PGUID 12 f f t f i 2 1114 "1082 1083" _null_ _null_ _null_ datetime_timestamp - _null_ ));
@@ -1611,9 +1603,20 @@ DATA(insert OID = 1294 ( currtid2		   PGNSP PGUID 12 f f t f v 2 27 "25 27" _nul
 DESCR("latest tid of a tuple");
 DATA(insert OID = 1265 ( tidne			   PGNSP PGUID 12 f f t f i 2 16 "27 27" _null_ _null_ _null_ tidne - _null_ ));
 DESCR("not equal");
-
-DATA(insert OID = 2168 ( pg_database_size		PGNSP PGUID 12 f f t f v 1 20 "19" _null_ _null_ _null_ pg_database_size_name - _null_ ));
-DESCR("Calculate total disk space usage for the specified database");
+DATA(insert OID = 2790 ( tidgt			   PGNSP PGUID 12 f f t f i 2 16 "27 27" _null_ _null_ _null_ tidgt - _null_));
+DESCR("greater-than");
+DATA(insert OID = 2791 ( tidlt			   PGNSP PGUID 12 f f t f i 2 16 "27 27" _null_ _null_ _null_ tidlt - _null_));
+DESCR("less-than");
+DATA(insert OID = 2792 ( tidge			   PGNSP PGUID 12 f f t f i 2 16 "27 27" _null_ _null_ _null_ tidge - _null_));
+DESCR("greater-than-or-equal");
+DATA(insert OID = 2793 ( tidle			   PGNSP PGUID 12 f f t f i 2 16 "27 27" _null_ _null_ _null_ tidle - _null_));
+DESCR("less-than-or-equal");
+DATA(insert OID = 2794 ( bttidcmp		   PGNSP PGUID 12 f f t f i 2 23 "27 27" _null_ _null_ _null_ bttidcmp - _null_));
+DESCR("btree less-equal-greater");
+DATA(insert OID = 2795 ( tidlarger		   PGNSP PGUID 12 f f t f i 2 27 "27 27" _null_ _null_ _null_ tidlarger - _null_ ));
+DESCR("larger of two");
+DATA(insert OID = 2796 ( tidsmaller		   PGNSP PGUID 12 f f t f i 2 27 "27 27" _null_ _null_ _null_ tidsmaller - _null_ ));
+DESCR("smaller of two");
 
 DATA(insert OID = 1296 (  timedate_pl	   PGNSP PGUID 14 f f t f i 2 1114 "1083 1082" _null_ _null_ _null_ "select ($2 + $1)" - _null_ ));
 DESCR("convert time and date to timestamp");
@@ -3064,7 +3067,6 @@ DESCR("is opclass visible in search path?");
 DATA(insert OID = 2093 (  pg_conversion_is_visible	PGNSP PGUID 12 f f t f s 1 16 "26" _null_ _null_ _null_ pg_conversion_is_visible - _null_ ));
 DESCR("is conversion visible in search path?");
 
-
 DATA(insert OID = 2171 ( pg_cancel_backend		PGNSP PGUID 12 f f t f v 1 16 "23" _null_ _null_ _null_ pg_cancel_backend - _null_ ));
 DESCR("Cancel a server process' current query");
 DATA(insert OID = 2172 ( pg_start_backup		PGNSP PGUID 12 f f t f v 1 25 "25" _null_ _null_ _null_ pg_start_backup - _null_ ));
@@ -3124,6 +3126,7 @@ DATA(insert OID = 2129 (  max				PGNSP PGUID 12 t f f f i 1 25 "25" _null_ _null
 DATA(insert OID = 2130 (  max				PGNSP PGUID 12 t f f f i 1 1700 "1700" _null_ _null_ _null_ aggregate_dummy - _null_ ));
 DATA(insert OID = 2050 (  max				PGNSP PGUID 12 t f f f i 1 2277 "2277" _null_ _null_ _null_ aggregate_dummy - _null_ ));
 DATA(insert OID = 2244 (  max				PGNSP PGUID 12 t f f f i 1 1042 "1042" _null_ _null_ _null_ aggregate_dummy - _null_ ));
+DATA(insert OID = 2797 (  max				PGNSP PGUID 12 t f f f i 1 27 "27" _null_ _null_ _null_ aggregate_dummy - _null_ ));
 
 DATA(insert OID = 2131 (  min				PGNSP PGUID 12 t f f f i 1 20 "20" _null_ _null_ _null_ aggregate_dummy - _null_ ));
 DATA(insert OID = 2132 (  min				PGNSP PGUID 12 t f f f i 1 23 "23" _null_ _null_ _null_ aggregate_dummy - _null_ ));
@@ -3143,6 +3146,7 @@ DATA(insert OID = 2145 (  min				PGNSP PGUID 12 t f f f i 1 25 "25" _null_ _null
 DATA(insert OID = 2146 (  min				PGNSP PGUID 12 t f f f i 1 1700 "1700" _null_ _null_ _null_ aggregate_dummy - _null_ ));
 DATA(insert OID = 2051 (  min				PGNSP PGUID 12 t f f f i 1 2277 "2277" _null_ _null_ _null_ aggregate_dummy - _null_ ));
 DATA(insert OID = 2245 (  min				PGNSP PGUID 12 t f f f i 1 1042 "1042" _null_ _null_ _null_ aggregate_dummy - _null_ ));
+DATA(insert OID = 2798 (  min				PGNSP PGUID 12 t f f f i 1 27 "27" _null_ _null_ _null_ aggregate_dummy - _null_ ));
 
 DATA(insert OID = 2147 (  count				PGNSP PGUID 12 t f f f i 1 20 "2276" _null_ _null_ _null_  aggregate_dummy - _null_ ));
 
@@ -3305,17 +3309,6 @@ DESCR("current user privilege on schema by schema name");
 DATA(insert OID = 2273 (  has_schema_privilege		   PGNSP PGUID 12 f f t f s 2 16 "26 25" _null_ _null_ _null_ has_schema_privilege_id - _null_ ));
 DESCR("current user privilege on schema by schema oid");
 
-DATA(insert OID = 2325 ( pg_relation_size		PGNSP PGUID 12 f f t f v 1 20 "26" _null_ _null_ _null_ pg_relation_size_oid - _null_ ));
-DESCR("Calculate disk space usage for the specified table or index");
-DATA(insert OID = 2289 ( pg_relation_size		PGNSP PGUID 12 f f t f v 1 20 "25" _null_ _null_ _null_ pg_relation_size_name - _null_ ));
-DESCR("Calculate disk space usage for the specified table or index");
-DATA(insert OID = 2286 ( pg_total_relation_size		PGNSP PGUID 12 f f t f v 1 20 "26" _null_ _null_ _null_ pg_total_relation_size_oid - _null_ ));
-DESCR("Calculate total disk space usage for the specified table and associated indexes and toast tables");
-DATA(insert OID = 2287 ( pg_total_relation_size		PGNSP PGUID 12 f f t f v 1 20 "25" _null_ _null_ _null_ pg_total_relation_size_name - _null_ ));
-DESCR("Calculate total disk space usage for the specified table and associated indexes and toast tables");
-DATA(insert OID = 2288 ( pg_size_pretty			PGNSP PGUID 12 f f t f v 1 25 "20" _null_ _null_ _null_ pg_size_pretty - _null_ ));
-DESCR("Convert a long int to a human readable text using size units");
-
 DATA(insert OID = 2390 (  has_tablespace_privilege		   PGNSP PGUID 12 f f t f s 3 16 "19 25 25" _null_ _null_ _null_	has_tablespace_privilege_name_name - _null_ ));
 DESCR("user privilege on tablespace by username, tablespace name");
 DATA(insert OID = 2391 (  has_tablespace_privilege		   PGNSP PGUID 12 f f t f s 3 16 "19 26 25" _null_ _null_ _null_	has_tablespace_privilege_name_id - _null_ ));
@@ -3342,6 +3335,27 @@ DESCR("current user privilege on role by role name");
 DATA(insert OID = 2710 (  pg_has_role		PGNSP PGUID 12 f f t f s 2 16 "26 25" _null_ _null_ _null_ pg_has_role_id - _null_ ));
 DESCR("current user privilege on role by role oid");
 
+DATA(insert OID = 1269 (  pg_column_size		PGNSP PGUID 12 f f t f s 1 23 "2276" _null_ _null_ _null_  pg_column_size - _null_ ));
+DESCR("bytes required to store the value, perhaps with compression");
+DATA(insert OID = 2322 ( pg_tablespace_size		PGNSP PGUID 12 f f t f v 1 20 "26" _null_ _null_ _null_ pg_tablespace_size_oid - _null_ ));
+DESCR("Calculate total disk space usage for the specified tablespace");
+DATA(insert OID = 2323 ( pg_tablespace_size		PGNSP PGUID 12 f f t f v 1 20 "19" _null_ _null_ _null_ pg_tablespace_size_name - _null_ ));
+DESCR("Calculate total disk space usage for the specified tablespace");
+DATA(insert OID = 2324 ( pg_database_size		PGNSP PGUID 12 f f t f v 1 20 "26" _null_ _null_ _null_ pg_database_size_oid - _null_ ));
+DESCR("Calculate total disk space usage for the specified database");
+DATA(insert OID = 2168 ( pg_database_size		PGNSP PGUID 12 f f t f v 1 20 "19" _null_ _null_ _null_ pg_database_size_name - _null_ ));
+DESCR("Calculate total disk space usage for the specified database");
+DATA(insert OID = 2325 ( pg_relation_size		PGNSP PGUID 12 f f t f v 1 20 "26" _null_ _null_ _null_ pg_relation_size_oid - _null_ ));
+DESCR("Calculate disk space usage for the specified table or index");
+DATA(insert OID = 2289 ( pg_relation_size		PGNSP PGUID 12 f f t f v 1 20 "25" _null_ _null_ _null_ pg_relation_size_name - _null_ ));
+DESCR("Calculate disk space usage for the specified table or index");
+DATA(insert OID = 2286 ( pg_total_relation_size		PGNSP PGUID 12 f f t f v 1 20 "26" _null_ _null_ _null_ pg_total_relation_size_oid - _null_ ));
+DESCR("Calculate total disk space usage for the specified table and associated indexes and toast tables");
+DATA(insert OID = 2287 ( pg_total_relation_size		PGNSP PGUID 12 f f t f v 1 20 "25" _null_ _null_ _null_ pg_total_relation_size_name - _null_ ));
+DESCR("Calculate total disk space usage for the specified table and associated indexes and toast tables");
+DATA(insert OID = 2288 ( pg_size_pretty			PGNSP PGUID 12 f f t f v 1 25 "20" _null_ _null_ _null_ pg_size_pretty - _null_ ));
+DESCR("Convert a long int to a human readable text using size units");
+
 DATA(insert OID = 2290 (  record_in			PGNSP PGUID 12 f f t f v 3 2249 "2275 26 23" _null_ _null_ _null_	record_in - _null_ ));
 DESCR("I/O");
 DATA(insert OID = 2291 (  record_out		PGNSP PGUID 12 f f t f v 1 2275 "2249" _null_ _null_ _null_ record_out - _null_ ));
@@ -3780,10 +3794,6 @@ DESCR("current value from last used sequence");
 DATA(insert OID = 2560 (  pg_postmaster_start_time PGNSP PGUID 12 f f t f s 0 1184 "" _null_ _null_ _null_ pgsql_postmaster_start_time - _null_ ));
 DESCR("postmaster start time");
 
-/* Column storage size */
-DATA(insert OID = 1269 (  pg_column_size	   PGNSP PGUID 12 f f t f s 1 23 "2276" _null_ _null_ _null_  pg_column_size - _null_ ));
-DESCR("bytes required to store the value, perhaps with compression");
-
 /* new functions for Y-direction rtree opclasses */
 DATA(insert OID = 2562 (  box_below		   PGNSP PGUID 12 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_below - _null_ ));
 DESCR("is below");
diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h
index a46f187bcbf..74dee731510 100644
--- a/src/include/utils/builtins.h
+++ b/src/include/utils/builtins.h
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.279 2006/04/08 18:49:52 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.280 2006/07/21 20:51:33 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -538,6 +538,13 @@ extern Datum tidrecv(PG_FUNCTION_ARGS);
 extern Datum tidsend(PG_FUNCTION_ARGS);
 extern Datum tideq(PG_FUNCTION_ARGS);
 extern Datum tidne(PG_FUNCTION_ARGS);
+extern Datum tidlt(PG_FUNCTION_ARGS);
+extern Datum tidle(PG_FUNCTION_ARGS);
+extern Datum tidgt(PG_FUNCTION_ARGS);
+extern Datum tidge(PG_FUNCTION_ARGS);
+extern Datum bttidcmp(PG_FUNCTION_ARGS);
+extern Datum tidlarger(PG_FUNCTION_ARGS);
+extern Datum tidsmaller(PG_FUNCTION_ARGS);
 extern Datum currtid_byreloid(PG_FUNCTION_ARGS);
 extern Datum currtid_byrelname(PG_FUNCTION_ARGS);
 
-- 
GitLab