Skip to content

New contrib/fixeddecimal: add support for Cloudberry#1584

Open
tuhaihe wants to merge 32 commits intoapache:mainfrom
tuhaihe:add-fixeddecimal
Open

New contrib/fixeddecimal: add support for Cloudberry#1584
tuhaihe wants to merge 32 commits intoapache:mainfrom
tuhaihe:add-fixeddecimal

Conversation

@tuhaihe
Copy link
Member

@tuhaihe tuhaihe commented Feb 28, 2026

Fixes #ISSUE_Number

What does this PR do?

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Breaking Changes

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:

User-facing changes:

Dependencies:

Checklist

Additional Context

CI Skip Instructions


david-rowley and others added 30 commits February 28, 2026 10:39
1. Added typmod enforcement for fixednumeric.
2. Added hash index support.
3. Added missing copywrite notice
4. Added tests for indexes
This cast only serves to check that the typmod is valid or the fixeddecimal.
So we only need to bother doing this when the typmod is actually present,
i.e, not -1.
Also fixed small cast compiler warning in paramter to hash_any()
The problem was that the .sql file for the extension created a BRIN op class.
The solution to this was to move the CREATE OPERATOR CLASS for BRIN to another
file and have the makefile dynamically build the .sql file for the extension
based on which version of Postgres we're building for. For versions < 9.5 we
don't include BRIN.

This also required similar logic for the BRIN tests. To fix this I've moved
the BRIN test to a separate file, which is now only tested in version >= 9.5
This adds support for XL's concept of aggregate collect functions which allows
the aggregate to be partially calculated on each node, and the agg state to be
passed to another node to allow the final aggregation to take place.

Also added sanity checks for bogus values of FIXEDDECIMAL_SCALE

Also removed accidental commit of regression test actual result files.
This change adds logic to the Makefile to detect when running on Postgres-XL
and run XL specific tests for this case.
Added credits, comments and legal wording prior to release
Also add various functions to allow cross type operators to save having to
cast lesser types up to fixeddecimal.

Please note that the upgrade script to upgrade from 1.0.0 to 1.1.0 is currently
only for 9.6 and beyond. If you're running XL or 9.5 or less this script will
need to be altered.
Clarify explanations
Test for all versions from 9.5 to 12.
Rework makefile

Signed-off-by: Florin Irion <[email protected]>
@tuhaihe tuhaihe marked this pull request as draft February 28, 2026 04:34
Add fixeddecimal to contrib recursive targets so it is built and tested with
the rest of contrib modules.

Rework contrib/fixeddecimal/Makefile to support both in-tree and PGXS builds:
- use standard contrib in-tree includes (src/Makefile.global + contrib-global.mk)
- keep USE_PGXS path for out-of-tree usage
- remove hard dependency on pg_config for in-tree builds
- fix generated SQL dependency path handling when srcdir is empty

Fix fixeddecimal runtime issues seen in distributed aggregate execution:
- avoid MAXINT8LEN macro conflict with core headers
- switch int64 overflow checks to pg_add_s64_overflow/pg_sub_s64_overflow
- harden aggregate state serialize/deserialize against NULL states
- restore memory context before early return in aggregate combine

Update fixeddecimal regression expected files for Cloudberry behavior
(distribution-key NOTICEs, GPORCA plans, and distributed index semantics).

With these changes, fixeddecimal builds, installs, and passes installcheck
as a regular contrib extension in Cloudberry.
Add compliance metadata for the newly imported contrib/fixeddecimal extension.

- Add fixeddecimal license notice entry under the
  "Apache Cloudberry includes codes from" section in LICENSE
  (PostgreSQL License, with a pointer to licenses/LICENSE-fixeddecimal.txt).
- Add licenses/LICENSE-fixeddecimal.txt with fixeddecimal attribution and
  PostgreSQL license text.
- Add Apache RAT exclusion for contrib/fixeddecimal/** in pom.xml, and place
  it in the Cloudberry-origin section (not the Greenplum section).

This keeps license attribution and RAT classification aligned with
fixeddecimal’s origin and repository organization.
@tuhaihe tuhaihe marked this pull request as ready for review February 28, 2026 07:01
Copy link
Contributor

@leborchuk leborchuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the cloudberry version of https://github.com/2ndQuadrant/fixeddecimal/commits/master/ extension.

See that all 30 original commits are in a place, extension was added to CI workflow and tests are green.

The original licence is

fixeddecimal is open source using The PostgreSQL Licence, copyright is novated to the PostgreSQL Global Development Group.

And it reflects in LICENSE-fixeddecimal.txt file.

LGTM

Copy link
Contributor

@avamingli avamingli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And why we must add this contrib into repo?

Comment on lines 39 to 52
-------------------------------------------
Index Scan using fixdec_d_idx on fixdec
Index Cond: (d = '12.34'::fixeddecimal)
(2 rows)
QUERY PLAN
------------------------------------------
Gather Motion 3:1 (slice1; segments: 3)
-> Seq Scan on fixdec
Filter: (d = '12.34'::fixeddecimal)
Optimizer: GPORCA
(4 rows)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any explain about that?

Merge Key: d
-> Sort
Sort Key: d
-> Seq Scan on fixdec
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix that, not just copy the error into tests.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The origin test is intend to test duplicated keys:

ERROR: could not create unique index "fixdec_d_idx"
DETAIL: Key (d)=(123.45) is duplicated.
ERROR: UNIQUE index must contain all columns in the table's distribution key
DETAIL: Distribution key column "id" is not included in the constraint.

@tuhaihe
Copy link
Member Author

tuhaihe commented Mar 2, 2026

And why we must add this contrib into repo?

There was one discussion on integrating More Extensions into Apache Cloudberryhttps://lists.apache.org/thread/o5n45tw6ok7wqpd7wdyhdgyhzlcs5t7j. fixeddecimal is one part of the work.

Copy link
Contributor

@gfphoenix78 gfphoenix78 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM +1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants