## v1.5.5 [2024-02-15] Lars Kanis - Explicitly retype timespec fields to int64_t to fix compatibility with 32bit arches. [#547](https://github.com/ged/ruby-pg/pull/547) - Fix possible buffer overflows in PG::BinaryDecoder::CopyRow on 32 bit systems. [#548](https://github.com/ged/ruby-pg/pull/548) - Add binary Windows gems for Ruby 3.3. - Update Windows fat binary gem to OpenSSL-3.2.1 and PostgreSQL-16.2. ## v1.5.4 [2023-09-01] Lars Kanis - Fix compiling the pg extension with MSVC 2022. [#535](https://github.com/ged/ruby-pg/pull/535) - Set PG::Connection's encoding even if setting client_encoding on connection startup fails. [#541](https://github.com/ged/ruby-pg/pull/541) - Don't set the server's client_encoding if it's unnecessary. [#542](https://github.com/ged/ruby-pg/pull/542) This is important for connection proxies, who disallow configuration settings. - Update Windows fat binary gem to OpenSSL-3.1.2 and PostgreSQL-15.4. ## v1.5.3 [2023-04-28] Lars Kanis - Fix possible segfault when creating a new PG::Result with type map. [#530](https://github.com/ged/ruby-pg/pull/530) - Add category to deprecation warnings of Coder.new, so that they are suppressed for most users. [#528](https://github.com/ged/ruby-pg/pull/528) ## v1.5.2 [2023-04-26] Lars Kanis - Fix regression in copy_data regarding binary format when using no coder. [#527](https://github.com/ged/ruby-pg/pull/527) ## v1.5.1 [2023-04-24] Lars Kanis - Don't overwrite flags of timestamp coders. [#524](https://github.com/ged/ruby-pg/pull/524) Fixes a regression in rails: https://github.com/rails/rails/issues/48049 ## v1.5.0 [2023-04-24] Lars Kanis Enhancements: - Better support for binary format: - Extend PG::Connection#copy_data to better support binary transfers [#511](https://github.com/ged/ruby-pg/pull/511) - Add binary COPY encoder and decoder: * PG::BinaryEncoder::CopyRow * PG::BinaryDecoder::CopyRow - Add binary timestamp encoders: * PG::BinaryEncoder::TimestampUtc * PG::BinaryEncoder::TimestampLocal * PG::BinaryEncoder::Timestamp - Add PG::BinaryEncoder::Float4 and Float8 - Add binary date type: [#515](https://github.com/ged/ruby-pg/pull/515) * PG::BinaryEncoder::Date * PG::BinaryDecoder::Date - Add PG::Result#binary_tuples [#511](https://github.com/ged/ruby-pg/pull/511) It is useful for COPY and not deprecated in that context. - Add PG::TextEncoder::Bytea to BasicTypeRegistry [#506](https://github.com/ged/ruby-pg/pull/506) - Ractor support: [#519](https://github.com/ged/ruby-pg/pull/519) - Pg is now fully compatible with Ractor introduced in Ruby-3.0 and doesn't use any global mutable state. - All type en/decoders and type maps are shareable between ractors if they are made frozen by `Ractor.make_shareable`. - Also frozen PG::Result and PG::Tuple objects can be shared. - All frozen objects (except PG::Connection) can still be used to do communication with the PostgreSQL server or to read retrieved data. - PG::Connection is not shareable and must be created within each Ractor to establish a dedicated connection. - Use keyword arguments instead of hashes for Coder initialization and #to_h. [#511](https://github.com/ged/ruby-pg/pull/511) - Add PG::Result.res_status as a class method and extend Result#res_status to return the status of self. [#508](https://github.com/ged/ruby-pg/pull/508) - Reduce the number of files loaded at `require 'pg'` by using autoload. [#513](https://github.com/ged/ruby-pg/pull/513) Previously stdlib libraries `date`, `json`, `ipaddr` and `bigdecimal` were static dependencies, but now only `socket` is mandatory. - Improve garbage collector performance by adding write barriers to all PG classes. [#518](https://github.com/ged/ruby-pg/pull/518) Now they can be promoted to the old generation, which means they only get marked on major GC. - New method PG::Connection#check_socket to check the socket state. [#521](https://github.com/ged/ruby-pg/pull/521) - Mark many internal constants as private. [#522](https://github.com/ged/ruby-pg/pull/522) - Update Windows fat binary gem to OpenSSL-3.1.0. Bugfixes: - Move nfields-check of stream-methods after result status check [#507](https://github.com/ged/ruby-pg/pull/507) This ensures that the nfield-check doesn't hide errors like statement timeout. Removed: - Remove deprecated PG::BasicTypeRegistry.register_type and co. [Part of #519](https://github.com/ged/ruby-pg/commit/2919ee1a0c6b216e18e1d06c95c2616ef69d2f97) - Add deprecation warning about PG::Coder initialization per Hash argument. [#514](https://github.com/ged/ruby-pg/pull/514) It is recommended to use keyword arguments instead. - The internal encoding cache was removed. [#516](https://github.com/ged/ruby-pg/pull/516) It shouldn't have a practical performance impact. Repository: - `rake test` tries to find PostgreSQL server commands by pg_config [#503](https://github.com/ged/ruby-pg/pull/503) So there's no need to set the PATH manuelly any longer. ## v1.4.6 [2023-02-26] Lars Kanis - Add japanese README file. [#502](https://github.com/ged/ruby-pg/pull/502) - Improve `discard_results` to not block under memory pressure. [#500](https://github.com/ged/ruby-pg/pull/500) - Use a dedicated error class `PG::LostCopyState` for errors due to another query within `copy_data` and mention that it's probably due to another query. Previously the "no COPY in progress" `PG::Error` was less specific. [#499](https://github.com/ged/ruby-pg/pull/499) - Make sure an error in `put_copy_end` of `copy_data` doesn't lose the original exception. - Disable nonblocking mode while large object calls. [#498](https://github.com/ged/ruby-pg/pull/498) Since pg-1.3.0 libpq's "lo_*" calls failed when a bigger amount of data was transferred. This specifically forced the `active_storage-postgresql` gem to use pg-1.2.3. - Add rdoc options to gemspec, so that "gem install" generates complete offline documentation. - Add binary Windows gems for Ruby 3.2. - Update Windows fat binary gem to PostgreSQL-15.2 and OpenSSL-3.0.8. ## v1.4.5 [2022-11-17] Lars Kanis - Return the libpq default port when blank in conninfo. [#492](https://github.com/ged/ruby-pg/pull/492) - Add PG::DEF_PGPORT constant and use it in specs. [#492](https://github.com/ged/ruby-pg/pull/492) - Fix name resolution when empty or `nil` port is given. - Update error codes to PostgreSQL-15. - Update Windows fat binary gem to PostgreSQL-15.1 AND OpenSSL-1.1.1s. ## v1.4.4 [2022-10-11] Lars Kanis - Revert to let libpq do the host iteration while connecting. [#485](https://github.com/ged/ruby-pg/pull/485) Ensure that parameter `connect_timeout` is still respected. - Handle multiple hosts in the connection string, where only one host has writable session. [#476](https://github.com/ged/ruby-pg/pull/476) - Add some useful information to PG::Connection#inspect. [#487](https://github.com/ged/ruby-pg/pull/487) - Support new pgresult_stream_any API in sequel_pg-1.17.0. [#481](https://github.com/ged/ruby-pg/pull/481) - Update Windows fat binary gem to PostgreSQL-14.5. ## v1.4.3 [2022-08-09] Lars Kanis - Avoid memory bloat possible in put_copy_data in pg-1.4.0 to 1.4.2. [#473](https://github.com/ged/ruby-pg/pull/473) - Use Encoding::BINARY for JOHAB, removing some useless code. [#472](https://github.com/ged/ruby-pg/pull/472) ## v1.4.2 [2022-07-27] Lars Kanis Bugfixes: - Properly handle empty host parameter when connecting. [#471](https://github.com/ged/ruby-pg/pull/471) - Update Windows fat binary gem to OpenSSL-1.1.1q. ## v1.4.1 [2022-06-24] Lars Kanis Bugfixes: - Fix another ruby-2.7 keyword warning. [#465](https://github.com/ged/ruby-pg/pull/465) - Allow PG::Error to be created without arguments. [#466](https://github.com/ged/ruby-pg/pull/466) ## v1.4.0 [2022-06-20] Lars Kanis Added: - Add PG::Connection#hostaddr, present since PostgreSQL-12. [#453](https://github.com/ged/ruby-pg/pull/453) - Add PG::Connection.conninfo_parse to wrap PQconninfoParse. [#453](https://github.com/ged/ruby-pg/pull/453) Bugfixes: - Try IPv6 and IPv4 addresses, if DNS resolves to both. [#452](https://github.com/ged/ruby-pg/pull/452) - Re-add block-call semantics to PG::Connection.new accidently removed in pg-1.3.0. [#454](https://github.com/ged/ruby-pg/pull/454) - Handle client error after all data consumed in #copy_data for output. [#455](https://github.com/ged/ruby-pg/pull/455) - Avoid spurious keyword argument warning on Ruby 2.7. [#456](https://github.com/ged/ruby-pg/pull/456) - Change connection setup to respect connect_timeout parameter. [#459](https://github.com/ged/ruby-pg/pull/459) - Fix indefinite hang in case of connection error on Windows [#458](https://github.com/ged/ruby-pg/pull/458) - Set connection attribute of PG::Error in various places where it was missing. [#461](https://github.com/ged/ruby-pg/pull/461) - Fix transaction leak on early break/return. [#463](https://github.com/ged/ruby-pg/pull/463) - Update Windows fat binary gem to OpenSSL-1.1.1o and PostgreSQL-14.4. Enhancements: - Don't flush at each put_copy_data call, but flush at get_result. [#462](https://github.com/ged/ruby-pg/pull/462) ## v1.3.5 [2022-03-31] Lars Kanis Bugfixes: - Handle PGRES_COMMAND_OK in pgresult_stream_any. [#447](https://github.com/ged/ruby-pg/pull/447) Fixes usage when trying to stream the result of a procedure call that returns no results. Enhancements: - Rename BasicTypeRegistry#define_default_types to #register_default_types to use a more consistent terminology. Keeping define_default_types for compatibility. - BasicTypeRegistry: return self instead of objects by accident. This allows call chaining. - Add some April fun. [#449](https://github.com/ged/ruby-pg/pull/449) Documentation: - Refine documentation of conn.socket_io and conn.connect_poll ## v1.3.4 [2022-03-10] Lars Kanis Bugfixes: - Don't leak IO in case of connection errors. [#439](https://github.com/ged/ruby-pg/pull/439) Previously it was kept open until the PG::Connection was garbage collected. - Fix a performance regession in conn.get_result noticed in single row mode. [#442](https://github.com/ged/ruby-pg/pull/442) - Fix occasional error Errno::EBADF (Bad file descriptor) while connecting. [#444](https://github.com/ged/ruby-pg/pull/444) - Fix compatibility of res.stream_each* methods with Fiber.scheduler. [#446](https://github.com/ged/ruby-pg/pull/446) - Remove FL_TEST and FL_SET, which are MRI-internal. [#437](https://github.com/ged/ruby-pg/pull/437) Enhancements: - Allow pgresult_stream_any to be used by sequel_pg. [#443](https://github.com/ged/ruby-pg/pull/443) ## v1.3.3 [2022-02-22] Lars Kanis Bugfixes: - Fix omission of the third digit of IPv4 addresses in connection URI. [#435](https://github.com/ged/ruby-pg/pull/435) - Fix wrong permission of certs/larskanis-2022.pem in the pg-1.3.2.gem. [#432](https://github.com/ged/ruby-pg/pull/432) ## v1.3.2 [2022-02-14] Lars Kanis Bugfixes: - Cancel only active query after failing transaction. [#430](https://github.com/ged/ruby-pg/pull/430) This avoids an incompatibility with pgbouncer since pg-1.3.0. - Fix String objects with non-applied encoding when using COPY or record decoders. [#427](https://github.com/ged/ruby-pg/pull/427) - Update Windows fat binary gem to PostgreSQL-14.2. Enhancements: - Improve extconf.rb checks to reduces the number of compiler calls. - Add a check for PGRES_PIPELINE_SYNC, to make sure the library version and the header files are PostgreSQL-14+. [#429](https://github.com/ged/ruby-pg/pull/429) ## v1.3.1 [2022-02-01] Michael Granger Bugfixes: - Fix wrong handling of socket writability on Windows introduced in [#417](https://github.com/ged/ruby-pg/pull/417). This caused starvation in conn.put_copy_data. - Fix error in PG.version_string(true). [#419](https://github.com/ged/ruby-pg/pull/419) - Fix a regression in pg 1.3.0 where Ruby 2.x busy-looping any fractional seconds for every wait. [#420](https://github.com/ged/ruby-pg/pull/420) Enhancements: - Raise an error when conn.copy_data is used in nonblocking mode. ## v1.3.0 [2022-01-20] Michael Granger Install Enhancements: - Print some install help if libpq wasn't found. [#396](https://github.com/ged/ruby-pg/pull/396) This should help to pick the necessary package without googling. - Update Windows fat binary gem to OpenSSL-1.1.1m and PostgreSQL-14.1. - Add binary Windows gems for Ruby 3.0 and 3.1. - Make the library path of libpq available in ruby as PG::POSTGRESQL_LIB_PATH and add it to the search paths on Windows similar to +rpath+ on Unix systems. [#373](https://github.com/ged/ruby-pg/pull/373) - Fall back to pkg-config if pg_config is not found. [#380](https://github.com/ged/ruby-pg/pull/380) - Add option to extconf.rb to disable nogvl-wrapping of libpq functions. All methods (except PG::Connection.ping) are nonblocking now, so that GVL unlock is in theory no longer necessary. However it can have some advantage in concurrency, so that GVL unlock is still enabled by default. Use: - gem inst pg -- --disable-gvl-unlock API Enhancements: - Add full compatibility to Fiber.scheduler introduced in Ruby-3.0. [#397](https://github.com/ged/ruby-pg/pull/397) - Add async_connect and async_send methods and add specific specs for Fiber.scheduler [#342](https://github.com/ged/ruby-pg/pull/342) - Add async_get_result and async_get_last_result - Add async_get_copy_data - Implement async_put_copy_data/async_put_copy_end - Implement async_reset method using the nonblocking libpq API - Add async_set_client_encoding which is compatible to scheduler - Add async_cancel as a nonblocking version of conn#cancel - Add async_encrypt_password - Run Connection.ping in a second thread. - Make discard_results scheduler friendly - Do all socket waiting through the conn.socket_io object. - Avoid PG.connect blocking while address resolution by automatically providing the +hostaddr+ parameter and resolving in Ruby instead of libpq. - On Windows Fiber.scheduler support requires Ruby-3.1+. It is also only partly usable since may ruby IO methods are not yet scheduler aware on Windows. - Add support for pipeline mode of PostgreSQL-14. [#401](https://github.com/ged/ruby-pg/pull/401) - Allow specification of multiple hosts in PostgreSQL URI. [#387](https://github.com/ged/ruby-pg/pull/387) - Add new method conn.backend_key - used to implement our own cancel method. Type cast enhancements: - Add PG::BasicTypeMapForQueries::BinaryData for encoding of bytea columns. [#348](https://github.com/ged/ruby-pg/pull/348) - Reduce time to build coder maps and permit to reuse them for several type maps per PG::BasicTypeRegistry::CoderMapsBundle.new(conn) . [#376](https://github.com/ged/ruby-pg/pull/376) - Make BasicTypeRegistry a class and use a global default instance of it. Now a local type registry can be instanciated and given to the type map, to avoid changing shared global states. - Allow PG::BasicTypeMapForQueries to take a Proc as callback for undefined types. Other Enhancements: - Convert all PG classes implemented in C to TypedData objects. [#349](https://github.com/ged/ruby-pg/pull/349) - Support ObjectSpace.memsize_of(obj) on all classes implemented in C. [#393](https://github.com/ged/ruby-pg/pull/393) - Make all PG objects implemented in C memory moveable and therefore GC.compact friendly. [#349](https://github.com/ged/ruby-pg/pull/349) - Update errorcodes and error classes to PostgreSQL-14.0. - Add PG::CONNECTION_* constants for conn.status of newer PostgreSQL versions. - Add better support for logical replication. [#339](https://github.com/ged/ruby-pg/pull/339) - Change conn.socket_io to read+write mode and to a BasicSocket object instead of IO. - Use rb_io_wait() and the conn.socket_io object if available for better compatibility to Fiber.scheduler . Fall back to rb_wait_for_single_fd() on ruby < 3.0. - On Windows use a specialized wait function as a workaround for very poor performance of rb_io_wait(). [#416](https://github.com/ged/ruby-pg/pull/416) Bugfixes: - Release GVL while calling PQping which is a blocking method, but it didn't release GVL so far. - Fix Connection#transaction to no longer block on interrupts, for instance when pressing Ctrl-C and cancel a running query. [#390](https://github.com/ged/ruby-pg/pull/390) - Avoid casting of OIDs to fix compat with Redshift database. [#369](https://github.com/ged/ruby-pg/pull/369) - Call conn.block before each conn.get_result call to avoid possible blocking in case of a slow network and multiple query results. - Sporadic Errno::ENOTSOCK when using conn.socket_io on Windows [#398](https://github.com/ged/ruby-pg/pull/398) Deprecated: - Add deprecation warning to PG::BasicTypeRegistry.register_type and siblings. Removed: - Remove support of ruby-2.2, 2.3 and 2.4. Minimum is ruby-2.5 now. - Remove support for PostgreSQL-9.2. Minimum is PostgreSQL-9.3 now. - Remove constant PG::REVISION, which was broken since pg-1.1.4. Repository: - Replace Hoe by Bundler for gem packaging - Add Github Actions CI and testing of source and binary gems. ## v1.2.3 [2020-03-18] Michael Granger Bugfixes: - Fix possible segfault at `PG::Coder#encode`, `decode` or their implicit calls through a typemap after GC.compact. [#327](https://github.com/ged/ruby-pg/pull/327) - Fix possible segfault in `PG::TypeMapByClass` after GC.compact. [#328](https://github.com/ged/ruby-pg/pull/328) ## v1.2.2 [2020-01-06] Michael Granger Enhancements: - Add a binary gem for Ruby 2.7. ## v1.2.1 [2020-01-02] Michael Granger Enhancements: - Added internal API for sequel_pg compatibility. ## v1.2.0 [2019-12-20] Michael Granger Repository: - Our primary repository has been moved to Github https://github.com/ged/ruby-pg . Most of the issues from https://bitbucket.org/ged/ruby-pg have been migrated. [#43](https://github.com/ged/ruby-pg/pull/43) API enhancements: - Add PG::Result#field_name_type= and siblings to allow symbols to be used as field names. [#306](https://github.com/ged/ruby-pg/pull/306) - Add new methods for error reporting: - PG::Connection#set_error_context_visibility - PG::Result#verbose_error_message - PG::Result#result_verbose_error_message (alias) - Update errorcodes and error classes to PostgreSQL-12.0. - New constants: PG_DIAG_SEVERITY_NONLOCALIZED, PQERRORS_SQLSTATE, PQSHOW_CONTEXT_NEVER, PQSHOW_CONTEXT_ERRORS, PQSHOW_CONTEXT_ALWAYS Type cast enhancements: - Add PG::TextEncoder::Record and PG::TextDecoder::Record for en/decoding of Composite Types. [#258](https://github.com/ged/ruby-pg/pull/258), [#36](https://github.com/ged/ruby-pg/pull/36) - Add PG::BasicTypeRegistry.register_coder to register instances instead of classes. This is useful to register parametrized en/decoders like PG::TextDecoder::Record . - Add PG::BasicTypeMapForQueries#encode_array_as= to switch between various interpretations of ruby arrays. - Add Time, Array