8000 Do not check for handshake if we are already running queries - fixes #80 · IGOpen/postgresql-async@37c85b6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 37c85b6

Browse files
committed
Do not check for handshake if we are already running queries - fixes mauricio#80
1 parent 79c2729 commit 37c85b6

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

mysql-async/src/main/scala/com/github/mauricio/async/db/mysql/codec/MySQLFrameDecoder.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,15 @@ class MySQLFrameDecoder(charset: Charset, connectionId : String) extends ByteToM
7777
val slice = buffer.readSlice(size)
7878

7979
if ( log.isTraceEnabled ) {
80-
log.trace(s"Reading message is $messageType - " +
80+
log.trace(s"Reading message type $messageType - " +
8181
s"(count=$messagesCount,size=$size,isInQuery=$isInQuery,processingColumns=$processingColumns,processingParams=$processingParams,processedColumns=$processedColumns,processedParams=$processedParams)" +
82-
s"\n${BufferDumper.dumpAsHex(buffer)}}")
82+
s"\n${BufferDumper.dumpAsHex(slice)}}")
8383
}
8484

8585
slice.readByte()
8686

8787
val decoder = messageType match {
88-
case ServerMessage.ServerProtocolVersion => this.handshakeDecoder
88+
case ServerMessage.ServerProtocolVersion if !isInQuery => this.handshakeDecoder
8989
case ServerMessage.Error => {
9090
this.clear
9191
this.errorDecoder

mysql-async/src/test/scala/com/github/mauricio/async/db/mysql/QuerySpec.scala

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,46 @@ class QuerySpec extends Specification with ConnectionHelper {
223223

224224
}
225225

226+
"select from another empty table with many columns" in {
227+
withConnection {
228+
connection =>
229+
val create = """create temporary table test_11 (
230+
| id int primary key not null,
231+
| c2 text not null, c3 text not null, c4 text not null,
232+
| c5 text not null, c6 text not null, c7 text not null,
233+
| c8 text not null, c9 text not null, c10 text not null,
234+
| c11 text not null
235+
|) ENGINE=InnoDB DEFAULT CHARSET=utf8;""".stripMargin
236+
237+
executeQuery(connection, create)
238+
239+
val result = executeQuery(connection, "select * from test_11")
240+
241+
result.rows.get.size === 0
242+
}
243+
}
244+
245+
"select from an empty table with many columns" in {
246+
247+
withConnection {
248+
connection =>
249+
250+
val create = """create temporary table test_10 (
251+
| id int primary key not null,
252+
| c2 text not null, c3 text not null, c4 text not null,
253+
| c5 text not null, c6 text not null, c7 text not null,
254+
| c8 text not null, c9 text not null, c10 text not null
255+
|) ENGINE=InnoDB DEFAULT CHARSET=utf8;""".stripMargin
256+
257+
executeQuery(connection, create)
258+
259+
val result = executeQuery(connection, "select * from test_10")
260+
261+
result.rows.get.size === 0
262+
}
263+
264+
}
265+
226266
}
227267

228268
}

0 commit comments

Comments
 (0)
0