public inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH] remove deprecated v8.2 containment operators
2+ messages / 2 participants
[nested] [flat]

* [PATCH] remove deprecated v8.2 containment operators
@ 2020-04-12 03:57  Justin Pryzby <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Justin Pryzby @ 2020-04-12 03:57 UTC (permalink / raw)

See also:
ba920e1c9182eac55d5f1327ab0d29b721154277 684ad6a92fcc33adebdab65c4e7d72a68ba05408
3165426e54df02a6199c0a216546e5095e875a0a 2f70fdb0644c32c4154236c2b5c241bec92eac5e 591d282e8d3e0448ec1339c6b066e10953f040a2
---
 contrib/cube/Makefile                   |  2 +-
 contrib/cube/cube--1.4--1.5.sql         |  8 ++++++++
 contrib/cube/cube.control               |  2 +-
 contrib/hstore/Makefile                 |  1 +
 contrib/hstore/hstore--1.8--1.9.sql     |  7 +++++++
 contrib/hstore/hstore.control           |  2 +-
 contrib/intarray/Makefile               |  2 +-
 contrib/intarray/intarray--1.4--1.5.sql | 10 ++++++++++
 contrib/intarray/intarray.control       |  2 +-
 contrib/seg/Makefile                    |  2 +-
 contrib/seg/seg--1.3--1.4.sql           |  8 ++++++++
 contrib/seg/seg.control                 |  2 +-
 doc/src/sgml/cube.sgml                  |  8 --------
 doc/src/sgml/hstore.sgml                | 10 ----------
 doc/src/sgml/intarray.sgml              |  8 --------
 doc/src/sgml/seg.sgml                   |  8 --------
 16 files changed, 41 insertions(+), 41 deletions(-)
 create mode 100644 contrib/cube/cube--1.4--1.5.sql
 create mode 100644 contrib/hstore/hstore--1.8--1.9.sql
 create mode 100644 contrib/intarray/intarray--1.4--1.5.sql
 create mode 100644 contrib/seg/seg--1.3--1.4.sql

diff --git a/contrib/cube/Makefile b/contrib/cube/Makefile
index 54f609db17..cf195506c7 100644
--- a/contrib/cube/Makefile
+++ b/contrib/cube/Makefile
@@ -7,7 +7,7 @@ OBJS = \
 	cubeparse.o
 
 EXTENSION = cube
-DATA = cube--1.2.sql cube--1.2--1.3.sql cube--1.3--1.4.sql \
+DATA = cube--1.2.sql cube--1.2--1.3.sql cube--1.3--1.4.sql cube--1.4--1.5.sql \
 	cube--1.1--1.2.sql cube--1.0--1.1.sql
 PGFILEDESC = "cube - multidimensional cube data type"
 
diff --git a/contrib/cube/cube--1.4--1.5.sql b/contrib/cube/cube--1.4--1.5.sql
new file mode 100644
index 0000000000..54492e5d18
--- /dev/null
+++ b/contrib/cube/cube--1.4--1.5.sql
@@ -0,0 +1,8 @@
+/* contrib/cube/cube--1.4--1.5.sql */
+
+-- complain if script is sourced in psql, rather than via ALTER EXTENSION
+\echo Use "ALTER EXTENSION cube UPDATE TO '1.5'" to load this file. \quit
+
+-- Remove @ and ~
+DROP OPERATOR @ (cube, cube);
+DROP OPERATOR ~ (cube, cube);
diff --git a/contrib/cube/cube.control b/contrib/cube/cube.control
index 3e238fc937..50427ec117 100644
--- a/contrib/cube/cube.control
+++ b/contrib/cube/cube.control
@@ -1,6 +1,6 @@
 # cube extension
 comment = 'data type for multidimensional cubes'
-default_version = '1.4'
+default_version = '1.5'
 module_pathname = '$libdir/cube'
 relocatable = true
 trusted = true
diff --git a/contrib/hstore/Makefile b/contrib/hstore/Makefile
index c4e339b57c..97b228b65f 100644
--- a/contrib/hstore/Makefile
+++ b/contrib/hstore/Makefile
@@ -12,6 +12,7 @@ OBJS = \
 
 EXTENSION = hstore
 DATA = hstore--1.4.sql \
+	hstore--1.8--1.9.sql \
 	hstore--1.7--1.8.sql \
 	hstore--1.6--1.7.sql \
 	hstore--1.5--1.6.sql \
diff --git a/contrib/hstore/hstore--1.8--1.9.sql b/contrib/hstore/hstore--1.8--1.9.sql
new file mode 100644
index 0000000000..7cd3467c55
--- /dev/null
+++ b/contrib/hstore/hstore--1.8--1.9.sql
@@ -0,0 +1,7 @@
+/* contrib/hstore/hstore--1.8--1.9.sql */
+
+-- complain if script is sourced in psql, rather than via ALTER EXTENSION
+\echo Use "ALTER EXTENSION hstore UPDATE TO '1.9'" to load this file. \quit
+
+-- Remove @
+DROP OPERATOR @ (hstore, hstore);
diff --git a/contrib/hstore/hstore.control b/contrib/hstore/hstore.control
index 89e3c746c4..b73c28aa4d 100644
--- a/contrib/hstore/hstore.control
+++ b/contrib/hstore/hstore.control
@@ -1,6 +1,6 @@
 # hstore extension
 comment = 'data type for storing sets of (key, value) pairs'
-default_version = '1.8'
+default_version = '1.9'
 module_pathname = '$libdir/hstore'
 relocatable = true
 trusted = true
diff --git a/contrib/intarray/Makefile b/contrib/intarray/Makefile
index 01faa36b10..3817c1669a 100644
--- a/contrib/intarray/Makefile
+++ b/contrib/intarray/Makefile
@@ -12,7 +12,7 @@ OBJS = \
 	_intbig_gist.o
 
 EXTENSION = intarray
-DATA = intarray--1.3--1.4.sql intarray--1.2--1.3.sql \
+DATA = intarray--1.4--1.5.sql intarray--1.3--1.4.sql intarray--1.2--1.3.sql \
 	intarray--1.2.sql intarray--1.1--1.2.sql \
 	intarray--1.0--1.1.sql
 PGFILEDESC = "intarray - functions and operators for arrays of integers"
diff --git a/contrib/intarray/intarray--1.4--1.5.sql b/contrib/intarray/intarray--1.4--1.5.sql
new file mode 100644
index 0000000000..d0ac11545c
--- /dev/null
+++ b/contrib/intarray/intarray--1.4--1.5.sql
@@ -0,0 +1,10 @@
+/* contrib/intarray/intarray--1.4--1.5.sql */
+
+-- complain if script is sourced in psql, rather than via ALTER EXTENSION
+\echo Use "ALTER EXTENSION intarray UPDATE TO '1.5'" to load this file. \quit
+
+-- Remove @
+DROP OPERATOR @ (_int4, _int4);
+
+-- Remove ~ from GIN - it was removed from gist in 1.4
+DROP OPERATOR ~ (_int4, _int4);
diff --git a/contrib/intarray/intarray.control b/contrib/intarray/intarray.control
index bbc837c573..c3ff753e2c 100644
--- a/contrib/intarray/intarray.control
+++ b/contrib/intarray/intarray.control
@@ -1,6 +1,6 @@
 # intarray extension
 comment = 'functions, operators, and index support for 1-D arrays of integers'
-default_version = '1.4'
+default_version = '1.5'
 module_pathname = '$libdir/_int'
 relocatable = true
 trusted = true
diff --git a/contrib/seg/Makefile b/contrib/seg/Makefile
index f3578a8634..bb63e83506 100644
--- a/contrib/seg/Makefile
+++ b/contrib/seg/Makefile
@@ -7,7 +7,7 @@ OBJS = \
 	segparse.o
 
 EXTENSION = seg
-DATA = seg--1.1.sql seg--1.1--1.2.sql seg--1.2--1.3.sql \
+DATA = seg--1.1.sql seg--1.1--1.2.sql seg--1.2--1.3.sql seg--1.3--1.4.sql \
 	seg--1.0--1.1.sql
 PGFILEDESC = "seg - line segment data type"
 
