public inbox for [email protected]
help / color / mirror / Atom feed[PATCH 5/8] add special pg_brin_bloom_summary data type
27+ messages / 4 participants
[nested] [flat]
* [PATCH 5/8] add special pg_brin_bloom_summary data type
@ 2020-08-06 15:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Tomas Vondra @ 2020-08-06 15:56 UTC (permalink / raw)
---
src/backend/access/brin/brin_bloom.c | 91 ++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 14 ++++
src/include/catalog/pg_type.dat | 7 ++
src/test/regress/expected/type_sanity.out | 7 +-
4 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index b119e4e264..e7ca100821 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -647,7 +647,7 @@ brin_bloom_opcinfo(PG_FUNCTION_ARGS)
result->oi_regular_nulls = true;
result->oi_opaque = (BloomOpaque *)
MAXALIGN((char *) result + SizeofBrinOpcInfo(1));
- result->oi_typcache[0] = lookup_type_cache(BYTEAOID, 0);
+ result->oi_typcache[0] = lookup_type_cache(BRINBLOOMSUMMARYOID, 0);
PG_RETURN_POINTER(result);
}
@@ -978,3 +978,92 @@ brin_bloom_options(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+/*
+ * brin_bloom_summary_in
+ * - input routine for type brin_bloom_summary.
+ *
+ * brin_bloom_summary is only used internally to represent summaries
+ * in BRIN bloom indexes, so it has no operations of its own, and we
+ * disallow input too.
+ */
+Datum
+brin_bloom_summary_in(PG_FUNCTION_ARGS)
+{
+ /*
+ * brin_bloom_summary stores the data in binary form and parsing
+ * text input is not needed, so disallow this.
+ */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+
+/*
+ * brin_bloom_summary_out
+ * - output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized into a bytea value, but we want
+ * to output something nicer humans can understand.
+ */
+Datum
+brin_bloom_summary_out(PG_FUNCTION_ARGS)
+{
+ BloomFilter *filter;
+ StringInfoData str;
+
+ initStringInfo(&str);
+ appendStringInfoChar(&str, '{');
+
+ /*
+ * XXX not sure the detoasting is necessary (probably not, this
+ * can only be in an index).
+ */
+ filter = (BloomFilter *) PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
+
+ if (BLOOM_IS_HASHED(filter))
+ {
+ appendStringInfo(&str, "mode: hashed nhashes: %u nbits: %u nbits_set: %u",
+ filter->nhashes, filter->nbits, filter->nbits_set);
+ }
+ else
+ {
+ appendStringInfo(&str, "mode: sorted nvalues: %u nsorted: %u",
+ filter->nvalues, filter->nsorted);
+ /* TODO include the sorted/unsorted values */
+ }
+
+ appendStringInfoChar(&str, '}');
+
+ PG_RETURN_CSTRING(str.data);
+}
+
+/*
+ * brin_bloom_summary_recv
+ * - binary input routine for type brin_bloom_summary.
+ */
+Datum
+brin_bloom_summary_recv(PG_FUNCTION_ARGS)
+{
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+/*
+ * brin_bloom_summary_send
+ * - binary output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized in a bytea value (although the
+ * type is named differently), so let's just send that.
+ */
+Datum
+brin_bloom_summary_send(PG_FUNCTION_ARGS)
+{
+ return byteasend(fcinfo);
+}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5336aa7b9c..da4c9c6202 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10975,3 +10975,17 @@
prosrc => 'unicode_is_normalized' },
]
+
+{ oid => '9035', descr => 'I/O',
+ proname => 'brin_bloom_summary_in', prorettype => 'pg_brin_bloom_summary',
+ proargtypes => 'cstring', prosrc => 'brin_bloom_summary_in' },
+{ oid => '9036', descr => 'I/O',
+ proname => 'brin_bloom_summary_out', prorettype => 'cstring',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_out' },
+{ oid => '9037', descr => 'I/O',
+ proname => 'brin_bloom_summary_recv', provolatile => 's',
+ prorettype => 'pg_brin_bloom_summary', proargtypes => 'internal',
+ prosrc => 'brin_bloom_summary_recv' },
+{ oid => '9038', descr => 'I/O',
+ proname => 'brin_bloom_summary_send', provolatile => 's', prorettype => 'bytea',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_send' },
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index b2cec07416..a41c2e5418 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -631,3 +631,10 @@
typalign => 'd', typstorage => 'x' },
]
+
+{ oid => '9034', oid_symbol => 'BRINBLOOMSUMMARYOID',
+ descr => 'BRIN bloom summary',
+ typname => 'pg_brin_bloom_summary', typlen => '-1', typbyval => 'f', typcategory => 'S',
+ typinput => 'brin_bloom_summary_in', typoutput => 'brin_bloom_summary_out',
+ typreceive => 'brin_bloom_summary_recv', typsend => 'brin_bloom_summary_send',
+ typalign => 'i', typstorage => 'x', typcollation => 'default' },
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index 274130e706..97bf9797de 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -67,13 +67,14 @@ WHERE p1.typtype not in ('c','d','p') AND p1.typname NOT LIKE E'\\_%'
(SELECT 1 FROM pg_type as p2
WHERE p2.typname = ('_' || p1.typname)::name AND
p2.typelem = p1.oid and p1.typarray = p2.oid);
- oid | typname
-------+-----------------
+ oid | typname
+------+-----------------------
194 | pg_node_tree
3361 | pg_ndistinct
3402 | pg_dependencies
5017 | pg_mcv_list
-(4 rows)
+ 9034 | pg_brin_bloom_summary
+(5 rows)
-- Make sure typarray points to a varlena array type of our own base
SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype,
--
2.25.4
--jsivyprvf2oxfjz3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="0006-BRIN-multi-range-minmax-indexes-20200807.patch"
^ permalink raw reply [nested|flat] 27+ messages in thread
* [PATCH 5/8] add special pg_brin_bloom_summary data type
@ 2020-08-06 15:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Tomas Vondra @ 2020-08-06 15:56 UTC (permalink / raw)
---
src/backend/access/brin/brin_bloom.c | 91 ++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 14 ++++
src/include/catalog/pg_type.dat | 7 ++
src/test/regress/expected/type_sanity.out | 7 +-
4 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index b119e4e264..e7ca100821 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -647,7 +647,7 @@ brin_bloom_opcinfo(PG_FUNCTION_ARGS)
result->oi_regular_nulls = true;
result->oi_opaque = (BloomOpaque *)
MAXALIGN((char *) result + SizeofBrinOpcInfo(1));
- result->oi_typcache[0] = lookup_type_cache(BYTEAOID, 0);
+ result->oi_typcache[0] = lookup_type_cache(BRINBLOOMSUMMARYOID, 0);
PG_RETURN_POINTER(result);
}
@@ -978,3 +978,92 @@ brin_bloom_options(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+/*
+ * brin_bloom_summary_in
+ * - input routine for type brin_bloom_summary.
+ *
+ * brin_bloom_summary is only used internally to represent summaries
+ * in BRIN bloom indexes, so it has no operations of its own, and we
+ * disallow input too.
+ */
+Datum
+brin_bloom_summary_in(PG_FUNCTION_ARGS)
+{
+ /*
+ * brin_bloom_summary stores the data in binary form and parsing
+ * text input is not needed, so disallow this.
+ */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+
+/*
+ * brin_bloom_summary_out
+ * - output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized into a bytea value, but we want
+ * to output something nicer humans can understand.
+ */
+Datum
+brin_bloom_summary_out(PG_FUNCTION_ARGS)
+{
+ BloomFilter *filter;
+ StringInfoData str;
+
+ initStringInfo(&str);
+ appendStringInfoChar(&str, '{');
+
+ /*
+ * XXX not sure the detoasting is necessary (probably not, this
+ * can only be in an index).
+ */
+ filter = (BloomFilter *) PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
+
+ if (BLOOM_IS_HASHED(filter))
+ {
+ appendStringInfo(&str, "mode: hashed nhashes: %u nbits: %u nbits_set: %u",
+ filter->nhashes, filter->nbits, filter->nbits_set);
+ }
+ else
+ {
+ appendStringInfo(&str, "mode: sorted nvalues: %u nsorted: %u",
+ filter->nvalues, filter->nsorted);
+ /* TODO include the sorted/unsorted values */
+ }
+
+ appendStringInfoChar(&str, '}');
+
+ PG_RETURN_CSTRING(str.data);
+}
+
+/*
+ * brin_bloom_summary_recv
+ * - binary input routine for type brin_bloom_summary.
+ */
+Datum
+brin_bloom_summary_recv(PG_FUNCTION_ARGS)
+{
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+/*
+ * brin_bloom_summary_send
+ * - binary output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized in a bytea value (although the
+ * type is named differently), so let's just send that.
+ */
+Datum
+brin_bloom_summary_send(PG_FUNCTION_ARGS)
+{
+ return byteasend(fcinfo);
+}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5336aa7b9c..da4c9c6202 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10975,3 +10975,17 @@
prosrc => 'unicode_is_normalized' },
]
+
+{ oid => '9035', descr => 'I/O',
+ proname => 'brin_bloom_summary_in', prorettype => 'pg_brin_bloom_summary',
+ proargtypes => 'cstring', prosrc => 'brin_bloom_summary_in' },
+{ oid => '9036', descr => 'I/O',
+ proname => 'brin_bloom_summary_out', prorettype => 'cstring',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_out' },
+{ oid => '9037', descr => 'I/O',
+ proname => 'brin_bloom_summary_recv', provolatile => 's',
+ prorettype => 'pg_brin_bloom_summary', proargtypes => 'internal',
+ prosrc => 'brin_bloom_summary_recv' },
+{ oid => '9038', descr => 'I/O',
+ proname => 'brin_bloom_summary_send', provolatile => 's', prorettype => 'bytea',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_send' },
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index b2cec07416..a41c2e5418 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -631,3 +631,10 @@
typalign => 'd', typstorage => 'x' },
]
+
+{ oid => '9034', oid_symbol => 'BRINBLOOMSUMMARYOID',
+ descr => 'BRIN bloom summary',
+ typname => 'pg_brin_bloom_summary', typlen => '-1', typbyval => 'f', typcategory => 'S',
+ typinput => 'brin_bloom_summary_in', typoutput => 'brin_bloom_summary_out',
+ typreceive => 'brin_bloom_summary_recv', typsend => 'brin_bloom_summary_send',
+ typalign => 'i', typstorage => 'x', typcollation => 'default' },
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index 274130e706..97bf9797de 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -67,13 +67,14 @@ WHERE p1.typtype not in ('c','d','p') AND p1.typname NOT LIKE E'\\_%'
(SELECT 1 FROM pg_type as p2
WHERE p2.typname = ('_' || p1.typname)::name AND
p2.typelem = p1.oid and p1.typarray = p2.oid);
- oid | typname
-------+-----------------
+ oid | typname
+------+-----------------------
194 | pg_node_tree
3361 | pg_ndistinct
3402 | pg_dependencies
5017 | pg_mcv_list
-(4 rows)
+ 9034 | pg_brin_bloom_summary
+(5 rows)
-- Make sure typarray points to a varlena array type of our own base
SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype,
--
2.25.4
--jsivyprvf2oxfjz3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="0006-BRIN-multi-range-minmax-indexes-20200807.patch"
^ permalink raw reply [nested|flat] 27+ messages in thread
* [PATCH 5/8] add special pg_brin_bloom_summary data type
@ 2020-08-06 15:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Tomas Vondra @ 2020-08-06 15:56 UTC (permalink / raw)
---
src/backend/access/brin/brin_bloom.c | 91 ++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 14 ++++
src/include/catalog/pg_type.dat | 7 ++
src/test/regress/expected/type_sanity.out | 7 +-
4 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index b119e4e264..e7ca100821 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -647,7 +647,7 @@ brin_bloom_opcinfo(PG_FUNCTION_ARGS)
result->oi_regular_nulls = true;
result->oi_opaque = (BloomOpaque *)
MAXALIGN((char *) result + SizeofBrinOpcInfo(1));
- result->oi_typcache[0] = lookup_type_cache(BYTEAOID, 0);
+ result->oi_typcache[0] = lookup_type_cache(BRINBLOOMSUMMARYOID, 0);
PG_RETURN_POINTER(result);
}
@@ -978,3 +978,92 @@ brin_bloom_options(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+/*
+ * brin_bloom_summary_in
+ * - input routine for type brin_bloom_summary.
+ *
+ * brin_bloom_summary is only used internally to represent summaries
+ * in BRIN bloom indexes, so it has no operations of its own, and we
+ * disallow input too.
+ */
+Datum
+brin_bloom_summary_in(PG_FUNCTION_ARGS)
+{
+ /*
+ * brin_bloom_summary stores the data in binary form and parsing
+ * text input is not needed, so disallow this.
+ */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+
+/*
+ * brin_bloom_summary_out
+ * - output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized into a bytea value, but we want
+ * to output something nicer humans can understand.
+ */
+Datum
+brin_bloom_summary_out(PG_FUNCTION_ARGS)
+{
+ BloomFilter *filter;
+ StringInfoData str;
+
+ initStringInfo(&str);
+ appendStringInfoChar(&str, '{');
+
+ /*
+ * XXX not sure the detoasting is necessary (probably not, this
+ * can only be in an index).
+ */
+ filter = (BloomFilter *) PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
+
+ if (BLOOM_IS_HASHED(filter))
+ {
+ appendStringInfo(&str, "mode: hashed nhashes: %u nbits: %u nbits_set: %u",
+ filter->nhashes, filter->nbits, filter->nbits_set);
+ }
+ else
+ {
+ appendStringInfo(&str, "mode: sorted nvalues: %u nsorted: %u",
+ filter->nvalues, filter->nsorted);
+ /* TODO include the sorted/unsorted values */
+ }
+
+ appendStringInfoChar(&str, '}');
+
+ PG_RETURN_CSTRING(str.data);
+}
+
+/*
+ * brin_bloom_summary_recv
+ * - binary input routine for type brin_bloom_summary.
+ */
+Datum
+brin_bloom_summary_recv(PG_FUNCTION_ARGS)
+{
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+/*
+ * brin_bloom_summary_send
+ * - binary output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized in a bytea value (although the
+ * type is named differently), so let's just send that.
+ */
+Datum
+brin_bloom_summary_send(PG_FUNCTION_ARGS)
+{
+ return byteasend(fcinfo);
+}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5336aa7b9c..da4c9c6202 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10975,3 +10975,17 @@
prosrc => 'unicode_is_normalized' },
]
+
+{ oid => '9035', descr => 'I/O',
+ proname => 'brin_bloom_summary_in', prorettype => 'pg_brin_bloom_summary',
+ proargtypes => 'cstring', prosrc => 'brin_bloom_summary_in' },
+{ oid => '9036', descr => 'I/O',
+ proname => 'brin_bloom_summary_out', prorettype => 'cstring',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_out' },
+{ oid => '9037', descr => 'I/O',
+ proname => 'brin_bloom_summary_recv', provolatile => 's',
+ prorettype => 'pg_brin_bloom_summary', proargtypes => 'internal',
+ prosrc => 'brin_bloom_summary_recv' },
+{ oid => '9038', descr => 'I/O',
+ proname => 'brin_bloom_summary_send', provolatile => 's', prorettype => 'bytea',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_send' },
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index b2cec07416..a41c2e5418 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -631,3 +631,10 @@
typalign => 'd', typstorage => 'x' },
]
+
+{ oid => '9034', oid_symbol => 'BRINBLOOMSUMMARYOID',
+ descr => 'BRIN bloom summary',
+ typname => 'pg_brin_bloom_summary', typlen => '-1', typbyval => 'f', typcategory => 'S',
+ typinput => 'brin_bloom_summary_in', typoutput => 'brin_bloom_summary_out',
+ typreceive => 'brin_bloom_summary_recv', typsend => 'brin_bloom_summary_send',
+ typalign => 'i', typstorage => 'x', typcollation => 'default' },
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index 274130e706..97bf9797de 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -67,13 +67,14 @@ WHERE p1.typtype not in ('c','d','p') AND p1.typname NOT LIKE E'\\_%'
(SELECT 1 FROM pg_type as p2
WHERE p2.typname = ('_' || p1.typname)::name AND
p2.typelem = p1.oid and p1.typarray = p2.oid);
- oid | typname
-------+-----------------
+ oid | typname
+------+-----------------------
194 | pg_node_tree
3361 | pg_ndistinct
3402 | pg_dependencies
5017 | pg_mcv_list
-(4 rows)
+ 9034 | pg_brin_bloom_summary
+(5 rows)
-- Make sure typarray points to a varlena array type of our own base
SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype,
--
2.25.4
--jsivyprvf2oxfjz3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="0006-BRIN-multi-range-minmax-indexes-20200807.patch"
^ permalink raw reply [nested|flat] 27+ messages in thread
* [PATCH 5/8] add special pg_brin_bloom_summary data type
@ 2020-08-06 15:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Tomas Vondra @ 2020-08-06 15:56 UTC (permalink / raw)
---
src/backend/access/brin/brin_bloom.c | 91 ++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 14 ++++
src/include/catalog/pg_type.dat | 7 ++
src/test/regress/expected/type_sanity.out | 7 +-
4 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index b119e4e264..e7ca100821 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -647,7 +647,7 @@ brin_bloom_opcinfo(PG_FUNCTION_ARGS)
result->oi_regular_nulls = true;
result->oi_opaque = (BloomOpaque *)
MAXALIGN((char *) result + SizeofBrinOpcInfo(1));
- result->oi_typcache[0] = lookup_type_cache(BYTEAOID, 0);
+ result->oi_typcache[0] = lookup_type_cache(BRINBLOOMSUMMARYOID, 0);
PG_RETURN_POINTER(result);
}
@@ -978,3 +978,92 @@ brin_bloom_options(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+/*
+ * brin_bloom_summary_in
+ * - input routine for type brin_bloom_summary.
+ *
+ * brin_bloom_summary is only used internally to represent summaries
+ * in BRIN bloom indexes, so it has no operations of its own, and we
+ * disallow input too.
+ */
+Datum
+brin_bloom_summary_in(PG_FUNCTION_ARGS)
+{
+ /*
+ * brin_bloom_summary stores the data in binary form and parsing
+ * text input is not needed, so disallow this.
+ */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+
+/*
+ * brin_bloom_summary_out
+ * - output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized into a bytea value, but we want
+ * to output something nicer humans can understand.
+ */
+Datum
+brin_bloom_summary_out(PG_FUNCTION_ARGS)
+{
+ BloomFilter *filter;
+ StringInfoData str;
+
+ initStringInfo(&str);
+ appendStringInfoChar(&str, '{');
+
+ /*
+ * XXX not sure the detoasting is necessary (probably not, this
+ * can only be in an index).
+ */
+ filter = (BloomFilter *) PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
+
+ if (BLOOM_IS_HASHED(filter))
+ {
+ appendStringInfo(&str, "mode: hashed nhashes: %u nbits: %u nbits_set: %u",
+ filter->nhashes, filter->nbits, filter->nbits_set);
+ }
+ else
+ {
+ appendStringInfo(&str, "mode: sorted nvalues: %u nsorted: %u",
+ filter->nvalues, filter->nsorted);
+ /* TODO include the sorted/unsorted values */
+ }
+
+ appendStringInfoChar(&str, '}');
+
+ PG_RETURN_CSTRING(str.data);
+}
+
+/*
+ * brin_bloom_summary_recv
+ * - binary input routine for type brin_bloom_summary.
+ */
+Datum
+brin_bloom_summary_recv(PG_FUNCTION_ARGS)
+{
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+/*
+ * brin_bloom_summary_send
+ * - binary output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized in a bytea value (although the
+ * type is named differently), so let's just send that.
+ */
+Datum
+brin_bloom_summary_send(PG_FUNCTION_ARGS)
+{
+ return byteasend(fcinfo);
+}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c00e4ece94..dc17d4ce38 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10993,3 +10993,17 @@
prosrc => 'unicode_is_normalized' },
]
+
+{ oid => '9035', descr => 'I/O',
+ proname => 'brin_bloom_summary_in', prorettype => 'pg_brin_bloom_summary',
+ proargtypes => 'cstring', prosrc => 'brin_bloom_summary_in' },
+{ oid => '9036', descr => 'I/O',
+ proname => 'brin_bloom_summary_out', prorettype => 'cstring',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_out' },
+{ oid => '9037', descr => 'I/O',
+ proname => 'brin_bloom_summary_recv', provolatile => 's',
+ prorettype => 'pg_brin_bloom_summary', proargtypes => 'internal',
+ prosrc => 'brin_bloom_summary_recv' },
+{ oid => '9038', descr => 'I/O',
+ proname => 'brin_bloom_summary_send', provolatile => 's', prorettype => 'bytea',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_send' },
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index b2cec07416..a41c2e5418 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -631,3 +631,10 @@
typalign => 'd', typstorage => 'x' },
]
+
+{ oid => '9034', oid_symbol => 'BRINBLOOMSUMMARYOID',
+ descr => 'BRIN bloom summary',
+ typname => 'pg_brin_bloom_summary', typlen => '-1', typbyval => 'f', typcategory => 'S',
+ typinput => 'brin_bloom_summary_in', typoutput => 'brin_bloom_summary_out',
+ typreceive => 'brin_bloom_summary_recv', typsend => 'brin_bloom_summary_send',
+ typalign => 'i', typstorage => 'x', typcollation => 'default' },
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index 274130e706..97bf9797de 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -67,13 +67,14 @@ WHERE p1.typtype not in ('c','d','p') AND p1.typname NOT LIKE E'\\_%'
(SELECT 1 FROM pg_type as p2
WHERE p2.typname = ('_' || p1.typname)::name AND
p2.typelem = p1.oid and p1.typarray = p2.oid);
- oid | typname
-------+-----------------
+ oid | typname
+------+-----------------------
194 | pg_node_tree
3361 | pg_ndistinct
3402 | pg_dependencies
5017 | pg_mcv_list
-(4 rows)
+ 9034 | pg_brin_bloom_summary
+(5 rows)
-- Make sure typarray points to a varlena array type of our own base
SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype,
--
2.25.4
--vurodj3csurzcvv3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="0006-BRIN-minmax-multi-indexes-20200906.patch"
^ permalink raw reply [nested|flat] 27+ messages in thread
* [PATCH 5/8] add special pg_brin_bloom_summary data type
@ 2020-08-06 15:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Tomas Vondra @ 2020-08-06 15:56 UTC (permalink / raw)
---
src/backend/access/brin/brin_bloom.c | 91 ++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 14 ++++
src/include/catalog/pg_type.dat | 7 ++
src/test/regress/expected/type_sanity.out | 7 +-
4 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index b119e4e264..e7ca100821 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -647,7 +647,7 @@ brin_bloom_opcinfo(PG_FUNCTION_ARGS)
result->oi_regular_nulls = true;
result->oi_opaque = (BloomOpaque *)
MAXALIGN((char *) result + SizeofBrinOpcInfo(1));
- result->oi_typcache[0] = lookup_type_cache(BYTEAOID, 0);
+ result->oi_typcache[0] = lookup_type_cache(BRINBLOOMSUMMARYOID, 0);
PG_RETURN_POINTER(result);
}
@@ -978,3 +978,92 @@ brin_bloom_options(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+/*
+ * brin_bloom_summary_in
+ * - input routine for type brin_bloom_summary.
+ *
+ * brin_bloom_summary is only used internally to represent summaries
+ * in BRIN bloom indexes, so it has no operations of its own, and we
+ * disallow input too.
+ */
+Datum
+brin_bloom_summary_in(PG_FUNCTION_ARGS)
+{
+ /*
+ * brin_bloom_summary stores the data in binary form and parsing
+ * text input is not needed, so disallow this.
+ */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+
+/*
+ * brin_bloom_summary_out
+ * - output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized into a bytea value, but we want
+ * to output something nicer humans can understand.
+ */
+Datum
+brin_bloom_summary_out(PG_FUNCTION_ARGS)
+{
+ BloomFilter *filter;
+ StringInfoData str;
+
+ initStringInfo(&str);
+ appendStringInfoChar(&str, '{');
+
+ /*
+ * XXX not sure the detoasting is necessary (probably not, this
+ * can only be in an index).
+ */
+ filter = (BloomFilter *) PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
+
+ if (BLOOM_IS_HASHED(filter))
+ {
+ appendStringInfo(&str, "mode: hashed nhashes: %u nbits: %u nbits_set: %u",
+ filter->nhashes, filter->nbits, filter->nbits_set);
+ }
+ else
+ {
+ appendStringInfo(&str, "mode: sorted nvalues: %u nsorted: %u",
+ filter->nvalues, filter->nsorted);
+ /* TODO include the sorted/unsorted values */
+ }
+
+ appendStringInfoChar(&str, '}');
+
+ PG_RETURN_CSTRING(str.data);
+}
+
+/*
+ * brin_bloom_summary_recv
+ * - binary input routine for type brin_bloom_summary.
+ */
+Datum
+brin_bloom_summary_recv(PG_FUNCTION_ARGS)
+{
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+/*
+ * brin_bloom_summary_send
+ * - binary output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized in a bytea value (although the
+ * type is named differently), so let's just send that.
+ */
+Datum
+brin_bloom_summary_send(PG_FUNCTION_ARGS)
+{
+ return byteasend(fcinfo);
+}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5336aa7b9c..da4c9c6202 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10975,3 +10975,17 @@
prosrc => 'unicode_is_normalized' },
]
+
+{ oid => '9035', descr => 'I/O',
+ proname => 'brin_bloom_summary_in', prorettype => 'pg_brin_bloom_summary',
+ proargtypes => 'cstring', prosrc => 'brin_bloom_summary_in' },
+{ oid => '9036', descr => 'I/O',
+ proname => 'brin_bloom_summary_out', prorettype => 'cstring',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_out' },
+{ oid => '9037', descr => 'I/O',
+ proname => 'brin_bloom_summary_recv', provolatile => 's',
+ prorettype => 'pg_brin_bloom_summary', proargtypes => 'internal',
+ prosrc => 'brin_bloom_summary_recv' },
+{ oid => '9038', descr => 'I/O',
+ proname => 'brin_bloom_summary_send', provolatile => 's', prorettype => 'bytea',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_send' },
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index b2cec07416..a41c2e5418 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -631,3 +631,10 @@
typalign => 'd', typstorage => 'x' },
]
+
+{ oid => '9034', oid_symbol => 'BRINBLOOMSUMMARYOID',
+ descr => 'BRIN bloom summary',
+ typname => 'pg_brin_bloom_summary', typlen => '-1', typbyval => 'f', typcategory => 'S',
+ typinput => 'brin_bloom_summary_in', typoutput => 'brin_bloom_summary_out',
+ typreceive => 'brin_bloom_summary_recv', typsend => 'brin_bloom_summary_send',
+ typalign => 'i', typstorage => 'x', typcollation => 'default' },
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index 274130e706..97bf9797de 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -67,13 +67,14 @@ WHERE p1.typtype not in ('c','d','p') AND p1.typname NOT LIKE E'\\_%'
(SELECT 1 FROM pg_type as p2
WHERE p2.typname = ('_' || p1.typname)::name AND
p2.typelem = p1.oid and p1.typarray = p2.oid);
- oid | typname
-------+-----------------
+ oid | typname
+------+-----------------------
194 | pg_node_tree
3361 | pg_ndistinct
3402 | pg_dependencies
5017 | pg_mcv_list
-(4 rows)
+ 9034 | pg_brin_bloom_summary
+(5 rows)
-- Make sure typarray points to a varlena array type of our own base
SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype,
--
2.25.4
--jsivyprvf2oxfjz3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="0006-BRIN-multi-range-minmax-indexes-20200807.patch"
^ permalink raw reply [nested|flat] 27+ messages in thread
* [PATCH 5/8] add special pg_brin_bloom_summary data type
@ 2020-08-06 15:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Tomas Vondra @ 2020-08-06 15:56 UTC (permalink / raw)
---
src/backend/access/brin/brin_bloom.c | 91 ++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 14 ++++
src/include/catalog/pg_type.dat | 7 ++
src/test/regress/expected/type_sanity.out | 7 +-
4 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index b119e4e264..e7ca100821 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -647,7 +647,7 @@ brin_bloom_opcinfo(PG_FUNCTION_ARGS)
result->oi_regular_nulls = true;
result->oi_opaque = (BloomOpaque *)
MAXALIGN((char *) result + SizeofBrinOpcInfo(1));
- result->oi_typcache[0] = lookup_type_cache(BYTEAOID, 0);
+ result->oi_typcache[0] = lookup_type_cache(BRINBLOOMSUMMARYOID, 0);
PG_RETURN_POINTER(result);
}
@@ -978,3 +978,92 @@ brin_bloom_options(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+/*
+ * brin_bloom_summary_in
+ * - input routine for type brin_bloom_summary.
+ *
+ * brin_bloom_summary is only used internally to represent summaries
+ * in BRIN bloom indexes, so it has no operations of its own, and we
+ * disallow input too.
+ */
+Datum
+brin_bloom_summary_in(PG_FUNCTION_ARGS)
+{
+ /*
+ * brin_bloom_summary stores the data in binary form and parsing
+ * text input is not needed, so disallow this.
+ */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+
+/*
+ * brin_bloom_summary_out
+ * - output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized into a bytea value, but we want
+ * to output something nicer humans can understand.
+ */
+Datum
+brin_bloom_summary_out(PG_FUNCTION_ARGS)
+{
+ BloomFilter *filter;
+ StringInfoData str;
+
+ initStringInfo(&str);
+ appendStringInfoChar(&str, '{');
+
+ /*
+ * XXX not sure the detoasting is necessary (probably not, this
+ * can only be in an index).
+ */
+ filter = (BloomFilter *) PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
+
+ if (BLOOM_IS_HASHED(filter))
+ {
+ appendStringInfo(&str, "mode: hashed nhashes: %u nbits: %u nbits_set: %u",
+ filter->nhashes, filter->nbits, filter->nbits_set);
+ }
+ else
+ {
+ appendStringInfo(&str, "mode: sorted nvalues: %u nsorted: %u",
+ filter->nvalues, filter->nsorted);
+ /* TODO include the sorted/unsorted values */
+ }
+
+ appendStringInfoChar(&str, '}');
+
+ PG_RETURN_CSTRING(str.data);
+}
+
+/*
+ * brin_bloom_summary_recv
+ * - binary input routine for type brin_bloom_summary.
+ */
+Datum
+brin_bloom_summary_recv(PG_FUNCTION_ARGS)
+{
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+/*
+ * brin_bloom_summary_send
+ * - binary output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized in a bytea value (although the
+ * type is named differently), so let's just send that.
+ */
+Datum
+brin_bloom_summary_send(PG_FUNCTION_ARGS)
+{
+ return byteasend(fcinfo);
+}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5336aa7b9c..da4c9c6202 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10975,3 +10975,17 @@
prosrc => 'unicode_is_normalized' },
]
+
+{ oid => '9035', descr => 'I/O',
+ proname => 'brin_bloom_summary_in', prorettype => 'pg_brin_bloom_summary',
+ proargtypes => 'cstring', prosrc => 'brin_bloom_summary_in' },
+{ oid => '9036', descr => 'I/O',
+ proname => 'brin_bloom_summary_out', prorettype => 'cstring',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_out' },
+{ oid => '9037', descr => 'I/O',
+ proname => 'brin_bloom_summary_recv', provolatile => 's',
+ prorettype => 'pg_brin_bloom_summary', proargtypes => 'internal',
+ prosrc => 'brin_bloom_summary_recv' },
+{ oid => '9038', descr => 'I/O',
+ proname => 'brin_bloom_summary_send', provolatile => 's', prorettype => 'bytea',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_send' },
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index b2cec07416..a41c2e5418 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -631,3 +631,10 @@
typalign => 'd', typstorage => 'x' },
]
+
+{ oid => '9034', oid_symbol => 'BRINBLOOMSUMMARYOID',
+ descr => 'BRIN bloom summary',
+ typname => 'pg_brin_bloom_summary', typlen => '-1', typbyval => 'f', typcategory => 'S',
+ typinput => 'brin_bloom_summary_in', typoutput => 'brin_bloom_summary_out',
+ typreceive => 'brin_bloom_summary_recv', typsend => 'brin_bloom_summary_send',
+ typalign => 'i', typstorage => 'x', typcollation => 'default' },
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index 274130e706..97bf9797de 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -67,13 +67,14 @@ WHERE p1.typtype not in ('c','d','p') AND p1.typname NOT LIKE E'\\_%'
(SELECT 1 FROM pg_type as p2
WHERE p2.typname = ('_' || p1.typname)::name AND
p2.typelem = p1.oid and p1.typarray = p2.oid);
- oid | typname
-------+-----------------
+ oid | typname
+------+-----------------------
194 | pg_node_tree
3361 | pg_ndistinct
3402 | pg_dependencies
5017 | pg_mcv_list
-(4 rows)
+ 9034 | pg_brin_bloom_summary
+(5 rows)
-- Make sure typarray points to a varlena array type of our own base
SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype,
--
2.25.4
--jsivyprvf2oxfjz3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="0006-BRIN-multi-range-minmax-indexes-20200807.patch"
^ permalink raw reply [nested|flat] 27+ messages in thread
* [PATCH 5/8] add special pg_brin_bloom_summary data type
@ 2020-08-06 15:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Tomas Vondra @ 2020-08-06 15:56 UTC (permalink / raw)
---
src/backend/access/brin/brin_bloom.c | 91 ++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 14 ++++
src/include/catalog/pg_type.dat | 7 ++
src/test/regress/expected/type_sanity.out | 7 +-
4 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index b119e4e264..e7ca100821 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -647,7 +647,7 @@ brin_bloom_opcinfo(PG_FUNCTION_ARGS)
result->oi_regular_nulls = true;
result->oi_opaque = (BloomOpaque *)
MAXALIGN((char *) result + SizeofBrinOpcInfo(1));
- result->oi_typcache[0] = lookup_type_cache(BYTEAOID, 0);
+ result->oi_typcache[0] = lookup_type_cache(BRINBLOOMSUMMARYOID, 0);
PG_RETURN_POINTER(result);
}
@@ -978,3 +978,92 @@ brin_bloom_options(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+/*
+ * brin_bloom_summary_in
+ * - input routine for type brin_bloom_summary.
+ *
+ * brin_bloom_summary is only used internally to represent summaries
+ * in BRIN bloom indexes, so it has no operations of its own, and we
+ * disallow input too.
+ */
+Datum
+brin_bloom_summary_in(PG_FUNCTION_ARGS)
+{
+ /*
+ * brin_bloom_summary stores the data in binary form and parsing
+ * text input is not needed, so disallow this.
+ */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+
+/*
+ * brin_bloom_summary_out
+ * - output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized into a bytea value, but we want
+ * to output something nicer humans can understand.
+ */
+Datum
+brin_bloom_summary_out(PG_FUNCTION_ARGS)
+{
+ BloomFilter *filter;
+ StringInfoData str;
+
+ initStringInfo(&str);
+ appendStringInfoChar(&str, '{');
+
+ /*
+ * XXX not sure the detoasting is necessary (probably not, this
+ * can only be in an index).
+ */
+ filter = (BloomFilter *) PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
+
+ if (BLOOM_IS_HASHED(filter))
+ {
+ appendStringInfo(&str, "mode: hashed nhashes: %u nbits: %u nbits_set: %u",
+ filter->nhashes, filter->nbits, filter->nbits_set);
+ }
+ else
+ {
+ appendStringInfo(&str, "mode: sorted nvalues: %u nsorted: %u",
+ filter->nvalues, filter->nsorted);
+ /* TODO include the sorted/unsorted values */
+ }
+
+ appendStringInfoChar(&str, '}');
+
+ PG_RETURN_CSTRING(str.data);
+}
+
+/*
+ * brin_bloom_summary_recv
+ * - binary input routine for type brin_bloom_summary.
+ */
+Datum
+brin_bloom_summary_recv(PG_FUNCTION_ARGS)
+{
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+/*
+ * brin_bloom_summary_send
+ * - binary output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized in a bytea value (although the
+ * type is named differently), so let's just send that.
+ */
+Datum
+brin_bloom_summary_send(PG_FUNCTION_ARGS)
+{
+ return byteasend(fcinfo);
+}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5336aa7b9c..da4c9c6202 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10975,3 +10975,17 @@
prosrc => 'unicode_is_normalized' },
]
+
+{ oid => '9035', descr => 'I/O',
+ proname => 'brin_bloom_summary_in', prorettype => 'pg_brin_bloom_summary',
+ proargtypes => 'cstring', prosrc => 'brin_bloom_summary_in' },
+{ oid => '9036', descr => 'I/O',
+ proname => 'brin_bloom_summary_out', prorettype => 'cstring',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_out' },
+{ oid => '9037', descr => 'I/O',
+ proname => 'brin_bloom_summary_recv', provolatile => 's',
+ prorettype => 'pg_brin_bloom_summary', proargtypes => 'internal',
+ prosrc => 'brin_bloom_summary_recv' },
+{ oid => '9038', descr => 'I/O',
+ proname => 'brin_bloom_summary_send', provolatile => 's', prorettype => 'bytea',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_send' },
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index b2cec07416..a41c2e5418 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -631,3 +631,10 @@
typalign => 'd', typstorage => 'x' },
]
+
+{ oid => '9034', oid_symbol => 'BRINBLOOMSUMMARYOID',
+ descr => 'BRIN bloom summary',
+ typname => 'pg_brin_bloom_summary', typlen => '-1', typbyval => 'f', typcategory => 'S',
+ typinput => 'brin_bloom_summary_in', typoutput => 'brin_bloom_summary_out',
+ typreceive => 'brin_bloom_summary_recv', typsend => 'brin_bloom_summary_send',
+ typalign => 'i', typstorage => 'x', typcollation => 'default' },
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index 274130e706..97bf9797de 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -67,13 +67,14 @@ WHERE p1.typtype not in ('c','d','p') AND p1.typname NOT LIKE E'\\_%'
(SELECT 1 FROM pg_type as p2
WHERE p2.typname = ('_' || p1.typname)::name AND
p2.typelem = p1.oid and p1.typarray = p2.oid);
- oid | typname
-------+-----------------
+ oid | typname
+------+-----------------------
194 | pg_node_tree
3361 | pg_ndistinct
3402 | pg_dependencies
5017 | pg_mcv_list
-(4 rows)
+ 9034 | pg_brin_bloom_summary
+(5 rows)
-- Make sure typarray points to a varlena array type of our own base
SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype,
--
2.25.4
--jsivyprvf2oxfjz3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="0006-BRIN-multi-range-minmax-indexes-20200807.patch"
^ permalink raw reply [nested|flat] 27+ messages in thread
* [PATCH 5/8] add special pg_brin_bloom_summary data type
@ 2020-08-06 15:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Tomas Vondra @ 2020-08-06 15:56 UTC (permalink / raw)
---
src/backend/access/brin/brin_bloom.c | 91 ++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 14 ++++
src/include/catalog/pg_type.dat | 7 ++
src/test/regress/expected/type_sanity.out | 7 +-
4 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index b119e4e264..e7ca100821 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -647,7 +647,7 @@ brin_bloom_opcinfo(PG_FUNCTION_ARGS)
result->oi_regular_nulls = true;
result->oi_opaque = (BloomOpaque *)
MAXALIGN((char *) result + SizeofBrinOpcInfo(1));
- result->oi_typcache[0] = lookup_type_cache(BYTEAOID, 0);
+ result->oi_typcache[0] = lookup_type_cache(BRINBLOOMSUMMARYOID, 0);
PG_RETURN_POINTER(result);
}
@@ -978,3 +978,92 @@ brin_bloom_options(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+/*
+ * brin_bloom_summary_in
+ * - input routine for type brin_bloom_summary.
+ *
+ * brin_bloom_summary is only used internally to represent summaries
+ * in BRIN bloom indexes, so it has no operations of its own, and we
+ * disallow input too.
+ */
+Datum
+brin_bloom_summary_in(PG_FUNCTION_ARGS)
+{
+ /*
+ * brin_bloom_summary stores the data in binary form and parsing
+ * text input is not needed, so disallow this.
+ */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+
+/*
+ * brin_bloom_summary_out
+ * - output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized into a bytea value, but we want
+ * to output something nicer humans can understand.
+ */
+Datum
+brin_bloom_summary_out(PG_FUNCTION_ARGS)
+{
+ BloomFilter *filter;
+ StringInfoData str;
+
+ initStringInfo(&str);
+ appendStringInfoChar(&str, '{');
+
+ /*
+ * XXX not sure the detoasting is necessary (probably not, this
+ * can only be in an index).
+ */
+ filter = (BloomFilter *) PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
+
+ if (BLOOM_IS_HASHED(filter))
+ {
+ appendStringInfo(&str, "mode: hashed nhashes: %u nbits: %u nbits_set: %u",
+ filter->nhashes, filter->nbits, filter->nbits_set);
+ }
+ else
+ {
+ appendStringInfo(&str, "mode: sorted nvalues: %u nsorted: %u",
+ filter->nvalues, filter->nsorted);
+ /* TODO include the sorted/unsorted values */
+ }
+
+ appendStringInfoChar(&str, '}');
+
+ PG_RETURN_CSTRING(str.data);
+}
+
+/*
+ * brin_bloom_summary_recv
+ * - binary input routine for type brin_bloom_summary.
+ */
+Datum
+brin_bloom_summary_recv(PG_FUNCTION_ARGS)
+{
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+/*
+ * brin_bloom_summary_send
+ * - binary output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized in a bytea value (although the
+ * type is named differently), so let's just send that.
+ */
+Datum
+brin_bloom_summary_send(PG_FUNCTION_ARGS)
+{
+ return byteasend(fcinfo);
+}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5336aa7b9c..da4c9c6202 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10975,3 +10975,17 @@
prosrc => 'unicode_is_normalized' },
]
+
+{ oid => '9035', descr => 'I/O',
+ proname => 'brin_bloom_summary_in', prorettype => 'pg_brin_bloom_summary',
+ proargtypes => 'cstring', prosrc => 'brin_bloom_summary_in' },
+{ oid => '9036', descr => 'I/O',
+ proname => 'brin_bloom_summary_out', prorettype => 'cstring',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_out' },
+{ oid => '9037', descr => 'I/O',
+ proname => 'brin_bloom_summary_recv', provolatile => 's',
+ prorettype => 'pg_brin_bloom_summary', proargtypes => 'internal',
+ prosrc => 'brin_bloom_summary_recv' },
+{ oid => '9038', descr => 'I/O',
+ proname => 'brin_bloom_summary_send', provolatile => 's', prorettype => 'bytea',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_send' },
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index b2cec07416..a41c2e5418 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -631,3 +631,10 @@
typalign => 'd', typstorage => 'x' },
]
+
+{ oid => '9034', oid_symbol => 'BRINBLOOMSUMMARYOID',
+ descr => 'BRIN bloom summary',
+ typname => 'pg_brin_bloom_summary', typlen => '-1', typbyval => 'f', typcategory => 'S',
+ typinput => 'brin_bloom_summary_in', typoutput => 'brin_bloom_summary_out',
+ typreceive => 'brin_bloom_summary_recv', typsend => 'brin_bloom_summary_send',
+ typalign => 'i', typstorage => 'x', typcollation => 'default' },
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index 274130e706..97bf9797de 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -67,13 +67,14 @@ WHERE p1.typtype not in ('c','d','p') AND p1.typname NOT LIKE E'\\_%'
(SELECT 1 FROM pg_type as p2
WHERE p2.typname = ('_' || p1.typname)::name AND
p2.typelem = p1.oid and p1.typarray = p2.oid);
- oid | typname
-------+-----------------
+ oid | typname
+------+-----------------------
194 | pg_node_tree
3361 | pg_ndistinct
3402 | pg_dependencies
5017 | pg_mcv_list
-(4 rows)
+ 9034 | pg_brin_bloom_summary
+(5 rows)
-- Make sure typarray points to a varlena array type of our own base
SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype,
--
2.25.4
--jsivyprvf2oxfjz3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="0006-BRIN-multi-range-minmax-indexes-20200807.patch"
^ permalink raw reply [nested|flat] 27+ messages in thread
* [PATCH 5/8] add special pg_brin_bloom_summary data type
@ 2020-08-06 15:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Tomas Vondra @ 2020-08-06 15:56 UTC (permalink / raw)
---
src/backend/access/brin/brin_bloom.c | 91 ++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 14 ++++
src/include/catalog/pg_type.dat | 7 ++
src/test/regress/expected/type_sanity.out | 7 +-
4 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index b119e4e264..e7ca100821 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -647,7 +647,7 @@ brin_bloom_opcinfo(PG_FUNCTION_ARGS)
result->oi_regular_nulls = true;
result->oi_opaque = (BloomOpaque *)
MAXALIGN((char *) result + SizeofBrinOpcInfo(1));
- result->oi_typcache[0] = lookup_type_cache(BYTEAOID, 0);
+ result->oi_typcache[0] = lookup_type_cache(BRINBLOOMSUMMARYOID, 0);
PG_RETURN_POINTER(result);
}
@@ -978,3 +978,92 @@ brin_bloom_options(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+/*
+ * brin_bloom_summary_in
+ * - input routine for type brin_bloom_summary.
+ *
+ * brin_bloom_summary is only used internally to represent summaries
+ * in BRIN bloom indexes, so it has no operations of its own, and we
+ * disallow input too.
+ */
+Datum
+brin_bloom_summary_in(PG_FUNCTION_ARGS)
+{
+ /*
+ * brin_bloom_summary stores the data in binary form and parsing
+ * text input is not needed, so disallow this.
+ */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+
+/*
+ * brin_bloom_summary_out
+ * - output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized into a bytea value, but we want
+ * to output something nicer humans can understand.
+ */
+Datum
+brin_bloom_summary_out(PG_FUNCTION_ARGS)
+{
+ BloomFilter *filter;
+ StringInfoData str;
+
+ initStringInfo(&str);
+ appendStringInfoChar(&str, '{');
+
+ /*
+ * XXX not sure the detoasting is necessary (probably not, this
+ * can only be in an index).
+ */
+ filter = (BloomFilter *) PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
+
+ if (BLOOM_IS_HASHED(filter))
+ {
+ appendStringInfo(&str, "mode: hashed nhashes: %u nbits: %u nbits_set: %u",
+ filter->nhashes, filter->nbits, filter->nbits_set);
+ }
+ else
+ {
+ appendStringInfo(&str, "mode: sorted nvalues: %u nsorted: %u",
+ filter->nvalues, filter->nsorted);
+ /* TODO include the sorted/unsorted values */
+ }
+
+ appendStringInfoChar(&str, '}');
+
+ PG_RETURN_CSTRING(str.data);
+}
+
+/*
+ * brin_bloom_summary_recv
+ * - binary input routine for type brin_bloom_summary.
+ */
+Datum
+brin_bloom_summary_recv(PG_FUNCTION_ARGS)
+{
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+/*
+ * brin_bloom_summary_send
+ * - binary output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized in a bytea value (although the
+ * type is named differently), so let's just send that.
+ */
+Datum
+brin_bloom_summary_send(PG_FUNCTION_ARGS)
+{
+ return byteasend(fcinfo);
+}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5336aa7b9c..da4c9c6202 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10975,3 +10975,17 @@
prosrc => 'unicode_is_normalized' },
]
+
+{ oid => '9035', descr => 'I/O',
+ proname => 'brin_bloom_summary_in', prorettype => 'pg_brin_bloom_summary',
+ proargtypes => 'cstring', prosrc => 'brin_bloom_summary_in' },
+{ oid => '9036', descr => 'I/O',
+ proname => 'brin_bloom_summary_out', prorettype => 'cstring',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_out' },
+{ oid => '9037', descr => 'I/O',
+ proname => 'brin_bloom_summary_recv', provolatile => 's',
+ prorettype => 'pg_brin_bloom_summary', proargtypes => 'internal',
+ prosrc => 'brin_bloom_summary_recv' },
+{ oid => '9038', descr => 'I/O',
+ proname => 'brin_bloom_summary_send', provolatile => 's', prorettype => 'bytea',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_send' },
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index b2cec07416..a41c2e5418 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -631,3 +631,10 @@
typalign => 'd', typstorage => 'x' },
]
+
+{ oid => '9034', oid_symbol => 'BRINBLOOMSUMMARYOID',
+ descr => 'BRIN bloom summary',
+ typname => 'pg_brin_bloom_summary', typlen => '-1', typbyval => 'f', typcategory => 'S',
+ typinput => 'brin_bloom_summary_in', typoutput => 'brin_bloom_summary_out',
+ typreceive => 'brin_bloom_summary_recv', typsend => 'brin_bloom_summary_send',
+ typalign => 'i', typstorage => 'x', typcollation => 'default' },
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index 274130e706..97bf9797de 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -67,13 +67,14 @@ WHERE p1.typtype not in ('c','d','p') AND p1.typname NOT LIKE E'\\_%'
(SELECT 1 FROM pg_type as p2
WHERE p2.typname = ('_' || p1.typname)::name AND
p2.typelem = p1.oid and p1.typarray = p2.oid);
- oid | typname
-------+-----------------
+ oid | typname
+------+-----------------------
194 | pg_node_tree
3361 | pg_ndistinct
3402 | pg_dependencies
5017 | pg_mcv_list
-(4 rows)
+ 9034 | pg_brin_bloom_summary
+(5 rows)
-- Make sure typarray points to a varlena array type of our own base
SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype,
--
2.25.4
--jsivyprvf2oxfjz3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="0006-BRIN-multi-range-minmax-indexes-20200807.patch"
^ permalink raw reply [nested|flat] 27+ messages in thread
* [PATCH 5/8] add special pg_brin_bloom_summary data type
@ 2020-08-06 15:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Tomas Vondra @ 2020-08-06 15:56 UTC (permalink / raw)
---
src/backend/access/brin/brin_bloom.c | 91 ++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 14 ++++
src/include/catalog/pg_type.dat | 7 ++
src/test/regress/expected/type_sanity.out | 7 +-
4 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index b119e4e264..e7ca100821 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -647,7 +647,7 @@ brin_bloom_opcinfo(PG_FUNCTION_ARGS)
result->oi_regular_nulls = true;
result->oi_opaque = (BloomOpaque *)
MAXALIGN((char *) result + SizeofBrinOpcInfo(1));
- result->oi_typcache[0] = lookup_type_cache(BYTEAOID, 0);
+ result->oi_typcache[0] = lookup_type_cache(BRINBLOOMSUMMARYOID, 0);
PG_RETURN_POINTER(result);
}
@@ -978,3 +978,92 @@ brin_bloom_options(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+/*
+ * brin_bloom_summary_in
+ * - input routine for type brin_bloom_summary.
+ *
+ * brin_bloom_summary is only used internally to represent summaries
+ * in BRIN bloom indexes, so it has no operations of its own, and we
+ * disallow input too.
+ */
+Datum
+brin_bloom_summary_in(PG_FUNCTION_ARGS)
+{
+ /*
+ * brin_bloom_summary stores the data in binary form and parsing
+ * text input is not needed, so disallow this.
+ */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+
+/*
+ * brin_bloom_summary_out
+ * - output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized into a bytea value, but we want
+ * to output something nicer humans can understand.
+ */
+Datum
+brin_bloom_summary_out(PG_FUNCTION_ARGS)
+{
+ BloomFilter *filter;
+ StringInfoData str;
+
+ initStringInfo(&str);
+ appendStringInfoChar(&str, '{');
+
+ /*
+ * XXX not sure the detoasting is necessary (probably not, this
+ * can only be in an index).
+ */
+ filter = (BloomFilter *) PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
+
+ if (BLOOM_IS_HASHED(filter))
+ {
+ appendStringInfo(&str, "mode: hashed nhashes: %u nbits: %u nbits_set: %u",
+ filter->nhashes, filter->nbits, filter->nbits_set);
+ }
+ else
+ {
+ appendStringInfo(&str, "mode: sorted nvalues: %u nsorted: %u",
+ filter->nvalues, filter->nsorted);
+ /* TODO include the sorted/unsorted values */
+ }
+
+ appendStringInfoChar(&str, '}');
+
+ PG_RETURN_CSTRING(str.data);
+}
+
+/*
+ * brin_bloom_summary_recv
+ * - binary input routine for type brin_bloom_summary.
+ */
+Datum
+brin_bloom_summary_recv(PG_FUNCTION_ARGS)
+{
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+/*
+ * brin_bloom_summary_send
+ * - binary output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized in a bytea value (although the
+ * type is named differently), so let's just send that.
+ */
+Datum
+brin_bloom_summary_send(PG_FUNCTION_ARGS)
+{
+ return byteasend(fcinfo);
+}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5336aa7b9c..da4c9c6202 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10975,3 +10975,17 @@
prosrc => 'unicode_is_normalized' },
]
+
+{ oid => '9035', descr => 'I/O',
+ proname => 'brin_bloom_summary_in', prorettype => 'pg_brin_bloom_summary',
+ proargtypes => 'cstring', prosrc => 'brin_bloom_summary_in' },
+{ oid => '9036', descr => 'I/O',
+ proname => 'brin_bloom_summary_out', prorettype => 'cstring',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_out' },
+{ oid => '9037', descr => 'I/O',
+ proname => 'brin_bloom_summary_recv', provolatile => 's',
+ prorettype => 'pg_brin_bloom_summary', proargtypes => 'internal',
+ prosrc => 'brin_bloom_summary_recv' },
+{ oid => '9038', descr => 'I/O',
+ proname => 'brin_bloom_summary_send', provolatile => 's', prorettype => 'bytea',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_send' },
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index b2cec07416..a41c2e5418 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -631,3 +631,10 @@
typalign => 'd', typstorage => 'x' },
]
+
+{ oid => '9034', oid_symbol => 'BRINBLOOMSUMMARYOID',
+ descr => 'BRIN bloom summary',
+ typname => 'pg_brin_bloom_summary', typlen => '-1', typbyval => 'f', typcategory => 'S',
+ typinput => 'brin_bloom_summary_in', typoutput => 'brin_bloom_summary_out',
+ typreceive => 'brin_bloom_summary_recv', typsend => 'brin_bloom_summary_send',
+ typalign => 'i', typstorage => 'x', typcollation => 'default' },
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index 274130e706..97bf9797de 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -67,13 +67,14 @@ WHERE p1.typtype not in ('c','d','p') AND p1.typname NOT LIKE E'\\_%'
(SELECT 1 FROM pg_type as p2
WHERE p2.typname = ('_' || p1.typname)::name AND
p2.typelem = p1.oid and p1.typarray = p2.oid);
- oid | typname
-------+-----------------
+ oid | typname
+------+-----------------------
194 | pg_node_tree
3361 | pg_ndistinct
3402 | pg_dependencies
5017 | pg_mcv_list
-(4 rows)
+ 9034 | pg_brin_bloom_summary
+(5 rows)
-- Make sure typarray points to a varlena array type of our own base
SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype,
--
2.25.4
--jsivyprvf2oxfjz3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="0006-BRIN-multi-range-minmax-indexes-20200807.patch"
^ permalink raw reply [nested|flat] 27+ messages in thread
* [PATCH 5/8] add special pg_brin_bloom_summary data type
@ 2020-08-06 15:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Tomas Vondra @ 2020-08-06 15:56 UTC (permalink / raw)
---
src/backend/access/brin/brin_bloom.c | 91 ++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 14 ++++
src/include/catalog/pg_type.dat | 7 ++
src/test/regress/expected/type_sanity.out | 7 +-
4 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index b119e4e264..e7ca100821 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -647,7 +647,7 @@ brin_bloom_opcinfo(PG_FUNCTION_ARGS)
result->oi_regular_nulls = true;
result->oi_opaque = (BloomOpaque *)
MAXALIGN((char *) result + SizeofBrinOpcInfo(1));
- result->oi_typcache[0] = lookup_type_cache(BYTEAOID, 0);
+ result->oi_typcache[0] = lookup_type_cache(BRINBLOOMSUMMARYOID, 0);
PG_RETURN_POINTER(result);
}
@@ -978,3 +978,92 @@ brin_bloom_options(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+/*
+ * brin_bloom_summary_in
+ * - input routine for type brin_bloom_summary.
+ *
+ * brin_bloom_summary is only used internally to represent summaries
+ * in BRIN bloom indexes, so it has no operations of its own, and we
+ * disallow input too.
+ */
+Datum
+brin_bloom_summary_in(PG_FUNCTION_ARGS)
+{
+ /*
+ * brin_bloom_summary stores the data in binary form and parsing
+ * text input is not needed, so disallow this.
+ */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+
+/*
+ * brin_bloom_summary_out
+ * - output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized into a bytea value, but we want
+ * to output something nicer humans can understand.
+ */
+Datum
+brin_bloom_summary_out(PG_FUNCTION_ARGS)
+{
+ BloomFilter *filter;
+ StringInfoData str;
+
+ initStringInfo(&str);
+ appendStringInfoChar(&str, '{');
+
+ /*
+ * XXX not sure the detoasting is necessary (probably not, this
+ * can only be in an index).
+ */
+ filter = (BloomFilter *) PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
+
+ if (BLOOM_IS_HASHED(filter))
+ {
+ appendStringInfo(&str, "mode: hashed nhashes: %u nbits: %u nbits_set: %u",
+ filter->nhashes, filter->nbits, filter->nbits_set);
+ }
+ else
+ {
+ appendStringInfo(&str, "mode: sorted nvalues: %u nsorted: %u",
+ filter->nvalues, filter->nsorted);
+ /* TODO include the sorted/unsorted values */
+ }
+
+ appendStringInfoChar(&str, '}');
+
+ PG_RETURN_CSTRING(str.data);
+}
+
+/*
+ * brin_bloom_summary_recv
+ * - binary input routine for type brin_bloom_summary.
+ */
+Datum
+brin_bloom_summary_recv(PG_FUNCTION_ARGS)
+{
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+/*
+ * brin_bloom_summary_send
+ * - binary output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized in a bytea value (although the
+ * type is named differently), so let's just send that.
+ */
+Datum
+brin_bloom_summary_send(PG_FUNCTION_ARGS)
+{
+ return byteasend(fcinfo);
+}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5336aa7b9c..da4c9c6202 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10975,3 +10975,17 @@
prosrc => 'unicode_is_normalized' },
]
+
+{ oid => '9035', descr => 'I/O',
+ proname => 'brin_bloom_summary_in', prorettype => 'pg_brin_bloom_summary',
+ proargtypes => 'cstring', prosrc => 'brin_bloom_summary_in' },
+{ oid => '9036', descr => 'I/O',
+ proname => 'brin_bloom_summary_out', prorettype => 'cstring',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_out' },
+{ oid => '9037', descr => 'I/O',
+ proname => 'brin_bloom_summary_recv', provolatile => 's',
+ prorettype => 'pg_brin_bloom_summary', proargtypes => 'internal',
+ prosrc => 'brin_bloom_summary_recv' },
+{ oid => '9038', descr => 'I/O',
+ proname => 'brin_bloom_summary_send', provolatile => 's', prorettype => 'bytea',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_send' },
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index b2cec07416..a41c2e5418 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -631,3 +631,10 @@
typalign => 'd', typstorage => 'x' },
]
+
+{ oid => '9034', oid_symbol => 'BRINBLOOMSUMMARYOID',
+ descr => 'BRIN bloom summary',
+ typname => 'pg_brin_bloom_summary', typlen => '-1', typbyval => 'f', typcategory => 'S',
+ typinput => 'brin_bloom_summary_in', typoutput => 'brin_bloom_summary_out',
+ typreceive => 'brin_bloom_summary_recv', typsend => 'brin_bloom_summary_send',
+ typalign => 'i', typstorage => 'x', typcollation => 'default' },
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index 274130e706..97bf9797de 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -67,13 +67,14 @@ WHERE p1.typtype not in ('c','d','p') AND p1.typname NOT LIKE E'\\_%'
(SELECT 1 FROM pg_type as p2
WHERE p2.typname = ('_' || p1.typname)::name AND
p2.typelem = p1.oid and p1.typarray = p2.oid);
- oid | typname
-------+-----------------
+ oid | typname
+------+-----------------------
194 | pg_node_tree
3361 | pg_ndistinct
3402 | pg_dependencies
5017 | pg_mcv_list
-(4 rows)
+ 9034 | pg_brin_bloom_summary
+(5 rows)
-- Make sure typarray points to a varlena array type of our own base
SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype,
--
2.25.4
--jsivyprvf2oxfjz3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="0006-BRIN-multi-range-minmax-indexes-20200807.patch"
^ permalink raw reply [nested|flat] 27+ messages in thread
* [PATCH 5/8] add special pg_brin_bloom_summary data type
@ 2020-08-06 15:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Tomas Vondra @ 2020-08-06 15:56 UTC (permalink / raw)
---
src/backend/access/brin/brin_bloom.c | 91 ++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 14 ++++
src/include/catalog/pg_type.dat | 7 ++
src/test/regress/expected/type_sanity.out | 7 +-
4 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index b119e4e264..e7ca100821 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -647,7 +647,7 @@ brin_bloom_opcinfo(PG_FUNCTION_ARGS)
result->oi_regular_nulls = true;
result->oi_opaque = (BloomOpaque *)
MAXALIGN((char *) result + SizeofBrinOpcInfo(1));
- result->oi_typcache[0] = lookup_type_cache(BYTEAOID, 0);
+ result->oi_typcache[0] = lookup_type_cache(BRINBLOOMSUMMARYOID, 0);
PG_RETURN_POINTER(result);
}
@@ -978,3 +978,92 @@ brin_bloom_options(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+/*
+ * brin_bloom_summary_in
+ * - input routine for type brin_bloom_summary.
+ *
+ * brin_bloom_summary is only used internally to represent summaries
+ * in BRIN bloom indexes, so it has no operations of its own, and we
+ * disallow input too.
+ */
+Datum
+brin_bloom_summary_in(PG_FUNCTION_ARGS)
+{
+ /*
+ * brin_bloom_summary stores the data in binary form and parsing
+ * text input is not needed, so disallow this.
+ */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+
+/*
+ * brin_bloom_summary_out
+ * - output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized into a bytea value, but we want
+ * to output something nicer humans can understand.
+ */
+Datum
+brin_bloom_summary_out(PG_FUNCTION_ARGS)
+{
+ BloomFilter *filter;
+ StringInfoData str;
+
+ initStringInfo(&str);
+ appendStringInfoChar(&str, '{');
+
+ /*
+ * XXX not sure the detoasting is necessary (probably not, this
+ * can only be in an index).
+ */
+ filter = (BloomFilter *) PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
+
+ if (BLOOM_IS_HASHED(filter))
+ {
+ appendStringInfo(&str, "mode: hashed nhashes: %u nbits: %u nbits_set: %u",
+ filter->nhashes, filter->nbits, filter->nbits_set);
+ }
+ else
+ {
+ appendStringInfo(&str, "mode: sorted nvalues: %u nsorted: %u",
+ filter->nvalues, filter->nsorted);
+ /* TODO include the sorted/unsorted values */
+ }
+
+ appendStringInfoChar(&str, '}');
+
+ PG_RETURN_CSTRING(str.data);
+}
+
+/*
+ * brin_bloom_summary_recv
+ * - binary input routine for type brin_bloom_summary.
+ */
+Datum
+brin_bloom_summary_recv(PG_FUNCTION_ARGS)
+{
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+/*
+ * brin_bloom_summary_send
+ * - binary output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized in a bytea value (although the
+ * type is named differently), so let's just send that.
+ */
+Datum
+brin_bloom_summary_send(PG_FUNCTION_ARGS)
+{
+ return byteasend(fcinfo);
+}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5336aa7b9c..da4c9c6202 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10975,3 +10975,17 @@
prosrc => 'unicode_is_normalized' },
]
+
+{ oid => '9035', descr => 'I/O',
+ proname => 'brin_bloom_summary_in', prorettype => 'pg_brin_bloom_summary',
+ proargtypes => 'cstring', prosrc => 'brin_bloom_summary_in' },
+{ oid => '9036', descr => 'I/O',
+ proname => 'brin_bloom_summary_out', prorettype => 'cstring',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_out' },
+{ oid => '9037', descr => 'I/O',
+ proname => 'brin_bloom_summary_recv', provolatile => 's',
+ prorettype => 'pg_brin_bloom_summary', proargtypes => 'internal',
+ prosrc => 'brin_bloom_summary_recv' },
+{ oid => '9038', descr => 'I/O',
+ proname => 'brin_bloom_summary_send', provolatile => 's', prorettype => 'bytea',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_send' },
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index b2cec07416..a41c2e5418 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -631,3 +631,10 @@
typalign => 'd', typstorage => 'x' },
]
+
+{ oid => '9034', oid_symbol => 'BRINBLOOMSUMMARYOID',
+ descr => 'BRIN bloom summary',
+ typname => 'pg_brin_bloom_summary', typlen => '-1', typbyval => 'f', typcategory => 'S',
+ typinput => 'brin_bloom_summary_in', typoutput => 'brin_bloom_summary_out',
+ typreceive => 'brin_bloom_summary_recv', typsend => 'brin_bloom_summary_send',
+ typalign => 'i', typstorage => 'x', typcollation => 'default' },
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index 274130e706..97bf9797de 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -67,13 +67,14 @@ WHERE p1.typtype not in ('c','d','p') AND p1.typname NOT LIKE E'\\_%'
(SELECT 1 FROM pg_type as p2
WHERE p2.typname = ('_' || p1.typname)::name AND
p2.typelem = p1.oid and p1.typarray = p2.oid);
- oid | typname
-------+-----------------
+ oid | typname
+------+-----------------------
194 | pg_node_tree
3361 | pg_ndistinct
3402 | pg_dependencies
5017 | pg_mcv_list
-(4 rows)
+ 9034 | pg_brin_bloom_summary
+(5 rows)
-- Make sure typarray points to a varlena array type of our own base
SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype,
--
2.25.4
--jsivyprvf2oxfjz3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="0006-BRIN-multi-range-minmax-indexes-20200807.patch"
^ permalink raw reply [nested|flat] 27+ messages in thread
* [PATCH 5/8] add special pg_brin_bloom_summary data type
@ 2020-08-06 15:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Tomas Vondra @ 2020-08-06 15:56 UTC (permalink / raw)
---
src/backend/access/brin/brin_bloom.c | 91 ++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 14 ++++
src/include/catalog/pg_type.dat | 7 ++
src/test/regress/expected/type_sanity.out | 7 +-
4 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index b119e4e264..e7ca100821 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -647,7 +647,7 @@ brin_bloom_opcinfo(PG_FUNCTION_ARGS)
result->oi_regular_nulls = true;
result->oi_opaque = (BloomOpaque *)
MAXALIGN((char *) result + SizeofBrinOpcInfo(1));
- result->oi_typcache[0] = lookup_type_cache(BYTEAOID, 0);
+ result->oi_typcache[0] = lookup_type_cache(BRINBLOOMSUMMARYOID, 0);
PG_RETURN_POINTER(result);
}
@@ -978,3 +978,92 @@ brin_bloom_options(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+/*
+ * brin_bloom_summary_in
+ * - input routine for type brin_bloom_summary.
+ *
+ * brin_bloom_summary is only used internally to represent summaries
+ * in BRIN bloom indexes, so it has no operations of its own, and we
+ * disallow input too.
+ */
+Datum
+brin_bloom_summary_in(PG_FUNCTION_ARGS)
+{
+ /*
+ * brin_bloom_summary stores the data in binary form and parsing
+ * text input is not needed, so disallow this.
+ */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+
+/*
+ * brin_bloom_summary_out
+ * - output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized into a bytea value, but we want
+ * to output something nicer humans can understand.
+ */
+Datum
+brin_bloom_summary_out(PG_FUNCTION_ARGS)
+{
+ BloomFilter *filter;
+ StringInfoData str;
+
+ initStringInfo(&str);
+ appendStringInfoChar(&str, '{');
+
+ /*
+ * XXX not sure the detoasting is necessary (probably not, this
+ * can only be in an index).
+ */
+ filter = (BloomFilter *) PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
+
+ if (BLOOM_IS_HASHED(filter))
+ {
+ appendStringInfo(&str, "mode: hashed nhashes: %u nbits: %u nbits_set: %u",
+ filter->nhashes, filter->nbits, filter->nbits_set);
+ }
+ else
+ {
+ appendStringInfo(&str, "mode: sorted nvalues: %u nsorted: %u",
+ filter->nvalues, filter->nsorted);
+ /* TODO include the sorted/unsorted values */
+ }
+
+ appendStringInfoChar(&str, '}');
+
+ PG_RETURN_CSTRING(str.data);
+}
+
+/*
+ * brin_bloom_summary_recv
+ * - binary input routine for type brin_bloom_summary.
+ */
+Datum
+brin_bloom_summary_recv(PG_FUNCTION_ARGS)
+{
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+/*
+ * brin_bloom_summary_send
+ * - binary output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized in a bytea value (although the
+ * type is named differently), so let's just send that.
+ */
+Datum
+brin_bloom_summary_send(PG_FUNCTION_ARGS)
+{
+ return byteasend(fcinfo);
+}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5336aa7b9c..da4c9c6202 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10975,3 +10975,17 @@
prosrc => 'unicode_is_normalized' },
]
+
+{ oid => '9035', descr => 'I/O',
+ proname => 'brin_bloom_summary_in', prorettype => 'pg_brin_bloom_summary',
+ proargtypes => 'cstring', prosrc => 'brin_bloom_summary_in' },
+{ oid => '9036', descr => 'I/O',
+ proname => 'brin_bloom_summary_out', prorettype => 'cstring',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_out' },
+{ oid => '9037', descr => 'I/O',
+ proname => 'brin_bloom_summary_recv', provolatile => 's',
+ prorettype => 'pg_brin_bloom_summary', proargtypes => 'internal',
+ prosrc => 'brin_bloom_summary_recv' },
+{ oid => '9038', descr => 'I/O',
+ proname => 'brin_bloom_summary_send', provolatile => 's', prorettype => 'bytea',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_send' },
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index b2cec07416..a41c2e5418 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -631,3 +631,10 @@
typalign => 'd', typstorage => 'x' },
]
+
+{ oid => '9034', oid_symbol => 'BRINBLOOMSUMMARYOID',
+ descr => 'BRIN bloom summary',
+ typname => 'pg_brin_bloom_summary', typlen => '-1', typbyval => 'f', typcategory => 'S',
+ typinput => 'brin_bloom_summary_in', typoutput => 'brin_bloom_summary_out',
+ typreceive => 'brin_bloom_summary_recv', typsend => 'brin_bloom_summary_send',
+ typalign => 'i', typstorage => 'x', typcollation => 'default' },
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index 274130e706..97bf9797de 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -67,13 +67,14 @@ WHERE p1.typtype not in ('c','d','p') AND p1.typname NOT LIKE E'\\_%'
(SELECT 1 FROM pg_type as p2
WHERE p2.typname = ('_' || p1.typname)::name AND
p2.typelem = p1.oid and p1.typarray = p2.oid);
- oid | typname
-------+-----------------
+ oid | typname
+------+-----------------------
194 | pg_node_tree
3361 | pg_ndistinct
3402 | pg_dependencies
5017 | pg_mcv_list
-(4 rows)
+ 9034 | pg_brin_bloom_summary
+(5 rows)
-- Make sure typarray points to a varlena array type of our own base
SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype,
--
2.25.4
--jsivyprvf2oxfjz3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="0006-BRIN-multi-range-minmax-indexes-20200807.patch"
^ permalink raw reply [nested|flat] 27+ messages in thread
* [PATCH 5/8] add special pg_brin_bloom_summary data type
@ 2020-08-06 15:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Tomas Vondra @ 2020-08-06 15:56 UTC (permalink / raw)
---
src/backend/access/brin/brin_bloom.c | 91 ++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 14 ++++
src/include/catalog/pg_type.dat | 7 ++
src/test/regress/expected/type_sanity.out | 7 +-
4 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index b119e4e264..e7ca100821 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -647,7 +647,7 @@ brin_bloom_opcinfo(PG_FUNCTION_ARGS)
result->oi_regular_nulls = true;
result->oi_opaque = (BloomOpaque *)
MAXALIGN((char *) result + SizeofBrinOpcInfo(1));
- result->oi_typcache[0] = lookup_type_cache(BYTEAOID, 0);
+ result->oi_typcache[0] = lookup_type_cache(BRINBLOOMSUMMARYOID, 0);
PG_RETURN_POINTER(result);
}
@@ -978,3 +978,92 @@ brin_bloom_options(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+/*
+ * brin_bloom_summary_in
+ * - input routine for type brin_bloom_summary.
+ *
+ * brin_bloom_summary is only used internally to represent summaries
+ * in BRIN bloom indexes, so it has no operations of its own, and we
+ * disallow input too.
+ */
+Datum
+brin_bloom_summary_in(PG_FUNCTION_ARGS)
+{
+ /*
+ * brin_bloom_summary stores the data in binary form and parsing
+ * text input is not needed, so disallow this.
+ */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+
+/*
+ * brin_bloom_summary_out
+ * - output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized into a bytea value, but we want
+ * to output something nicer humans can understand.
+ */
+Datum
+brin_bloom_summary_out(PG_FUNCTION_ARGS)
+{
+ BloomFilter *filter;
+ StringInfoData str;
+
+ initStringInfo(&str);
+ appendStringInfoChar(&str, '{');
+
+ /*
+ * XXX not sure the detoasting is necessary (probably not, this
+ * can only be in an index).
+ */
+ filter = (BloomFilter *) PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
+
+ if (BLOOM_IS_HASHED(filter))
+ {
+ appendStringInfo(&str, "mode: hashed nhashes: %u nbits: %u nbits_set: %u",
+ filter->nhashes, filter->nbits, filter->nbits_set);
+ }
+ else
+ {
+ appendStringInfo(&str, "mode: sorted nvalues: %u nsorted: %u",
+ filter->nvalues, filter->nsorted);
+ /* TODO include the sorted/unsorted values */
+ }
+
+ appendStringInfoChar(&str, '}');
+
+ PG_RETURN_CSTRING(str.data);
+}
+
+/*
+ * brin_bloom_summary_recv
+ * - binary input routine for type brin_bloom_summary.
+ */
+Datum
+brin_bloom_summary_recv(PG_FUNCTION_ARGS)
+{
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+/*
+ * brin_bloom_summary_send
+ * - binary output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized in a bytea value (although the
+ * type is named differently), so let's just send that.
+ */
+Datum
+brin_bloom_summary_send(PG_FUNCTION_ARGS)
+{
+ return byteasend(fcinfo);
+}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5336aa7b9c..da4c9c6202 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10975,3 +10975,17 @@
prosrc => 'unicode_is_normalized' },
]
+
+{ oid => '9035', descr => 'I/O',
+ proname => 'brin_bloom_summary_in', prorettype => 'pg_brin_bloom_summary',
+ proargtypes => 'cstring', prosrc => 'brin_bloom_summary_in' },
+{ oid => '9036', descr => 'I/O',
+ proname => 'brin_bloom_summary_out', prorettype => 'cstring',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_out' },
+{ oid => '9037', descr => 'I/O',
+ proname => 'brin_bloom_summary_recv', provolatile => 's',
+ prorettype => 'pg_brin_bloom_summary', proargtypes => 'internal',
+ prosrc => 'brin_bloom_summary_recv' },
+{ oid => '9038', descr => 'I/O',
+ proname => 'brin_bloom_summary_send', provolatile => 's', prorettype => 'bytea',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_send' },
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index b2cec07416..a41c2e5418 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -631,3 +631,10 @@
typalign => 'd', typstorage => 'x' },
]
+
+{ oid => '9034', oid_symbol => 'BRINBLOOMSUMMARYOID',
+ descr => 'BRIN bloom summary',
+ typname => 'pg_brin_bloom_summary', typlen => '-1', typbyval => 'f', typcategory => 'S',
+ typinput => 'brin_bloom_summary_in', typoutput => 'brin_bloom_summary_out',
+ typreceive => 'brin_bloom_summary_recv', typsend => 'brin_bloom_summary_send',
+ typalign => 'i', typstorage => 'x', typcollation => 'default' },
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index 274130e706..97bf9797de 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -67,13 +67,14 @@ WHERE p1.typtype not in ('c','d','p') AND p1.typname NOT LIKE E'\\_%'
(SELECT 1 FROM pg_type as p2
WHERE p2.typname = ('_' || p1.typname)::name AND
p2.typelem = p1.oid and p1.typarray = p2.oid);
- oid | typname
-------+-----------------
+ oid | typname
+------+-----------------------
194 | pg_node_tree
3361 | pg_ndistinct
3402 | pg_dependencies
5017 | pg_mcv_list
-(4 rows)
+ 9034 | pg_brin_bloom_summary
+(5 rows)
-- Make sure typarray points to a varlena array type of our own base
SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype,
--
2.25.4
--jsivyprvf2oxfjz3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="0006-BRIN-multi-range-minmax-indexes-20200807.patch"
^ permalink raw reply [nested|flat] 27+ messages in thread
* [PATCH 5/8] add special pg_brin_bloom_summary data type
@ 2020-08-06 15:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Tomas Vondra @ 2020-08-06 15:56 UTC (permalink / raw)
---
src/backend/access/brin/brin_bloom.c | 91 ++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 14 ++++
src/include/catalog/pg_type.dat | 7 ++
src/test/regress/expected/type_sanity.out | 7 +-
4 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index b119e4e264..e7ca100821 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -647,7 +647,7 @@ brin_bloom_opcinfo(PG_FUNCTION_ARGS)
result->oi_regular_nulls = true;
result->oi_opaque = (BloomOpaque *)
MAXALIGN((char *) result + SizeofBrinOpcInfo(1));
- result->oi_typcache[0] = lookup_type_cache(BYTEAOID, 0);
+ result->oi_typcache[0] = lookup_type_cache(BRINBLOOMSUMMARYOID, 0);
PG_RETURN_POINTER(result);
}
@@ -978,3 +978,92 @@ brin_bloom_options(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+/*
+ * brin_bloom_summary_in
+ * - input routine for type brin_bloom_summary.
+ *
+ * brin_bloom_summary is only used internally to represent summaries
+ * in BRIN bloom indexes, so it has no operations of its own, and we
+ * disallow input too.
+ */
+Datum
+brin_bloom_summary_in(PG_FUNCTION_ARGS)
+{
+ /*
+ * brin_bloom_summary stores the data in binary form and parsing
+ * text input is not needed, so disallow this.
+ */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+
+/*
+ * brin_bloom_summary_out
+ * - output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized into a bytea value, but we want
+ * to output something nicer humans can understand.
+ */
+Datum
+brin_bloom_summary_out(PG_FUNCTION_ARGS)
+{
+ BloomFilter *filter;
+ StringInfoData str;
+
+ initStringInfo(&str);
+ appendStringInfoChar(&str, '{');
+
+ /*
+ * XXX not sure the detoasting is necessary (probably not, this
+ * can only be in an index).
+ */
+ filter = (BloomFilter *) PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
+
+ if (BLOOM_IS_HASHED(filter))
+ {
+ appendStringInfo(&str, "mode: hashed nhashes: %u nbits: %u nbits_set: %u",
+ filter->nhashes, filter->nbits, filter->nbits_set);
+ }
+ else
+ {
+ appendStringInfo(&str, "mode: sorted nvalues: %u nsorted: %u",
+ filter->nvalues, filter->nsorted);
+ /* TODO include the sorted/unsorted values */
+ }
+
+ appendStringInfoChar(&str, '}');
+
+ PG_RETURN_CSTRING(str.data);
+}
+
+/*
+ * brin_bloom_summary_recv
+ * - binary input routine for type brin_bloom_summary.
+ */
+Datum
+brin_bloom_summary_recv(PG_FUNCTION_ARGS)
+{
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+/*
+ * brin_bloom_summary_send
+ * - binary output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized in a bytea value (although the
+ * type is named differently), so let's just send that.
+ */
+Datum
+brin_bloom_summary_send(PG_FUNCTION_ARGS)
+{
+ return byteasend(fcinfo);
+}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5336aa7b9c..da4c9c6202 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10975,3 +10975,17 @@
prosrc => 'unicode_is_normalized' },
]
+
+{ oid => '9035', descr => 'I/O',
+ proname => 'brin_bloom_summary_in', prorettype => 'pg_brin_bloom_summary',
+ proargtypes => 'cstring', prosrc => 'brin_bloom_summary_in' },
+{ oid => '9036', descr => 'I/O',
+ proname => 'brin_bloom_summary_out', prorettype => 'cstring',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_out' },
+{ oid => '9037', descr => 'I/O',
+ proname => 'brin_bloom_summary_recv', provolatile => 's',
+ prorettype => 'pg_brin_bloom_summary', proargtypes => 'internal',
+ prosrc => 'brin_bloom_summary_recv' },
+{ oid => '9038', descr => 'I/O',
+ proname => 'brin_bloom_summary_send', provolatile => 's', prorettype => 'bytea',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_send' },
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index b2cec07416..a41c2e5418 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -631,3 +631,10 @@
typalign => 'd', typstorage => 'x' },
]
+
+{ oid => '9034', oid_symbol => 'BRINBLOOMSUMMARYOID',
+ descr => 'BRIN bloom summary',
+ typname => 'pg_brin_bloom_summary', typlen => '-1', typbyval => 'f', typcategory => 'S',
+ typinput => 'brin_bloom_summary_in', typoutput => 'brin_bloom_summary_out',
+ typreceive => 'brin_bloom_summary_recv', typsend => 'brin_bloom_summary_send',
+ typalign => 'i', typstorage => 'x', typcollation => 'default' },
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index 274130e706..97bf9797de 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -67,13 +67,14 @@ WHERE p1.typtype not in ('c','d','p') AND p1.typname NOT LIKE E'\\_%'
(SELECT 1 FROM pg_type as p2
WHERE p2.typname = ('_' || p1.typname)::name AND
p2.typelem = p1.oid and p1.typarray = p2.oid);
- oid | typname
-------+-----------------
+ oid | typname
+------+-----------------------
194 | pg_node_tree
3361 | pg_ndistinct
3402 | pg_dependencies
5017 | pg_mcv_list
-(4 rows)
+ 9034 | pg_brin_bloom_summary
+(5 rows)
-- Make sure typarray points to a varlena array type of our own base
SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype,
--
2.25.4
--jsivyprvf2oxfjz3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="0006-BRIN-multi-range-minmax-indexes-20200807.patch"
^ permalink raw reply [nested|flat] 27+ messages in thread
* [PATCH 5/8] add special pg_brin_bloom_summary data type
@ 2020-08-06 15:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Tomas Vondra @ 2020-08-06 15:56 UTC (permalink / raw)
---
src/backend/access/brin/brin_bloom.c | 91 ++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 14 ++++
src/include/catalog/pg_type.dat | 7 ++
src/test/regress/expected/type_sanity.out | 7 +-
4 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index b119e4e264..e7ca100821 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -647,7 +647,7 @@ brin_bloom_opcinfo(PG_FUNCTION_ARGS)
result->oi_regular_nulls = true;
result->oi_opaque = (BloomOpaque *)
MAXALIGN((char *) result + SizeofBrinOpcInfo(1));
- result->oi_typcache[0] = lookup_type_cache(BYTEAOID, 0);
+ result->oi_typcache[0] = lookup_type_cache(BRINBLOOMSUMMARYOID, 0);
PG_RETURN_POINTER(result);
}
@@ -978,3 +978,92 @@ brin_bloom_options(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+/*
+ * brin_bloom_summary_in
+ * - input routine for type brin_bloom_summary.
+ *
+ * brin_bloom_summary is only used internally to represent summaries
+ * in BRIN bloom indexes, so it has no operations of its own, and we
+ * disallow input too.
+ */
+Datum
+brin_bloom_summary_in(PG_FUNCTION_ARGS)
+{
+ /*
+ * brin_bloom_summary stores the data in binary form and parsing
+ * text input is not needed, so disallow this.
+ */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+
+/*
+ * brin_bloom_summary_out
+ * - output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized into a bytea value, but we want
+ * to output something nicer humans can understand.
+ */
+Datum
+brin_bloom_summary_out(PG_FUNCTION_ARGS)
+{
+ BloomFilter *filter;
+ StringInfoData str;
+
+ initStringInfo(&str);
+ appendStringInfoChar(&str, '{');
+
+ /*
+ * XXX not sure the detoasting is necessary (probably not, this
+ * can only be in an index).
+ */
+ filter = (BloomFilter *) PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
+
+ if (BLOOM_IS_HASHED(filter))
+ {
+ appendStringInfo(&str, "mode: hashed nhashes: %u nbits: %u nbits_set: %u",
+ filter->nhashes, filter->nbits, filter->nbits_set);
+ }
+ else
+ {
+ appendStringInfo(&str, "mode: sorted nvalues: %u nsorted: %u",
+ filter->nvalues, filter->nsorted);
+ /* TODO include the sorted/unsorted values */
+ }
+
+ appendStringInfoChar(&str, '}');
+
+ PG_RETURN_CSTRING(str.data);
+}
+
+/*
+ * brin_bloom_summary_recv
+ * - binary input routine for type brin_bloom_summary.
+ */
+Datum
+brin_bloom_summary_recv(PG_FUNCTION_ARGS)
+{
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+/*
+ * brin_bloom_summary_send
+ * - binary output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized in a bytea value (although the
+ * type is named differently), so let's just send that.
+ */
+Datum
+brin_bloom_summary_send(PG_FUNCTION_ARGS)
+{
+ return byteasend(fcinfo);
+}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5336aa7b9c..da4c9c6202 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10975,3 +10975,17 @@
prosrc => 'unicode_is_normalized' },
]
+
+{ oid => '9035', descr => 'I/O',
+ proname => 'brin_bloom_summary_in', prorettype => 'pg_brin_bloom_summary',
+ proargtypes => 'cstring', prosrc => 'brin_bloom_summary_in' },
+{ oid => '9036', descr => 'I/O',
+ proname => 'brin_bloom_summary_out', prorettype => 'cstring',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_out' },
+{ oid => '9037', descr => 'I/O',
+ proname => 'brin_bloom_summary_recv', provolatile => 's',
+ prorettype => 'pg_brin_bloom_summary', proargtypes => 'internal',
+ prosrc => 'brin_bloom_summary_recv' },
+{ oid => '9038', descr => 'I/O',
+ proname => 'brin_bloom_summary_send', provolatile => 's', prorettype => 'bytea',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_send' },
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index b2cec07416..a41c2e5418 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -631,3 +631,10 @@
typalign => 'd', typstorage => 'x' },
]
+
+{ oid => '9034', oid_symbol => 'BRINBLOOMSUMMARYOID',
+ descr => 'BRIN bloom summary',
+ typname => 'pg_brin_bloom_summary', typlen => '-1', typbyval => 'f', typcategory => 'S',
+ typinput => 'brin_bloom_summary_in', typoutput => 'brin_bloom_summary_out',
+ typreceive => 'brin_bloom_summary_recv', typsend => 'brin_bloom_summary_send',
+ typalign => 'i', typstorage => 'x', typcollation => 'default' },
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index 274130e706..97bf9797de 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -67,13 +67,14 @@ WHERE p1.typtype not in ('c','d','p') AND p1.typname NOT LIKE E'\\_%'
(SELECT 1 FROM pg_type as p2
WHERE p2.typname = ('_' || p1.typname)::name AND
p2.typelem = p1.oid and p1.typarray = p2.oid);
- oid | typname
-------+-----------------
+ oid | typname
+------+-----------------------
194 | pg_node_tree
3361 | pg_ndistinct
3402 | pg_dependencies
5017 | pg_mcv_list
-(4 rows)
+ 9034 | pg_brin_bloom_summary
+(5 rows)
-- Make sure typarray points to a varlena array type of our own base
SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype,
--
2.25.4
--jsivyprvf2oxfjz3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="0006-BRIN-multi-range-minmax-indexes-20200807.patch"
^ permalink raw reply [nested|flat] 27+ messages in thread
* [PATCH 5/8] add special pg_brin_bloom_summary data type
@ 2020-08-06 15:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Tomas Vondra @ 2020-08-06 15:56 UTC (permalink / raw)
---
src/backend/access/brin/brin_bloom.c | 91 ++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 14 ++++
src/include/catalog/pg_type.dat | 7 ++
src/test/regress/expected/type_sanity.out | 7 +-
4 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index b119e4e264..e7ca100821 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -647,7 +647,7 @@ brin_bloom_opcinfo(PG_FUNCTION_ARGS)
result->oi_regular_nulls = true;
result->oi_opaque = (BloomOpaque *)
MAXALIGN((char *) result + SizeofBrinOpcInfo(1));
- result->oi_typcache[0] = lookup_type_cache(BYTEAOID, 0);
+ result->oi_typcache[0] = lookup_type_cache(BRINBLOOMSUMMARYOID, 0);
PG_RETURN_POINTER(result);
}
@@ -978,3 +978,92 @@ brin_bloom_options(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+/*
+ * brin_bloom_summary_in
+ * - input routine for type brin_bloom_summary.
+ *
+ * brin_bloom_summary is only used internally to represent summaries
+ * in BRIN bloom indexes, so it has no operations of its own, and we
+ * disallow input too.
+ */
+Datum
+brin_bloom_summary_in(PG_FUNCTION_ARGS)
+{
+ /*
+ * brin_bloom_summary stores the data in binary form and parsing
+ * text input is not needed, so disallow this.
+ */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+
+/*
+ * brin_bloom_summary_out
+ * - output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized into a bytea value, but we want
+ * to output something nicer humans can understand.
+ */
+Datum
+brin_bloom_summary_out(PG_FUNCTION_ARGS)
+{
+ BloomFilter *filter;
+ StringInfoData str;
+
+ initStringInfo(&str);
+ appendStringInfoChar(&str, '{');
+
+ /*
+ * XXX not sure the detoasting is necessary (probably not, this
+ * can only be in an index).
+ */
+ filter = (BloomFilter *) PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
+
+ if (BLOOM_IS_HASHED(filter))
+ {
+ appendStringInfo(&str, "mode: hashed nhashes: %u nbits: %u nbits_set: %u",
+ filter->nhashes, filter->nbits, filter->nbits_set);
+ }
+ else
+ {
+ appendStringInfo(&str, "mode: sorted nvalues: %u nsorted: %u",
+ filter->nvalues, filter->nsorted);
+ /* TODO include the sorted/unsorted values */
+ }
+
+ appendStringInfoChar(&str, '}');
+
+ PG_RETURN_CSTRING(str.data);
+}
+
+/*
+ * brin_bloom_summary_recv
+ * - binary input routine for type brin_bloom_summary.
+ */
+Datum
+brin_bloom_summary_recv(PG_FUNCTION_ARGS)
+{
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+/*
+ * brin_bloom_summary_send
+ * - binary output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized in a bytea value (although the
+ * type is named differently), so let's just send that.
+ */
+Datum
+brin_bloom_summary_send(PG_FUNCTION_ARGS)
+{
+ return byteasend(fcinfo);
+}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5336aa7b9c..da4c9c6202 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10975,3 +10975,17 @@
prosrc => 'unicode_is_normalized' },
]
+
+{ oid => '9035', descr => 'I/O',
+ proname => 'brin_bloom_summary_in', prorettype => 'pg_brin_bloom_summary',
+ proargtypes => 'cstring', prosrc => 'brin_bloom_summary_in' },
+{ oid => '9036', descr => 'I/O',
+ proname => 'brin_bloom_summary_out', prorettype => 'cstring',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_out' },
+{ oid => '9037', descr => 'I/O',
+ proname => 'brin_bloom_summary_recv', provolatile => 's',
+ prorettype => 'pg_brin_bloom_summary', proargtypes => 'internal',
+ prosrc => 'brin_bloom_summary_recv' },
+{ oid => '9038', descr => 'I/O',
+ proname => 'brin_bloom_summary_send', provolatile => 's', prorettype => 'bytea',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_send' },
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index b2cec07416..a41c2e5418 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -631,3 +631,10 @@
typalign => 'd', typstorage => 'x' },
]
+
+{ oid => '9034', oid_symbol => 'BRINBLOOMSUMMARYOID',
+ descr => 'BRIN bloom summary',
+ typname => 'pg_brin_bloom_summary', typlen => '-1', typbyval => 'f', typcategory => 'S',
+ typinput => 'brin_bloom_summary_in', typoutput => 'brin_bloom_summary_out',
+ typreceive => 'brin_bloom_summary_recv', typsend => 'brin_bloom_summary_send',
+ typalign => 'i', typstorage => 'x', typcollation => 'default' },
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index 274130e706..97bf9797de 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -67,13 +67,14 @@ WHERE p1.typtype not in ('c','d','p') AND p1.typname NOT LIKE E'\\_%'
(SELECT 1 FROM pg_type as p2
WHERE p2.typname = ('_' || p1.typname)::name AND
p2.typelem = p1.oid and p1.typarray = p2.oid);
- oid | typname
-------+-----------------
+ oid | typname
+------+-----------------------
194 | pg_node_tree
3361 | pg_ndistinct
3402 | pg_dependencies
5017 | pg_mcv_list
-(4 rows)
+ 9034 | pg_brin_bloom_summary
+(5 rows)
-- Make sure typarray points to a varlena array type of our own base
SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype,
--
2.25.4
--jsivyprvf2oxfjz3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="0006-BRIN-multi-range-minmax-indexes-20200807.patch"
^ permalink raw reply [nested|flat] 27+ messages in thread
* [PATCH 5/8] add special pg_brin_bloom_summary data type
@ 2020-08-06 15:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Tomas Vondra @ 2020-08-06 15:56 UTC (permalink / raw)
---
src/backend/access/brin/brin_bloom.c | 91 ++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 14 ++++
src/include/catalog/pg_type.dat | 7 ++
src/test/regress/expected/type_sanity.out | 7 +-
4 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index b119e4e264..e7ca100821 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -647,7 +647,7 @@ brin_bloom_opcinfo(PG_FUNCTION_ARGS)
result->oi_regular_nulls = true;
result->oi_opaque = (BloomOpaque *)
MAXALIGN((char *) result + SizeofBrinOpcInfo(1));
- result->oi_typcache[0] = lookup_type_cache(BYTEAOID, 0);
+ result->oi_typcache[0] = lookup_type_cache(BRINBLOOMSUMMARYOID, 0);
PG_RETURN_POINTER(result);
}
@@ -978,3 +978,92 @@ brin_bloom_options(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+/*
+ * brin_bloom_summary_in
+ * - input routine for type brin_bloom_summary.
+ *
+ * brin_bloom_summary is only used internally to represent summaries
+ * in BRIN bloom indexes, so it has no operations of its own, and we
+ * disallow input too.
+ */
+Datum
+brin_bloom_summary_in(PG_FUNCTION_ARGS)
+{
+ /*
+ * brin_bloom_summary stores the data in binary form and parsing
+ * text input is not needed, so disallow this.
+ */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+
+/*
+ * brin_bloom_summary_out
+ * - output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized into a bytea value, but we want
+ * to output something nicer humans can understand.
+ */
+Datum
+brin_bloom_summary_out(PG_FUNCTION_ARGS)
+{
+ BloomFilter *filter;
+ StringInfoData str;
+
+ initStringInfo(&str);
+ appendStringInfoChar(&str, '{');
+
+ /*
+ * XXX not sure the detoasting is necessary (probably not, this
+ * can only be in an index).
+ */
+ filter = (BloomFilter *) PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
+
+ if (BLOOM_IS_HASHED(filter))
+ {
+ appendStringInfo(&str, "mode: hashed nhashes: %u nbits: %u nbits_set: %u",
+ filter->nhashes, filter->nbits, filter->nbits_set);
+ }
+ else
+ {
+ appendStringInfo(&str, "mode: sorted nvalues: %u nsorted: %u",
+ filter->nvalues, filter->nsorted);
+ /* TODO include the sorted/unsorted values */
+ }
+
+ appendStringInfoChar(&str, '}');
+
+ PG_RETURN_CSTRING(str.data);
+}
+
+/*
+ * brin_bloom_summary_recv
+ * - binary input routine for type brin_bloom_summary.
+ */
+Datum
+brin_bloom_summary_recv(PG_FUNCTION_ARGS)
+{
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+/*
+ * brin_bloom_summary_send
+ * - binary output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized in a bytea value (although the
+ * type is named differently), so let's just send that.
+ */
+Datum
+brin_bloom_summary_send(PG_FUNCTION_ARGS)
+{
+ return byteasend(fcinfo);
+}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5336aa7b9c..da4c9c6202 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10975,3 +10975,17 @@
prosrc => 'unicode_is_normalized' },
]
+
+{ oid => '9035', descr => 'I/O',
+ proname => 'brin_bloom_summary_in', prorettype => 'pg_brin_bloom_summary',
+ proargtypes => 'cstring', prosrc => 'brin_bloom_summary_in' },
+{ oid => '9036', descr => 'I/O',
+ proname => 'brin_bloom_summary_out', prorettype => 'cstring',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_out' },
+{ oid => '9037', descr => 'I/O',
+ proname => 'brin_bloom_summary_recv', provolatile => 's',
+ prorettype => 'pg_brin_bloom_summary', proargtypes => 'internal',
+ prosrc => 'brin_bloom_summary_recv' },
+{ oid => '9038', descr => 'I/O',
+ proname => 'brin_bloom_summary_send', provolatile => 's', prorettype => 'bytea',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_send' },
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index b2cec07416..a41c2e5418 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -631,3 +631,10 @@
typalign => 'd', typstorage => 'x' },
]
+
+{ oid => '9034', oid_symbol => 'BRINBLOOMSUMMARYOID',
+ descr => 'BRIN bloom summary',
+ typname => 'pg_brin_bloom_summary', typlen => '-1', typbyval => 'f', typcategory => 'S',
+ typinput => 'brin_bloom_summary_in', typoutput => 'brin_bloom_summary_out',
+ typreceive => 'brin_bloom_summary_recv', typsend => 'brin_bloom_summary_send',
+ typalign => 'i', typstorage => 'x', typcollation => 'default' },
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index 274130e706..97bf9797de 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -67,13 +67,14 @@ WHERE p1.typtype not in ('c','d','p') AND p1.typname NOT LIKE E'\\_%'
(SELECT 1 FROM pg_type as p2
WHERE p2.typname = ('_' || p1.typname)::name AND
p2.typelem = p1.oid and p1.typarray = p2.oid);
- oid | typname
-------+-----------------
+ oid | typname
+------+-----------------------
194 | pg_node_tree
3361 | pg_ndistinct
3402 | pg_dependencies
5017 | pg_mcv_list
-(4 rows)
+ 9034 | pg_brin_bloom_summary
+(5 rows)
-- Make sure typarray points to a varlena array type of our own base
SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype,
--
2.25.4
--jsivyprvf2oxfjz3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="0006-BRIN-multi-range-minmax-indexes-20200807.patch"
^ permalink raw reply [nested|flat] 27+ messages in thread
* [PATCH 5/8] add special pg_brin_bloom_summary data type
@ 2020-08-06 15:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Tomas Vondra @ 2020-08-06 15:56 UTC (permalink / raw)
---
src/backend/access/brin/brin_bloom.c | 91 ++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 14 ++++
src/include/catalog/pg_type.dat | 7 ++
src/test/regress/expected/type_sanity.out | 7 +-
4 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index b119e4e264..e7ca100821 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -647,7 +647,7 @@ brin_bloom_opcinfo(PG_FUNCTION_ARGS)
result->oi_regular_nulls = true;
result->oi_opaque = (BloomOpaque *)
MAXALIGN((char *) result + SizeofBrinOpcInfo(1));
- result->oi_typcache[0] = lookup_type_cache(BYTEAOID, 0);
+ result->oi_typcache[0] = lookup_type_cache(BRINBLOOMSUMMARYOID, 0);
PG_RETURN_POINTER(result);
}
@@ -978,3 +978,92 @@ brin_bloom_options(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+/*
+ * brin_bloom_summary_in
+ * - input routine for type brin_bloom_summary.
+ *
+ * brin_bloom_summary is only used internally to represent summaries
+ * in BRIN bloom indexes, so it has no operations of its own, and we
+ * disallow input too.
+ */
+Datum
+brin_bloom_summary_in(PG_FUNCTION_ARGS)
+{
+ /*
+ * brin_bloom_summary stores the data in binary form and parsing
+ * text input is not needed, so disallow this.
+ */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+
+/*
+ * brin_bloom_summary_out
+ * - output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized into a bytea value, but we want
+ * to output something nicer humans can understand.
+ */
+Datum
+brin_bloom_summary_out(PG_FUNCTION_ARGS)
+{
+ BloomFilter *filter;
+ StringInfoData str;
+
+ initStringInfo(&str);
+ appendStringInfoChar(&str, '{');
+
+ /*
+ * XXX not sure the detoasting is necessary (probably not, this
+ * can only be in an index).
+ */
+ filter = (BloomFilter *) PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
+
+ if (BLOOM_IS_HASHED(filter))
+ {
+ appendStringInfo(&str, "mode: hashed nhashes: %u nbits: %u nbits_set: %u",
+ filter->nhashes, filter->nbits, filter->nbits_set);
+ }
+ else
+ {
+ appendStringInfo(&str, "mode: sorted nvalues: %u nsorted: %u",
+ filter->nvalues, filter->nsorted);
+ /* TODO include the sorted/unsorted values */
+ }
+
+ appendStringInfoChar(&str, '}');
+
+ PG_RETURN_CSTRING(str.data);
+}
+
+/*
+ * brin_bloom_summary_recv
+ * - binary input routine for type brin_bloom_summary.
+ */
+Datum
+brin_bloom_summary_recv(PG_FUNCTION_ARGS)
+{
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+/*
+ * brin_bloom_summary_send
+ * - binary output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized in a bytea value (although the
+ * type is named differently), so let's just send that.
+ */
+Datum
+brin_bloom_summary_send(PG_FUNCTION_ARGS)
+{
+ return byteasend(fcinfo);
+}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5336aa7b9c..da4c9c6202 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10975,3 +10975,17 @@
prosrc => 'unicode_is_normalized' },
]
+
+{ oid => '9035', descr => 'I/O',
+ proname => 'brin_bloom_summary_in', prorettype => 'pg_brin_bloom_summary',
+ proargtypes => 'cstring', prosrc => 'brin_bloom_summary_in' },
+{ oid => '9036', descr => 'I/O',
+ proname => 'brin_bloom_summary_out', prorettype => 'cstring',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_out' },
+{ oid => '9037', descr => 'I/O',
+ proname => 'brin_bloom_summary_recv', provolatile => 's',
+ prorettype => 'pg_brin_bloom_summary', proargtypes => 'internal',
+ prosrc => 'brin_bloom_summary_recv' },
+{ oid => '9038', descr => 'I/O',
+ proname => 'brin_bloom_summary_send', provolatile => 's', prorettype => 'bytea',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_send' },
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index b2cec07416..a41c2e5418 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -631,3 +631,10 @@
typalign => 'd', typstorage => 'x' },
]
+
+{ oid => '9034', oid_symbol => 'BRINBLOOMSUMMARYOID',
+ descr => 'BRIN bloom summary',
+ typname => 'pg_brin_bloom_summary', typlen => '-1', typbyval => 'f', typcategory => 'S',
+ typinput => 'brin_bloom_summary_in', typoutput => 'brin_bloom_summary_out',
+ typreceive => 'brin_bloom_summary_recv', typsend => 'brin_bloom_summary_send',
+ typalign => 'i', typstorage => 'x', typcollation => 'default' },
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index 274130e706..97bf9797de 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -67,13 +67,14 @@ WHERE p1.typtype not in ('c','d','p') AND p1.typname NOT LIKE E'\\_%'
(SELECT 1 FROM pg_type as p2
WHERE p2.typname = ('_' || p1.typname)::name AND
p2.typelem = p1.oid and p1.typarray = p2.oid);
- oid | typname
-------+-----------------
+ oid | typname
+------+-----------------------
194 | pg_node_tree
3361 | pg_ndistinct
3402 | pg_dependencies
5017 | pg_mcv_list
-(4 rows)
+ 9034 | pg_brin_bloom_summary
+(5 rows)
-- Make sure typarray points to a varlena array type of our own base
SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype,
--
2.25.4
--jsivyprvf2oxfjz3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="0006-BRIN-multi-range-minmax-indexes-20200807.patch"
^ permalink raw reply [nested|flat] 27+ messages in thread
* [PATCH 05/10] add special pg_brin_bloom_summary data type
@ 2020-08-06 15:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Tomas Vondra @ 2020-08-06 15:56 UTC (permalink / raw)
---
src/backend/access/brin/brin_bloom.c | 91 ++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 14 ++++
src/include/catalog/pg_type.dat | 7 ++
src/test/regress/expected/type_sanity.out | 7 +-
4 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index b119e4e264..e7ca100821 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -647,7 +647,7 @@ brin_bloom_opcinfo(PG_FUNCTION_ARGS)
result->oi_regular_nulls = true;
result->oi_opaque = (BloomOpaque *)
MAXALIGN((char *) result + SizeofBrinOpcInfo(1));
- result->oi_typcache[0] = lookup_type_cache(BYTEAOID, 0);
+ result->oi_typcache[0] = lookup_type_cache(BRINBLOOMSUMMARYOID, 0);
PG_RETURN_POINTER(result);
}
@@ -978,3 +978,92 @@ brin_bloom_options(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+/*
+ * brin_bloom_summary_in
+ * - input routine for type brin_bloom_summary.
+ *
+ * brin_bloom_summary is only used internally to represent summaries
+ * in BRIN bloom indexes, so it has no operations of its own, and we
+ * disallow input too.
+ */
+Datum
+brin_bloom_summary_in(PG_FUNCTION_ARGS)
+{
+ /*
+ * brin_bloom_summary stores the data in binary form and parsing
+ * text input is not needed, so disallow this.
+ */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+
+/*
+ * brin_bloom_summary_out
+ * - output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized into a bytea value, but we want
+ * to output something nicer humans can understand.
+ */
+Datum
+brin_bloom_summary_out(PG_FUNCTION_ARGS)
+{
+ BloomFilter *filter;
+ StringInfoData str;
+
+ initStringInfo(&str);
+ appendStringInfoChar(&str, '{');
+
+ /*
+ * XXX not sure the detoasting is necessary (probably not, this
+ * can only be in an index).
+ */
+ filter = (BloomFilter *) PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
+
+ if (BLOOM_IS_HASHED(filter))
+ {
+ appendStringInfo(&str, "mode: hashed nhashes: %u nbits: %u nbits_set: %u",
+ filter->nhashes, filter->nbits, filter->nbits_set);
+ }
+ else
+ {
+ appendStringInfo(&str, "mode: sorted nvalues: %u nsorted: %u",
+ filter->nvalues, filter->nsorted);
+ /* TODO include the sorted/unsorted values */
+ }
+
+ appendStringInfoChar(&str, '}');
+
+ PG_RETURN_CSTRING(str.data);
+}
+
+/*
+ * brin_bloom_summary_recv
+ * - binary input routine for type brin_bloom_summary.
+ */
+Datum
+brin_bloom_summary_recv(PG_FUNCTION_ARGS)
+{
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+/*
+ * brin_bloom_summary_send
+ * - binary output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized in a bytea value (although the
+ * type is named differently), so let's just send that.
+ */
+Datum
+brin_bloom_summary_send(PG_FUNCTION_ARGS)
+{
+ return byteasend(fcinfo);
+}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index c00e4ece94..dc17d4ce38 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10993,3 +10993,17 @@
prosrc => 'unicode_is_normalized' },
]
+
+{ oid => '9035', descr => 'I/O',
+ proname => 'brin_bloom_summary_in', prorettype => 'pg_brin_bloom_summary',
+ proargtypes => 'cstring', prosrc => 'brin_bloom_summary_in' },
+{ oid => '9036', descr => 'I/O',
+ proname => 'brin_bloom_summary_out', prorettype => 'cstring',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_out' },
+{ oid => '9037', descr => 'I/O',
+ proname => 'brin_bloom_summary_recv', provolatile => 's',
+ prorettype => 'pg_brin_bloom_summary', proargtypes => 'internal',
+ prosrc => 'brin_bloom_summary_recv' },
+{ oid => '9038', descr => 'I/O',
+ proname => 'brin_bloom_summary_send', provolatile => 's', prorettype => 'bytea',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_send' },
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index b2cec07416..a41c2e5418 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -631,3 +631,10 @@
typalign => 'd', typstorage => 'x' },
]
+
+{ oid => '9034', oid_symbol => 'BRINBLOOMSUMMARYOID',
+ descr => 'BRIN bloom summary',
+ typname => 'pg_brin_bloom_summary', typlen => '-1', typbyval => 'f', typcategory => 'S',
+ typinput => 'brin_bloom_summary_in', typoutput => 'brin_bloom_summary_out',
+ typreceive => 'brin_bloom_summary_recv', typsend => 'brin_bloom_summary_send',
+ typalign => 'i', typstorage => 'x', typcollation => 'default' },
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index 274130e706..97bf9797de 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -67,13 +67,14 @@ WHERE p1.typtype not in ('c','d','p') AND p1.typname NOT LIKE E'\\_%'
(SELECT 1 FROM pg_type as p2
WHERE p2.typname = ('_' || p1.typname)::name AND
p2.typelem = p1.oid and p1.typarray = p2.oid);
- oid | typname
-------+-----------------
+ oid | typname
+------+-----------------------
194 | pg_node_tree
3361 | pg_ndistinct
3402 | pg_dependencies
5017 | pg_mcv_list
-(4 rows)
+ 9034 | pg_brin_bloom_summary
+(5 rows)
-- Make sure typarray points to a varlena array type of our own base
SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype,
--
2.25.4
--6k3bcoookz7x4sns
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="0006-BRIN-minmax-multi-indexes-20200911.patch"
^ permalink raw reply [nested|flat] 27+ messages in thread
* [PATCH 5/8] add special pg_brin_bloom_summary data type
@ 2020-08-06 15:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Tomas Vondra @ 2020-08-06 15:56 UTC (permalink / raw)
---
src/backend/access/brin/brin_bloom.c | 91 ++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 14 ++++
src/include/catalog/pg_type.dat | 7 ++
src/test/regress/expected/type_sanity.out | 7 +-
4 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index b119e4e264..e7ca100821 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -647,7 +647,7 @@ brin_bloom_opcinfo(PG_FUNCTION_ARGS)
result->oi_regular_nulls = true;
result->oi_opaque = (BloomOpaque *)
MAXALIGN((char *) result + SizeofBrinOpcInfo(1));
- result->oi_typcache[0] = lookup_type_cache(BYTEAOID, 0);
+ result->oi_typcache[0] = lookup_type_cache(BRINBLOOMSUMMARYOID, 0);
PG_RETURN_POINTER(result);
}
@@ -978,3 +978,92 @@ brin_bloom_options(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+/*
+ * brin_bloom_summary_in
+ * - input routine for type brin_bloom_summary.
+ *
+ * brin_bloom_summary is only used internally to represent summaries
+ * in BRIN bloom indexes, so it has no operations of its own, and we
+ * disallow input too.
+ */
+Datum
+brin_bloom_summary_in(PG_FUNCTION_ARGS)
+{
+ /*
+ * brin_bloom_summary stores the data in binary form and parsing
+ * text input is not needed, so disallow this.
+ */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+
+/*
+ * brin_bloom_summary_out
+ * - output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized into a bytea value, but we want
+ * to output something nicer humans can understand.
+ */
+Datum
+brin_bloom_summary_out(PG_FUNCTION_ARGS)
+{
+ BloomFilter *filter;
+ StringInfoData str;
+
+ initStringInfo(&str);
+ appendStringInfoChar(&str, '{');
+
+ /*
+ * XXX not sure the detoasting is necessary (probably not, this
+ * can only be in an index).
+ */
+ filter = (BloomFilter *) PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
+
+ if (BLOOM_IS_HASHED(filter))
+ {
+ appendStringInfo(&str, "mode: hashed nhashes: %u nbits: %u nbits_set: %u",
+ filter->nhashes, filter->nbits, filter->nbits_set);
+ }
+ else
+ {
+ appendStringInfo(&str, "mode: sorted nvalues: %u nsorted: %u",
+ filter->nvalues, filter->nsorted);
+ /* TODO include the sorted/unsorted values */
+ }
+
+ appendStringInfoChar(&str, '}');
+
+ PG_RETURN_CSTRING(str.data);
+}
+
+/*
+ * brin_bloom_summary_recv
+ * - binary input routine for type brin_bloom_summary.
+ */
+Datum
+brin_bloom_summary_recv(PG_FUNCTION_ARGS)
+{
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+/*
+ * brin_bloom_summary_send
+ * - binary output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized in a bytea value (although the
+ * type is named differently), so let's just send that.
+ */
+Datum
+brin_bloom_summary_send(PG_FUNCTION_ARGS)
+{
+ return byteasend(fcinfo);
+}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5336aa7b9c..da4c9c6202 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10975,3 +10975,17 @@
prosrc => 'unicode_is_normalized' },
]
+
+{ oid => '9035', descr => 'I/O',
+ proname => 'brin_bloom_summary_in', prorettype => 'pg_brin_bloom_summary',
+ proargtypes => 'cstring', prosrc => 'brin_bloom_summary_in' },
+{ oid => '9036', descr => 'I/O',
+ proname => 'brin_bloom_summary_out', prorettype => 'cstring',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_out' },
+{ oid => '9037', descr => 'I/O',
+ proname => 'brin_bloom_summary_recv', provolatile => 's',
+ prorettype => 'pg_brin_bloom_summary', proargtypes => 'internal',
+ prosrc => 'brin_bloom_summary_recv' },
+{ oid => '9038', descr => 'I/O',
+ proname => 'brin_bloom_summary_send', provolatile => 's', prorettype => 'bytea',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_send' },
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index b2cec07416..a41c2e5418 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -631,3 +631,10 @@
typalign => 'd', typstorage => 'x' },
]
+
+{ oid => '9034', oid_symbol => 'BRINBLOOMSUMMARYOID',
+ descr => 'BRIN bloom summary',
+ typname => 'pg_brin_bloom_summary', typlen => '-1', typbyval => 'f', typcategory => 'S',
+ typinput => 'brin_bloom_summary_in', typoutput => 'brin_bloom_summary_out',
+ typreceive => 'brin_bloom_summary_recv', typsend => 'brin_bloom_summary_send',
+ typalign => 'i', typstorage => 'x', typcollation => 'default' },
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index 274130e706..97bf9797de 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -67,13 +67,14 @@ WHERE p1.typtype not in ('c','d','p') AND p1.typname NOT LIKE E'\\_%'
(SELECT 1 FROM pg_type as p2
WHERE p2.typname = ('_' || p1.typname)::name AND
p2.typelem = p1.oid and p1.typarray = p2.oid);
- oid | typname
-------+-----------------
+ oid | typname
+------+-----------------------
194 | pg_node_tree
3361 | pg_ndistinct
3402 | pg_dependencies
5017 | pg_mcv_list
-(4 rows)
+ 9034 | pg_brin_bloom_summary
+(5 rows)
-- Make sure typarray points to a varlena array type of our own base
SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype,
--
2.25.4
--jsivyprvf2oxfjz3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="0006-BRIN-multi-range-minmax-indexes-20200807.patch"
^ permalink raw reply [nested|flat] 27+ messages in thread
* [PATCH 5/8] add special pg_brin_bloom_summary data type
@ 2020-08-06 15:56 Tomas Vondra <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Tomas Vondra @ 2020-08-06 15:56 UTC (permalink / raw)
---
src/backend/access/brin/brin_bloom.c | 91 ++++++++++++++++++++++-
src/include/catalog/pg_proc.dat | 14 ++++
src/include/catalog/pg_type.dat | 7 ++
src/test/regress/expected/type_sanity.out | 7 +-
4 files changed, 115 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/brin/brin_bloom.c b/src/backend/access/brin/brin_bloom.c
index b119e4e264..e7ca100821 100644
--- a/src/backend/access/brin/brin_bloom.c
+++ b/src/backend/access/brin/brin_bloom.c
@@ -647,7 +647,7 @@ brin_bloom_opcinfo(PG_FUNCTION_ARGS)
result->oi_regular_nulls = true;
result->oi_opaque = (BloomOpaque *)
MAXALIGN((char *) result + SizeofBrinOpcInfo(1));
- result->oi_typcache[0] = lookup_type_cache(BYTEAOID, 0);
+ result->oi_typcache[0] = lookup_type_cache(BRINBLOOMSUMMARYOID, 0);
PG_RETURN_POINTER(result);
}
@@ -978,3 +978,92 @@ brin_bloom_options(PG_FUNCTION_ARGS)
PG_RETURN_VOID();
}
+
+/*
+ * brin_bloom_summary_in
+ * - input routine for type brin_bloom_summary.
+ *
+ * brin_bloom_summary is only used internally to represent summaries
+ * in BRIN bloom indexes, so it has no operations of its own, and we
+ * disallow input too.
+ */
+Datum
+brin_bloom_summary_in(PG_FUNCTION_ARGS)
+{
+ /*
+ * brin_bloom_summary stores the data in binary form and parsing
+ * text input is not needed, so disallow this.
+ */
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+
+/*
+ * brin_bloom_summary_out
+ * - output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized into a bytea value, but we want
+ * to output something nicer humans can understand.
+ */
+Datum
+brin_bloom_summary_out(PG_FUNCTION_ARGS)
+{
+ BloomFilter *filter;
+ StringInfoData str;
+
+ initStringInfo(&str);
+ appendStringInfoChar(&str, '{');
+
+ /*
+ * XXX not sure the detoasting is necessary (probably not, this
+ * can only be in an index).
+ */
+ filter = (BloomFilter *) PG_DETOAST_DATUM(PG_GETARG_BYTEA_PP(0));
+
+ if (BLOOM_IS_HASHED(filter))
+ {
+ appendStringInfo(&str, "mode: hashed nhashes: %u nbits: %u nbits_set: %u",
+ filter->nhashes, filter->nbits, filter->nbits_set);
+ }
+ else
+ {
+ appendStringInfo(&str, "mode: sorted nvalues: %u nsorted: %u",
+ filter->nvalues, filter->nsorted);
+ /* TODO include the sorted/unsorted values */
+ }
+
+ appendStringInfoChar(&str, '}');
+
+ PG_RETURN_CSTRING(str.data);
+}
+
+/*
+ * brin_bloom_summary_recv
+ * - binary input routine for type brin_bloom_summary.
+ */
+Datum
+brin_bloom_summary_recv(PG_FUNCTION_ARGS)
+{
+ ereport(ERROR,
+ (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+ errmsg("cannot accept a value of type %s", "pg_brin_bloom_summary")));
+
+ PG_RETURN_VOID(); /* keep compiler quiet */
+}
+
+/*
+ * brin_bloom_summary_send
+ * - binary output routine for type brin_bloom_summary.
+ *
+ * BRIN bloom summaries are serialized in a bytea value (although the
+ * type is named differently), so let's just send that.
+ */
+Datum
+brin_bloom_summary_send(PG_FUNCTION_ARGS)
+{
+ return byteasend(fcinfo);
+}
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 5336aa7b9c..da4c9c6202 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -10975,3 +10975,17 @@
prosrc => 'unicode_is_normalized' },
]
+
+{ oid => '9035', descr => 'I/O',
+ proname => 'brin_bloom_summary_in', prorettype => 'pg_brin_bloom_summary',
+ proargtypes => 'cstring', prosrc => 'brin_bloom_summary_in' },
+{ oid => '9036', descr => 'I/O',
+ proname => 'brin_bloom_summary_out', prorettype => 'cstring',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_out' },
+{ oid => '9037', descr => 'I/O',
+ proname => 'brin_bloom_summary_recv', provolatile => 's',
+ prorettype => 'pg_brin_bloom_summary', proargtypes => 'internal',
+ prosrc => 'brin_bloom_summary_recv' },
+{ oid => '9038', descr => 'I/O',
+ proname => 'brin_bloom_summary_send', provolatile => 's', prorettype => 'bytea',
+ proargtypes => 'pg_brin_bloom_summary', prosrc => 'brin_bloom_summary_send' },
diff --git a/src/include/catalog/pg_type.dat b/src/include/catalog/pg_type.dat
index b2cec07416..a41c2e5418 100644
--- a/src/include/catalog/pg_type.dat
+++ b/src/include/catalog/pg_type.dat
@@ -631,3 +631,10 @@
typalign => 'd', typstorage => 'x' },
]
+
+{ oid => '9034', oid_symbol => 'BRINBLOOMSUMMARYOID',
+ descr => 'BRIN bloom summary',
+ typname => 'pg_brin_bloom_summary', typlen => '-1', typbyval => 'f', typcategory => 'S',
+ typinput => 'brin_bloom_summary_in', typoutput => 'brin_bloom_summary_out',
+ typreceive => 'brin_bloom_summary_recv', typsend => 'brin_bloom_summary_send',
+ typalign => 'i', typstorage => 'x', typcollation => 'default' },
diff --git a/src/test/regress/expected/type_sanity.out b/src/test/regress/expected/type_sanity.out
index 274130e706..97bf9797de 100644
--- a/src/test/regress/expected/type_sanity.out
+++ b/src/test/regress/expected/type_sanity.out
@@ -67,13 +67,14 @@ WHERE p1.typtype not in ('c','d','p') AND p1.typname NOT LIKE E'\\_%'
(SELECT 1 FROM pg_type as p2
WHERE p2.typname = ('_' || p1.typname)::name AND
p2.typelem = p1.oid and p1.typarray = p2.oid);
- oid | typname
-------+-----------------
+ oid | typname
+------+-----------------------
194 | pg_node_tree
3361 | pg_ndistinct
3402 | pg_dependencies
5017 | pg_mcv_list
-(4 rows)
+ 9034 | pg_brin_bloom_summary
+(5 rows)
-- Make sure typarray points to a varlena array type of our own base
SELECT p1.oid, p1.typname as basetype, p2.typname as arraytype,
--
2.25.4
--jsivyprvf2oxfjz3
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename="0006-BRIN-multi-range-minmax-indexes-20200807.patch"
^ permalink raw reply [nested|flat] 27+ messages in thread
* Should we remove db_user_namespace?
@ 2023-06-30 20:05 Nathan Bossart <[email protected]>
2023-06-30 20:42 ` Re: Should we remove db_user_namespace? Nathan Bossart <[email protected]>
2023-06-30 21:40 ` Re: Should we remove db_user_namespace? Tom Lane <[email protected]>
2023-07-03 07:20 ` Re: Should we remove db_user_namespace? Michael Paquier <[email protected]>
0 siblings, 3 replies; 27+ messages in thread
From: Nathan Bossart @ 2023-06-30 20:05 UTC (permalink / raw)
To: pgsql-hackers
I think this is the second decennial thread [0] for removing this GUC.
This topic came up at PGCon, so I thought I'd start the discussion on the
lists.
I'm personally not aware of anyone using this parameter. A couple of my
colleagues claimed to have used it in the aughts, but they also noted that
users were confused by the current implementation, and they seemed
generally in favor of removing it. AFAICT the strongest reason for keeping
it is that there is presently no viable replacement. Does this opinion
still stand? If so, perhaps we can look into adding a viable replacement
for v17.
The attached patch simply removes the GUC.
[0] https://postgr.es/m/CAA-aLv6wnwp6Qr5fZo%2B7K%3DVSr51qFMuLsCeYvTkSF3E5qEPvqA%40mail.gmail.com
--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com
Attachments:
[text/x-diff] v1-0001-remove-db_user_namespace.patch (7.5K, ../../20230630200509.GA2830328@nathanxps13/2-v1-0001-remove-db_user_namespace.patch)
download | inline diff:
From 6677f4b98fd0b1bd68e07d773b04caf45cf27715 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <[email protected]>
Date: Fri, 30 Jun 2023 12:46:08 -0700
Subject: [PATCH v1 1/1] remove db_user_namespace
---
doc/src/sgml/config.sgml | 52 -------------------
src/backend/libpq/auth.c | 5 --
src/backend/libpq/hba.c | 12 -----
src/backend/postmaster/postmaster.c | 19 -------
src/backend/utils/misc/guc_tables.c | 9 ----
src/backend/utils/misc/postgresql.conf.sample | 1 -
src/include/libpq/pqcomm.h | 2 -
7 files changed, 100 deletions(-)
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 6262cb7bb2..e6cea8ddfc 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1188,58 +1188,6 @@ include_dir 'conf.d'
</para>
</listitem>
</varlistentry>
-
- <varlistentry id="guc-db-user-namespace" xreflabel="db_user_namespace">
- <term><varname>db_user_namespace</varname> (<type>boolean</type>)
- <indexterm>
- <primary><varname>db_user_namespace</varname> configuration parameter</primary>
- </indexterm>
- </term>
- <listitem>
- <para>
- This parameter enables per-database user names. It is off by default.
- This parameter can only be set in the <filename>postgresql.conf</filename>
- file or on the server command line.
- </para>
-
- <para>
- If this is on, you should create users as <replaceable>username@dbname</replaceable>.
- When <replaceable>username</replaceable> is passed by a connecting client,
- <literal>@</literal> and the database name are appended to the user
- name and that database-specific user name is looked up by the
- server. Note that when you create users with names containing
- <literal>@</literal> within the SQL environment, you will need to
- quote the user name.
- </para>
-
- <para>
- With this parameter enabled, you can still create ordinary global
- users. Simply append <literal>@</literal> when specifying the user
- name in the client, e.g., <literal>joe@</literal>. The <literal>@</literal>
- will be stripped off before the user name is looked up by the
- server.
- </para>
-
- <para>
- <varname>db_user_namespace</varname> causes the client's and
- server's user name representation to differ.
- Authentication checks are always done with the server's user name
- so authentication methods must be configured for the
- server's user name, not the client's. Because
- <literal>md5</literal> uses the user name as salt on both the
- client and server, <literal>md5</literal> cannot be used with
- <varname>db_user_namespace</varname>.
- </para>
-
- <note>
- <para>
- This feature is intended as a temporary measure until a
- complete solution is found. At that time, this option will
- be removed.
- </para>
- </note>
- </listitem>
- </varlistentry>
</variablelist>
</sect2>
diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c
index a98b934a8e..65d452f099 100644
--- a/src/backend/libpq/auth.c
+++ b/src/backend/libpq/auth.c
@@ -873,11 +873,6 @@ CheckMD5Auth(Port *port, char *shadow_pass, const char **logdetail)
char *passwd;
int result;
- if (Db_user_namespace)
- ereport(FATAL,
- (errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),
- errmsg("MD5 authentication is not supported when \"db_user_namespace\" is enabled")));
-
/* include the salt to use for computing the response */
if (!pg_strong_random(md5Salt, 4))
{
diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c
index f89f138f3c..5d4ddbb04d 100644
--- a/src/backend/libpq/hba.c
+++ b/src/backend/libpq/hba.c
@@ -1741,19 +1741,7 @@ parse_hba_line(TokenizedAuthLine *tok_line, int elevel)
else if (strcmp(token->string, "reject") == 0)
parsedline->auth_method = uaReject;
else if (strcmp(token->string, "md5") == 0)
- {
- if (Db_user_namespace)
- {
- ereport(elevel,
- (errcode(ERRCODE_CONFIG_FILE_ERROR),
- errmsg("MD5 authentication is not supported when \"db_user_namespace\" is enabled"),
- errcontext("line %d of configuration file \"%s\"",
- line_num, file_name)));
- *err_msg = "MD5 authentication is not supported when \"db_user_namespace\" is enabled";
- return NULL;
- }
parsedline->auth_method = uaMD5;
- }
else if (strcmp(token->string, "scram-sha-256") == 0)
parsedline->auth_method = uaSCRAM;
else if (strcmp(token->string, "pam") == 0)
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 4c49393fc5..33a13fdf32 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -236,7 +236,6 @@ int AuthenticationTimeout = 60;
bool log_hostname; /* for ps display and logging */
bool Log_connections = false;
-bool Db_user_namespace = false;
bool enable_bonjour = false;
char *bonjour_name;
@@ -2272,24 +2271,6 @@ retry1:
if (port->database_name == NULL || port->database_name[0] == '\0')
port->database_name = pstrdup(port->user_name);
- if (Db_user_namespace)
- {
- /*
- * If user@, it is a global user, remove '@'. We only want to do this
- * if there is an '@' at the end and no earlier in the user string or
- * they may fake as a local user of another database attaching to this
- * database.
- */
- if (strchr(port->user_name, '@') ==
- port->user_name + strlen(port->user_name) - 1)
- *strchr(port->user_name, '@') = '\0';
- else
- {
- /* Append '@' and dbname */
- port->user_name = psprintf("%s@%s", port->user_name, port->database_name);
- }
- }
-
/*
* Truncate given database and user names to length of a Postgres name.
* This avoids lookup failures when overlength names are given.
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 71e27f8eb0..25d9008bb6 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -1534,15 +1534,6 @@ struct config_bool ConfigureNamesBool[] =
false,
NULL, NULL, NULL
},
- {
- {"db_user_namespace", PGC_SIGHUP, CONN_AUTH_AUTH,
- gettext_noop("Enables per-database user names."),
- NULL
- },
- &Db_user_namespace,
- false,
- NULL, NULL, NULL
- },
{
{"default_transaction_read_only", PGC_USERSET, CLIENT_CONN_STATEMENT,
gettext_noop("Sets the default read-only status of new transactions."),
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index e4c0269fa3..c768af9a73 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -96,7 +96,6 @@
#authentication_timeout = 1min # 1s-600s
#password_encryption = scram-sha-256 # scram-sha-256 or md5
#scram_iterations = 4096
-#db_user_namespace = off
# GSSAPI using Kerberos
#krb_server_keyfile = 'FILE:${sysconfdir}/krb5.keytab'
diff --git a/src/include/libpq/pqcomm.h b/src/include/libpq/pqcomm.h
index c85090259d..3da00f7983 100644
--- a/src/include/libpq/pqcomm.h
+++ b/src/include/libpq/pqcomm.h
@@ -103,8 +103,6 @@ typedef ProtocolVersion MsgType;
typedef uint32 PacketLen;
-extern PGDLLIMPORT bool Db_user_namespace;
-
/*
* In protocol 3.0 and later, the startup packet length is not fixed, but
* we set an arbitrary limit on it anyway. This is just to prevent simple
--
2.25.1
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Should we remove db_user_namespace?
2023-06-30 20:05 Should we remove db_user_namespace? Nathan Bossart <[email protected]>
@ 2023-06-30 20:42 ` Nathan Bossart <[email protected]>
2 siblings, 0 replies; 27+ messages in thread
From: Nathan Bossart @ 2023-06-30 20:42 UTC (permalink / raw)
To: pgsql-hackers
On Fri, Jun 30, 2023 at 01:05:09PM -0700, Nathan Bossart wrote:
> The attached patch simply removes the GUC.
And here's a new version of the patch with docs that actually build.
--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com
Attachments:
[text/x-diff] v2-0001-remove-db_user_namespace.patch (8.1K, ../../20230630204211.GA2840453@nathanxps13/2-v2-0001-remove-db_user_namespace.patch)
download | inline diff:
From 3b7fdd41eb429bc9bb03dcecf38126fbc63dafa3 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <[email protected]>
Date: Fri, 30 Jun 2023 12:46:08 -0700
Subject: [PATCH v2 1/1] remove db_user_namespace
---
doc/src/sgml/client-auth.sgml | 5 --
doc/src/sgml/config.sgml | 52 -------------------
src/backend/libpq/auth.c | 5 --
src/backend/libpq/hba.c | 12 -----
src/backend/postmaster/postmaster.c | 19 -------
src/backend/utils/misc/guc_tables.c | 9 ----
src/backend/utils/misc/postgresql.conf.sample | 1 -
src/include/libpq/pqcomm.h | 2 -
8 files changed, 105 deletions(-)
diff --git a/doc/src/sgml/client-auth.sgml b/doc/src/sgml/client-auth.sgml
index 204d09df67..6c95f0df1e 100644
--- a/doc/src/sgml/client-auth.sgml
+++ b/doc/src/sgml/client-auth.sgml
@@ -1253,11 +1253,6 @@ omicron bryanh guest1
attacks.
</para>
- <para>
- The <literal>md5</literal> method cannot be used with
- the <xref linkend="guc-db-user-namespace"/> feature.
- </para>
-
<para>
To ease transition from the <literal>md5</literal> method to the newer
SCRAM method, if <literal>md5</literal> is specified as a method
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 6262cb7bb2..e6cea8ddfc 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1188,58 +1188,6 @@ include_dir 'conf.d'
</para>
</listitem>
</varlistentry>
-
- <varlistentry id="guc-db-user-namespace" xreflabel="db_user_namespace">
- <term><varname>db_user_namespace</varname> (<type>boolean</type>)
- <indexterm>
- <primary><varname>db_user_namespace</varname> configuration parameter</primary>
- </indexterm>
- </term>
- <listitem>
- <para>
- This parameter enables per-database user names. It is off by default.
- This parameter can only be set in the <filename>postgresql.conf</filename>
- file or on the server command line.
- </para>
-
- <para>
- If this is on, you should create users as <replaceable>username@dbname</replaceable>.
- When <replaceable>username</replaceable> is passed by a connecting client,
- <literal>@</literal> and the database name are appended to the user
- name and that database-specific user name is looked up by the
- server. Note that when you create users with names containing
- <literal>@</literal> within the SQL environment, you will need to
- quote the user name.
- </para>
-
- <para>
- With this parameter enabled, you can still create ordinary global
- users. Simply append <literal>@</literal> when specifying the user
- name in the client, e.g., <literal>joe@</literal>. The <literal>@</literal>
- will be stripped off before the user name is looked up by the
- server.
- </para>
-
- <para>
- <varname>db_user_namespace</varname> causes the client's and
- server's user name representation to differ.
- Authentication checks are always done with the server's user name
- so authentication methods must be configured for the
- server's user name, not the client's. Because
- <literal>md5</literal> uses the user name as salt on both the
- client and server, <literal>md5</literal> cannot be used with
- <varname>db_user_namespace</varname>.
- </para>
-
- <note>
- <para>
- This feature is intended as a temporary measure until a
- complete solution is found. At that time, this option will
- be removed.
- </para>
- </note>
- </listitem>
- </varlistentry>
</variablelist>
</sect2>
diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c
index a98b934a8e..65d452f099 100644
--- a/src/backend/libpq/auth.c
+++ b/src/backend/libpq/auth.c
@@ -873,11 +873,6 @@ CheckMD5Auth(Port *port, char *shadow_pass, const char **logdetail)
char *passwd;
int result;
- if (Db_user_namespace)
- ereport(FATAL,
- (errcode(ERRCODE_INVALID_AUTHORIZATION_SPECIFICATION),
- errmsg("MD5 authentication is not supported when \"db_user_namespace\" is enabled")));
-
/* include the salt to use for computing the response */
if (!pg_strong_random(md5Salt, 4))
{
diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c
index f89f138f3c..5d4ddbb04d 100644
--- a/src/backend/libpq/hba.c
+++ b/src/backend/libpq/hba.c
@@ -1741,19 +1741,7 @@ parse_hba_line(TokenizedAuthLine *tok_line, int elevel)
else if (strcmp(token->string, "reject") == 0)
parsedline->auth_method = uaReject;
else if (strcmp(token->string, "md5") == 0)
- {
- if (Db_user_namespace)
- {
- ereport(elevel,
- (errcode(ERRCODE_CONFIG_FILE_ERROR),
- errmsg("MD5 authentication is not supported when \"db_user_namespace\" is enabled"),
- errcontext("line %d of configuration file \"%s\"",
- line_num, file_name)));
- *err_msg = "MD5 authentication is not supported when \"db_user_namespace\" is enabled";
- return NULL;
- }
parsedline->auth_method = uaMD5;
- }
else if (strcmp(token->string, "scram-sha-256") == 0)
parsedline->auth_method = uaSCRAM;
else if (strcmp(token->string, "pam") == 0)
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 4c49393fc5..33a13fdf32 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -236,7 +236,6 @@ int AuthenticationTimeout = 60;
bool log_hostname; /* for ps display and logging */
bool Log_connections = false;
-bool Db_user_namespace = false;
bool enable_bonjour = false;
char *bonjour_name;
@@ -2272,24 +2271,6 @@ retry1:
if (port->database_name == NULL || port->database_name[0] == '\0')
port->database_name = pstrdup(port->user_name);
- if (Db_user_namespace)
- {
- /*
- * If user@, it is a global user, remove '@'. We only want to do this
- * if there is an '@' at the end and no earlier in the user string or
- * they may fake as a local user of another database attaching to this
- * database.
- */
- if (strchr(port->user_name, '@') ==
- port->user_name + strlen(port->user_name) - 1)
- *strchr(port->user_name, '@') = '\0';
- else
- {
- /* Append '@' and dbname */
- port->user_name = psprintf("%s@%s", port->user_name, port->database_name);
- }
- }
-
/*
* Truncate given database and user names to length of a Postgres name.
* This avoids lookup failures when overlength names are given.
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 71e27f8eb0..25d9008bb6 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -1534,15 +1534,6 @@ struct config_bool ConfigureNamesBool[] =
false,
NULL, NULL, NULL
},
- {
- {"db_user_namespace", PGC_SIGHUP, CONN_AUTH_AUTH,
- gettext_noop("Enables per-database user names."),
- NULL
- },
- &Db_user_namespace,
- false,
- NULL, NULL, NULL
- },
{
{"default_transaction_read_only", PGC_USERSET, CLIENT_CONN_STATEMENT,
gettext_noop("Sets the default read-only status of new transactions."),
diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample
index e4c0269fa3..c768af9a73 100644
--- a/src/backend/utils/misc/postgresql.conf.sample
+++ b/src/backend/utils/misc/postgresql.conf.sample
@@ -96,7 +96,6 @@
#authentication_timeout = 1min # 1s-600s
#password_encryption = scram-sha-256 # scram-sha-256 or md5
#scram_iterations = 4096
-#db_user_namespace = off
# GSSAPI using Kerberos
#krb_server_keyfile = 'FILE:${sysconfdir}/krb5.keytab'
diff --git a/src/include/libpq/pqcomm.h b/src/include/libpq/pqcomm.h
index c85090259d..3da00f7983 100644
--- a/src/include/libpq/pqcomm.h
+++ b/src/include/libpq/pqcomm.h
@@ -103,8 +103,6 @@ typedef ProtocolVersion MsgType;
typedef uint32 PacketLen;
-extern PGDLLIMPORT bool Db_user_namespace;
-
/*
* In protocol 3.0 and later, the startup packet length is not fixed, but
* we set an arbitrary limit on it anyway. This is just to prevent simple
--
2.25.1
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Should we remove db_user_namespace?
2023-06-30 20:05 Should we remove db_user_namespace? Nathan Bossart <[email protected]>
@ 2023-06-30 21:40 ` Tom Lane <[email protected]>
2023-06-30 21:43 ` Re: Should we remove db_user_namespace? Nathan Bossart <[email protected]>
2 siblings, 1 reply; 27+ messages in thread
From: Tom Lane @ 2023-06-30 21:40 UTC (permalink / raw)
To: Nathan Bossart <[email protected]>; +Cc: pgsql-hackers
Nathan Bossart <[email protected]> writes:
> I'm personally not aware of anyone using this parameter.
Might be worth asking on pgsql-general whether anyone knows of
active use of this feature. If not, I'm good with killing it.
regards, tom lane
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Should we remove db_user_namespace?
2023-06-30 20:05 Should we remove db_user_namespace? Nathan Bossart <[email protected]>
2023-06-30 21:40 ` Re: Should we remove db_user_namespace? Tom Lane <[email protected]>
@ 2023-06-30 21:43 ` Nathan Bossart <[email protected]>
0 siblings, 0 replies; 27+ messages in thread
From: Nathan Bossart @ 2023-06-30 21:43 UTC (permalink / raw)
To: Tom Lane <[email protected]>; +Cc: pgsql-hackers
On Fri, Jun 30, 2023 at 05:40:18PM -0400, Tom Lane wrote:
> Might be worth asking on pgsql-general whether anyone knows of
> active use of this feature. If not, I'm good with killing it.
Will do.
--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com
^ permalink raw reply [nested|flat] 27+ messages in thread
* Re: Should we remove db_user_namespace?
2023-06-30 20:05 Should we remove db_user_namespace? Nathan Bossart <[email protected]>
@ 2023-07-03 07:20 ` Michael Paquier <[email protected]>
2 siblings, 0 replies; 27+ messages in thread
From: Michael Paquier @ 2023-07-03 07:20 UTC (permalink / raw)
To: Nathan Bossart <[email protected]>; +Cc: pgsql-hackers
On Fri, Jun 30, 2023 at 01:05:09PM -0700, Nathan Bossart wrote:
> The attached patch simply removes the GUC.
I am on the side of +1'ing for the removal.
--
Michael
Attachments:
[application/pgp-signature] signature.asc (833B, ../../[email protected]/2-signature.asc)
download
^ permalink raw reply [nested|flat] 27+ messages in thread
end of thread, other threads:[~2023-07-03 07:20 UTC | newest]
Thread overview: 27+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-08-06 15:56 [PATCH 5/8] add special pg_brin_bloom_summary data type Tomas Vondra <[email protected]>
2020-08-06 15:56 [PATCH 5/8] add special pg_brin_bloom_summary data type Tomas Vondra <[email protected]>
2020-08-06 15:56 [PATCH 5/8] add special pg_brin_bloom_summary data type Tomas Vondra <[email protected]>
2020-08-06 15:56 [PATCH 5/8] add special pg_brin_bloom_summary data type Tomas Vondra <[email protected]>
2020-08-06 15:56 [PATCH 5/8] add special pg_brin_bloom_summary data type Tomas Vondra <[email protected]>
2020-08-06 15:56 [PATCH 5/8] add special pg_brin_bloom_summary data type Tomas Vondra <[email protected]>
2020-08-06 15:56 [PATCH 5/8] add special pg_brin_bloom_summary data type Tomas Vondra <[email protected]>
2020-08-06 15:56 [PATCH 5/8] add special pg_brin_bloom_summary data type Tomas Vondra <[email protected]>
2020-08-06 15:56 [PATCH 5/8] add special pg_brin_bloom_summary data type Tomas Vondra <[email protected]>
2020-08-06 15:56 [PATCH 5/8] add special pg_brin_bloom_summary data type Tomas Vondra <[email protected]>
2020-08-06 15:56 [PATCH 5/8] add special pg_brin_bloom_summary data type Tomas Vondra <[email protected]>
2020-08-06 15:56 [PATCH 5/8] add special pg_brin_bloom_summary data type Tomas Vondra <[email protected]>
2020-08-06 15:56 [PATCH 5/8] add special pg_brin_bloom_summary data type Tomas Vondra <[email protected]>
2020-08-06 15:56 [PATCH 5/8] add special pg_brin_bloom_summary data type Tomas Vondra <[email protected]>
2020-08-06 15:56 [PATCH 5/8] add special pg_brin_bloom_summary data type Tomas Vondra <[email protected]>
2020-08-06 15:56 [PATCH 5/8] add special pg_brin_bloom_summary data type Tomas Vondra <[email protected]>
2020-08-06 15:56 [PATCH 5/8] add special pg_brin_bloom_summary data type Tomas Vondra <[email protected]>
2020-08-06 15:56 [PATCH 5/8] add special pg_brin_bloom_summary data type Tomas Vondra <[email protected]>
2020-08-06 15:56 [PATCH 5/8] add special pg_brin_bloom_summary data type Tomas Vondra <[email protected]>
2020-08-06 15:56 [PATCH 05/10] add special pg_brin_bloom_summary data type Tomas Vondra <[email protected]>
2020-08-06 15:56 [PATCH 5/8] add special pg_brin_bloom_summary data type Tomas Vondra <[email protected]>
2020-08-06 15:56 [PATCH 5/8] add special pg_brin_bloom_summary data type Tomas Vondra <[email protected]>
2023-06-30 20:05 Should we remove db_user_namespace? Nathan Bossart <[email protected]>
2023-06-30 20:42 ` Re: Should we remove db_user_namespace? Nathan Bossart <[email protected]>
2023-06-30 21:40 ` Re: Should we remove db_user_namespace? Tom Lane <[email protected]>
2023-06-30 21:43 ` Re: Should we remove db_user_namespace? Nathan Bossart <[email protected]>
2023-07-03 07:20 ` Re: Should we remove db_user_namespace? Michael Paquier <[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