Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 1f20a846
authored
Sep 01, 2010
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
latest nodejs-mysql-native version
1 parent
5498e7ee
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
7 deletions
lib/nodejs-mysql-native/client.js
lib/nodejs-mysql-native/commands.js
lib/nodejs-mysql-native/constants.js
lib/nodejs-mysql-native/index.js
lib/nodejs-mysql-native/serializers.js
lib/nodejs-mysql-native/client.js
View file @
1f20a84
...
@@ -16,9 +16,9 @@
...
@@ -16,9 +16,9 @@
exports
.
createTCPClient
=
function
(
host
,
port
)
exports
.
createTCPClient
=
function
(
host
,
port
)
{
{
var
host
=
host
?
host
:
"locahost"
;
var
host
=
host
?
host
:
"loca
l
host"
;
var
port
=
port
?
port
:
3306
;
var
port
=
port
?
port
:
3306
;
var
connection
=
net
.
createConnection
(
3306
,
"localhost"
);
var
connection
=
net
.
createConnection
(
port
,
host
);
connection
.
pscache
=
{};
connection
.
pscache
=
{};
connection
.
setEncoding
(
"binary"
);
connection
.
setEncoding
(
"binary"
);
connection
.
setTimeout
(
0
);
connection
.
setTimeout
(
0
);
...
@@ -26,6 +26,17 @@
...
@@ -26,6 +26,17 @@
return
new
socketClient
(
connection
);
return
new
socketClient
(
connection
);
}
}
exports
.
createUNIXClient
=
function
(
path
)
{
var
path
=
path
?
path
:
"/var/run/mysqld/mysqld.sock"
;
var
connection
=
net
.
createConnection
(
path
);
connection
.
pscache
=
{};
connection
.
setEncoding
(
"binary"
);
connection
.
setTimeout
(
0
);
return
new
socketClient
(
connection
);
}
function
dump
(
d
)
function
dump
(
d
)
{
{
return
;
return
;
...
@@ -121,7 +132,7 @@ function dump(d)
...
@@ -121,7 +132,7 @@ function dump(d)
}
}
// proxy request to socket eventemitter
// proxy request to socket eventemitter
this
.
addListener
=
function
()
this
.
on
=
this
.
addListener
=
function
()
{
{
this
.
connection
.
addListener
.
apply
(
this
.
connection
,
arguments
);
this
.
connection
.
addListener
.
apply
(
this
.
connection
,
arguments
);
}
}
...
...
lib/nodejs-mysql-native/commands.js
View file @
1f20a84
...
@@ -174,8 +174,6 @@ function auth(db, user, password)
...
@@ -174,8 +174,6 @@ function auth(db, user, password)
{
{
if
(
!
user
)
if
(
!
user
)
user
=
''
;
user
=
''
;
if
(
!
password
)
password
=
''
;
var
c
=
new
cmd
(
var
c
=
new
cmd
(
{
{
...
@@ -193,7 +191,7 @@ function auth(db, user, password)
...
@@ -193,7 +191,7 @@ function auth(db, user, password)
r
.
bytes
(
12
);
r
.
bytes
(
12
);
salt
+=
r
.
bytes
(
12
);
salt
+=
r
.
bytes
(
12
);
var
token
=
scramble
(
password
,
salt
)
;
var
token
=
password
!==
""
?
scramble
(
password
,
salt
)
:
""
;
var
reply
=
new
writer
();
var
reply
=
new
writer
();
var
client_flags
=
flags
.
CLIENT_BASIC_FLAGS
;
var
client_flags
=
flags
.
CLIENT_BASIC_FLAGS
;
reply
.
add
(
client_flags
);
reply
.
add
(
client_flags
);
...
...
lib/nodejs-mysql-native/constants.js
View file @
1f20a84
...
@@ -36,7 +36,6 @@ exports.flags.CLIENT_BASIC_FLAGS = flags.CLIENT_LONG_PASSWORD |
...
@@ -36,7 +36,6 @@ exports.flags.CLIENT_BASIC_FLAGS = flags.CLIENT_LONG_PASSWORD |
flags
.
CLIENT_FOUND_ROWS
|
flags
.
CLIENT_FOUND_ROWS
|
flags
.
CLIENT_LONG_FLAG
|
flags
.
CLIENT_LONG_FLAG
|
flags
.
CLIENT_CONNECT_WITH_DB
|
flags
.
CLIENT_CONNECT_WITH_DB
|
flags
.
CLIENT_NO_SCHEMA
|
flags
.
CLIENT_ODBC
|
flags
.
CLIENT_ODBC
|
flags
.
CLIENT_LOCAL_FILES
|
flags
.
CLIENT_LOCAL_FILES
|
flags
.
CLIENT_IGNORE_SPACE
|
flags
.
CLIENT_IGNORE_SPACE
|
...
...
lib/nodejs-mysql-native/index.js
0 → 100644
View file @
1f20a84
var
client
=
require
(
'./client'
);
var
pool
=
require
(
'./pool'
);
exports
.
createClient
=
client
.
createClient
;
exports
.
createTCPClient
=
client
.
createTCPClient
;
exports
.
createUNIXClient
=
client
.
createUNIXClient
;
exports
.
pool
=
pool
.
pool
;
lib/nodejs-mysql-native/serializers.js
View file @
1f20a84
...
@@ -97,6 +97,14 @@ function reader(data)
...
@@ -97,6 +97,14 @@ function reader(data)
}
}
reader
.
prototype
.
dump
=
function
()
{
for
(
var
i
=
this
.
pos
;
i
<
this
.
data
.
length
;
++
i
)
{
sys
.
puts
(
this
.
data
.
charCodeAt
(
i
));
}
}
// libmysql sets all fields to zero when binary packet has zero length
// libmysql sets all fields to zero when binary packet has zero length
function
zeroTime
()
function
zeroTime
()
{
{
...
@@ -171,6 +179,27 @@ reader.prototype.unpackBinaryDate = function()
...
@@ -171,6 +179,27 @@ reader.prototype.unpackBinaryDate = function()
return
dt
;
return
dt
;
}
}
function
parseIEEE754Double
(
data
)
{
var
fraction
=
0.0
;
fraction
+=
data
.
charCodeAt
(
2
)
/
(
16
*
256
*
256
*
256
*
256
*
256
*
256
);
fraction
+=
data
.
charCodeAt
(
3
)
/
(
16
*
256
*
256
*
256
*
256
*
256
);
fraction
+=
data
.
charCodeAt
(
4
)
/
(
16
*
256
*
256
*
256
*
256
);
fraction
+=
data
.
charCodeAt
(
5
)
/
(
16
*
256
*
256
*
256
);
fraction
+=
data
.
charCodeAt
(
6
)
/
(
16
*
256
*
256
);
fraction
+=
data
.
charCodeAt
(
7
)
/
(
16
*
256
);
fraction
+=
(
data
.
charCodeAt
(
8
)
&
0x0f
)
/
16.0
;
var
signbit
=
data
.
charCodeAt
(
9
)
&
128
;
var
exponent
=
((
data
.
charCodeAt
(
8
)
&
0xf0
)
>>
4
)
+
((
data
.
charCodeAt
(
9
)
&
127
)
<<
4
);
var
factor
=
Math
.
pow
(
2
,
exponent
-
1023
);
var
mantissa
=
1.0
+
fraction
;
var
sign
=
signbit
>
0
?
-
1
:
1
;
return
sign
*
factor
*
mantissa
;
}
// deserialise mysql binary field
// deserialise mysql binary field
reader
.
prototype
.
unpackBinary
=
function
(
type
,
unsigned
)
reader
.
prototype
.
unpackBinary
=
function
(
type
,
unsigned
)
{
{
...
@@ -194,6 +223,9 @@ reader.prototype.unpackBinary = function(type, unsigned)
...
@@ -194,6 +223,9 @@ reader.prototype.unpackBinary = function(type, unsigned)
case
constants
.
types
.
MYSQL_TYPE_NEWDECIMAL
:
case
constants
.
types
.
MYSQL_TYPE_NEWDECIMAL
:
result
=
parseFloat
(
this
.
lcstring
());
result
=
parseFloat
(
this
.
lcstring
());
break
;
break
;
case
constants
.
types
.
MYSQL_TYPE_DOUBLE
:
result
=
parseIEEE754Double
(
this
.
data
);
break
;
/*
/*
MYSQL_TYPE_TIMESTAMP: 7,
MYSQL_TYPE_TIMESTAMP: 7,
MYSQL_TYPE_LONGLONG: 8,
MYSQL_TYPE_LONGLONG: 8,
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment