Skip to content

Commit 19f638a

Browse files
committed
Merge latest nodejs-adapter from 7.3 to 7.4
1 parent f4fab68 commit 19f638a

File tree

158 files changed

+11883
-2542
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+11883
-2542
lines changed

storage/ndb/nodejs/.bzrignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ perftest/jscrund.config
88
test/disabled-tests.conf
99
config.gypi
1010
config.waf
11+
benchmark_logs

storage/ndb/nodejs/API-documentation/Batch

+6
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,12 @@ save(String tableName, Object values, [callback], [...]);
330330
*/
331331
isBatch();
332332

333+
/** How many operations are currently defined in this batch?
334+
* @return number of operations in batch
335+
* IMMEDIATE
336+
*/
337+
getOperationCount();
338+
333339
/** execute()
334340
* ASYNC
335341
* Execute this batch. All operations are executed and for each operation

storage/ndb/nodejs/API-documentation/Errors

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,16 @@ var Sqlstates = {
3131
"22000" : "Data error",
3232
"22001" : "String too long",
3333
"22003" : "Numeric value out of range",
34-
"22008" : "Invalid datetime",
34+
"22007" : "Invalid datetime",
3535

3636
// Constraint violations
3737
// 23000 includes both duplicate primary key and duplicate unique key
3838
"23000" : "Integrity Constraint Violation",
3939

40+
// 0Fxxx "Locator Exception" SQLStates relate to BLOB values
41+
// (which must represented in JavaScript as Node Buffers)
42+
"0F001" : "Invalid BLOB value",
43+
4044
// misc. errors
4145
"25000" : "Invalid Transaction State",
4246
"2C000" : "Invalid character set name",

storage/ndb/nodejs/API-documentation/Mynode

+11
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,17 @@ ConnectionProperties(implName_or_connectionProperties);
2828
TableMapping(tableName_or_tableMapping);
2929

3030

31+
/**
32+
* Projection()
33+
* IMMEDIATE
34+
* CONSTRUCTOR
35+
*
36+
* The Projection constructor is visible as a top-level function.
37+
* Refer to the Projection documentation for details.
38+
*/
39+
Projection(constructor);
40+
41+
3142
/**
3243
* connect()
3344
* ASYNC
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/** @class Projection
2+
*
3+
* A Projection describes the projection of a domain object in the application.
4+
* A Projection specifies the complete set of fields and relationships to be
5+
* instantiated when the operation with which it is used is executed.
6+
*
7+
* A *default* Projection is one where each field is specified.
8+
*
9+
*/
10+
Projection = {
11+
domainObject : "" , /** function */
12+
error : "", /** error report for this projection */
13+
fields : "" , /** field names */
14+
relationships : null /** relationships, which consist of a name and projection */
15+
};
16+
17+
18+
/** Projection constructor
19+
*
20+
* @class Projection
21+
* @constructor
22+
* @param {function} [constructor]
23+
*/
24+
function Projection(constructor) {};
25+
26+
27+
28+
/***** Projection methods
29+
-------------------- *****/
30+
31+
/* @method addFields
32+
addFields(fields)
33+
IMMEDIATE
34+
35+
Add fields by name to the projection
36+
37+
@param fields String or [String]
38+
The fields parameter is the name of a field or an array of field names. It can be a string
39+
or an array of strings. Multiple field names are accepted as parameters.
40+
41+
@return {Projection} @chainable
42+
addFields() returns the current Projection object, so that method
43+
invocations can be chained.
44+
*/
45+
function addFields(fields) {};
46+
47+
/* @method addField
48+
ALIAS for addFields for ease of use
49+
addField(fields)
50+
IMMEDIATE
51+
@see addFields
52+
53+
Add fields to the projection
54+
55+
*/
56+
function addField(fields) {};
57+
58+
59+
/* @method addRelationship
60+
addRelationship(name, projection)
61+
IMMEDIATE
62+
63+
Add a relationship to the projection.
64+
65+
@param name {String} name of the relationship field in the domain object
66+
@param projection {Projection} the projection to be assigned to the relationship
67+
@return Projection @chainable
68+
*/
69+
function addRelationship(name, projection) {};
70+
71+
72+
/* This file is a JavaScript module */
73+
exports.Projection = Projection;

storage/ndb/nodejs/API-documentation/Session

+15-1
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ remove(String tableName, Object keys, [callback], [...]);
214214
* If the instance does not exist in the database, an error is reported.
215215
* This method cannot be used to change the primary key.
216216
*
217+
* To efficiently perform read/modify/write, the user should find the object,
218+
* modify the fields to be updated, set the fields *not* to be updated
219+
* to undefined, and call update on the object.
220+
*
217221
* This function returns a promise. On success, the promise will be fulfilled.
218222
* The optional callback receives only an error value. Any extra arguments
219223
* passed after the callback will be passed to the callback function verbatim
@@ -490,7 +494,17 @@ listTables(databaseName, callback);
490494
getTableMetadata(databaseName, tableName, callback);
491495
}
492496

493-
497+
/** Use the projection for find and query operations on the domain object.
498+
* projection:= {constructor: domainObject,
499+
* fields: [field, field...],
500+
* relationships: [relationship, relationship...]}
501+
* The domain object must be mapped and will be validated by this function.
502+
* If fields is omitted, all fields in the mapping will be fetched.
503+
* If relationships is omitted, no relationships in the mapping will be fetched.
504+
* This method returns a promise and can use a callback.
505+
* ASYNC
506+
*/
507+
useProjection(projection, callback);
494508

