vertx-mysql-postgresql-client icon indicating copy to clipboard operation
vertx-mysql-postgresql-client copied to clipboard

sql select timestamptz type column raise exception Invalid format

Open manorsuperman opened this issue 6 years ago • 4 comments

when I use

 		<dependency>
			<groupId>io.vertx</groupId>
			<artifactId>vertx-mysql-postgresql-client</artifactId>
			<version>3.5.3</version>
		</dependency>

The following code throws an exception, which cannot be resolved with the timestamptz time data. I find that when SQL SELECT is used directly for a timestamptz data, it throws back this exception. In addition, I also found that timestamptz can return normally in the cursor.

m_postgreClient = (SQLClient) PostgreSQLClient.createShared(vertx, postgreConfig, "test-pool");
m_postgreClient.getConnection(rcon -> {
		if (rcon.succeeded()) {
			SQLConnection conn = rcon.result();
			conn.query("select alarm_create_date from alarm_event limit 1", 
					ar->{
						if (ar.succeeded()) {
							System.out.println(ar.result().getRows().get(0).toString());
						} else {
							ar.cause().printStackTrace();
						}
					});
});

java.lang.IllegalArgumentException: Invalid format: "2018-08-15 18:26:36+08" is malformed at "+08" at org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:945) at com.github.mauricio.async.db.postgresql.column.PostgreSQLTimestampEncoderDecoder$.decode(PostgreSQLTimestampEncoderDecoder.scala:71) at com.github.mauricio.async.db.postgresql.column.PostgreSQLColumnDecoderRegistry.decode(PostgreSQLColumnDecoderRegistry.scala:52) at com.github.mauricio.async.db.postgresql.PostgreSQLConnection.onDataRow(PostgreSQLConnection.scala:203) at com.github.mauricio.async.db.postgresql.codec.PostgreSQLConnectionHandler.channelRead0(PostgreSQLConnectionHandler.scala:203) at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:297) at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:413) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:265) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1359) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:935) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:141) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459) at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:844)

manorsuperman avatar Aug 17 '18 02:08 manorsuperman

I was able to reproduce your problem, The currentparser doesn't support timezones as they are used by PostgreSQL (that's the +08 at the end) but it should according to the docs: https://www.postgresql.org/docs/9.1/static/datatype-datetime.html

I will take a look.

codepitbull avatar Aug 18 '18 21:08 codepitbull

Oh crap, It's actually a bug with the underlying driver. I will have to file an issue there to get this resolved.

codepitbull avatar Aug 18 '18 21:08 codepitbull

I see you already filed an issue there: https://github.com/mauricio/postgresql-async/issues/240

codepitbull avatar Aug 18 '18 21:08 codepitbull

Fixed it in the driver: https://github.com/mauricio/postgresql-async/pull/255 We can integrate the fix in vertx as soons as the PR is merged and a new version is available.

codepitbull avatar Aug 18 '18 22:08 codepitbull