Skip to content

Commit b2adbe8

Browse files
bpinteadnhatn
authored andcommitted
Forward port 8.19 RegexMatch serialization change version
Fwd port ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY_8_19.
1 parent ee716f1 commit b2adbe8

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

server/src/main/java/org/elasticsearch/TransportVersions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ static TransportVersion def(int id) {
189189
public static final TransportVersion DATA_STREAM_OPTIONS_API_REMOVE_INCLUDE_DEFAULTS_8_19 = def(8_841_0_41);
190190
public static final TransportVersion JOIN_ON_ALIASES_8_19 = def(8_841_0_42);
191191
public static final TransportVersion ILM_ADD_SKIP_SETTING_8_19 = def(8_841_0_43);
192-
public static final TransportVersion ML_INFERENCE_MISTRAL_CHAT_COMPLETION_ADDED_8_19 = def(8_841_0_44);
192+
public static final TransportVersion ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY_8_19 = def(8_841_0_44);
193193
public static final TransportVersion V_9_0_0 = def(9_000_0_09);
194194
public static final TransportVersion INITIAL_ELASTICSEARCH_9_0_1 = def(9_000_0_10);
195195
public static final TransportVersion INITIAL_ELASTICSEARCH_9_0_2 = def(9_000_0_11);

x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/string/regex/RegexMatch.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import java.io.IOException;
2626

27+
import static org.elasticsearch.TransportVersions.ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY_8_19;
2728
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.ParamOrdinal.DEFAULT;
2829
import static org.elasticsearch.xpack.esql.core.expression.TypeResolutions.isString;
2930

@@ -72,22 +73,24 @@ public String nodeString() {
7273
}
7374

7475
void serializeCaseInsensitivity(StreamOutput out) throws IOException {
75-
if (out.getTransportVersion().before(TransportVersions.ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY)) {
76-
if (caseInsensitive()) {
77-
// The plan has been optimized to run a case-insensitive match, which the remote peer cannot be notified of. Simply avoiding
78-
// the serialization of the boolean would result in wrong results.
79-
throw new EsqlIllegalArgumentException(
80-
name() + " with case insensitivity is not supported in peer node's version [{}]. Upgrade to version [{}] or newer.",
81-
out.getTransportVersion(),
82-
TransportVersions.ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY
83-
);
84-
} // else: write nothing, the remote peer can execute the case-sensitive query
85-
} else {
76+
var transportVersion = out.getTransportVersion();
77+
if (transportVersion.onOrAfter(TransportVersions.ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY)
78+
|| transportVersion.isPatchFrom(ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY_8_19)) {
8679
out.writeBoolean(caseInsensitive());
87-
}
80+
} else if (caseInsensitive()) {
81+
// The plan has been optimized to run a case-insensitive match, which the remote peer cannot be notified of. Simply avoiding
82+
// the serialization of the boolean would result in wrong results.
83+
throw new EsqlIllegalArgumentException(
84+
name() + " with case insensitivity is not supported in peer node's version [{}]. Upgrade to version [{}] or newer.",
85+
out.getTransportVersion(),
86+
TransportVersions.ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY
87+
);
88+
} // else: write nothing, the remote peer can execute the case-sensitive query
8889
}
8990

9091
static boolean deserializeCaseInsensitivity(StreamInput in) throws IOException {
91-
return in.getTransportVersion().onOrAfter(TransportVersions.ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY) && in.readBoolean();
92+
var transportVersion = in.getTransportVersion();
93+
return (transportVersion.onOrAfter(TransportVersions.ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY)
94+
|| transportVersion.isPatchFrom(ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY_8_19)) && in.readBoolean();
9295
}
9396
}

0 commit comments

Comments
 (0)