495509
/*
496510
* Users may find useful a "user" property of session and batch.

storage/ndb/nodejs/API-documentation/Stats

+6-47
Original file line numberDiff line numberDiff line change
@@ -66,56 +66,15 @@
6666
/********* WRITING APPLICATION-LEVEL STATISTICS **********/
6767

6868
/**
69-
* To write statistics, obtain a StatWriter for a particular domain, and then
70-
* use the writer's incr(), set(), and push() methods.
71-
*
72-
*/
69+
* To maintain statistics, a module keeps its own statistics object,
70+
* and registers that object with the stats module.
7371

74-
/** Get a stats writer for a domain.
72+
/** Register statistics for a domain.
7573
* IMMEDIATE
7674
*
77-
* The domain is specified as an array literal
7875
* EXAMPLES:
79-
* var stats = stats_module.get_writer(["app"]);
80-
* var stats = stats_module.get_writer(["app","user_connections"]);
81-
*
82-
* stats.incr(["created"]);
83-
* stats.incr(["get","cached"]);
84-
* stats.set(["login"],"enabled");
85-
* stats.push(["users"], current_user);
86-
*/
87-
getWriter([ domain ]);
88-
89-
90-
/*** StatWriter methods ***/
91-
92-
/** Coerce the value at domain to a Number, then set it to 1 (if new)
93-
* or increment it (if existing).
94-
* The domain is specified as an array literal.
95-
* A single-part domain can alternately be given as a string
96-
* IMMEDIATE
97-
*
98-
*/
99-
statWriter.incr(domain);
100-
101-
102-
/** Set the current value at "domain" to "value".
103-
* IMMEDIATE
104-
* The domain is specified as an array literal.
105-
* A single-part domain can alternately be given as a string
106-
*
107-
*/
108-
statWriter.set(domain, value);
109-
110-
111-
/** Coerce the value at "domain" to an Array, then push value to it.
112-
* IMMEDIATE
113-
* The domain is specified as an array literal.
114-
* A single-part domain can alternately be given as a string
115-
*
116-
* Note that pop(), etc. are missing; to access the array directly, use query()
117-
* to fetch it.
76+
* stats_module.register(my_stats, "app");
77+
* stats_module.register(module_stats, "app","sub_module_1");
11878
*
11979
*/
120-
statWriter.push(domain, value);
121-
80+
register(stats_container, domain_part, ... );

storage/ndb/nodejs/API-documentation/TableMapping

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* A *default* TableMapping is one where each column in a table is mapped
77
* to a field of the same name.
88
*
9+
* Errors that are detected during construction of a TableMapping, including
10+
* field mapping functions, are reported via the error field.
911
*/
1012
TableMapping = {
1113
table : "" , /** Table name @type String */
@@ -18,11 +20,12 @@ TableMapping = {
1820
@property mapAllColumns @type Boolean
1921
@default true
2022
*/
21-
fields : null /** Holds an array of FieldMapping objects.
23+
fields : null, /** Holds an array of FieldMapping objects.
2224
Can also be called "field",
2325
and can also hold a single FieldMapping.
24-
@property fields @type Array
25-
*/
26+
@property fields @type Array */
27+
error : '' /** Reports errors during construction */
28+
2629
};
2730

2831

storage/ndb/nodejs/API-documentation/TableMetadata

+15-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ TableMetadata = {
99
name : "", // Table Name
1010
columns : {}, // ordered array of ColumnMetadata objects
1111
indexes : {}, // array of IndexMetadata objects
12+
foreignKeys : {}, // array of ForeignKeyMetadata objects
1213
partitionKey : {}, // ordered array of column numbers in the partition key
1314
};
1415

@@ -40,7 +41,6 @@ ColumnMetadata = {
4041
/* Group B: Non-numeric */
4142
length : 0 , // CHAR or VARCHAR length in characters
4243
isBinary : false, // true for BLOB/BINARY/VARBINARY
43-
charsetNumber : 0 , // internal number of charset
4444
charsetName : "" , // name of charset
4545
};
4646

@@ -61,6 +61,20 @@ IndexMetadata = {
6161
};
6262

6363

64+
/* ForeignKeyMetadata represents a foreign key constraint.
65+
66+
The "foreignKeys" array of TableMetadata will hold the foreign key constraints.
67+
68+
*/
69+
ForeignKeyMetadata = {
70+
name : "" , // Constraint name
71+
columnNames : null , // an ordered array of column numbers
72+
targetTable : "" , // referenced table name
73+
targetDatabase : "" , // referenced database
74+
targetColumnNames: null , // an ordered array of target column names
75+
};
76+
77+
6478
ColumnTypes = [
6579
"TINYINT",
6680
"SMALLINT",

storage/ndb/nodejs/Adapter/api/Batch.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2013, Oracle and/or its affiliates. All rights
2+
Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights
33
reserved.
44
55
This program is free software; you can redistribute it and/or
@@ -46,7 +46,7 @@ exports.Batch.prototype.clear = function() {
4646
// clear all operations from the batch
4747
// if any pending operations, synchronously call each callback with an error
4848
// the transaction state is unchanged
49-
udebug.log_detail('Batch.clear with operationContexts.length ' + this.operationContexts.length);
49+
if(udebug.is_detail()) if(udebug.is_debug()) udebug.log('Batch.clear with operationContexts.length ' + this.operationContexts.length);
5050
// for each context, extract the operation and clear it
5151
this.operationContexts.forEach(function(context) {
5252
// first, mark the context as cleared so if getTableHandler returns during a user callback,
@@ -168,3 +168,7 @@ exports.Batch.prototype.isBatch = function() {
168168
return true;
169169
};
170170

171+
exports.Batch.prototype.getOperationCount = function() {
172+
return this.operationContexts.length;
173+
};
174+

0 commit comments

Comments
 (0)