Skip to content

Commit c07678f

Browse files
bpinteavaleriy42
authored andcommitted
ESQL: Forward port 8.19 RegexMatch serialization change version (elastic#128979)
Fwd port ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY_8_19. Related: elastic#128919.
1 parent d888d2d commit c07678f

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
@@ -72,22 +72,25 @@ public String nodeString() {
7272
}
7373

7474
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 {
75+
var transportVersion = out.getTransportVersion();
76+
if (transportVersion.onOrAfter(TransportVersions.ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY)
77+
|| transportVersion.isPatchFrom(TransportVersions.ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY_8_19)) {
8678
out.writeBoolean(caseInsensitive());
87-
}
79+
} else if (caseInsensitive()) {
80+
// The plan has been optimized to run a case-insensitive match, which the remote peer cannot be notified of. Simply avoiding
81+
// the serialization of the boolean would result in wrong results.
82+
throw new EsqlIllegalArgumentException(
83+
name() + " with case insensitivity is not supported in peer node's version [{}]. Upgrade to version [{}, {}] or newer.",
84+
transportVersion,
85+
TransportVersions.ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY_8_19,
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(TransportVersions.ESQL_REGEX_MATCH_WITH_CASE_INSENSITIVITY_8_19)) && in.readBoolean();
9295
}
9396
}

0 commit comments

Comments
 (0)