Re: parse partition strategy string in gram.y

From: Japin Li <japinli(at)hotmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: parse partition strategy string in gram.y
Date: 2022-10-21 10:05:18
Message-ID: MEYP282MB1669D218D1BFFE0F1A811A99B62D9@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On Fri, 21 Oct 2022 at 17:32, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
> Hello
>
> I've had this patch sitting in a local branch for way too long. It's a
> trivial thing but for some reason it bothered me: we let the partition
> strategy flow into the backend as a string and only parse it into the
> catalog 1-char version quite late.
>
> This patch makes gram.y responsible for parsing it and passing it down
> as a value from a new enum, which looks more neat. Because it's an
> enum, some "default:" cases can be removed in a couple of places. I
> also added a new elog() in case the catalog contents becomes broken.

Does there an error about forget the LIST partition?

+/*
+ * Parse a user-supplied partition strategy string into parse node
+ * PartitionStrategy representation, or die trying.
+ */
+static PartitionStrategy
+parsePartitionStrategy(char *strategy)
+{
+ if (pg_strcasecmp(strategy, "range") == 0) <-- it should be list
+ return PARTITION_STRATEGY_RANGE; <-- PARTITION_STRATEGY_LIST
+ else if (pg_strcasecmp(strategy, "hash") == 0)
+ return PARTITION_STRATEGY_HASH;
+ else if (pg_strcasecmp(strategy, "range") == 0)
+ return PARTITION_STRATEGY_RANGE;
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("unrecognized partitioning strategy \"%s\"",
+ strategy)));
+}
+

--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2022-10-21 10:12:11 Re: parse partition strategy string in gram.y
Previous Message Richard Guo 2022-10-21 09:53:25 Re: Crash after a call to pg_backup_start()