aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/c.h26
-rw-r--r--src/include/pg_config.h.in3
-rw-r--r--src/include/pg_config.h.win323
-rw-r--r--src/test/regress/expected/select_parallel.out24
-rw-r--r--src/test/regress/sql/select_parallel.sql6
5 files changed, 57 insertions, 5 deletions
diff --git a/src/include/c.h b/src/include/c.h
index bf4043dddf7..3a569c80602 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -355,13 +355,29 @@ typedef unsigned long long int uint64;
/*
* 128-bit signed and unsigned integers
- * There currently is only a limited support for the type. E.g. 128bit
- * literals and snprintf are not supported; but math is.
+ * There currently is only limited support for such types.
+ * E.g. 128bit literals and snprintf are not supported; but math is.
+ * Also, because we exclude such types when choosing MAXIMUM_ALIGNOF,
+ * it must be possible to coerce the compiler to allocate them on no
+ * more than MAXALIGN boundaries.
*/
#if defined(PG_INT128_TYPE)
-#define HAVE_INT128
-typedef PG_INT128_TYPE int128;
-typedef unsigned PG_INT128_TYPE uint128;
+#if defined(pg_attribute_aligned) || ALIGNOF_PG_INT128_TYPE <= MAXIMUM_ALIGNOF
+#define HAVE_INT128 1
+
+typedef PG_INT128_TYPE int128
+#if defined(pg_attribute_aligned)
+pg_attribute_aligned(MAXIMUM_ALIGNOF)
+#endif
+;
+
+typedef unsigned PG_INT128_TYPE uint128
+#if defined(pg_attribute_aligned)
+pg_attribute_aligned(MAXIMUM_ALIGNOF)
+#endif
+;
+
+#endif
#endif
/*
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 1e0583f7b15..f7ac5658cc4 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -27,6 +27,9 @@
/* The normal alignment of `long long int', in bytes. */
#undef ALIGNOF_LONG_LONG_INT
+/* The normal alignment of `PG_INT128_TYPE', in bytes. */
+#undef ALIGNOF_PG_INT128_TYPE
+
/* The normal alignment of `short', in bytes. */
#undef ALIGNOF_SHORT
diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32
index 0c2403f1bf0..d7dcb85af4f 100644
--- a/src/include/pg_config.h.win32
+++ b/src/include/pg_config.h.win32
@@ -34,6 +34,9 @@
/* The alignment requirement of a `long long int'. */
#define ALIGNOF_LONG_LONG_INT 8
+/* The normal alignment of `PG_INT128_TYPE', in bytes. */
+#undef ALIGNOF_PG_INT128_TYPE
+
/* The alignment requirement of a `short'. */
#define ALIGNOF_SHORT 2
diff --git a/src/test/regress/expected/select_parallel.out b/src/test/regress/expected/select_parallel.out
index 164c4bd61c9..72dd4204ace 100644
--- a/src/test/regress/expected/select_parallel.out
+++ b/src/test/regress/expected/select_parallel.out
@@ -99,6 +99,30 @@ explain (costs off)
-> Index Only Scan using tenk1_unique1 on tenk1
(3 rows)
+-- check parallelized int8 aggregate (bug #14897)
+explain (costs off)
+select avg(aa::int8) from a_star;
+ QUERY PLAN
+-----------------------------------------------------
+ Finalize Aggregate
+ -> Gather
+ Workers Planned: 1
+ -> Partial Aggregate
+ -> Append
+ -> Parallel Seq Scan on a_star
+ -> Parallel Seq Scan on b_star
+ -> Parallel Seq Scan on c_star
+ -> Parallel Seq Scan on d_star
+ -> Parallel Seq Scan on e_star
+ -> Parallel Seq Scan on f_star
+(11 rows)
+
+select avg(aa::int8) from a_star;
+ avg
+---------------------
+ 13.6538461538461538
+(1 row)
+
-- test the sanity of parallel query after the active role is dropped.
set force_parallel_mode=1;
drop role if exists regress_parallel_worker;
diff --git a/src/test/regress/sql/select_parallel.sql b/src/test/regress/sql/select_parallel.sql
index e310c096811..af0cc558104 100644
--- a/src/test/regress/sql/select_parallel.sql
+++ b/src/test/regress/sql/select_parallel.sql
@@ -39,6 +39,12 @@ explain (costs off)
select sum(parallel_restricted(unique1)) from tenk1
group by(parallel_restricted(unique1));
+-- check parallelized int8 aggregate (bug #14897)
+explain (costs off)
+select avg(aa::int8) from a_star;
+
+select avg(aa::int8) from a_star;
+
-- test the sanity of parallel query after the active role is dropped.
set force_parallel_mode=1;
drop role if exists regress_parallel_worker;