nocfbot-0065-Use-width-explicit-integer-limit-macros-in-row-pa.txt
text/plain
Filename: nocfbot-0065-Use-width-explicit-integer-limit-macros-in-row-pa.txt
Type: text/plain
Part: 63
Message:
Re: Row pattern recognition
From 4b9ecedd7ec29067c70a2289159aa30730f90ada Mon Sep 17 00:00:00 2001
From: Henson Choi <assam258@gmail.com>
Date: Mon, 8 Jun 2026 14:59:00 +0900
Subject: [PATCH 65/68] Use width-explicit integer limit macros in row pattern
recognition
Replace INT_MAX/INT16_MAX/INT32_MAX/INT64_MAX/UINT8_MAX with the
PG_INT*_MAX/PG_UINT8_MAX equivalents, and type RPRPatternNode.min/max
as int32 to match the plan representation. Value- and output-preserving.
---
src/backend/commands/explain.c | 2 +-
src/backend/executor/execRPR.c | 11 +++--
src/backend/executor/nodeWindowAgg.c | 16 +++----
src/backend/optimizer/plan/createplan.c | 14 +++---
src/backend/optimizer/plan/rpr.c | 6 +--
src/backend/parser/gram.y | 64 ++++++++++++-------------
src/backend/utils/adt/ruleutils.c | 6 +--
src/include/nodes/execnodes.h | 2 +-
src/include/nodes/parsenodes.h | 4 +-
src/include/optimizer/rpr.h | 11 +++--
10 files changed, 69 insertions(+), 67 deletions(-)
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index 7992829d5c4..70fd7f386a0 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -3270,7 +3270,7 @@ show_window_def(WindowAggState *planstate, List *ancestors, ExplainState *es)
es);
break;
case RPR_NAV_OFFSET_FIXED:
- if (firstOffset == INT64_MAX)
+ if (firstOffset == PG_INT64_MAX)
ExplainPropertyText("Nav Mark Lookahead", "infinite",
es);
else
diff --git a/src/backend/executor/execRPR.c b/src/backend/executor/execRPR.c
index 3faee7d91ca..8be0d6c8266 100644
--- a/src/backend/executor/execRPR.c
+++ b/src/backend/executor/execRPR.c
@@ -1546,7 +1546,7 @@ nfa_advance(WindowAggState *winstate, RPRNFAContext *ctx, int64 currentPos)
sizeof(bitmapword) *
(winstate->nfaVisitedMaxWord -
winstate->nfaVisitedMinWord + 1));
- winstate->nfaVisitedMinWord = INT16_MAX;
+ winstate->nfaVisitedMinWord = PG_INT16_MAX;
winstate->nfaVisitedMaxWord = -1;
}
@@ -1806,10 +1806,11 @@ ExecRPRProcessRow(WindowAggState *winstate, int64 currentPos,
int64 ctxFrameEnd;
/*
- * Clamp to INT64_MAX on overflow. frameOffset can be as large as
- * PG_INT64_MAX (e.g. "ROWS <huge> FOLLOWING"), so add the offset
- * and the trailing +1 in two separately checked steps to avoid
- * signed-integer overflow in the "frameOffset + 1" subexpression.
+ * Clamp to PG_INT64_MAX on overflow. frameOffset can be as large
+ * as PG_INT64_MAX (e.g. "ROWS <huge> FOLLOWING"), so add the
+ * offset and the trailing +1 in two separately checked steps to
+ * avoid signed-integer overflow in the "frameOffset + 1"
+ * subexpression.
*/
if (pg_add_s64_overflow(ctx->matchStartRow, frameOffset,
&ctxFrameEnd) ||
diff --git a/src/backend/executor/nodeWindowAgg.c b/src/backend/executor/nodeWindowAgg.c
index 576abff3ce6..0ec49d44867 100644
--- a/src/backend/executor/nodeWindowAgg.c
+++ b/src/backend/executor/nodeWindowAgg.c
@@ -3070,7 +3070,7 @@ ExecInitWindowAgg(WindowAgg *node, EState *estate, int eflags)
winstate->nfaVisitedElems = palloc0(sizeof(bitmapword) *
nfaVisitedNWords);
/* High-water mark sentinels: no bits set yet. */
- winstate->nfaVisitedMinWord = INT16_MAX;
+ winstate->nfaVisitedMinWord = PG_INT16_MAX;
winstate->nfaVisitedMaxWord = -1;
}
@@ -4048,7 +4048,7 @@ typedef struct
* NEXT_LAST (= max(inner - outer, 0))
* - minFirstOffset (forward reach from match_start): FIRST,
* compound PREV_FIRST (= inner - outer, may be negative),
- * compound NEXT_FIRST (= inner + outer, clamped to INT64_MAX on
+ * compound NEXT_FIRST (= inner + outer, clamped to PG_INT64_MAX on
* overflow; always >= 0 so never updates minFirstOffset in practice)
*
* Counterpart of visit_nav_plan but using runtime evaluation instead of
@@ -4137,7 +4137,7 @@ visit_nav_exec(NavTraversal *t, RPRNavExpr *nav)
{
/*
* reach = inner - outer. Both are non-negative, so the result >=
- * -INT64_MAX, which cannot underflow int64.
+ * -PG_INT64_MAX, which cannot underflow int64.
*/
reach = inner - outer;
}
@@ -4146,10 +4146,10 @@ visit_nav_exec(NavTraversal *t, RPRNavExpr *nav)
/*
* NEXT_FIRST: reach = inner + outer. This can overflow, but the
* result is always >= 0, so it never updates minFirstOffset
- * (which tracks the minimum). Clamp to INT64_MAX on overflow.
+ * (which tracks the minimum). Clamp to PG_INT64_MAX on overflow.
*/
if (pg_add_s64_overflow(inner, outer, &reach))
- reach = INT64_MAX;
+ reach = PG_INT64_MAX;
}
context->minFirstOffset = Min(context->minFirstOffset, reach);
}
@@ -4184,7 +4184,7 @@ eval_define_offsets(WindowAggState *winstate, List *defineClause)
ctx.winstate = winstate;
ctx.maxOffset = 0;
ctx.maxOverflow = false;
- ctx.minFirstOffset = INT64_MAX;
+ ctx.minFirstOffset = PG_INT64_MAX;
trav.visit = visit_nav_exec;
trav.data = &ctx;
@@ -4213,10 +4213,10 @@ eval_define_offsets(WindowAggState *winstate, List *defineClause)
if (needsFirst)
{
winstate->navFirstOffsetKind = RPR_NAV_OFFSET_FIXED;
- if (ctx.minFirstOffset < INT64_MAX)
+ if (ctx.minFirstOffset < PG_INT64_MAX)
winstate->navFirstOffset = ctx.minFirstOffset;
else
- winstate->navFirstOffset = INT64_MAX;
+ winstate->navFirstOffset = PG_INT64_MAX;
}
}
diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
index 5608d71cbe2..d2e19d61d58 100644
--- a/src/backend/optimizer/plan/createplan.c
+++ b/src/backend/optimizer/plan/createplan.c
@@ -2669,8 +2669,8 @@ visit_nav_plan(NavTraversal *t, RPRNavExpr *nav)
{
/*
* reach = inner - outer. Both are non-negative, so the
- * result >= -INT64_MAX, which cannot underflow int64. No
- * overflow check needed.
+ * result >= -PG_INT64_MAX, which cannot underflow int64.
+ * No overflow check needed.
*/
reach = inner - outer;
}
@@ -2680,10 +2680,10 @@ visit_nav_plan(NavTraversal *t, RPRNavExpr *nav)
* NEXT_FIRST: reach = inner + outer. This can overflow,
* but the result is always >= 0, so it never updates
* firstOffset (which tracks the minimum). Clamp to
- * INT64_MAX on overflow.
+ * PG_INT64_MAX on overflow.
*/
if (pg_add_s64_overflow(inner, outer, &reach))
- reach = INT64_MAX;
+ reach = PG_INT64_MAX;
}
context->firstOffset = Min(context->firstOffset, reach);
@@ -2741,7 +2741,7 @@ compute_define_metadata(List *defineClause,
ctx.maxOffset = 0;
ctx.maxNeedsEval = false;
ctx.maxOverflow = false;
- ctx.firstOffset = INT64_MAX; /* sentinel: no FIRST found yet */
+ ctx.firstOffset = PG_INT64_MAX; /* sentinel: no FIRST found yet */
ctx.hasFirst = false;
ctx.firstNeedsEval = false;
ctx.curVarIdx = 0;
@@ -2789,8 +2789,8 @@ compute_define_metadata(List *defineClause,
else
{
*firstKind = RPR_NAV_OFFSET_FIXED;
- *firstResult = ctx.firstOffset; /* may be negative; INT64_MAX if
- * overflowed */
+ *firstResult = ctx.firstOffset; /* may be negative; PG_INT64_MAX
+ * if overflowed */
}
}
else
diff --git a/src/backend/optimizer/plan/rpr.c b/src/backend/optimizer/plan/rpr.c
index 9364136b071..d768422deeb 100644
--- a/src/backend/optimizer/plan/rpr.c
+++ b/src/backend/optimizer/plan/rpr.c
@@ -1210,7 +1210,7 @@ fillRPRPatternVar(RPRPatternNode *node, RPRPattern *pat, int *idx, RPRDepth dept
elem->varId = getVarIdFromPattern(pat, node->varName);
elem->depth = depth;
elem->min = node->min;
- elem->max = (node->max == INT_MAX) ? RPR_QUANTITY_INF : node->max;
+ elem->max = (node->max == PG_INT32_MAX) ? RPR_QUANTITY_INF : node->max;
Assert(elem->min >= 0 && elem->min < RPR_QUANTITY_INF &&
elem->max >= 1 &&
(elem->max == RPR_QUANTITY_INF || elem->min <= elem->max));
@@ -1263,7 +1263,7 @@ fillRPRPatternGroup(RPRPatternNode *node, RPRPattern *pat, int *idx, RPRDepth de
elem->varId = RPR_VARID_BEGIN;
elem->depth = depth;
elem->min = node->min;
- elem->max = (node->max == INT_MAX) ? RPR_QUANTITY_INF : node->max;
+ elem->max = (node->max == PG_INT32_MAX) ? RPR_QUANTITY_INF : node->max;
Assert(elem->min >= 0 && elem->min < RPR_QUANTITY_INF &&
elem->max >= 1 &&
(elem->max == RPR_QUANTITY_INF || elem->min <= elem->max));
@@ -1291,7 +1291,7 @@ fillRPRPatternGroup(RPRPatternNode *node, RPRPattern *pat, int *idx, RPRDepth de
endElem->varId = RPR_VARID_END;
endElem->depth = depth;
endElem->min = node->min;
- endElem->max = (node->max == INT_MAX) ? RPR_QUANTITY_INF : node->max;
+ endElem->max = (node->max == PG_INT32_MAX) ? RPR_QUANTITY_INF : node->max;
Assert(endElem->min >= 0 && endElem->min < RPR_QUANTITY_INF &&
endElem->max >= 1 &&
(endElem->max == RPR_QUANTITY_INF || endElem->min <= endElem->max));
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index e0799f35638..ac2e5d7914a 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -212,7 +212,7 @@ static void preprocess_pubobj_list(List *pubobjspec_list,
static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
static RPRPatternNode *makeRPRSeqOrSingle(List *children, int location);
static RPRPatternNode *splitRPRTrailingAlt(RPRPatternNode *node, core_yyscan_t yyscanner);
-static RPRPatternNode *makeRPRQuantifier(int min, int max, ParseLoc reluctant, int location,
+static RPRPatternNode *makeRPRQuantifier(int32 min, int32 max, ParseLoc reluctant, int location,
core_yyscan_t yyscanner);
%}
@@ -17745,11 +17745,11 @@ row_pattern_quantifier_opt:
}
| '*'
{
- $$ = (Node *) makeRPRQuantifier(0, INT_MAX, -1, @1, yyscanner);
+ $$ = (Node *) makeRPRQuantifier(0, PG_INT32_MAX, -1, @1, yyscanner);
}
| '+'
{
- $$ = (Node *) makeRPRQuantifier(1, INT_MAX, -1, @1, yyscanner);
+ $$ = (Node *) makeRPRQuantifier(1, PG_INT32_MAX, -1, @1, yyscanner);
}
| Op
{
@@ -17757,19 +17757,19 @@ row_pattern_quantifier_opt:
if (strcmp($1, "?") == 0)
$$ = (Node *) makeRPRQuantifier(0, 1, -1, @1, yyscanner);
else if (strcmp($1, "*?") == 0)
- $$ = (Node *) makeRPRQuantifier(0, INT_MAX, @1 + 1, @1, yyscanner);
+ $$ = (Node *) makeRPRQuantifier(0, PG_INT32_MAX, @1 + 1, @1, yyscanner);
else if (strcmp($1, "+?") == 0)
- $$ = (Node *) makeRPRQuantifier(1, INT_MAX, @1 + 1, @1, yyscanner);
+ $$ = (Node *) makeRPRQuantifier(1, PG_INT32_MAX, @1 + 1, @1, yyscanner);
else if (strcmp($1, "??") == 0)
$$ = (Node *) makeRPRQuantifier(0, 1, @1 + 1, @1, yyscanner);
else if (strcmp($1, "*|") == 0)
{
- $$ = (Node *) makeRPRQuantifier(0, INT_MAX, -1, @1, yyscanner);
+ $$ = (Node *) makeRPRQuantifier(0, PG_INT32_MAX, -1, @1, yyscanner);
((RPRPatternNode *) $$)->trailing_alt = true;
}
else if (strcmp($1, "+|") == 0)
{
- $$ = (Node *) makeRPRQuantifier(1, INT_MAX, -1, @1, yyscanner);
+ $$ = (Node *) makeRPRQuantifier(1, PG_INT32_MAX, -1, @1, yyscanner);
((RPRPatternNode *) $$)->trailing_alt = true;
}
else if (strcmp($1, "?|") == 0)
@@ -17779,12 +17779,12 @@ row_pattern_quantifier_opt:
}
else if (strcmp($1, "*?|") == 0)
{
- $$ = (Node *) makeRPRQuantifier(0, INT_MAX, @1 + 1, @1, yyscanner);
+ $$ = (Node *) makeRPRQuantifier(0, PG_INT32_MAX, @1 + 1, @1, yyscanner);
((RPRPatternNode *) $$)->trailing_alt = true;
}
else if (strcmp($1, "+?|") == 0)
{
- $$ = (Node *) makeRPRQuantifier(1, INT_MAX, @1 + 1, @1, yyscanner);
+ $$ = (Node *) makeRPRQuantifier(1, PG_INT32_MAX, @1 + 1, @1, yyscanner);
((RPRPatternNode *) $$)->trailing_alt = true;
}
else if (strcmp($1, "??|") == 0)
@@ -17803,11 +17803,11 @@ row_pattern_quantifier_opt:
| '*' Op
{
if (strcmp($2, "?") == 0)
- $$ = (Node *) makeRPRQuantifier(0, INT_MAX, @2, @1, yyscanner);
+ $$ = (Node *) makeRPRQuantifier(0, PG_INT32_MAX, @2, @1, yyscanner);
else if (strcmp($2, "?|") == 0)
{
/* "A* ?|B" = reluctant "A*?" plus alternation */
- $$ = (Node *) makeRPRQuantifier(0, INT_MAX, @2, @1, yyscanner);
+ $$ = (Node *) makeRPRQuantifier(0, PG_INT32_MAX, @2, @1, yyscanner);
((RPRPatternNode *) $$)->trailing_alt = true;
}
else
@@ -17820,11 +17820,11 @@ row_pattern_quantifier_opt:
| '+' Op
{
if (strcmp($2, "?") == 0)
- $$ = (Node *) makeRPRQuantifier(1, INT_MAX, @2, @1, yyscanner);
+ $$ = (Node *) makeRPRQuantifier(1, PG_INT32_MAX, @2, @1, yyscanner);
else if (strcmp($2, "?|") == 0)
{
/* "A+ ?|B" = reluctant "A+?" plus alternation */
- $$ = (Node *) makeRPRQuantifier(1, INT_MAX, @2, @1, yyscanner);
+ $$ = (Node *) makeRPRQuantifier(1, PG_INT32_MAX, @2, @1, yyscanner);
((RPRPatternNode *) $$)->trailing_alt = true;
}
else
@@ -17860,37 +17860,37 @@ row_pattern_quantifier_opt:
/* {n}, {n,}, {,m}, {n,m} quantifiers */
| '{' Iconst '}'
{
- if ($2 <= 0 || $2 >= INT_MAX)
+ if ($2 <= 0 || $2 >= PG_INT32_MAX)
ereport(ERROR,
errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("quantifier bound must be between 1 and %d", INT_MAX - 1),
+ errmsg("quantifier bound must be between 1 and %d", PG_INT32_MAX - 1),
parser_errposition(@2));
$$ = (Node *) makeRPRQuantifier($2, $2, -1, @1, yyscanner);
}
| '{' Iconst ',' '}'
{
- if ($2 < 0 || $2 >= INT_MAX)
+ if ($2 < 0 || $2 >= PG_INT32_MAX)
ereport(ERROR,
errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("quantifier bound must be between 0 and %d", INT_MAX - 1),
+ errmsg("quantifier bound must be between 0 and %d", PG_INT32_MAX - 1),
parser_errposition(@2));
- $$ = (Node *) makeRPRQuantifier($2, INT_MAX, -1, @1, yyscanner);
+ $$ = (Node *) makeRPRQuantifier($2, PG_INT32_MAX, -1, @1, yyscanner);
}
| '{' ',' Iconst '}'
{
- if ($3 <= 0 || $3 >= INT_MAX)
+ if ($3 <= 0 || $3 >= PG_INT32_MAX)
ereport(ERROR,
errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("quantifier bound must be between 1 and %d", INT_MAX - 1),
+ errmsg("quantifier bound must be between 1 and %d", PG_INT32_MAX - 1),
parser_errposition(@3));
$$ = (Node *) makeRPRQuantifier(0, $3, -1, @1, yyscanner);
}
| '{' Iconst ',' Iconst '}'
{
- if ($2 < 0 || $4 <= 0 || $2 >= INT_MAX || $4 >= INT_MAX)
+ if ($2 < 0 || $4 <= 0 || $2 >= PG_INT32_MAX || $4 >= PG_INT32_MAX)
ereport(ERROR,
errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("quantifier bounds must be between 0 and %d with max >= 1", INT_MAX - 1),
+ errmsg("quantifier bounds must be between 0 and %d with max >= 1", PG_INT32_MAX - 1),
parser_errposition(@2));
if ($2 > $4)
ereport(ERROR,
@@ -17908,10 +17908,10 @@ row_pattern_quantifier_opt:
errmsg("invalid token after range quantifier"),
errhint("Only \"?\" is allowed after {n} to make it reluctant."),
parser_errposition(@4));
- if ($2 <= 0 || $2 >= INT_MAX)
+ if ($2 <= 0 || $2 >= PG_INT32_MAX)
ereport(ERROR,
errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("quantifier bound must be between 1 and %d", INT_MAX - 1),
+ errmsg("quantifier bound must be between 1 and %d", PG_INT32_MAX - 1),
parser_errposition(@2));
$$ = (Node *) makeRPRQuantifier($2, $2, @4, @1, yyscanner);
if (strcmp($4, "?|") == 0)
@@ -17925,12 +17925,12 @@ row_pattern_quantifier_opt:
errmsg("invalid token after range quantifier"),
errhint("Only \"?\" is allowed after {n,} or {,m} to make it reluctant."),
parser_errposition(@5));
- if ($2 < 0 || $2 >= INT_MAX)
+ if ($2 < 0 || $2 >= PG_INT32_MAX)
ereport(ERROR,
errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("quantifier bound must be between 0 and %d", INT_MAX - 1),
+ errmsg("quantifier bound must be between 0 and %d", PG_INT32_MAX - 1),
parser_errposition(@2));
- $$ = (Node *) makeRPRQuantifier($2, INT_MAX, @5, @1, yyscanner);
+ $$ = (Node *) makeRPRQuantifier($2, PG_INT32_MAX, @5, @1, yyscanner);
if (strcmp($5, "?|") == 0)
((RPRPatternNode *) $$)->trailing_alt = true;
}
@@ -17942,10 +17942,10 @@ row_pattern_quantifier_opt:
errmsg("invalid token after range quantifier"),
errhint("Only \"?\" is allowed after {n,} or {,m} to make it reluctant."),
parser_errposition(@5));
- if ($3 <= 0 || $3 >= INT_MAX)
+ if ($3 <= 0 || $3 >= PG_INT32_MAX)
ereport(ERROR,
errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("quantifier bound must be between 1 and %d", INT_MAX - 1),
+ errmsg("quantifier bound must be between 1 and %d", PG_INT32_MAX - 1),
parser_errposition(@3));
$$ = (Node *) makeRPRQuantifier(0, $3, @5, @1, yyscanner);
if (strcmp($5, "?|") == 0)
@@ -17959,10 +17959,10 @@ row_pattern_quantifier_opt:
errmsg("invalid token after range quantifier"),
errhint("Only \"?\" is allowed after {n,m} to make it reluctant."),
parser_errposition(@6));
- if ($2 < 0 || $4 <= 0 || $2 >= INT_MAX || $4 >= INT_MAX)
+ if ($2 < 0 || $4 <= 0 || $2 >= PG_INT32_MAX || $4 >= PG_INT32_MAX)
ereport(ERROR,
errcode(ERRCODE_SYNTAX_ERROR),
- errmsg("quantifier bounds must be between 0 and %d with max >= 1", INT_MAX - 1),
+ errmsg("quantifier bounds must be between 0 and %d with max >= 1", PG_INT32_MAX - 1),
parser_errposition(@2));
if ($2 > $4)
ereport(ERROR,
@@ -21400,7 +21400,7 @@ makeRecursiveViewSelect(char *relname, List *aliases, Node *query)
* Create an RPRPatternNode with specified quantifier bounds.
*/
static RPRPatternNode *
-makeRPRQuantifier(int min, int max, ParseLoc reluctant_location, int location,
+makeRPRQuantifier(int32 min, int32 max, ParseLoc reluctant_location, int location,
core_yyscan_t yyscanner)
{
RPRPatternNode *n = makeNode(RPRPatternNode);
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index e8087d4316a..d588cd8263d 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -7124,13 +7124,13 @@ append_pattern_quantifier(StringInfo buf, RPRPatternNode *node)
/* {1,1} = no quantifier */
has_quantifier = false;
}
- else if (node->min == 0 && node->max == INT_MAX)
+ else if (node->min == 0 && node->max == PG_INT32_MAX)
appendStringInfoChar(buf, '*');
- else if (node->min == 1 && node->max == INT_MAX)
+ else if (node->min == 1 && node->max == PG_INT32_MAX)
appendStringInfoChar(buf, '+');
else if (node->min == 0 && node->max == 1)
appendStringInfoChar(buf, '?');
- else if (node->max == INT_MAX)
+ else if (node->max == PG_INT32_MAX)
appendStringInfo(buf, "{%d,}", node->min);
else if (node->min == node->max)
appendStringInfo(buf, "{%d}", node->min);
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 771d095209f..792aa3f0d05 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -2673,7 +2673,7 @@ typedef struct WindowAggState
bitmapword *nfaVisitedElems; /* elemIdx visited bitmap for cycle
* detection */
int16 nfaVisitedMinWord; /* lowest bitmapword index touched since
- * last reset (INT16_MAX = none) */
+ * last reset (PG_INT16_MAX = none) */
int16 nfaVisitedMaxWord; /* highest bitmapword index touched since
* last reset (-1 = none) */
int64 nfaLastProcessedRow; /* last row processed by NFA (-1 =
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 9636a8efca1..16f31dbe7ff 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -625,8 +625,8 @@ typedef struct RPRPatternNode
{
NodeTag type; /* T_RPRPatternNode */
RPRPatternNodeType nodeType; /* VAR, SEQ, ALT, GROUP */
- int min; /* minimum repetitions (0 for *, ?) */
- int max; /* maximum repetitions (INT_MAX for *, +) */
+ int32 min; /* minimum repetitions (0 for *, ?) */
+ int32 max; /* maximum repetitions (PG_INT32_MAX for *, +) */
bool reluctant; /* true for reluctant (non-greedy) */
ParseLoc reluctant_location; /* location of '?' token, or -1 */
ParseLoc location; /* token location, or -1 */
diff --git a/src/include/optimizer/rpr.h b/src/include/optimizer/rpr.h
index 73c827de2b1..8e0bc7efc53 100644
--- a/src/include/optimizer/rpr.h
+++ b/src/include/optimizer/rpr.h
@@ -26,12 +26,13 @@
* before release.
*/
#define RPR_VARID_MAX 0xEF /* pattern variables are 0 to 0xEF */
-#define RPR_QUANTITY_INF INT32_MAX /* unbounded quantifier */
-#define RPR_COUNT_MAX INT32_MAX /* max runtime count (NFA state) */
-#define RPR_ELEMIDX_MAX INT16_MAX /* max pattern elements */
+#define RPR_QUANTITY_INF PG_INT32_MAX /* unbounded quantifier */
+#define RPR_COUNT_MAX PG_INT32_MAX /* max runtime count (NFA state) */
+#define RPR_ELEMIDX_MAX PG_INT16_MAX /* max pattern elements */
#define RPR_ELEMIDX_INVALID ((RPRElemIdx) -1) /* invalid index */
-#define RPR_DEPTH_MAX (UINT8_MAX - 1) /* max pattern nesting depth: 254 */
-#define RPR_DEPTH_NONE UINT8_MAX /* no enclosing group (top-level) */
+#define RPR_DEPTH_MAX (PG_UINT8_MAX - 1) /* max pattern nesting depth:
+ * 254 */
+#define RPR_DEPTH_NONE PG_UINT8_MAX /* no enclosing group (top-level) */
/* Reserved control-element varIds (high nibble 0xF; 0xF0-0xFB spare) */
#define RPR_VARID_BEGIN ((RPRVarId) 0xFC) /* group begin */
--
2.50.1 (Apple Git-155)