summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamantha Ritter <samantha.ritter@10gen.com>2015-03-26 14:31:58 -0400
committerRamon Fernandez <ramon.fernandez@mongodb.com>2015-04-20 14:43:32 -0400
commitad6f455452db9dd395a0ba71ec38d34848770f3d (patch)
treef58562a79ac9c66714fb0bad6e638d7ecd222ee5
parentc09d38c2de92bb0227cc273767ec4a9c22702cc0 (diff)
downloadmongo-ad6f455452db9dd395a0ba71ec38d34848770f3d.tar.gz
SERVER-17453 eval command is deprecated
(cherry picked from commit 465bb26c0fb0f4731f4dbb5e09e0a791177bbc64)
-rw-r--r--src/mongo/db/dbeval.cpp7
-rw-r--r--src/mongo/s/commands_public.cpp5
-rw-r--r--src/mongo/shell/db.js11
3 files changed, 18 insertions, 5 deletions
diff --git a/src/mongo/db/dbeval.cpp b/src/mongo/db/dbeval.cpp
index ee4f3480aeb..82986beaae0 100644
--- a/src/mongo/db/dbeval.cpp
+++ b/src/mongo/db/dbeval.cpp
@@ -63,6 +63,10 @@ namespace {
BSONObjBuilder& result,
string& errmsg) {
+ RARELY {
+ warning() << "the eval command is deprecated" << startupWarningsLog;
+ }
+
const BSONElement e = cmd.firstElement();
uassert(10046,
"eval needs Code",
@@ -151,7 +155,8 @@ namespace {
}
virtual void help(stringstream &help) const {
- help << "Evaluate javascript at the server.\n"
+ help << "DEPRECATED\n"
+ << "Evaluate javascript at the server.\n"
<< "http://dochub.mongodb.org/core/serversidecodeexecution";
}
virtual bool isWriteCommandForConfigServer() const { return false; }
diff --git a/src/mongo/s/commands_public.cpp b/src/mongo/s/commands_public.cpp
index 3d8cf5dc8ad..ccfd0a57d1f 100644
--- a/src/mongo/s/commands_public.cpp
+++ b/src/mongo/s/commands_public.cpp
@@ -2324,6 +2324,11 @@ namespace mongo {
string& errmsg,
BSONObjBuilder& result,
bool) {
+
+ RARELY {
+ warning() << "the eval command is deprecated" << startupWarningsLog;
+ }
+
// $eval isn't allowed to access sharded collections, but we need to leave the
// shard to detect that.
DBConfigPtr conf = grid.getDBConfig( dbName , false );
diff --git a/src/mongo/shell/db.js b/src/mongo/shell/db.js
index 185ca273b6b..6607dd6f131 100644
--- a/src/mongo/shell/db.js
+++ b/src/mongo/shell/db.js
@@ -329,7 +329,7 @@ DB.prototype.help = function() {
print("\tdb.createUser(userDocument)");
print("\tdb.currentOp() displays currently executing operations in the db");
print("\tdb.dropDatabase()");
- print("\tdb.eval(func, args) run code server-side");
+ print("\tdb.eval() - deprecated");
print("\tdb.fsyncLock() flush data to disk and lock server for backups");
print("\tdb.fsyncUnlock() unlocks server following a db.fsyncLock()");
print("\tdb.getCollection(cname) same as db['cname'] or db.cname");
@@ -430,8 +430,9 @@ DB.prototype.setProfilingLevel = function(level,slowms) {
}
/**
+ * @deprecated
* <p> Evaluate a js expression at the database server.</p>
- *
+ *
* <p>Useful if you need to touch a lot of data lightly; in such a scenario
* the network transfer of the data could be a bottleneck. A good example
* is "select count(*)" -- can be done server side via this mechanism.
@@ -441,15 +442,17 @@ DB.prototype.setProfilingLevel = function(level,slowms) {
* If the eval fails, an exception is thrown of the form:
* </p>
* <code>{ dbEvalException: { retval: functionReturnValue, ok: num [, errno: num] [, errmsg: str] } }</code>
- *
+ *
* <p>Example: </p>
* <code>print( "mycount: " + db.eval( function(){db.mycoll.find({},{_id:ObjId()}).length();} );</code>
*
* @param {Function} jsfunction Javascript function to run on server. Note this it not a closure, but rather just "code".
* @return result of your function, or null if error
- *
+ *
*/
DB.prototype.eval = function(jsfunction) {
+ print("WARNING: db.eval is deprecated");
+
var cmd = { $eval : jsfunction };
if ( arguments.length > 1 ) {
cmd.args = argumentsToArray( arguments ).slice(1);