Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0958f8f

Browse files
committed
Revert "Reorganise jsonpath operators and methods"
This reverts commit283a95d.The reordering of JsonPathItemType affects the binary on-diskcompatibility of the jsonpath type, so we must not change it. Revertfor now and consider.
1 parent76ba8a8 commit0958f8f

File tree

5 files changed

+112
-119
lines changed

5 files changed

+112
-119
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17691,43 +17691,43 @@ strict $.**.HR
1769117691

1769217692
<row>
1769317693
<entry role="func_table_entry"><para role="func_signature">
17694-
<replaceable>number</replaceable> <literal>.</literal> <literal>abs()</literal>
17694+
<replaceable>number</replaceable> <literal>.</literal> <literal>ceiling()</literal>
1769517695
<returnvalue><replaceable>number</replaceable></returnvalue>
1769617696
</para>
1769717697
<para>
17698-
Absolute value of the given number
17698+
Nearest integer greater than or equal to the given number
1769917699
</para>
1770017700
<para>
17701-
<literal>jsonb_path_query('{"z":-0.3}', '$.z.abs()')</literal>
17702-
<returnvalue>0.3</returnvalue>
17701+
<literal>jsonb_path_query('{"h":1.3}', '$.h.ceiling()')</literal>
17702+
<returnvalue>2</returnvalue>
1770317703
</para></entry>
1770417704
</row>
1770517705

1770617706
<row>
1770717707
<entry role="func_table_entry"><para role="func_signature">
17708-
<replaceable>number</replaceable> <literal>.</literal> <literal>ceiling()</literal>
17708+
<replaceable>number</replaceable> <literal>.</literal> <literal>floor()</literal>
1770917709
<returnvalue><replaceable>number</replaceable></returnvalue>
1771017710
</para>
1771117711
<para>
17712-
Nearest integergreater than or equal to the given number
17712+
Nearest integerless than or equal to the given number
1771317713
</para>
1771417714
<para>
17715-
<literal>jsonb_path_query('{"h": 1.3}', '$.h.ceiling()')</literal>
17716-
<returnvalue>2</returnvalue>
17715+
<literal>jsonb_path_query('{"h": 1.7}', '$.h.floor()')</literal>
17716+
<returnvalue>1</returnvalue>
1771717717
</para></entry>
1771817718
</row>
1771917719

1772017720
<row>
1772117721
<entry role="func_table_entry"><para role="func_signature">
17722-
<replaceable>number</replaceable> <literal>.</literal> <literal>floor()</literal>
17722+
<replaceable>number</replaceable> <literal>.</literal> <literal>abs()</literal>
1772317723
<returnvalue><replaceable>number</replaceable></returnvalue>
1772417724
</para>
1772517725
<para>
17726-
Nearest integer less than or equal to the given number
17726+
Absolute value of the given number
1772717727
</para>
1772817728
<para>
17729-
<literal>jsonb_path_query('{"h":1.7}', '$.h.floor()')</literal>
17730-
<returnvalue>1</returnvalue>
17729+
<literal>jsonb_path_query('{"z":-0.3}', '$.z.abs()')</literal>
17730+
<returnvalue>0.3</returnvalue>
1773117731
</para></entry>
1773217732
</row>
1773317733