diff --git a/contrib/seg/seg--1.3--1.4.sql b/contrib/seg/seg--1.3--1.4.sql
new file mode 100644
index 0000000000..13babddba4
--- /dev/null
+++ b/contrib/seg/seg--1.3--1.4.sql
@@ -0,0 +1,8 @@
+/* contrib/seg/seg--1.3--1.4.sql */
+
+-- complain if script is sourced in psql, rather than via ALTER EXTENSION
+\echo Use "ALTER EXTENSION seg UPDATE TO '1.4'" to load this file. \quit
+
+-- Remove @ and ~
+DROP OPERATOR @ (seg, seg);
+DROP OPERATOR ~ (seg, seg);
diff --git a/contrib/seg/seg.control b/contrib/seg/seg.control
index 9ac3080848..e2c6a4750f 100644
--- a/contrib/seg/seg.control
+++ b/contrib/seg/seg.control
@@ -1,6 +1,6 @@
 # seg extension
 comment = 'data type for representing line segments or floating-point intervals'
-default_version = '1.3'
+default_version = '1.4'
 module_pathname = '$libdir/seg'
 relocatable = true
 trusted = true
diff --git a/doc/src/sgml/cube.sgml b/doc/src/sgml/cube.sgml
index 3dd89bb14d..adf8dbaa91 100644
--- a/doc/src/sgml/cube.sgml
+++ b/doc/src/sgml/cube.sgml
@@ -222,14 +222,6 @@
    </tgroup>
   </table>
 
-  <para>
-   (Before PostgreSQL 8.2, the containment operators <literal>@&gt;</literal> and <literal>&lt;@</literal> were
-   respectively called <literal>@</literal> and <literal>~</literal>.  These names are still available, but are
-   deprecated and will eventually be retired.  Notice that the old names
-   are reversed from the convention formerly followed by the core geometric
-   data types!)
-  </para>
-
   <para>
    In addition to the above operators, the usual comparison
    operators shown in <xref linkend="functions-comparison-op-table"/> are
diff --git a/doc/src/sgml/hstore.sgml b/doc/src/sgml/hstore.sgml
index e867fcc5ae..db5779052a 100644
--- a/doc/src/sgml/hstore.sgml
+++ b/doc/src/sgml/hstore.sgml
@@ -318,16 +318,6 @@ key =&gt; NULL
     </tgroup>
   </table>
 
-  <note>
-  <para>
-   Prior to PostgreSQL 8.2, the containment operators <literal>@&gt;</literal>
-   and <literal>&lt;@</literal> were called <literal>@</literal> and <literal>~</literal>,
-   respectively. These names are still available, but are deprecated and will
-   eventually be removed. Notice that the old names are reversed from the
-   convention formerly followed by the core geometric data types!
-   </para>
-  </note>
-
   <table id="hstore-func-table">
    <title><type>hstore</type> Functions</title>
     <tgroup cols="1">
diff --git a/doc/src/sgml/intarray.sgml b/doc/src/sgml/intarray.sgml
index af44c7b214..dfe98279c0 100644
--- a/doc/src/sgml/intarray.sgml
+++ b/doc/src/sgml/intarray.sgml
@@ -364,14 +364,6 @@
    </tgroup>
   </table>
 
-  <para>
-   (Before PostgreSQL 8.2, the containment operators <literal>@&gt;</literal> and
-   <literal>&lt;@</literal> were respectively called <literal>@</literal> and <literal>~</literal>.
-   These names are still available, but are deprecated and will eventually be
-   retired.  Notice that the old names are reversed from the convention
-   formerly followed by the core geometric data types!)
-  </para>
-
   <para>
    The operators <literal>&amp;&amp;</literal>, <literal>@&gt;</literal> and
    <literal>&lt;@</literal> are equivalent to <productname>PostgreSQL</productname>'s built-in
diff --git a/doc/src/sgml/seg.sgml b/doc/src/sgml/seg.sgml
index e0dfbc76cf..9be69e3609 100644
--- a/doc/src/sgml/seg.sgml
+++ b/doc/src/sgml/seg.sgml
@@ -352,14 +352,6 @@ test=&gt; select '6.25 .. 6.50'::seg as "pH";
     </tgroup>
   </table>
 
-  <para>
-   (Before PostgreSQL 8.2, the containment operators <literal>@&gt;</literal> and <literal>&lt;@</literal> were
-   respectively called <literal>@</literal> and <literal>~</literal>.  These names are still available, but are
-   deprecated and will eventually be retired.  Notice that the old names
-   are reversed from the convention formerly followed by the core geometric
-   data types!)
-  </para>
-
   <para>
    In addition to the above operators, the usual comparison
    operators shown in <xref linkend="functions-comparison-op-table"/> are
-- 
2.17.0


--0OWHXb1mYLuhj1Ox--





^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Remove header lock BufferGetLSNAtomic() on architectures with 64 bit atomic operations
@ 2026-01-14 06:31  Andreas Karlsson <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Andreas Karlsson @ 2026-01-14 06:31 UTC (permalink / raw)
  To: Andres Freund <[email protected]>; +Cc: pgsql-hackers

On 1/2/26 4:27 PM, Andres Freund wrote:
> A volatile on a non-pointer won't do you much good, I'm afraid. You need to
> make sure that the underlying value is read as a single 8 byte read, I don't
> see how this guarantees that, unfortunately.

Yeah, that was a quite big thinko. I have a attached a patch with the 
thinko fixed but I am still not happy with it. I think I will try to use 
atomics.h and see if that makes the code nicer to read.

Also will after that see what I can do about pageinspect.

Andreas


Attachments:

  [text/x-patch] v2-0001-Do-not-lock-in-BufferGetLSNAtomic-on-archs-with-8.patch (5.2K, ../../[email protected]/2-v2-0001-Do-not-lock-in-BufferGetLSNAtomic-on-archs-with-8.patch)
  download | inline diff:
From 80ff6ef3744034e8c34aa1cd1c2dfb9cca013905 Mon Sep 17 00:00:00 2001
From: Andreas Karlsson <[email protected]>
Date: Fri, 21 Nov 2025 10:15:06 +0100
Subject: [PATCH v2] Do not lock in BufferGetLSNAtomic() on archs with 8 byte
 atomic reads

On platforms where we can read or write the whole LSN to a buffer page
we do not need to lock the buffer header to be sure we do not get a torn
LSN. To ahcieve this we need to make sure we always read and write the
while LSN and do not write it field by field.

While working on this I converted PageXLogRecPtr from a struct with two
uint32 fields into an uint64 to make the intent more clear.

Idea by Andres Freund.
---
 src/backend/access/common/bufmask.c |  2 +-
 src/backend/storage/buffer/bufmgr.c | 12 ++++++--
 src/include/access/gist.h           |  4 +--
 src/include/storage/bufpage.h       | 46 +++++++++++++++++++++--------
 4 files changed, 46 insertions(+), 18 deletions(-)

diff --git a/src/backend/access/common/bufmask.c b/src/backend/access/common/bufmask.c
index 1a9e7bea5d2..8a67bfa1aff 100644
--- a/src/backend/access/common/bufmask.c
+++ b/src/backend/access/common/bufmask.c
@@ -32,7 +32,7 @@ mask_page_lsn_and_checksum(Page page)
 {
 	PageHeader	phdr = (PageHeader) page;
 
-	PageXLogRecPtrSet(phdr->pd_lsn, (uint64) MASK_MARKER);
+	PageXLogRecPtrSet(&phdr->pd_lsn, (uint64) MASK_MARKER);
 	phdr->pd_checksum = MASK_MARKER;
 }
 
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index ea5cb30fed0..58de896fa7c 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -4586,13 +4586,18 @@ BufferIsPermanent(Buffer buffer)
 
 /*
  * BufferGetLSNAtomic
- *		Retrieves the LSN of the buffer atomically using a buffer header lock.
- *		This is necessary for some callers who may not have an exclusive lock
- *		on the buffer.
+ *		Retrieves the LSN of the buffer atomically.
+ *
+ *		On platforms without 8 byte atomic reads/write we need to take a
+ *		header lock. This is necessary for some callers who may not have an
+ *		exclusive lock on the buffer.
  */
 XLogRecPtr
 BufferGetLSNAtomic(Buffer buffer)
 {
+#ifdef PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY
+	return PageGetLSN(BufferGetPage(buffer));
+#else
 	char	   *page = BufferGetPage(buffer);
 	BufferDesc *bufHdr;
 	XLogRecPtr	lsn;
@@ -4613,6 +4618,7 @@ BufferGetLSNAtomic(Buffer buffer)
 	UnlockBufHdr(bufHdr);
 
 	return lsn;
+#endif
 }
 
 /* ---------------------------------------------------------------------
diff --git a/src/include/access/gist.h b/src/include/access/gist.h
index 8fa30126f8f..9b385b13a88 100644
--- a/src/include/access/gist.h
+++ b/src/include/access/gist.h
@@ -186,8 +186,8 @@ typedef struct GISTENTRY
 #define GistMarkFollowRight(page) ( GistPageGetOpaque(page)->flags |= F_FOLLOW_RIGHT)
 #define GistClearFollowRight(page)	( GistPageGetOpaque(page)->flags &= ~F_FOLLOW_RIGHT)
 
-#define GistPageGetNSN(page) ( PageXLogRecPtrGet(GistPageGetOpaque(page)->nsn))
-#define GistPageSetNSN(page, val) ( PageXLogRecPtrSet(GistPageGetOpaque(page)->nsn, val))
+#define GistPageGetNSN(page) ( PageXLogRecPtrGet(&GistPageGetOpaque(page)->nsn))
+#define GistPageSetNSN(page, val) ( PageXLogRecPtrSet(&GistPageGetOpaque(page)->nsn, val))
 
 
 /*
diff --git a/src/include/storage/bufpage.h b/src/include/storage/bufpage.h
index 52989e5e535..d52fefd4aa0 100644
--- a/src/include/storage/bufpage.h
+++ b/src/include/storage/bufpage.h
@@ -91,23 +91,45 @@ typedef uint16 LocationIndex;
 
 
 /*
- * For historical reasons, the 64-bit LSN value is stored as two 32-bit
- * values.
+ * For historical reasons, the storage of 64-bit LSN values depends on the
+ * endianess because the field used to be stored as two 32-bit values. When
+ * reading and writing the LSN we need to convert between the two formats.
+ *
+ * We are careful to try to treat the LSN as a single uint64 so callers like
+ * BufferGetLSNAtomic() can be sure there are no torn reads or writes.
  */
-typedef struct
+typedef uint64 PageXLogRecPtr;
+
+#ifdef WORDS_BIGENDIAN
+
+static inline XLogRecPtr
+PageXLogRecPtrGet(const PageXLogRecPtr *val)
+{
+	return *val;
+}
+
+static inline void
+PageXLogRecPtrSet(PageXLogRecPtr *ptr, XLogRecPtr lsn)
 {
-	uint32		xlogid;			/* high bits */
-	uint32		xrecoff;		/* low bits */
-} PageXLogRecPtr;
+	*ptr = lsn;
+}
+
+#else
 
 static inline XLogRecPtr
-PageXLogRecPtrGet(PageXLogRecPtr val)
+PageXLogRecPtrGet(const volatile PageXLogRecPtr *val)
+{
+	PageXLogRecPtr tmp = *val;
+	return (tmp << 32) | (tmp >> 32);
+}
+
+static inline void
+PageXLogRecPtrSet(volatile PageXLogRecPtr *ptr, XLogRecPtr lsn)
 {
-	return (uint64) val.xlogid << 32 | val.xrecoff;
+	*ptr = (lsn << 32) | (lsn >> 32);
 }
 
-#define PageXLogRecPtrSet(ptr, lsn) \
-	((ptr).xlogid = (uint32) ((lsn) >> 32), (ptr).xrecoff = (uint32) (lsn))
+#endif
 
 /*
  * disk page organization
@@ -385,12 +407,12 @@ PageGetMaxOffsetNumber(const PageData *page)
 static inline XLogRecPtr
 PageGetLSN(const PageData *page)
 {
-	return PageXLogRecPtrGet(((const PageHeaderData *) page)->pd_lsn);
+	return PageXLogRecPtrGet(&((const PageHeaderData *) page)->pd_lsn);
 }
 static inline void
 PageSetLSN(Page page, XLogRecPtr lsn)
 {
-	PageXLogRecPtrSet(((PageHeader) page)->pd_lsn, lsn);
+	PageXLogRecPtrSet(&((PageHeader) page)->pd_lsn, lsn);
 }
 
 static inline bool
-- 
2.47.3



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-01-14 06:31 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-04-12 03:57 [PATCH] remove deprecated v8.2 containment operators Justin Pryzby <[email protected]>
2026-01-14 06:31 Re: Remove header lock BufferGetLSNAtomic() on architectures with 64 bit atomic operations Andreas Karlsson <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox