OSDN Git Service

Fix SEGV caused by duplicate memoize hints
authorKyotaro Horiguchi <horikyota.ntt@gmail.com>
Wed, 19 Jan 2022 03:59:59 +0000 (12:59 +0900)
committerKyotaro Horiguchi <horikyota.ntt@gmail.com>
Wed, 19 Jan 2022 03:59:59 +0000 (12:59 +0900)
HintTypeName was missing the item for the Memoize hint. This causes
SEGV or "(null)" printing by printf on erroring of duplicate memoize
hints.

Add the missing item and a static assertion to check the same kind of
fault.

Reported by ShangBenX <https://github.com/ShangBenX>

pg_hint_plan.c

index 8534cea..2dca0b3 100644 (file)
@@ -216,9 +216,13 @@ static const char *HintTypeName[] = {
        "leading",
        "set",
        "rows",
-       "parallel"
+       "parallel",
+       "memoize"
 };
 
+StaticAssertDecl(sizeof(HintTypeName) / sizeof(char *) == NUM_HINT_TYPE,
+                                "HintTypeName and HintType don't match");
+
 /* hint status */
 typedef enum HintStatus
 {