Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql select timestamptz type column raise exception Invalid format #122

Open
manorsuperman opened this issue Aug 17, 2018 · 4 comments
Open

Comments

@manorsuperman
Copy link

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)

@codepitbull
Copy link

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
Copy link

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

@codepitbull
Copy link

I see you already filed an issue there:
mauricio/postgresql-async#240

@codepitbull
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants