Skip to content

Commit

Permalink
Add function to check if the server is MariaDB
Browse files Browse the repository at this point in the history
  • Loading branch information
mscdex committed Aug 20, 2012
1 parent 880b1c0 commit 6e7084e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ Client.prototype.isConnected = function() {
return this._client.connected;
};

Client.prototype.isMariaDB = function() {
return this._client.isMariaDB();
};

Client.prototype._reset = function() {
this._closeOnEmpty = false;
this._queries = [];
Expand Down
12 changes: 12 additions & 0 deletions src/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,17 @@ class Client : public ObjectWrap {
return Undefined();
}

static Handle<Value> IsMariaDB(const Arguments& args) {
HandleScope scope;
Client* obj = ObjectWrap::Unwrap<Client>(args.This());
if (obj->state < STATE_CONNECTED) {
return ThrowException(Exception::Error(
String::New("Not connected"))
);
}
return scope.Close(Boolean::New(mariadb_connection(&obj->mysql)));
}

static void Initialize(Handle<Object> target) {
HandleScope scope;

Expand All @@ -564,6 +575,7 @@ class Client : public ObjectWrap {
NODE_SET_PROTOTYPE_METHOD(Client_constructor, "abortQuery", AbortQuery);
NODE_SET_PROTOTYPE_METHOD(Client_constructor, "escape", Escape);
NODE_SET_PROTOTYPE_METHOD(Client_constructor, "end", Close);
NODE_SET_PROTOTYPE_METHOD(Client_constructor, "isMariaDB", IsMariaDB);

emit_symbol = NODE_PSYMBOL("emit");
target->Set(name, Client_constructor->GetFunction());
Expand Down

0 comments on commit 6e7084e

Please sign in to comment.