Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

spelling mistakes (interruptible) and trim leftover whitespace

  • Loading branch information...
commit 88284c2a79fdf26cb2e8eb611467b61b88085934 1 parent a874d12
Di Wu authored
View
2  lib/authentication.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.6.1
(function() {
var Authentication;
View
4 lib/backend_message.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.6.1
(function() {
var AuthenticationMethods, BackendMessage, messageClass, name, typeOIDs,
__hasProp = {}.hasOwnProperty,
@@ -396,7 +396,7 @@
message = new messageClass(buffer.slice(5));
return message;
} else {
- throw new Error("Unkown message type: " + typeId);
+ throw new Error("Unknown message type: " + typeId);
}
};
View
2  lib/buffer.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.6.1
(function() {
var Buffer, _base, _base1, _base2, _base3, _base4, _base5, _base6, _base7, _base8, _base9, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
View
8 lib/connection.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.6.1
(function() {
var Authentication, BackendMessage, Connection, EventEmitter, FrontendMessage, Query, net, util,
__hasProp = {}.hasOwnProperty,
@@ -209,7 +209,7 @@
var chain, initializer, initializers, _i, _len;
initializers = [];
if (!this.connectionOptions.skipInitialization) {
- if (this.connectionOptions.interruptable) {
+ if (this.connectionOptions.interruptible) {
initializers.push(this._initializeInterrupt);
}
if (this.connectionOptions.role != null) {
@@ -348,7 +348,7 @@
return this.connection.write(msg.toBuffer(), null, callback);
};
- Connection.prototype.isInterruptable = function() {
+ Connection.prototype.isInterruptible = function() {
return this.sessionID != null;
};
@@ -362,7 +362,7 @@
bareClient = new Connection(bareConnectionOptions);
return bareClient.connect(cb);
} else {
- return cb("Cannot intterupt connection! It's not initialized as interruptable.", null);
+ return cb("Cannot interrupt connection! It's not initialized as interruptible.", null);
}
};
View
2  lib/frontend_message.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.6.1
(function() {
var Authentication, Buffer, FrontendMessage,
__hasProp = {}.hasOwnProperty,
View
2  lib/query.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.6.1
(function() {
var EventEmitter, FrontendMessage, Query, Resultset, decoders,
__hasProp = {}.hasOwnProperty,
View
4 lib/quoting.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.6.1
(function() {
exports.escape = function(val) {
@@ -7,7 +7,7 @@
exports.quote = function(val) {
var v;
- if (!(val != null)) {
+ if (val == null) {
return 'NULL';
} else if (typeof val.sqlQuoted === 'function') {
return val.sqlQuoted();
View
2  lib/resultset.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.6.1
(function() {
var Resultset;
View
2  lib/starttls.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.6.1
(function() {
var pipe,
_this = this;
View
4 lib/types.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.6.1
(function() {
var VerticaDate, VerticaInterval, VerticaTime, VerticaTimestamp, binaryDecoders, binaryEncoders, padWithZeroes, stringDecoders, stringEncoders;
@@ -137,7 +137,7 @@
},
setTimezoneOffset: function(offset) {
var matches, timezoneOffset;
- if (!(offset != null)) {
+ if (offset == null) {
return VerticaTimestamp.timezoneOffset = null;
} else if (matches = offset.match(/^([\+\-])(\d{1,2})(?:\:(\d{2}))?$/)) {
timezoneOffset = +matches[2] * 60 + (+matches[3] || 0);
View
2  lib/vertica.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.6.1
(function() {
var quoting, types;
View
4 src/authentication.coffee
@@ -1,4 +1,4 @@
-Authentication =
+Authentication =
methods:
OK: 0
KERBEROS_V5: 2
@@ -9,7 +9,7 @@ Authentication =
GSS: 7
GSS_CONTINUE: 8
SSPI: 9
-
+
# Exports
module.exports = Authentication
View
34 src/backend_message.coffee
@@ -3,17 +3,17 @@ typeOIDs = require('./types').typeOIDs
class BackendMessage
typeId: null
-
+
constructor: (buffer) ->
@read(buffer)
-
+
read: (buffer) ->
# Implement me in subclass
class BackendMessage.Authentication extends BackendMessage
typeId: 82 # R
-
+
read: (buffer) ->
@method = buffer.readUInt32(0)
if @method == AuthenticationMethods.MD5_PASSWORD
@@ -40,7 +40,7 @@ class BackendMessage.ParameterStatus extends BackendMessage
class BackendMessage.NotificationResponse extends BackendMessage
typeId: 65 # A
-
+
read: (buffer) ->
@pid = buffer.readUInt32(4)
@channel = buffer.readZeroTerminatedString(4)
@@ -53,7 +53,7 @@ class BackendMessage.EmptyQueryResponse extends BackendMessage
class BackendMessage.RowDescription extends BackendMessage
typeId: 84 # T
-
+
read: (buffer) ->
numberOfFields = buffer.readUInt16(0)
pos = 2
@@ -76,7 +76,7 @@ class BackendMessage.RowDescription extends BackendMessage
pos += 2
- fieldDescriptor =
+ fieldDescriptor =
name: name
tableOID: tableOID
tableFieldIndex: tableFieldIndex
@@ -91,7 +91,7 @@ class BackendMessage.RowDescription extends BackendMessage
class BackendMessage.DataRow extends BackendMessage
typeId: 68 # D
-
+
read: (buffer) ->
numberOfFields = buffer.readUInt16(0)
pos = 2
@@ -106,13 +106,13 @@ class BackendMessage.DataRow extends BackendMessage
else
data = buffer.slice(pos, pos + length)
pos += length
-
+
@values.push(data)
-
-
+
+
class BackendMessage.CommandComplete extends BackendMessage
typeId: 67 # C
-
+
read: (buffer) ->
@status = buffer.readZeroTerminatedString(0)
@@ -135,7 +135,7 @@ class BackendMessage.ParseComplete extends BackendMessage
class BackendMessage.ErrorResponse extends BackendMessage
typeId: 69 # E
-
+
fieldNames:
83: 'Severity'
67: 'Code'
@@ -149,17 +149,17 @@ class BackendMessage.ErrorResponse extends BackendMessage
70: 'File'
76: 'Line'
82: 'Routine'
-
+
read: (buffer) ->
@information = {}
-
+
fieldCode = buffer.readUInt8(0)
pos = 1
while fieldCode != 0x00
value = buffer.readZeroTerminatedString(pos)
@information[@fieldNames[fieldCode] || fieldCode] = value
pos += Buffer.byteLength(value) + 1
-
+
fieldCode = buffer.readUInt8(pos)
pos += 1
@@ -191,7 +191,7 @@ class BackendMessage.CopyInResponse extends BackendMessage
##############################################################
# BackendMessage factory
-##############################################################
+##############################################################
BackendMessage.types = {}
for name, messageClass of BackendMessage
@@ -207,7 +207,7 @@ BackendMessage.fromBuffer = (buffer) ->
message = new messageClass(buffer.slice(5))
message
else
- throw new Error("Unkown message type: #{typeId}")
+ throw new Error("Unknown message type: #{typeId}")
module.exports = BackendMessage
View
12 src/buffer.coffee
@@ -16,15 +16,15 @@ Buffer::writeUInt16 ?= (number, offset, endian) ->
Buffer::writeUInt32 ?= (number, offset, endian) ->
@_writeUInt(4, number, offset, endian)
-
+
Buffer::_writeUInt ?= (bytes, number, offset, endian) ->
encodingPositions = if endian == 'little' then [offset .. (offset + bytes - 1)] else [(offset + bytes - 1) .. offset]
for currentOffset, index in encodingPositions
@[currentOffset] = (number >> (8 * index)) & 0xff
-
+
return undefined
-
+
#######################################
# Writing strings
#######################################
@@ -33,7 +33,7 @@ Buffer::writeZeroTerminatedString ?= (str, offset, encoding) ->
written = @write(str, offset, null, encoding)
@writeUInt8(0, offset + written)
return written + 1
-
+
#######################################
# Reading ints
#######################################
@@ -49,7 +49,7 @@ Buffer::readUInt32 ?= (offset, endian) ->
Buffer::_readUInt ?= (bytes, offset, endian) ->
encodingPositions = if endian == 'little' then [offset .. (offset + bytes - 1)] else [(offset + bytes - 1) .. offset]
-
+
number = 0
for currentOffset, index in encodingPositions
number = (@[currentOffset] << (index * 8)) | number
@@ -75,4 +75,4 @@ Buffer::readZeroTerminatedString ?= (offset, encoding) ->
# "Buffer([#{bytes}])"
-exports.Buffer = Buffer
+exports.Buffer = Buffer
View
50 src/connection.coffee
@@ -6,9 +6,9 @@ FrontendMessage = require('./frontend_message')
BackendMessage = require('./backend_message')
Authentication = require('./authentication')
Query = require('./query')
-
+
class Connection extends EventEmitter
-
+
constructor: (@connectionOptions) ->
@connectionOptions.host ?= 'localhost'
@connectionOptions.port ?= 5433
@@ -28,11 +28,11 @@ class Connection extends EventEmitter
connect: (callback) ->
@connectedCallback = callback
@connection = net.createConnection @connectionOptions.port, @connectionOptions.host
-
+
@connection.on 'connect', =>
@connected = true
@_bindEventListeners()
-
+
if @connectionOptions.ssl
@_writeMessage(new FrontendMessage.SSLRequest)
@connection.once 'data', (buffer) =>
@@ -76,9 +76,9 @@ class Connection extends EventEmitter
@emit 'queuejob', job
else
@_runJob(job)
-
+
return job
-
+
_runJob: (job) ->
throw "Connection is closed" unless @connected
throw "Connection is busy" if @busy
@@ -93,7 +93,7 @@ class Connection extends EventEmitter
@_runJob(@queue.shift())
else
@emit 'ready', this
-
+
query: (sql, callback) ->
@_scheduleJob(new Query(this, sql, callback))
@@ -110,16 +110,16 @@ class Connection extends EventEmitter
if @connectedCallback then @connectedCallback(err.message) else @emit 'error', err
authenticationHandler = (msg) =>
- switch msg.method
+ switch msg.method
when Authentication.methods.OK
- @once 'ReadyForQuery', (msg) =>
+ @once 'ReadyForQuery', (msg) =>
@removeListener 'ErrorResponse', authenticationFailureHandler
@_initializeConnection()
-
+
when Authentication.methods.CLEARTEXT_PASSWORD, Authentication.methods.MD5_PASSWORD
@_writeMessage(new FrontendMessage.Password(@connectionOptions.password, msg.method, salt: msg.salt, user: @connectionOptions.user))
@once 'Authentication', authenticationHandler
-
+
else
throw new Error("Autentication method #{msg.method} not supported.")
@@ -131,7 +131,7 @@ class Connection extends EventEmitter
@on 'ParameterStatus', (msg) => @parameters[msg.name] = msg.value
@on 'BackendKeyData', (msg) => [@pid, @key] = [msg.pid, msg.key]
- @on 'ReadyForQuery', (msg) =>
+ @on 'ReadyForQuery', (msg) =>
@busy = false
@currentJob = false
@transactionStatus = msg.transactionStatus
@@ -139,7 +139,7 @@ class Connection extends EventEmitter
_initializeConnection: () ->
initializers = []
unless @connectionOptions.skipInitialization
- initializers.push @_initializeInterrupt if @connectionOptions.interruptable
+ initializers.push @_initializeInterrupt if @connectionOptions.interruptible
initializers.push @_initializeRoles if @connectionOptions.role?
initializers.push @_initializeSearchPath if @connectionOptions.searchPath?
initializers.push @_initializeTimezone if @connectionOptions.timezone?
@@ -148,7 +148,7 @@ class Connection extends EventEmitter
chain = @_initializationSuccess.bind(this)
for initializer in initializers
chain = initializer.bind(this, chain, @_initializationFailure.bind(this))
-
+
chain()
@@ -170,7 +170,7 @@ class Connection extends EventEmitter
_initializeInterrupt: (next, fail) ->
@_queryDirect "SELECT session_id FROM v_monitor.current_session", (err, result) =>
- if err? then fail(err)
+ if err? then fail(err)
@sessionID = result.theValue()
next()
@@ -178,10 +178,10 @@ class Connection extends EventEmitter
@on 'ReadyForQuery', @_processJobQueue.bind(this)
@_processJobQueue()
@connectedCallback(null, this) if @connectedCallback
-
+
_initializationFailure: (err) ->
if @connectedCallback then @connectedCallback(err) else @emit 'error', err
-
+
_onData: (buffer) ->
# Append the new data with the previous buffer's residue if there was any.
@@ -210,19 +210,19 @@ class Connection extends EventEmitter
@currentJob.onConnectionError("The connection was closed.") if @currentJob
@connected = false
@emit 'close', error
-
+
_onTimeout: () ->
@currentJob.onConnectionError("The connection timed out closed.") if @currentJob
@emit 'timeout'
-
+
_onError: (exception) ->
@emit 'error', exception
-
+
_writeMessage: (msg, callback) ->
console.log '=>', msg.__proto__.constructor.name, msg if @debug
@connection.write(msg.toBuffer(), null, callback)
- isInterruptable: ->
+ isInterruptible: ->
@sessionID?
_interruptConnection: (cb) ->
@@ -232,13 +232,13 @@ class Connection extends EventEmitter
bareClient = new Connection(bareConnectionOptions)
bareClient.connect(cb)
else
- cb("Cannot intterupt connection! It's not initialized as interruptable.", null)
+ cb("Cannot interrupt connection! It's not initialized as interruptible.", null)
_success: (err, cb) ->
- if err?
+ if err?
if cb? then cb(err) else @emit 'error', new Error(err)
return false
- else
+ else
return true
interruptSession: (cb) ->
@@ -247,7 +247,7 @@ class Connection extends EventEmitter
conn.query "SELECT CLOSE_SESSION('#{@sessionID}')", (err, rs) =>
conn.disconnect()
cb(null, rs.theValue()) if @_success(err, cb) && cb?
-
+
interruptStatement: (cb) ->
@_interruptConnection (err, conn) =>
View
48 src/frontend_message.coffee
@@ -7,13 +7,13 @@ Buffer = require('./buffer').Buffer
class FrontendMessage
typeId: null
-
+
payload: ->
new Buffer(0)
-
+
toBuffer: ->
payloadBuffer = @payload()
- if typeof payloadBuffer == 'string'
+ if typeof payloadBuffer == 'string'
bLength = Buffer.byteLength(payloadBuffer);
b = new Buffer(bLength + 1)
b.writeZeroTerminatedString(payloadBuffer, 0)
@@ -21,25 +21,25 @@ class FrontendMessage
headerLength = if @typeId? then 5 else 4
messageBuffer = new Buffer(headerLength + payloadBuffer.length)
-
+
if @typeId
messageBuffer.writeUInt8(@typeId, 0)
pos = 1
- else
+ else
pos = 0
messageBuffer.writeUInt32(payloadBuffer.length + 4, pos)
payloadBuffer.copy(messageBuffer, pos + 4)
-
+
return messageBuffer
class FrontendMessage.Startup extends FrontendMessage
typeId: null
protocol: 3 << 16
-
+
constructor: (@user, @database, @options) ->
-
+
payload: ->
pos = 0
pl = new Buffer(8192)
@@ -57,25 +57,25 @@ class FrontendMessage.Startup extends FrontendMessage
if @options
pos += pl.writeZeroTerminatedString('options', pos)
pos += pl.writeZeroTerminatedString(@options, pos)
-
+
pl.writeUInt8(0, pos)
pos += 1
return pl.slice(0, pos)
-
-
+
+
class FrontendMessage.SSLRequest extends FrontendMessage
typeId: null
sslMagicNumber: 80877103
-
+
payload: ->
pl = new Buffer(4)
pl.writeUInt32(@sslMagicNumber, 0)
return pl
-
+
class FrontendMessage.Password extends FrontendMessage
typeId: 112
- constructor: (@password, @authMethod, @options) ->
+ constructor: (@password, @authMethod, @options) ->
@password ?= ''
@authMethod ?= Authentication.methods.CLEARTEXT_PASSWORD
@options ?= {}
@@ -86,9 +86,9 @@ class FrontendMessage.Password extends FrontendMessage
hash.digest('hex')
encodedPassword: ->
- switch @authMethod
+ switch @authMethod
when Authentication.methods.CLEARTEXT_PASSWORD then @password
- when Authentication.methods.MD5_PASSWORD then "md5" + @md5(@md5(@password + @options.user) + @options.salt)
+ when Authentication.methods.MD5_PASSWORD then "md5" + @md5(@md5(@password + @options.user) + @options.salt)
else throw new Error("Authentication method #{@authMethod} not implemented.")
payload: ->
@@ -97,9 +97,9 @@ class FrontendMessage.Password extends FrontendMessage
class FrontendMessage.CancelRequest extends FrontendMessage
cancelRequestMagicNumber: 80877102
-
+
constructor: (@backendPid, @backendKey) ->
-
+
payload: ->
b = new Buffer(12)
b.writeUInt32(@cancelRequestMagicNumber, 0)
@@ -147,8 +147,8 @@ class FrontendMessage.Execute extends FrontendMessage
constructor: (@portal, @maxRows) ->
@portal ?= ""
@maxRows ?= 0
-
-
+
+
payload: ->
b = new Buffer(5 + @portal.length)
pos = b.writeZeroTerminatedString(@portal, 0)
@@ -166,7 +166,7 @@ class FrontendMessage.Query extends FrontendMessage
class FrontendMessage.Parse extends FrontendMessage
typeId: 80
-
+
constructor: (@name, @sql, @parameterTypes) ->
@name ?= ""
@parameterTypes ?= []
@@ -225,9 +225,9 @@ class FrontendMessage.Terminate extends FrontendMessage
class FrontendMessage.CopyData extends FrontendMessage
typeId: 100
-
+
constructor: (@data) ->
-
+
payload: ->
new Buffer(@data)
@@ -240,7 +240,7 @@ class FrontendMessage.CopyFail extends FrontendMessage
typeId: 102
constructor: (@error) ->
-
+
payload: ->
@error
View
20 src/query.coffee
@@ -4,7 +4,7 @@ decoders = require('./types').decoders
Resultset = require('./resultset')
class Query extends EventEmitter
-
+
constructor: (@connection, @sql, @callback) ->
@_handlingCopyIn = false
@@ -13,7 +13,7 @@ class Query extends EventEmitter
@emit 'start'
@connection._writeMessage(new FrontendMessage.Query(@sql))
-
+
@connection.once 'EmptyQueryResponse', @onEmptyQueryListener = @onEmptyQuery.bind(this)
@connection.on 'RowDescription', @onRowDescriptionListener = @onRowDescription.bind(this)
@connection.on 'DataRow', @onDataRowListener = @onDataRow.bind(this)
@@ -27,10 +27,10 @@ class Query extends EventEmitter
@error = "The query was empty!"
else
@emit 'error', "The query was empty!"
-
+
onRowDescription: (msg) ->
throw "Cannot handle multi-queries with a callback!" if @callback? && @status?
-
+
@fields = []
for column in msg.columns
field = new Query.Field(column)
@@ -39,15 +39,15 @@ class Query extends EventEmitter
@rows = [] if @callback
@emit 'fields', @fields
-
+
onDataRow: (msg) ->
row = []
for value, index in msg.values
row.push if value? then @fields[index].decoder(value) else null
-
+
@rows.push row if @callback
@emit 'row', row
-
+
onReadyForQuery: (msg) ->
@_removeAllListeners()
if @callback
@@ -63,7 +63,7 @@ class Query extends EventEmitter
onErrorResponse: (msg) ->
if @callback
- @error = msg
+ @error = msg
else
@emit 'error', msg.message
@@ -79,10 +79,10 @@ class Query extends EventEmitter
dataHandler = (data) => @copyData(data)
successHandler = () => @copyDone()
failureHandler = (err) => @copyFail(err)
-
+
copyInHandler = @_getCopyInHandler()
copyInHandler(dataHandler, successHandler, failureHandler)
-
+
_getCopyInHandler: ->
if typeof @copyInSource == 'function'
return @copyInSource
View
2  src/quoting.coffee
@@ -18,7 +18,7 @@ exports.quote = (val) ->
(exports.quote(v) for v in val).join(', ')
else if val instanceof Date
"'#{val.toISOString().replace(/T/, ' ').replace(/\.\d+Z$/, '')}'::timestamp"
- else
+ else
"'#{exports.escape(val)}'"
exports.quoteIdentifier = (val) ->
View
2  src/resultset.coffee
@@ -5,7 +5,7 @@ class Resultset
@rows = object.rows || []
@notices = object.notices || []
@status = object.status
-
+
theValue: ->
@rows[0][0]
View
4 src/starttls.coffee
@@ -29,9 +29,9 @@ pipe = (pair, socket) =>
cleartext.encrypted = pair.encrypted
cleartext.authorized = false
- onError = (e) ->
+ onError = (e) ->
cleartext.emit('error', e) if (cleartext._controlReleased)
-
+
onClose = ->
socket.removeListener('error', onError)
socket.removeListener('close', onClose)
View
8 test/connection_test.coffee
@@ -14,10 +14,10 @@ else
connect = (info, callback) ->
for key, value of baseConnectionInfo
info[key] ?= value
-
+
connection = Vertica.connect info, (err) -> callback(err, connection)
undefined
-
+
vow = vows.describe('Query')
@@ -52,8 +52,8 @@ else
assert.ok !conn.isSSL()
"it should be able to interrupt the session":
- topic: ->
- connect interruptable: true, (err, conn) =>
+ topic: ->
+ connect interruptible: true, (err, conn) =>
@callback(err) if err?
conn.query "SELECT sleep(10)", @callback
setTimeout conn.interruptSession.bind(conn), 100
Please sign in to comment.
Something went wrong with that request. Please try again.