Skip to content

Commit

Permalink
Updates for NAN
Browse files Browse the repository at this point in the history
  • Loading branch information
cjbj committed May 26, 2015
1 parent 6cf6524 commit e2fc019
Show file tree
Hide file tree
Showing 14 changed files with 290 additions and 70 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## node-oracledb v0.6.0 (26 May 2015)

- Node-oracledb now builds with Node.js 0.10, Node.js 0.12 and io.js.

- Fixed naming of `autoCommit` in examples.

## node-oracledb v0.5.0 (5 May 2015)

- Changed the `isAutoCommit` attribute name to `autoCommit`.
Expand Down
56 changes: 25 additions & 31 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ The Oracle Database Node.js driver node-oracledb powers high performance Node.js
The steps below create a Node.js installation for testing. Adjust the
steps for your environment.

This node-oracledb release currently works only with Node.js 0.10. It
has been tested with 0.10.35 on 64-bit Oracle Linux and Windows. The
driver can also build in some Mac OS X, 32-bit Linux, 32-bit Windows,
Solaris and AIX environments, but these architectures have not been fully
tested.
This node-oracledb release has been tested with Node 0.10 and 0.12 on
64-bit Oracle Linux and Windows. The driver can also build in some
Mac OS X, 32-bit Linux, 32-bit Windows, Solaris and AIX environments,
but these architectures have not been fully tested.

### Prerequisites

Expand Down Expand Up @@ -81,20 +80,18 @@ install Oracle Linux yourself, it is free from
### 2.1 Install Node.js

