@Test public void testPreparedStatementParams() throws Exception { TestUtils.assertMemoryLeak(() -> { final CountDownLatch haltLatch = new CountDownLatch(1); final AtomicBoolean running = new AtomicBoolean(true); try { startBasicServer( NetworkFacadeImpl.INSTANCE, new DefaultPGWireConfiguration(), haltLatch, running ); Properties properties = new Properties(); properties.setProperty("user", "admin"); properties.setProperty("password", "quest"); properties.setProperty("sslmode", "disable"); TimeZone.setDefault(TimeZone.getTimeZone("EDT")); final Connection connection = DriverManager.getConnection("jdbc:postgresql: PreparedStatement statement = connection.prepareStatement("select x,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? from long_sequence(5)"); statement.setInt(1, 4); statement.setLong(2, 123L); statement.setFloat(3, 5.43f); statement.setDouble(4, 0.56789); statement.setByte(5, (byte) 91); statement.setBoolean(6, true); statement.setString(7, "hello"); statement.setString(8, "группа туристов"); statement.setDate(9, new Date(100L)); statement.setTimestamp(10, new Timestamp(20000000033L)); statement.setNull(11, Types.INTEGER); statement.setNull(12, Types.BIGINT); statement.setNull(13, Types.REAL); statement.setNull(14, Types.DOUBLE); statement.setNull(15, Types.SMALLINT); statement.setNull(16, Types.BOOLEAN); statement.setNull(17, Types.VARCHAR); statement.setString(18, null); statement.setNull(19, Types.DATE); statement.setNull(20, Types.TIMESTAMP); statement.setTimestamp(21, new PGTimestamp(300011)); statement.setTimestamp(22, new PGTimestamp(500023, new GregorianCalendar())); final String expected = "x[BIGINT],$1[INTEGER],$2[BIGINT],$3[REAL],$4[DOUBLE],$5[SMALLINT],$6[BIT],$7[VARCHAR],$8[VARCHAR],$9[TIMESTAMP],$10[TIMESTAMP],$11[INTEGER],$12[BIGINT],$13[REAL],$14[DOUBLE],$15[SMALLINT],$16[BIT],$17[VARCHAR],$18[VARCHAR],$19[TIMESTAMP],$20[TIMESTAMP],$21[TIMESTAMP],$22[TIMESTAMP]\n" + "1,4,123,5.4299,0.56789,91,true,hello,группа туристов,1970-01-01 00:00:00.0,1970-08-20 11:33:20.033,null,null,null,null,0,false,null,null,null,null,1970-01-01 00:05:00.011,1970-01-01 00:08:20.023\n" + "2,4,123,5.4299,0.56789,91,true,hello,группа туристов,1970-01-01 00:00:00.0,1970-08-20 11:33:20.033,null,null,null,null,0,false,null,null,null,null,1970-01-01 00:05:00.011,1970-01-01 00:08:20.023\n" + "3,4,123,5.4299,0.56789,91,true,hello,группа туристов,1970-01-01 00:00:00.0,1970-08-20 11:33:20.033,null,null,null,null,0,false,null,null,null,null,1970-01-01 00:05:00.011,1970-01-01 00:08:20.023\n" + "4,4,123,5.4299,0.56789,91,true,hello,группа туристов,1970-01-01 00:00:00.0,1970-08-20 11:33:20.033,null,null,null,null,0,false,null,null,null,null,1970-01-01 00:05:00.011,1970-01-01 00:08:20.023\n" + "5,4,123,5.4299,0.56789,91,true,hello,группа туристов,1970-01-01 00:00:00.0,1970-08-20 11:33:20.033,null,null,null,null,0,false,null,null,null,null,1970-01-01 00:05:00.011,1970-01-01 00:08:20.023\n"; StringSink sink = new StringSink(); for (int i = 0; i < 10; i++) { sink.clear(); ResultSet rs = statement.executeQuery(); assertResultSet(expected, sink, rs); rs.close(); } connection.close(); } finally { running.set(false); haltLatch.await(); } }); }
@Override public void close() { Misc.free(compiler); }
PGJobContext implements Closeable { @Override public void close() { Misc.free(compiler); } }
PGJobContext implements Closeable { @Override public void close() { Misc.free(compiler); } PGJobContext(PGWireConfiguration configuration, CairoEngine engine, MessageBus messageBus, FunctionFactoryCache functionFactoryCache); }
PGJobContext implements Closeable { @Override public void close() { Misc.free(compiler); } PGJobContext(PGWireConfiguration configuration, CairoEngine engine, MessageBus messageBus, FunctionFactoryCache functionFactoryCache); @Override void close(); void handleClientOperation(PGConnectionContext context); }
PGJobContext implements Closeable { @Override public void close() { Misc.free(compiler); } PGJobContext(PGWireConfiguration configuration, CairoEngine engine, MessageBus messageBus, FunctionFactoryCache functionFactoryCache); @Override void close(); void handleClientOperation(PGConnectionContext context); static final int PG_VARCHAR; static final int PG_TIMESTAMP; static final int PG_TIMESTAMPZ; static final int PG_FLOAT8; static final int PG_FLOAT4; static final int PG_INT4; static final int PG_INT2; static final int PG_INT8; static final int PG_NUMERIC; static final int PG_BOOL; static final int PG_CHAR; static final int PG_DATE; static final int PG_BYTEA; static final int PG_UNSPECIFIED; }