@@ -18,6 +18,7 @@ var Query = function(config, values, callback) {
18
18
19
19
config = utils . normalizeQueryConfig ( config , values , callback ) ;
20
20
21
+ this . multiResult = config . multiResult ;
21
22
this . text = config . text ;
22
23
this . values = config . values ;
23
24
this . rows = config . rows ;
@@ -31,7 +32,10 @@ var Query = function(config, values, callback) {
31
32
if ( process . domain && config . callback ) {
32
33
this . callback = process . domain . bind ( config . callback ) ;
33
34
}
34
- this . _result = new Result ( config . rowMode , config . types ) ;
35
+ this . rowMode = config . rowMode ;
36
+ // the active result in muti result mode
37
+ this . _result = new Result ( this . rowMode ) ;
38
+ this . _resultsArray = [ ] ;
35
39
this . isPreparedStatement = false ;
36
40
this . _canceledDueToError = false ;
37
41
this . _promise = null ;
@@ -95,6 +99,11 @@ Query.prototype.handleCommandComplete = function(msg, con) {
95
99
if ( this . isPreparedStatement ) {
96
100
con . sync ( ) ;
97
101
}
102
+ // new result for next query
103
+ if ( this . multiResult ) {
104
+ this . _resultsArray . push ( this . _result ) ;
105
+ this . _result = new Result ( this . rowMode ) ;
106
+ }
98
107
} ;
99
108
100
109
//if a named prepared statement is created with empty query text
@@ -111,7 +120,7 @@ Query.prototype.handleReadyForQuery = function() {
111
120
return this . handleError ( this . _canceledDueToError ) ;
112
121
}
113
122
if ( this . callback ) {
114
- this . callback ( null , this . _result ) ;
123
+ this . callback ( null , this . multiResult ? this . _resultsArray : this . _result ) ;
115
124
}
116
125
this . emit ( 'end' , this . _result ) ;
117
126
} ;
0 commit comments