Download the
[Node.js 0.10 Linux 64-bit binaries](http://nodejs.org/download/) and
[Node.js Linux 64-bit binaries](http://nodejs.org/download/) and
extract the file, for example into `/opt`:

```
cd /opt
tar -zxf node-v0.10.38-linux-x64.tar.gz
tar -zxf node-v0.12.4-linux-x64.tar.gz
```

This node-oracledb release currently works only with Node.js 0.10.

Set PATH to include Node.js:

```
export PATH=/opt/node-v0.10.38-linux-x64/bin:$PATH
export PATH=/opt/node-v0.12.4-linux-x64/bin:$PATH
```

### 2.2 Install the free Oracle Instant Client RPMs
Expand All @@ -120,13 +117,19 @@ Install node-oracledb from the
npm install oracledb
```

Node-oracledb will automatically configured to use the highest version
Node-oracledb will automatically be configured to use the highest version
Instant Client RPMs installed. To use a different version, follow the
instructions to
[install on Linux with Instant Client ZIP files](#instzip) instead,
setting `OCI_LIB_DIR` and `OCI_INC_DIR` to the appropriate
directories.

If you have other Oracle software installed on the same machine, and
the runtime linker is configured to find this other software via
`LD_LIBRARY_PATH` or `ldconfig`, then update the environment to use
the Instant Client RPM libraries, for example
`/usr/lib/oracle/12.1/client64/lib`.

### 2.4 Run an example program

Download the
Expand Down Expand Up @@ -154,20 +157,18 @@ node select1.js
### 3.1 Install Node.js

Download the
[Node.js 0.10 Linux 64-bit binaries](http://nodejs.org/download/) and
[Node.js Linux 64-bit binaries](http://nodejs.org/download/) and
extract the file, for example into `/opt`:

```
cd /opt
tar -zxf node-v0.10.38-linux-x64.tar.gz
tar -zxf node-v0.12.4-linux-x64.tar.gz
```

This node-oracledb release currently works only with Node.js 0.10.

Set PATH to include Node.js:

```
export PATH=/opt/node-v0.10.38-linux-x64/bin:$PATH
export PATH=/opt/node-v0.12.4-linux-x64/bin:$PATH
```

### 3.2 Install the free Oracle Instant Client ZIPs
Expand Down Expand Up @@ -265,20 +266,18 @@ Oracle Database.
### 4.1 Install Node.js

Download the
[Node.js Linux 0.10 64-bit binaries](http://nodejs.org/download/) and
[Node.js Linux 64-bit binaries](http://nodejs.org/download/) and
extract the file, for example into `/opt`:

```
cd /opt
tar -zxf node-v0.10.38-linux-x64.tar.gz
tar -zxf node-v0.12.4-linux-x64.tar.gz
```

This node-oracledb release currently works only with Node.js 0.10.

Set your PATH variable to include Node.js:

```
export PATH=/opt/node-v0.10.38-linux-x64/bin:$PATH
export PATH=/opt/node-v0.12.4-linux-x64/bin:$PATH
```

### 4.2 Install the driver
Expand Down Expand Up @@ -342,14 +341,12 @@ Building node-oracledb requires Xcode from the Mac App store.

### 5.2 Install Node.js

Node.js 0.10 can be installed from various sources, such as via *brew*.
Node.js can be installed from various sources, such as via *brew*.

```
brew install node010
brew install node
```

This node-oracledb release currently works only with Node.js 0.10.

Set your PATH to include the *node* and *npm* binaries:

```
Expand Down Expand Up @@ -449,12 +446,10 @@ use a 32-bit stack during build and run time.

### 6.2 Install Node.js

Install the 64-bit Node.js 0.10 MSI (e.g. node-v0.10.38-x64.msi) from
Install the 64-bit Node.js MSI (e.g. node-v0.12.4-x64.msi) from
[nodejs.org](http://nodejs.org/download/). Make sure the option to
add the Node and npm directories to the path is selected.

This node-oracledb release currently works only with Node.js 0.10.

### 6.3 Install the free Oracle Instant Client ZIPs

Skip this step if you already have Oracle Database or the full Oracle client on your machine.
Expand All @@ -476,9 +471,8 @@ version first in the path.
### 6.4 Install the driver

Start Visual Studio and open a Developer Command Prompt within it.

If you instead decide to use command shell outside Visual Studio, then
run `vcvars64.bat` or `vcvars.bat` (for 32-bit builds).
(If you instead decide to use a command shell outside Visual Studio, then
run `vcvars64.bat` for 64-bit builds or `vcvars.bat` for 32-bit builds).

Use `set PATH` in the shell to confirm the Python, Node.js and Oracle
directories are correctly set. If they are not, then set PATH
Expand Down
29 changes: 29 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# node-oracledb

You may not use the identified files except in compliance with the
Apache License, Version 2.0 (the "License.")

Expand Down Expand Up @@ -217,3 +219,30 @@ 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.
```

# NAN

```
Copyright (c) 2015 NAN contributors
NAN contributors listed at https://github.com/rvagg/nan#contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
```
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# node-oracledb version 0.5
# node-oracledb version 0.6

## <a name="about"></a> 1. About node-oracledb

The Oracle Database Node.js driver powers high performance
Node.js applications.

Node-oracledb 0.5 supports basic and advanced Oracle features, including:
Node-oracledb 0.6 supports basic and advanced Oracle features, including:

- SQL and PL/SQL Execution
- Query results as JavaScript objects or array
Expand All @@ -23,7 +23,7 @@ Node-oracledb 0.5 supports basic and advanced Oracle features, including:
- [Runtime Load Balancing](http://docs.oracle.com/database/121/ADFNS/adfns_perf_scale.htm#ADFNS515) (RLB)
- [Transparent Application Failover](http://docs.oracle.com/database/121/ADFNS/adfns_avail.htm#ADFNS534) (TAF)

Node-oracledb 0.5 is a preview release. We are actively working on
Node-oracledb 0.6 is a preview release. We are actively working on
adding features including LOB support and batch fetching / streaming
of large query result sets.

Expand Down
45 changes: 26 additions & 19 deletions doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1421,35 +1421,42 @@ This paper also gives more detail on configuring DRCP.
### <a name="extauth"></a> 6.3 External Authentication
Instead of specifying a user and password at connection, Oracle
Database allows applications to use an external password store (such
as
External Authentication allows applications to use an external
password store (such as
[Oracle Wallet](http://docs.oracle.com/database/121/DBIMI/to_dbimi10236_d209.htm#DBIMI10236)),
the [Secure Socket Layer](http://docs.oracle.com/database/121/DBSEG/asossl.htm#DBSEG070)
the
[Secure Socket Layer](http://docs.oracle.com/database/121/DBSEG/asossl.htm#DBSEG070)
(SSL), or the
[operating system](http://docs.oracle.com/database/121/DBSEG/authentication.htm#DBSEG30035)
to validate user access. This mode of authentication is called
*external authentication*. One of the benefits is that database
to validate user access. One of the benefits is that database
credentials do not need to be hard coded in the application.
To use external authentication, set the *Oracledb*
[`externalAuth`](propdbextauth) property to *true*. Once this is
set, any subsequent connections obtained using the *Oracledb*
[`getConnection()`](#getconnectiondb) or *Pool*
[`externalAuth`](propdbextauth) property to *true*. This property can
also be set in the `connAttrs` or `poolAttrs` parameters of the
*Oracledb* [`getConnection()`](#getconnectiondb) or
[`createPool()`](#createpool) calls, respectively. The `user` and
`password` properties should not be set, or should be empty strings:
```javascript
oracledb.getConnection(
{
externalAuth: true,
connectString: "localhost/orcl"
},
. . .
```
When `externalAuth` is set, any subsequent connections obtained using
the *Oracledb* [`getConnection()`](#getconnectiondb) or *Pool*
[`getConnection()`](#getconnectionpool) calls will use external
authentication. Setting this property does not affect the operation
of existing connections or pools.
When `externalAuth` is *true*, the `user` and `password` properties
should not be set, or should be empty strings.
The `externalAuth` property can be overridden in the `connAttrs` or
`poolAttrs` parameters of the *Oracledb*
[`getConnection()`](#getconnectiondb) or [`createPool()`](#createpool)
calls, respectively. Overriding `externalAuth` is not possible for
a *Pool* `getConnection()` call. The connections from a *Pool* object
are always obtained in the manner in which the pool was initially
created.
Using `externalAuth` in the `connAttrs` parameter of a *Pool*
`getConnection()` call is not possible. The connections from a *Pool*
object are always obtained in the manner in which the pool was
initially created.
For pools created with external authentication, the number of
connections initially created is zero even if a non-zero value is
Expand Down
2 changes: 1 addition & 1 deletion examples/webapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ oracledb.createPool (
function handleError(response, text, err)
{
if (err) {
text += err.message;
text += err.message
}
console.error(text);
response.write("<p>Error: " + text + "</p>");
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "oracledb",
"version": "0.5.0",
"version": "0.6.0",
"description": "Oracle Database driver by Oracle Corp.",
"license": "Apache 2.0",
"license": "Apache-2.0",
"homepage": "http://www.oracle.com/technetwork/database/database-technologies/node_js/index.html",
"keywords": [
"oracledb",
Expand Down Expand Up @@ -37,7 +37,6 @@
"engines": {
"node": ">=0.10.28"
},
"engineStrict": true,
"maintainers": [
{
"name": "Oracle Corp."
Expand Down
37 changes: 31 additions & 6 deletions src/njs/src/njsConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,31 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file uses NAN:
*
* Copyright (c) 2015 NAN contributors
*
* NAN contributors listed at https://github.com/rvagg/nan#contributors
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
*
* NAME
* njsConnection.cpp
*
Expand Down Expand Up @@ -1312,14 +1337,14 @@ v8::Handle<v8::Value> Connection::GetOutBinds (eBaton* executeBaton)
return NanEscapeScope(GetOutBindArray( executeBaton->binds,
executeBaton->numOutBinds,
executeBaton->stmtIsReturning,
executeBaton->rowsAffected ));
(unsigned long)executeBaton->rowsAffected ));
}
else
{
// Binds as JS object
return NanEscapeScope(GetOutBindObject( executeBaton->binds,
executeBaton->stmtIsReturning,
executeBaton->rowsAffected ));
(unsigned long)executeBaton->rowsAffected ));
}
}
return NanUndefined();
Expand Down Expand Up @@ -1900,11 +1925,11 @@ void Connection::cbDynBufferAllocate ( void *ctx, bool dmlReturning,
bind->value = (char *)malloc ( ( bind->maxSize + 1) * nRows ) ;
if ( dmlReturning )
{
*(bind->len2) = bind->maxSize ;
*(bind->len2) = (unsigned int)bind->maxSize ;
}
else
{
*(bind->len) = bind->maxSize;
*(bind->len) = (unsigned int)bind->maxSize;
}
break;

Expand Down Expand Up @@ -1987,7 +2012,7 @@ int Connection::cbDynBufferGet ( void *ctx, DPI_SZ_TYPE nRows,
// First time callback, allocate the buffer(s).
if ( index == 0 )
{
Connection::cbDynBufferAllocate (ctx, true, nRows );
Connection::cbDynBufferAllocate (ctx, true, (unsigned long)nRows );
}

bind->ind[index] = -1;
Expand All @@ -1996,7 +2021,7 @@ int Connection::cbDynBufferGet ( void *ctx, DPI_SZ_TYPE nRows,
switch ( bind->type )
{
case dpi::DpiVarChar:
bind->len2[index] = bind->maxSize;
bind->len2[index] = (unsigned int)bind->maxSize;
/* 1 extra char for EOS, 1 extra to determine insufficient buf later */
*bufpp = (void *)&(((char *)bind->value)[ (bind->maxSize) * index]);
/* Buffer provided by the application could be small, in this case to
Expand Down
Loading

0 comments on commit e2fc019

Please sign in to comment.