Keyword table constness in jsonpath scanner.
Started by Mark Galmost 7 years ago2 messages
Hello all,
While looking over the new jsonpath stuff I noticed the keyword table
wasn't declared const. Shouldn't the table and the actual keyword
strings both be declared const? Perhaps something like the attached
(untested) patch.
-Mark
Attachments:
constify-jsonpath-keywords.patchtext/x-patch; charset=US-ASCII; name=constify-jsonpath-keywords.patchDownload
diff --git a/src/backend/utils/adt/jsonpath_scan.l b/src/backend/utils/adt/jsonpath_scan.l
index 110ea21..5019b57 100644
--- a/src/backend/utils/adt/jsonpath_scan.l
+++ b/src/backend/utils/adt/jsonpath_scan.l
@@ -287,7 +287,7 @@ typedef struct keyword
int16 len;
bool lowercase;
int val;
- char *keyword;
+ const char *keyword;
} keyword;
/*
@@ -295,7 +295,7 @@ typedef struct keyword
* alphabetical order
*/
-static keyword keywords[] = {
+static const keyword keywords[] = {
{ 2, false, IS_P, "is"},
{ 2, false, TO_P, "to"},
{ 3, false, ABS_P, "abs"},
@@ -324,7 +324,7 @@ checkSpecialVal()
{
int res = IDENT_P;
int diff;
- keyword *StopLow = keywords,
+ const keyword *StopLow = keywords,
*StopHigh = keywords + lengthof(keywords),
*StopMiddle;
Re: Keyword table constness in jsonpath scanner.
On Sat, Mar 16, 2019 at 10:47 PM Mark G <markg735@gmail.com> wrote:
While looking over the new jsonpath stuff I noticed the keyword table
wasn't declared const. Shouldn't the table and the actual keyword
strings both be declared const? Perhaps something like the attached
(untested) patch.
Looks good to me. Pushed, thanks.
------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company