summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorDavis Haupt <davis.haupt@mongodb.com>2022-02-18 14:53:22 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-02-18 15:21:20 +0000
commitbf6817d8a34a8a32b0ee195a30325b09a4db86ee (patch)
tree005a504a6da999a70adebf450610e12c9d23be8f /src/mongo/db
parentc01b04e5ec53149c0513342bd567b77de1f3fe77 (diff)
downloadmongo-bf6817d8a34a8a32b0ee195a30325b09a4db86ee.tar.gz
SERVER-63665 add compilation target for server-side rewrites
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/query/fle/SConscript23
-rw-r--r--src/mongo/db/query/fle/server_rewrite.cpp42
-rw-r--r--src/mongo/db/query/fle/server_rewrite.h40
-rw-r--r--src/mongo/db/query/fle/server_rewrite_test.cpp49
4 files changed, 154 insertions, 0 deletions
diff --git a/src/mongo/db/query/fle/SConscript b/src/mongo/db/query/fle/SConscript
new file mode 100644
index 00000000000..bf3f91f998f
--- /dev/null
+++ b/src/mongo/db/query/fle/SConscript
@@ -0,0 +1,23 @@
+Import("env")
+
+env = env.Clone()
+
+env.Library(
+ target="query_fle_server",
+ source=[
+ 'server_rewrite.cpp',
+ ],
+ LIBDEPS=[
+ '$BUILD_DIR/mongo/db/matcher/expressions',
+ ]
+)
+
+env.CppUnitTest(
+ target="fle_server_rewrite_test",
+ source=[
+ "server_rewrite_test.cpp",
+ ],
+ LIBDEPS=[
+ "query_fle_server",
+ ],
+)
diff --git a/src/mongo/db/query/fle/server_rewrite.cpp b/src/mongo/db/query/fle/server_rewrite.cpp
new file mode 100644
index 00000000000..a0eb609781c
--- /dev/null
+++ b/src/mongo/db/query/fle/server_rewrite.cpp
@@ -0,0 +1,42 @@
+/**
+ * Copyright (C) 2022-present MongoDB, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the Server Side Public License, version 1,
+ * as published by MongoDB, Inc.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Server Side Public License for more details.
+ *
+ * You should have received a copy of the Server Side Public License
+ * along with this program. If not, see
+ * <http://www.mongodb.com/licensing/server-side-public-license>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the Server Side Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#include "mongo/db/query/fle/server_rewrite.h"
+#include <memory>
+
+namespace mongo::fle {
+
+/**
+ * Placeholder function to make sure the compilation unit works.
+ * TODO SERVER-63294: Turn this into an actual function.
+ */
+std::unique_ptr<MatchExpression> rewriteMatchExpression(std::unique_ptr<MatchExpression> me) {
+ return me;
+}
+} // namespace mongo::fle
diff --git a/src/mongo/db/query/fle/server_rewrite.h b/src/mongo/db/query/fle/server_rewrite.h
new file mode 100644
index 00000000000..8707704366d
--- /dev/null
+++ b/src/mongo/db/query/fle/server_rewrite.h
@@ -0,0 +1,40 @@
+/**
+ * Copyright (C) 2022-present MongoDB, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the Server Side Public License, version 1,
+ * as published by MongoDB, Inc.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Server Side Public License for more details.
+ *
+ * You should have received a copy of the Server Side Public License
+ * along with this program. If not, see
+ * <http://www.mongodb.com/licensing/server-side-public-license>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the Server Side Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#pragma once
+
+#include <memory>
+
+#include "mongo/db/matcher/expression.h"
+
+namespace mongo::fle {
+
+std::unique_ptr<MatchExpression> rewriteMatchExpression(std::unique_ptr<MatchExpression> me);
+
+}
diff --git a/src/mongo/db/query/fle/server_rewrite_test.cpp b/src/mongo/db/query/fle/server_rewrite_test.cpp
new file mode 100644
index 00000000000..1c72a6cdd52
--- /dev/null
+++ b/src/mongo/db/query/fle/server_rewrite_test.cpp
@@ -0,0 +1,49 @@
+/**
+ * Copyright (C) 2022-present MongoDB, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the Server Side Public License, version 1,
+ * as published by MongoDB, Inc.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Server Side Public License for more details.
+ *
+ * You should have received a copy of the Server Side Public License
+ * along with this program. If not, see
+ * <http://www.mongodb.com/licensing/server-side-public-license>.
+ *
+ * As a special exception, the copyright holders give permission to link the
+ * code of portions of this program with the OpenSSL library under certain
+ * conditions as described in each individual source file and distribute
+ * linked combinations including the program with the OpenSSL library. You
+ * must comply with the Server Side Public License in all respects for
+ * all of the code used other than as permitted herein. If you modify file(s)
+ * with this exception, you may extend this exception to your version of the
+ * file(s), but you are not obligated to do so. If you do not wish to do so,
+ * delete this exception statement from your version. If you delete this
+ * exception statement from all source files in the program, then also delete
+ * it in the license file.
+ */
+
+#include <memory>
+
+#include "mongo/db/matcher/expression_leaf.h"
+#include "mongo/unittest/unittest.h"
+#include "mongo/util/assert_util.h"
+#include "server_rewrite.h"
+
+namespace mongo {
+namespace {
+
+// Placeholder test for placeholder function to make sure compilation unit works.
+// TODO SERVER-63294: replace this unit test with tests that check the actual behavior.
+TEST(FLE2ServerRewrites, ServerRewriteIdentity) {
+ auto me = std::make_unique<EqualityMatchExpression>("_id"_sd, Value(1));
+ auto expected = EqualityMatchExpression("_id"_sd, Value(1));
+ auto result = fle::rewriteMatchExpression(std::move(me));
+ ASSERT_EQUALS(expected.path(), result->path());
+}
+} // namespace
+} // namespace mongo