From: Andrew Dunstan Date: Thu, 2 Apr 2026 19:07:24 +0000 (-0400) Subject: Rename jsonpath method arg tokens X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a35c9d524ed0a225894c45a33017a82cd8bb6680;p=thirdparty%2Fpostgresql.git Rename jsonpath method arg tokens This is just cleanup in the jsonpath grammar. Rename the `csv_` tokens to `int_`, because they represent signed or unsigned integers, as follows: * `csv_elem` => `int_elem` * `csv_list` => `int_list` * `opt_csv_list` => `opt_int_list` Rename the `datetime_precision` tokens to `uint_arg`, as they represent unsigned integers and will be useful for other methods in the future, as follows: * `datetime_precision` => `uint_elem` * `opt_datetime_precision` => `opt_uint_arg` Rename the `datetime_template` tokens to `str_arg`, as they represent strings and will be useful for other methods in the future, as follows: * `datetime_template` => `str_elem` * `opt_datetime_template` => `opt_str_arg` Author: David E. Wheeler Reviewed-by: Andrew Dunstan Discussion: https://postgr.es/m/CA+v5N40sJF39m0v7h=QN86zGp0CUf9F1WKasnZy9nNVj_VhCZQ@mail.gmail.com --- diff --git a/src/backend/utils/adt/jsonpath_gram.y b/src/backend/utils/adt/jsonpath_gram.y index 87070235d11..eb449aa3709 100644 --- a/src/backend/utils/adt/jsonpath_gram.y +++ b/src/backend/utils/adt/jsonpath_gram.y @@ -92,10 +92,10 @@ static bool makeItemLikeRegex(JsonPathParseItem *expr, %type scalar_value path_primary expr array_accessor any_path accessor_op key predicate delimited_predicate index_elem starts_with_initial expr_or_predicate - datetime_template opt_datetime_template csv_elem - datetime_precision opt_datetime_precision + str_elem opt_str_arg int_elem + uint_elem opt_uint_arg -%type accessor_expr csv_list opt_csv_list +%type accessor_expr int_list opt_int_list %type index_list @@ -254,7 +254,7 @@ accessor_op: | '.' any_path { $$ = $2; } | '.' method '(' ')' { $$ = makeItemType($2); } | '?' '(' predicate ')' { $$ = makeItemUnary(jpiFilter, $3); } - | '.' DECIMAL_P '(' opt_csv_list ')' + | '.' DECIMAL_P '(' opt_int_list ')' { if (list_length($4) == 0) $$ = makeItemBinary(jpiDecimal, NULL, NULL); @@ -268,19 +268,19 @@ accessor_op: errmsg("invalid input syntax for type %s", "jsonpath"), errdetail(".decimal() can only have an optional precision[,scale]."))); } - | '.' DATETIME_P '(' opt_datetime_template ')' + | '.' DATETIME_P '(' opt_str_arg ')' { $$ = makeItemUnary(jpiDatetime, $4); } - | '.' TIME_P '(' opt_datetime_precision ')' + | '.' TIME_P '(' opt_uint_arg ')' { $$ = makeItemUnary(jpiTime, $4); } - | '.' TIME_TZ_P '(' opt_datetime_precision ')' + | '.' TIME_TZ_P '(' opt_uint_arg ')' { $$ = makeItemUnary(jpiTimeTz, $4); } - | '.' TIMESTAMP_P '(' opt_datetime_precision ')' + | '.' TIMESTAMP_P '(' opt_uint_arg ')' { $$ = makeItemUnary(jpiTimestamp, $4); } - | '.' TIMESTAMP_TZ_P '(' opt_datetime_precision ')' + | '.' TIMESTAMP_TZ_P '(' opt_uint_arg ')' { $$ = makeItemUnary(jpiTimestampTz, $4); } ; -csv_elem: +int_elem: INT_P { $$ = makeItemNumeric(&$1); } | '+' INT_P %prec UMINUS @@ -289,31 +289,31 @@ csv_elem: { $$ = makeItemUnary(jpiMinus, makeItemNumeric(&$2)); } ; -csv_list: - csv_elem { $$ = list_make1($1); } - | csv_list ',' csv_elem { $$ = lappend($1, $3); } +int_list: + int_elem { $$ = list_make1($1); } + | int_list ',' int_elem { $$ = lappend($1, $3); } ; -opt_csv_list: - csv_list { $$ = $1; } +opt_int_list: + int_list { $$ = $1; } | /* EMPTY */ { $$ = NULL; } ; -datetime_precision: +uint_elem: INT_P { $$ = makeItemNumeric(&$1); } ; -opt_datetime_precision: - datetime_precision { $$ = $1; } +opt_uint_arg: + uint_elem { $$ = $1; } | /* EMPTY */ { $$ = NULL; } ; -datetime_template: +str_elem: STRING_P { $$ = makeItemString(&$1); } ; -opt_datetime_template: - datetime_template { $$ = $1; } +opt_str_arg: + str_elem { $$ = $1; } | /* EMPTY */ { $$ = NULL; } ;