Skip to content

Releases: amphp/postgres

1.2.0

10 Feb 17:33
38ff6b2
Compare
Choose a tag to compare
  • PHP 7.1+ now required.
  • Removed circular reference in PgSqlHandle and PqHandle for faster GC.

1.1.1

16 Jan 20:36
d88ec8c
Compare
Choose a tag to compare
  • Fixed parsing of empty arrays when using ext-pgsql (#21)

1.1.0

30 Oct 16:55
15f8403
Compare
Choose a tag to compare
  • Added methods to PqConnection to toggle result set buffering on and off: shouldBufferResults(), shouldNotBufferResults(), and isBufferingResults().
  • Removed a circular reference when destructing of unbuffered result sets that would sometimes delay destruction.
  • Fixed a bug where simultaneously preparing the same statement and immediately destructing the first prepared statement object would cause the connection to be marked as available.

1.0.4

08 Apr 17:22
8a6767f
Compare
Choose a tag to compare
  • Fixed statement reference counts if the same statement was prepared simultaneously on a single connection.
  • The pool no longer caches statement pools internally. If you reuse a statement very frequently, it is recommended to retain a reference to the statement object returned from the pool for better performance. (#19)
  • Removed a circular reference within Connection that could delay automatic destruction and closure of a single connection.
  • Added back-pressure to unbuffered queries to improve memory consumption of large result sets.

1.0.3

16 Mar 13:26
6791ece
Compare
Choose a tag to compare
  • Fixed an issue where a transaction may have been released on a connection when there was an active query associated with the transaction, causing an assertion to fail.

1.0.2

14 Nov 21:42
7159f9d
Compare
Choose a tag to compare
  • Fixed an issue when using this library with amphp/mysql that caused the same Connector object to be returned by the connector() function in both libraries.

1.0.1

30 Oct 16:18
b7fa576
Compare
Choose a tag to compare
  • Fixed an issue where simultaneously preparing the same query in Pool would return two different StatementPool objects instead of the same object.

1.0.0

14 Oct 16:15
6306f4f
Compare
Choose a tag to compare

The interface structure of this library changed significantly, however most consumers of this library should be able to upgrade from v0.2.x by only updating the code initializing a connection or pool to use an instance of ConnectionConfig instead of a connection string. Using a connection or pool to perform queries has remained unchanged since v0.2.x, with the exception that transactions are now started with Link::beginTransaction() instead of Link::transaction().

  • Prepared statements now support ? and named placeholders (e.g.: SELECT * FROM people WHERE name = :name). Named placeholders are used by providing an array with keys matching the placeholders: $statement->execute(['name' => $name]).
  • The fetch-type parameter has been removed from ResultSet::getCurrent(). All rows are always returned as associate arrays.
  • Table data that is scalar or an array are automatically cast to the appropriate PHP type when using ext-pgsql. This matches the behavior when using pecl-pq.
  • Common interfaces such as Statement and Pool that are shared with amphp/mysql are now in a separate library, amphp/sql.
  • ConnectionConfig is now built with a list of parameters instead of a connection string. Use ConnectionConfig::fromString() to use a connection string.
  • Statements created in a pool are cached and reused if the same statement is prepared or executed again.
  • The Operation interface has been dropped in favor of decorators. This interface was internally used to automatically free resources on destruction.

Please review the interfaces in amphp/sql to ensure no other interface changes or method renames may affect your code.

0.2.1

15 Dec 17:11
b644e8c
Compare
Choose a tag to compare
  • Fixed an issue when a pool reached maximum size but a connection creation request was still pending, another subsequent request would enter an infinite loop waiting for a connection to become available.

0.2.0

12 Dec 16:52
d979278
Compare
Choose a tag to compare

This release adds some new features and bugfixes while mostly maintaining compatibility with the prior release. Parameter changes to execute() is the most notable API break that will require some minor updates to existing code using this library.

API Changes

  • Connection::execute() and Pool::execute() now use an array of query parameters as the second parameter instead of being variadic.
  • Statement::execute() also uses an array of query parameters instead of being variadic.
  • Pool no longer extends Connection. Instead Pool and Connection implement a new common interface, Link. Use Link if a pool or single connection may be used.
  • Abstract class TupleResult renamed to ResultSet and is now an interface. Result set classes have been renamed with ResultSet as a suffix (e.g.: PqUnbufferedResultSet).

New Features

  • Pool::extractConnection() added to extract a connection from a pool. Once extracted, the connection will not automatically re-added to the pool.
  • quoteString() and quoteName() added to Handle interface that quote value strings and identifier names respectively for safe insertion into query strings.
  • Added QueryExecutionError exception class extending QueryError, adding a getDiagnostics() method that returns an array of debug information. See PQresultErrorField docs.
  • Added isAlive() to Handle interface that returns false if the database connection has been closed. Connections in pool are automatically removed if isAlive() returns false.
  • Added getQuery() to Statement interface that returns the prepared SQL string.

Fixes

  • Preparing an invalid query with the pgsql extension will fail the promise returned from Executor::prepare() instead of failing when trying to use Statement::execute().
  • Prepared statements mark a pooled connection as busy to prevent unintentional query overlap. Avoid using a pool to generate a large number of long-held prepared statements.