public IRubyObject get_copy_data(ThreadContext context, IRubyObject[] args) {
try {
boolean async = false;
if (args.length == 1)
async = args[0].isTrue();
CopyData data = postgresqlConnection.getCopyData(async);
if (data == PostgresqlConnection.COPY_DATA_NOT_READY)
return context.runtime.getFalse();
else if (data == null)
return context.nil;
ByteBuffer value = data.getValue();
return context.runtime.newString(new ByteList(value.array(), value.arrayOffset() + value.position(), value.remaining()));
} catch (IOException e) {
throw newPgError(context, e.getLocalizedMessage(), null, getClientEncodingAsJavaEncoding(context));
}
}