From 0f20725c68bf5a6662245ab3ef6018830ebee70b Mon Sep 17 00:00:00 2001
From: Henson Choi <assam258@gmail.com>
Date: Mon, 16 Feb 2026 23:57:50 +0900
Subject: [PATCH 1/6] Normalize Sort Method memory in rpr_explain test for
 32-bit compatibility

---
 src/test/regress/expected/rpr_explain.out | 13 +++++++++----
 src/test/regress/sql/rpr_explain.sql      |  9 +++++++--
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/test/regress/expected/rpr_explain.out b/src/test/regress/expected/rpr_explain.out
index f23d06f6d59..bfe4ee2ba7d 100644
--- a/src/test/regress/expected/rpr_explain.out
+++ b/src/test/regress/expected/rpr_explain.out
@@ -33,7 +33,7 @@
 --   DEFINE Expression Variations
 --   Large Scale Statistics Verification
 -- ============================================================
--- Filter function to normalize Storage memory values only (not NFA statistics).
+-- Filter function to normalize platform-dependent memory values (not NFA statistics).
 -- NFA statistics should not change between platforms; if they do, it could
 -- indicate issues such as uninitialized memory access.
 -- Works for text, JSON, and XML formats.
@@ -45,7 +45,7 @@ declare
 begin
     for ln in execute $1
     loop
-        -- Normalize memory size in Storage line only (platform-dependent)
+        -- Normalize platform-dependent memory values
         -- Keep NFA statistics numbers unchanged (they are test assertions)
 
         -- Text format: "Storage: Memory  Maximum Storage: 18kB"
@@ -63,6 +63,11 @@ begin
             ln := regexp_replace(ln, '<Maximum-Storage>\d+</Maximum-Storage>', '<Maximum-Storage>0</Maximum-Storage>', 'g');
         end if;
 
+        -- Sort Method memory is platform-dependent (32-bit vs 64-bit)
+        if ln ~ 'Sort Method:.*Memory:' then
+            ln := regexp_replace(ln, 'Memory: \d+kB', 'Memory: NkB');
+        end if;
+
         return next ln;
     end loop;
 end;
@@ -1625,7 +1630,7 @@ WINDOW w AS (
    NFA: 54 absorbed (len 1/1/1.0), 18 skipped (len 1/1/1.0)
    ->  Sort (actual rows=90.00 loops=1)
          Sort Key: p.p
-         Sort Method: quicksort  Memory: 27kB
+         Sort Method: quicksort  Memory: NkB
          ->  Nested Loop (actual rows=90.00 loops=1)
                ->  Function Scan on generate_series p (actual rows=3.00 loops=1)
                ->  Function Scan on generate_series v (actual rows=30.00 loops=3)
@@ -1682,7 +1687,7 @@ WINDOW w AS (
    NFA: 19 absorbed (len 1/1/1.0), 5 skipped (len 1/1/1.0)
    ->  Sort (actual rows=50.00 loops=1)
          Sort Key: (CASE WHEN (v.v <= 25) THEN 1 ELSE 2 END)
-         Sort Method: quicksort  Memory: 26kB
+         Sort Method: quicksort  Memory: NkB
          ->  Function Scan on generate_series v (actual rows=50.00 loops=1)
 (12 rows)
 
diff --git a/src/test/regress/sql/rpr_explain.sql b/src/test/regress/sql/rpr_explain.sql
index f8c8f62e594..ea8c39b991e 100644
--- a/src/test/regress/sql/rpr_explain.sql
+++ b/src/test/regress/sql/rpr_explain.sql
@@ -34,7 +34,7 @@
 --   Large Scale Statistics Verification
 -- ============================================================
 
--- Filter function to normalize Storage memory values only (not NFA statistics).
+-- Filter function to normalize platform-dependent memory values (not NFA statistics).
 -- NFA statistics should not change between platforms; if they do, it could
 -- indicate issues such as uninitialized memory access.
 -- Works for text, JSON, and XML formats.
@@ -46,7 +46,7 @@ declare
 begin
     for ln in execute $1
     loop
-        -- Normalize memory size in Storage line only (platform-dependent)
+        -- Normalize platform-dependent memory values
         -- Keep NFA statistics numbers unchanged (they are test assertions)
 
         -- Text format: "Storage: Memory  Maximum Storage: 18kB"
@@ -64,6 +64,11 @@ begin
             ln := regexp_replace(ln, '<Maximum-Storage>\d+</Maximum-Storage>', '<Maximum-Storage>0</Maximum-Storage>', 'g');
         end if;
 
+        -- Sort Method memory is platform-dependent (32-bit vs 64-bit)
+        if ln ~ 'Sort Method:.*Memory:' then
+            ln := regexp_replace(ln, 'Memory: \d+kB', 'Memory: NkB');
+        end if;
+
         return next ln;
     end loop;
 end;
-- 
2.50.1 (Apple Git-155)

