Skip to content

Commit

Permalink
1. latest binaries checked in - significant stability improvements wh…
Browse files Browse the repository at this point in the history
…ere previously garbage collector could cause undefined behaviour and system crashes.
  • Loading branch information
TimelordUK committed Jul 24, 2016
1 parent f77f6fd commit 890fde5
Show file tree
Hide file tree
Showing 13 changed files with 99 additions and 6 deletions.
1 change: 1 addition & 0 deletions bindingdotgyp.old
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
'target_name': 'sqlserverv8',

'sources': [
'src/OdbcHandle.cpp',
'src/Column.cpp',
'src/TimestampColumn.cpp',
'src/Connection.cpp',
Expand Down
Binary file modified lib/bin/sqlserverv8.v0.12.15.ia32.node
Binary file not shown.
Binary file modified lib/bin/sqlserverv8.v0.12.15.x64.node
Binary file not shown.
Binary file modified lib/bin/sqlserverv8.v4.4.5.ia32.node
Binary file not shown.
Binary file modified lib/bin/sqlserverv8.v4.4.5.x64.node
Binary file not shown.
Binary file modified lib/bin/sqlserverv8.v5.12.0.ia32.node
Binary file not shown.
Binary file modified lib/bin/sqlserverv8.v5.12.0.x64.node
Binary file not shown.
Binary file modified lib/bin/sqlserverv8.v6.2.2.ia32.node
Binary file not shown.
Binary file modified lib/bin/sqlserverv8.v6.2.2.x64.node
Binary file not shown.
4 changes: 2 additions & 2 deletions lib/sqlserver.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
//
//---------------------------------------------------------------------------------------------------------------------------------

debugLoad();
//liveLoad();
//debugLoad();
liveLoad();

function debugLoad() {
var binaryDir= __dirname ;
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "msnodesqlv8",
"description": "Microsoft Driver for Node.js for SQL Server compatible with Node 0.14 / 4.4.3 / 6.1.0 and stored procedure support",
"description": "Microsoft Driver for Node.js SQL Server compatible with all versions of Node.",
"author": {
"name": "Stephen James"
},
Expand All @@ -12,9 +12,11 @@
"name": "Stephen James"
}
],
"version": "0.1.46",
"version": "0.2.1",
"keywords": [
"sql",
"prepared",
"statements",
"database",
"procedure",
"sproc",
Expand Down
3 changes: 1 addition & 2 deletions reptest.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ for /L %%n in (1,1,100) do (
rem FOR %%A IN (prepared.js params.js query.js querytimeout.js connect.js bulk.js sproc.js prepared.js userbind.js) DO (
rem node runtest.js -t %%A >> ./test.txt 2>&1
rem )
node runtest -t params.js -t query.js -t querytimeout.js -t connect.js -t bulk.js -t sproc.js -t prepared.js -t userbind.js -t dates.js >> ./test.txt 2>&1
rem node runtest -t userbind.js >> ./test.txt 2>&1
node runtest -t txn.js -t datatypes.js -t params.js -t query.js -t querytimeout.js -t connect.js -t bulk.js -t sproc.js -t prepared.js -t userbind.js -t dates.js >> ./test.txt 2>&1
echo "next " >> ./test.txt 2>&1
)
91 changes: 91 additions & 0 deletions src/OdbcHandle.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
//---------------------------------------------------------------------------------------------------------------------------------
// File: OdbcHandle.cpp
// Contents: Object to manage ODBC handles
//
// Copyright Microsoft Corporation and contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
//
// You may obtain a copy of the License at:
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//---------------------------------------------------------------------------------------------------------------------------------

#include "OdbcHandle.h"
#include "stdafx.h"

namespace mssql
{
OdbcHandle::OdbcHandle(SQLSMALLINT ht) : HandleType(ht), handle(nullptr)
{
}

OdbcHandle::~OdbcHandle()
{
Free();
}

bool OdbcHandle::Alloc()
{
assert(handle == SQL_NULL_HANDLE);
SQLRETURN ret = SQLAllocHandle(HandleType, nullptr, &handle);
if (!SQL_SUCCEEDED(ret))
{
return false;
}
return true;
}

bool OdbcHandle::Alloc(const OdbcHandle parent)
{
assert(handle == SQL_NULL_HANDLE);
SQLRETURN ret = SQLAllocHandle(HandleType, parent, &handle);
if (!SQL_SUCCEEDED(ret))
{
return false;
}
return true;
}

void OdbcHandle::Free()
{
if (handle != nullptr)
{
handle = nullptr;
SQLFreeHandle(HandleType, handle);
}
}

SQLHANDLE OdbcHandle::get() const
{
return handle;
}

shared_ptr<OdbcError> OdbcHandle::LastError(void) const
{
vector<wchar_t> buffer;

SQLWCHAR wszSqlState[6];
SQLINTEGER nativeError;
SQLSMALLINT actual;

SQLRETURN ret = SQLGetDiagRec(HandleType, handle, 1, wszSqlState, &nativeError, nullptr, 0, &actual);
assert(ret != SQL_INVALID_HANDLE);
assert(ret != SQL_NO_DATA);
assert(SQL_SUCCEEDED(ret));

buffer.resize(actual + 1);
ret = SQLGetDiagRec(HandleType, handle, 1, wszSqlState, &nativeError, &buffer[0], actual + 1, &actual);
assert(SQL_SUCCEEDED(ret));

string sqlstate = w2a(wszSqlState);
string message = w2a(buffer.data());
return make_shared<OdbcError>(sqlstate.c_str(), message.c_str(), nativeError);
}
}

0 comments on commit 890fde5

Please sign in to comment.