private void initSqlType(Field field) throws SQLException { if (field.isTypeInitialized()) { return; } TypeInfo typeInfo = connection.getTypeInfo(); int oid = field.getOID(); String pgType = typeInfo.getPGType(oid); int sqlType = typeInfo.getSQLType(pgType); field.setSQLType(sqlType); field.setPGType(pgType); }
@Override public boolean equals(Object obj) { if (obj instanceof Version) { return this.getVersionNum() == ((Version) obj).getVersionNum(); } return false; }
@Override public PGReplicationStream start(LogicalReplicationOptions options) throws SQLException { ReplicationProtocol protocol = baseConnection.getReplicationProtocol(); return protocol.startLogical(options); } });
/** * Receives a null-terminated string from the backend. If we don't see a null, then we assume * something has gone wrong. * * @return string from back end * @throws IOException if an I/O error occurs, or end of file */ public String receiveString() throws IOException { int len = pg_input.scanCStringLength(); String res = encoding.decode(pg_input.getBuffer(), pg_input.getIndex(), len - 1); pg_input.skip(len); return res; }
public int getScale(int column) throws SQLException { Field field = getField(column); return connection.getTypeInfo().getScale(field.getOID(), field.getMod()); }
private void sendSync() throws IOException { if (logger.logDebug()) logger.debug(" FE=> Sync"); pgStream.SendChar('S'); // Sync pgStream.SendInteger4(4); // Length pgStream.flush(); }
protected int getSQLType( int column ) throws SQLException { return connection.getTypeInfo().getSQLType(fields[column - 1].getOID()); }
private String receiveCommandStatus() throws IOException { //TODO: better handle the msg len int l_len = pgStream.ReceiveInteger4(); //read l_len -5 bytes (-4 for l_len and -1 for trailing \0) String status = pgStream.ReceiveString(l_len - 5); //now read and discard the trailing \0 pgStream.Receive(1); if (logger.logDebug()) logger.debug(" <=BE CommandStatus(" + status + ")"); return status; }
protected String getPGType( int column ) throws SQLException { return connection.getTypeInfo().getPGType(fields[column - 1].getOID()); }
public void setNull(int parameterIndex, int t, String typeName) throws SQLException { if (typeName == null) { setNull(parameterIndex, t); return; } checkClosed(); TypeInfo typeInfo = connection.getTypeInfo(); int oid = typeInfo.getPGType(typeName); preparedParameters.setNull(parameterIndex, oid); }
private boolean isMaster(QueryExecutor queryExecutor) throws SQLException, IOException { byte[][] results = SetupQueryRunner.run(queryExecutor, "show transaction_read_only", true); String value = queryExecutor.getEncoding().decode(results[0]); return value.equalsIgnoreCase("off"); } }
/** * * @return the default scale of the type */ public int getDefaultScale() { if (typeInfo == null) { return TypeRegistry.UNKNOWN_LENGTH; } return typeInfo.getScale(oid, TypeRegistry.NO_TYPE_MODIFIER); }
@Override public void handleResultRows(Query fromQuery, Field[] fields, List<byte[][]> tuples, ResultCursor cursor) { if (delegate != null) { delegate.handleResultRows(fromQuery, fields, tuples, cursor); } }
@Override public void handleWarning(SQLWarning warning) { if (delegate != null) { delegate.handleWarning(warning); } }
@Override public void handleError(SQLException error) { if (delegate != null) { delegate.handleError(error); } }
@Override public PGReplicationStream start(PhysicalReplicationOptions options) throws SQLException { ReplicationProtocol protocol = baseConnection.getReplicationProtocol(); return protocol.startPhysical(options); } });
@Override public CachedQuery createQuery(String sql, boolean escapeProcessing, boolean isParameterized, String... columnNames) throws SQLException { return queryExecutor.createQuery(sql, escapeProcessing, isParameterized, columnNames); }
@Override public void secureProgress() { if (delegate != null) { delegate.secureProgress(); } }
@Override public SQLWarning getWarning() { if (delegate != null) { return delegate.getWarning(); } return null; } }
public int getScale(int column) throws SQLException { Field field = getField(column); return connection.getTypeInfo().getScale(field.getOID(), field.getMod()); }