diff --git a/fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/KeyValueCursorBase.java b/fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/KeyValueCursorBase.java index 0bf452f923..2c95368af8 100644 --- a/fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/KeyValueCursorBase.java +++ b/fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/KeyValueCursorBase.java @@ -281,7 +281,7 @@ public abstract static class Builder> { protected Builder(@Nonnull Subspace subspace) { this.subspace = subspace; - this.serializationMode = SerializationMode.TO_OLD; + this.serializationMode = SerializationMode.TO_NEW; } /** diff --git a/fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/plans/RecordQueryIndexPlan.java b/fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/plans/RecordQueryIndexPlan.java index a144f41213..2ed9cc2b15 100644 --- a/fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/plans/RecordQueryIndexPlan.java +++ b/fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/query/plan/plans/RecordQueryIndexPlan.java @@ -219,7 +219,7 @@ public RecordQueryIndexPlan(@Nonnull final String indexName, @Nonnull final Optional matchCandidateOptional, @Nonnull final Type resultType, @Nonnull final QueryPlanConstraint constraint) { - this(indexName, commonPrimaryKey, scanParameters, indexFetchMethod, fetchIndexRecords, reverse, strictlySorted, matchCandidateOptional, resultType, constraint, KeyValueCursorBase.SerializationMode.TO_OLD); + this(indexName, commonPrimaryKey, scanParameters, indexFetchMethod, fetchIndexRecords, reverse, strictlySorted, matchCandidateOptional, resultType, constraint, KeyValueCursorBase.SerializationMode.TO_NEW); } @VisibleForTesting @@ -834,7 +834,7 @@ public byte[] toBytes() { if (bytes == null) { synchronized (this) { if (bytes == null) { - bytes = KeyValueCursorBase.Continuation.getInnerContinuation(new KeyValueCursorBase.Continuation(KeyValueCursorBase.Continuation.getInnerContinuation(baseContinuation.toBytes()), prefixLength, serializationMode).toBytes()); + bytes = new KeyValueCursorBase.Continuation(KeyValueCursorBase.Continuation.getInnerContinuation(baseContinuation.toBytes()), prefixLength, serializationMode).toBytes(); } } } diff --git a/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/query/ExplainTests.java b/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/query/ExplainTests.java index d32d35948c..69adc7b138 100644 --- a/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/query/ExplainTests.java +++ b/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/query/ExplainTests.java @@ -135,7 +135,7 @@ void explainWithContinuationSerializedPlanTest() throws Exception { final var continuationInfo = resultSet.getStruct(5); org.junit.jupiter.api.Assertions.assertNotNull(continuationInfo); final var assertStruct = RelationalStructAssert.assertThat(continuationInfo); - assertStruct.hasValue("EXECUTION_STATE", new byte[]{0, 21, 1, 21, 11}); + assertStruct.hasValue("EXECUTION_STATE", new byte[]{10, 5, 0, 21, 1, 21, 11, 17, -84, -51, 115, -104, -35, 66, 0, 94}); assertStruct.hasValue("VERSION", 1); assertStruct.hasValue("PLAN_HASH_MODE", "VC0"); assertStruct.hasValue("PLAN_HASH", -1635569052); @@ -167,7 +167,7 @@ void explainWithContinuationSerializedPlanWithDifferentQueryTest() throws Except final var continuationInfo = resultSet.getStruct(5); org.junit.jupiter.api.Assertions.assertNotNull(continuationInfo); final var assertStruct = RelationalStructAssert.assertThat(continuationInfo); - assertStruct.hasValue("EXECUTION_STATE", new byte[]{0, 21, 1, 21, 11}); + assertStruct.hasValue("EXECUTION_STATE", new byte[]{10, 5, 0, 21, 1, 21, 11, 17, -84, -51, 115, -104, -35, 66, 0, 94}); assertStruct.hasValue("VERSION", 1); assertStruct.hasValue("PLAN_HASH_MODE", "VC0"); assertStruct.hasValue("PLAN_HASH", -1635569052); @@ -199,7 +199,7 @@ void explainExecuteStatementTest() throws Exception { final var continuationInfo = resultSet.getStruct(5); org.junit.jupiter.api.Assertions.assertNotNull(continuationInfo); final var assertStruct = RelationalStructAssert.assertThat(continuationInfo); - assertStruct.hasValue("EXECUTION_STATE", new byte[]{0, 21, 1, 21, 11}); + assertStruct.hasValue("EXECUTION_STATE", new byte[]{10, 5, 0, 21, 1, 21, 11, 17, -84, -51, 115, -104, -35, 66, 0, 94}); assertStruct.hasValue("VERSION", 1); assertStruct.hasValue("PLAN_HASH_MODE", "VC0"); assertStruct.hasValue("PLAN_HASH", -1635569052); diff --git a/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/query/ForceContinuationQueryTests.java b/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/query/ForceContinuationQueryTests.java index 38c45028c4..02b4a07e24 100644 --- a/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/query/ForceContinuationQueryTests.java +++ b/fdb-relational-core/src/test/java/com/apple/foundationdb/relational/recordlayer/query/ForceContinuationQueryTests.java @@ -21,7 +21,6 @@ package com.apple.foundationdb.relational.recordlayer.query; import com.apple.foundationdb.relational.api.Continuation; -import com.apple.foundationdb.relational.api.exceptions.ContextualSQLException; import com.apple.foundationdb.relational.recordlayer.EmbeddedRelationalExtension; import com.apple.foundationdb.relational.recordlayer.RelationalConnectionRule; import com.apple.foundationdb.relational.recordlayer.RelationalStatementRule; @@ -31,7 +30,6 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Order; import org.junit.jupiter.api.extension.RegisterExtension; import org.junit.jupiter.params.ParameterizedTest; @@ -94,26 +92,7 @@ void setup() throws Exception { statement.execute("delete from t3"); } - @ParameterizedTest - @MethodSource("failedQueries") - void testOldSerializationFails(String sql, long result) throws Exception { - Continuation continuation; - statement.setMaxRows(1); - try (var resultSet = statement.executeQuery(sql)) { - Assertions.assertTrue(resultSet.next()); - Assertions.assertEquals(result, resultSet.getLong(1)); - continuation = resultSet.getContinuation(); - } - // old kvCursorContinuation cause continuation at beginning exception - try (final var preparedStatement = connection.prepareStatement("EXECUTE CONTINUATION ?param")) { - preparedStatement.setMaxRows(1); - preparedStatement.setBytes("param", continuation.serialize()); - Assertions.assertThrows(ContextualSQLException.class, preparedStatement::executeQuery); - } - } - // disabled until SerializationMode = TO_NEW - @Disabled @ParameterizedTest @MethodSource("failedQueries") void testNewSerialization(String sql, long result) throws Exception { diff --git a/yaml-tests/src/test/resources/aggregate-index-tests-count.yamsql b/yaml-tests/src/test/resources/aggregate-index-tests-count.yamsql index a35beadf2e..1dc4c7f827 100644 --- a/yaml-tests/src/test/resources/aggregate-index-tests-count.yamsql +++ b/yaml-tests/src/test/resources/aggregate-index-tests-count.yamsql @@ -50,6 +50,15 @@ test_block: # Cannot run with FORCE_CONTINUATIONS due to: https://github.com/FoundationDB/fdb-record-layer/issues/3206 - maxRows: 0 - result: [{4}] + - + - query: select count(*) from t1 + - explain: "AISCAN(MV1 <,> BY_GROUP -> [_0: VALUE:[0]]) | MAP (_ AS _0) | ON EMPTY NULL | MAP (coalesce_long(_._0._0, promote(0l AS LONG)) AS _0)" + # https://github.com/FoundationDB/fdb-record-layer/issues/3206 is fixed since !current_version + - maxRows: 1 + - initialVersionAtLeast: !current_version + - result: [{4}] + - result: [] + - initialVersionLessThan: !current_version - - query: select count(*) from t1 group by col2 - explain: "AISCAN(MV2 <,> BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) | MAP (_._1 AS _0)" @@ -60,6 +69,15 @@ test_block: # Cannot run with FORCE_CONTINUATIONS due to: https://github.com/FoundationDB/fdb-record-layer/issues/3206 - maxRows: 0 - result: [{2}] + - + - query: select count(col1) from t1 + - explain: "AISCAN(MV3 <,> BY_GROUP -> [_0: VALUE:[0]]) | MAP (_ AS _0) | ON EMPTY NULL | MAP (coalesce_long(_._0._0, promote(0l AS LONG)) AS _0)" + # https://github.com/FoundationDB/fdb-record-layer/issues/3206 is fixed since !current_version + - maxRows: 1 + - initialVersionAtLeast: !current_version + - result: [{2}] + - result: [] + - initialVersionLessThan: !current_version - - query: select count(col1) from t1 group by col2 - explain: "AISCAN(MV4 <,> BY_GROUP -> [_0: KEY:[0], _1: VALUE:[0]]) | MAP (_._1 AS _0)"