Skip to content

Generate queryjumble functions by gen_node_support.pl - #2070

Open
chenjinbao1989 wants to merge 1 commit into
apache:mainfrom
chenjinbao1989:generate_query_jumble
Open

chenjinbao1989 wants to merge 1 commit into
apache:mainfrom
chenjinbao1989:generate_query_jumble

Conversation

@chenjinbao1989

Copy link
Copy Markdown
Contributor

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


@leborchuk leborchuk added Merge PG16 Project Merge postgres 16 https://github.com/orgs/apache/projects/497 type: Refactoring A code change that neither fixes a bug nor adds a feature labels Oct 5, 2026
@chenjinbao1989
chenjinbao1989 enabled auto-merge (rebase) October 9, 2026 23:45
@chenjinbao1989
chenjinbao1989 requested review from Alena0704, jiaqizho, lss602726449 and reshke and removed request for Alena0704 October 9, 2026 23:46
@Alena0704

Alena0704 commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Does this change reuse code from several PostgreSQL commits, including 8eba3e3, 3db72eb, and 2ecbb0a, with additional generator changes from 62d712e, 5ac462e, and 27ee6ed?
Could you document these upstream references in the commit message and explicitly describe the adaptations for Cloudberry? Where possible, it would be preferable to cherry-pick the upstream commits with git cherry-pick -x to preserve the original authorship and provenance.

@Alena0704

Copy link
Copy Markdown
Collaborator

The generated _jumbleGpPolicy() hashes the attrs and opclasses pointer addresses instead of their contents. This makes identical CTAS statements produce different query IDs and splits their pg_stat_statements statistics. Reproduced on this PR: 20 identical CTAS executions produced two entries with calls = 1 and 19.

SHOW compute_query_id;
SHOW shared_preload_libraries;
SELECT pg_stat_statements_reset();

SELECT 'CREATE TEMP TABLE pr2070_ctas AS SELECT 1 AS a DISTRIBUTED BY (a); DROP TABLE pr2070_ctas;'
FROM generate_series(1, 20)
\gexec

SELECT queryid, calls, query
FROM pg_stat_statements
WHERE query LIKE 'CREATE TEMP TABLE pr2070_ctas AS%'
ORDER BY queryid;

SELECT count(*) AS distinct_queryids, sum(calls) AS total_calls
FROM pg_stat_statements
WHERE query LIKE 'CREATE TEMP TABLE pr2070_ctas AS%';
                                                                                                       version                                                                                                        
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 16.9 (Apache Cloudberry 3.0.0-devel build dev) on aarch64-apple-darwin25.6.0, compiled by Apple clang version 21.0.0 (clang-2100.1.1.101), 64-bit compiled on Oct 10 2026 14:30:48 (with assert checking)
(1 row)

 compute_query_id 
------------------
 on
(1 row)

    shared_preload_libraries     
---------------------------------
 interconnect,pg_stat_statements
(1 row)

 pg_stat_statements_reset 
--------------------------
 
(1 row)

SELECT 1
DROP TABLE
SELECT 1
DROP TABLE
SELECT 1
DROP TABLE
SELECT 1
DROP TABLE
SELECT 1
DROP TABLE
SELECT 1
DROP TABLE
SELECT 1
DROP TABLE
SELECT 1
DROP TABLE
SELECT 1
DROP TABLE
SELECT 1
DROP TABLE
SELECT 1
DROP TABLE
SELECT 1
DROP TABLE
SELECT 1
DROP TABLE
SELECT 1
DROP TABLE
SELECT 1
DROP TABLE
SELECT 1
DROP TABLE
SELECT 1
DROP TABLE
SELECT 1
DROP TABLE
SELECT 1
DROP TABLE
SELECT 1
DROP TABLE
       queryid        | calls |                               query                                
----------------------+-------+--------------------------------------------------------------------
 -5309283567727542932 |     1 | CREATE TEMP TABLE pr2070_ctas AS SELECT $1 AS a DISTRIBUTED BY (a)
  3061958272506938425 |    19 | CREATE TEMP TABLE pr2070_ctas AS SELECT $1 AS a DISTRIBUTED BY (a)
(2 rows)

 distinct_queryids | total_calls 
-------------------+-------------
                 2 |          20
(1 row)

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

Labels

Merge PG16 Project Merge postgres 16 https://github.com/orgs/apache/projects/497 type: Refactoring A code change that neither fixes a bug nor adds a feature

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

5 participants