‎src/backend/utils/adt/jsonpath.c

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -439,10 +439,10 @@ flattenJsonPathParseItem(StringInfo buf, int *result, struct Node *escontext,
439439
break;
440440
casejpiType:
441441
casejpiSize:
442-
casejpiDouble:
443442
casejpiAbs:
444-
casejpiCeiling:
445443
casejpiFloor:
444+
casejpiCeiling:
445+
casejpiDouble:
446446
casejpiKeyValue:
447447
break;
448448
default:
@@ -610,6 +610,18 @@ printJsonPathItem(StringInfo buf, JsonPathItem *v, bool inKey,
610610
if (printBracketes)
611611
appendStringInfoChar(buf,')');
612612
break;
613+
casejpiPlus:
614+
casejpiMinus:
615+
if (printBracketes)
616+
appendStringInfoChar(buf,'(');
617+
appendStringInfoChar(buf,v->type==jpiPlus ?'+' :'-');
618+
jspGetArg(v,&elem);
619+
printJsonPathItem(buf,&elem, false,
620+
operationPriority(elem.type) <=
621+
operationPriority(v->type));
622+
if (printBracketes)
623+
appendStringInfoChar(buf,')');
624+
break;
613625
casejpiFilter:
614626
appendStringInfoString(buf,"?(");
615627
jspGetArg(v,&elem);
@@ -700,35 +712,23 @@ printJsonPathItem(StringInfo buf, JsonPathItem *v, bool inKey,
700712
v->content.anybounds.first,
701713
v->content.anybounds.last);
702714
break;
703-
casejpiPlus:
704-
casejpiMinus:
705-
if (printBracketes)
706-
appendStringInfoChar(buf,'(');
707-
appendStringInfoChar(buf,v->type==jpiPlus ?'+' :'-');
708-
jspGetArg(v,&elem);
709-
printJsonPathItem(buf,&elem, false,
710-
operationPriority(elem.type) <=
711-
operationPriority(v->type));
712-
if (printBracketes)
713-
appendStringInfoChar(buf,')');
714-
break;
715715
casejpiType:
716716
appendStringInfoString(buf,".type()");
717717
break;
718718
casejpiSize:
719719
appendStringInfoString(buf,".size()");
720720
break;
721-
casejpiDouble:
722-
appendStringInfoString(buf,".double()");
723-
break;
724721
casejpiAbs:
725722
appendStringInfoString(buf,".abs()");
726723
break;
724+
casejpiFloor:
725+
appendStringInfoString(buf,".floor()");
726+
break;
727727
casejpiCeiling:
728728
appendStringInfoString(buf,".ceiling()");
729729
break;
730-
casejpiFloor:
731-
appendStringInfoString(buf,".floor()");
730+
casejpiDouble:
731+
appendStringInfoString(buf,".double()");
732732
break;
733733
casejpiDatetime:
734734
appendStringInfoString(buf,".datetime(");
@@ -771,38 +771,38 @@ jspOperationName(JsonPathItemType type)
771771
return"<=";
772772
casejpiGreaterOrEqual:
773773
return">=";
774-
casejpiAdd:
775774
casejpiPlus:
775+
casejpiAdd:
776776
return"+";
777-
casejpiSub:
778777
casejpiMinus:
778+
casejpiSub:
779779
return"-";
780780
casejpiMul:
781781
return"*";
782782
casejpiDiv:
783783
return"/";
784784
casejpiMod:
785785
return"%";
786+
casejpiStartsWith:
787+
return"starts with";
788+
casejpiLikeRegex:
789+
return"like_regex";
786790
casejpiType:
787791
return"type";
788792
casejpiSize:
789793
return"size";
794+
casejpiKeyValue:
795+
return"keyvalue";
790796
casejpiDouble:
791797
return"double";
792798
casejpiAbs:
793799
return"abs";
794-
casejpiCeiling:
795-
return"ceiling";
796800
casejpiFloor:
797801
return"floor";
802+
casejpiCeiling:
803+
return"ceiling";
798804
casejpiDatetime:
799805
return"datetime";
800-
casejpiKeyValue:
801-
return"keyvalue";
802-
casejpiStartsWith:
803-
return"starts with";
804-
casejpiLikeRegex:
805-
return"like_regex";
806806
default:
807807
elog(ERROR,"unrecognized jsonpath item type: %d",type);
808808
returnNULL;
@@ -893,10 +893,10 @@ jspInitByBuffer(JsonPathItem *v, char *base, int32 pos)
893893
casejpiAnyKey:
894894
casejpiType:
895895
casejpiSize:
896-
casejpiDouble:
897896
casejpiAbs:
898-
casejpiCeiling:
899897
casejpiFloor:
898+
casejpiCeiling:
899+
casejpiDouble:
900900
casejpiKeyValue:
901901
casejpiLast:
902902
break;
@@ -935,9 +935,9 @@ jspInitByBuffer(JsonPathItem *v, char *base, int32 pos)
935935
casejpiNot:
936936
casejpiExists:
937937
casejpiIsUnknown:
938-
casejpiFilter:
939938
casejpiPlus:
940939
casejpiMinus:
940+
casejpiFilter:
941941
casejpiDatetime:
942942
read_int32(v->content.arg,base,pos);
943943
break;
@@ -989,6 +989,13 @@ jspGetNext(JsonPathItem *v, JsonPathItem *a)
989989
v->type==jpiRoot||
990990
v->type==jpiVariable||
991991
v->type==jpiLast||
992+
v->type==jpiAdd||
993+
v->type==jpiSub||
994+
v->type==jpiMul||
995+
v->type==jpiDiv||
996+
v->type==jpiMod||
997+
v->type==jpiPlus||
998+
v->type==jpiMinus||
992999
v->type==jpiEqual||
9931000
v->type==jpiNotEqual||
9941001
v->type==jpiGreater||
@@ -999,19 +1006,12 @@ jspGetNext(JsonPathItem *v, JsonPathItem *a)
9991006
v->type==jpiOr||
10001007
v->type==jpiNot||
10011008
v->type==jpiIsUnknown||
1002-
v->type==jpiAdd||
1003-
v->type==jpiPlus||
1004-
v->type==jpiSub||
1005-
v->type==jpiMinus||
1006-
v->type==jpiMul||
1007-
v->type==jpiDiv||
1008-
v->type==jpiMod||
10091009
v->type==jpiType||
10101010
v->type==jpiSize||
1011-
v->type==jpiDouble||
10121011
v->type==jpiAbs||
1013-
v->type==jpiCeiling||
10141012
v->type==jpiFloor||
1013+
v->type==jpiCeiling||
1014+
v->type==jpiDouble||
10151015
v->type==jpiDatetime||
10161016
v->type==jpiKeyValue||
10171017
v->type==jpiStartsWith||

‎src/backend/utils/adt/jsonpath_exec.c

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -874,6 +874,33 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
874874
}
875875
break;
876876

877+
casejpiAdd:
878+
returnexecuteBinaryArithmExpr(cxt,jsp,jb,
879+
numeric_add_opt_error,found);
880+
881+
casejpiSub:
882+
returnexecuteBinaryArithmExpr(cxt,jsp,jb,
883+
numeric_sub_opt_error,found);
884+
885+
casejpiMul:
886+
returnexecuteBinaryArithmExpr(cxt,jsp,jb,
887+
numeric_mul_opt_error,found);
888+
889+
casejpiDiv:
890+
returnexecuteBinaryArithmExpr(cxt,jsp,jb,
891+
numeric_div_opt_error,found);
892+
893+
casejpiMod:
894+
returnexecuteBinaryArithmExpr(cxt,jsp,jb,
895+
numeric_mod_opt_error,found);
896+
897+
casejpiPlus:
898+
returnexecuteUnaryArithmExpr(cxt,jsp,jb,NULL,found);
899+
900+
casejpiMinus:
901+
returnexecuteUnaryArithmExpr(cxt,jsp,jb,numeric_uminus,
902+
found);
903+
877904
casejpiFilter:
878905
{
879906
JsonPathBoolst;
@@ -953,33 +980,6 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
953980
}
954981
break;
955982

956-
casejpiAdd:
957-
returnexecuteBinaryArithmExpr(cxt,jsp,jb,
958-
numeric_add_opt_error,found);
959-
960-
casejpiPlus:
961-
returnexecuteUnaryArithmExpr(cxt,jsp,jb,NULL,found);
962-
963-
casejpiSub:
964-
returnexecuteBinaryArithmExpr(cxt,jsp,jb,
965-
numeric_sub_opt_error,found);
966-
967-
casejpiMinus:
968-
returnexecuteUnaryArithmExpr(cxt,jsp,jb,numeric_uminus,
969-
found);
970-
971-
casejpiMul:
972-
returnexecuteBinaryArithmExpr(cxt,jsp,jb,
973-
numeric_mul_opt_error,found);
974-
975-
casejpiDiv:
976-
returnexecuteBinaryArithmExpr(cxt,jsp,jb,
977-
numeric_div_opt_error,found);
978-
979-
casejpiMod:
980-
returnexecuteBinaryArithmExpr(cxt,jsp,jb,
981-
numeric_mod_opt_error,found);
982-
983983
casejpiType:
984984
{
985985
JsonbValue*jbv=palloc(sizeof(*jbv));
@@ -1021,6 +1021,18 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
10211021
}
10221022
break;
10231023

1024+
casejpiAbs:
1025+
returnexecuteNumericItemMethod(cxt,jsp,jb,unwrap,numeric_abs,
1026+
found);
1027+
1028+
casejpiFloor:
1029+
returnexecuteNumericItemMethod(cxt,jsp,jb,unwrap,numeric_floor,
1030+
found);
1031+
1032+
casejpiCeiling:
1033+
returnexecuteNumericItemMethod(cxt,jsp,jb,unwrap,numeric_ceil,
1034+
found);
1035+
10241036
casejpiDouble:
10251037
{
10261038
JsonbValuejbv;
@@ -1086,18 +1098,6 @@ executeItemOptUnwrapTarget(JsonPathExecContext *cxt, JsonPathItem *jsp,
10861098
}
10871099
break;
10881100

1089-
casejpiAbs:
1090-
returnexecuteNumericItemMethod(cxt,jsp,jb,unwrap,numeric_abs,
1091-
found);
1092-
1093-
casejpiCeiling:
1094-
returnexecuteNumericItemMethod(cxt,jsp,jb,unwrap,numeric_ceil,
1095-
found);
1096-
1097-
casejpiFloor:
1098-
returnexecuteNumericItemMethod(cxt,jsp,jb,unwrap,numeric_floor,
1099-
found);
1100-
11011101
casejpiDatetime:
11021102
if (unwrap&&JsonbType(jb)==jbvArray)
11031103
returnexecuteItemUnwrapTargetArray(cxt,jsp,jb,found, false);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp