document x.1.0 changes
authorMichael Wallner <mike@php.net>
Mon, 22 Aug 2016 12:07:02 +0000 (14:07 +0200)
committerMichael Wallner <mike@php.net>
Mon, 22 Aug 2016 12:07:11 +0000 (14:07 +0200)
pq/Connection.md
pq/Connection/: Changelog.md [new file with mode: 0644]
pq/Connection/flush.md [new file with mode: 0644]
pq/Result.md
pq/Result/: Changelog.md [new file with mode: 0644]

index 4dd56abe18b395391c92902f8f0479672f055249..4f63c36ae4d66ecc6b1cccc1e00bb5267695afb4 100644 (file)
@@ -77,6 +77,8 @@ Negotiating environment-driven parameter settings.
   Connection character set.
 * public bool $unbuffered = FALSE  
   Whether to fetch [asynchronous](pq/Connection/: Asynchronous Usage) results in unbuffered mode, i.e. each row generates a distinct pq\Result.
+* public bool $nonblocking = FALSE  
+  Whether to set the underlying socket nonblocking, useful for asynchronous handling of writes. See also pq\Connection::flush().
 
 ### Connection Information:
 * public (readonly) string $db  
@@ -103,4 +105,3 @@ Negotiating environment-driven parameter settings.
   Default transaction readonlyness for futire pq\Transaction instances.
 * public bool $defaultTransactionDeferrable = FALSE  
   Default transaction deferrability for future pq\Transaction instances.
-  
diff --git a/pq/Connection/: Changelog.md b/pq/Connection/: Changelog.md
new file mode 100644 (file)
index 0000000..fe8abe7
--- /dev/null
@@ -0,0 +1,7 @@
+# pq\Connection Changelog
+
+0. v1.1.0, v2.1.0
+       * Added properties:
+               * pq\Connection::$nonblocking
+       * Added methods:
+               * pq\Connection::flush()
diff --git a/pq/Connection/flush.md b/pq/Connection/flush.md
new file mode 100644 (file)
index 0000000..6a281d9
--- /dev/null
@@ -0,0 +1,64 @@
+# bool pq\Connection::flush()
+
+Flush pending writes on the connection.
+Call after sending any command or data on a nonblocking connection.
+
+If it returns FALSE, wait for the socket to become read or write-ready.
+If it becomes write-ready, call pq\Connection::flush() again.
+If it becomes read-ready, call pq\Connection::poll(), then call pq\Connection::flush() again.
+Repeat until pq\Connection::flush() returns TRUE.
+
+> ***NOTE:***  
+> This method was added in v1.1.0, resp. v2.1.0.
+
+## Params:
+
+None.
+
+## Returns:
+
+* bool, whether everything has been flushed.
+
+## Throws:
+
+* pq\Connection\InvalidArgumentException
+* pq\Connection\RuntimeException when no asynchronous operation is active, or flushing failed
+
+## Example:
+
+       <?php
+       $c = new pq\Connection();
+       $c->nonblocking = true;
+
+       $c->execAsync("SELECT '".str_repeat("a", 6e7)."'", function($r) {
+               $r->fetchCol($s);
+               var_dump(strlen($s));
+       });
+
+       $flushed = $c->flush();
+       do {
+               while (!$flushed || $c->busy) {
+                       $r = $c->busy ? [$c->socket] : null;
+                       $w = !$flushed ?[$c->socket] : null;
+
+                       if (stream_select($r, $w, $e, null)) {
+                               if ($r) {
+                                       printf("P%d", $c->poll());
+                               }
+                               if ($w) {
+                                       printf("F%d", $flushed = $c->flush());
+                               }
+                       }
+               }
+               echo "\n";
+       } while ($c->getResult());
+       ?>
+
+### Yields:
+
+       F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0
+       ... (omitted)
+       F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F0F1P3P3P3P3P3P3P3P3
+       ... (omitted)
+       P3P3P3P3P3P3P3P3P3P3P3P3P3P3
+       int(60000000)
index af11174cf75835b96e1c4e1c151990395eae9cd5..9ad6238d0dc27106124b8ef114c017488a2f94cf 100644 (file)
@@ -71,6 +71,8 @@ See [Fetching Results](pq/Result/: Fetching Results) for a general overview.
   The number of fields in a single tuple of the result set.
 * public (readonly) int $affectedRows  
   The number of rows affected by a statement.
+* public (readonly) array $diag  
+  Error details. See [PQresultErrorField](https://www.postgresql.org/docs/current/static/libpq-exec.html#LIBPQ-PQRESULTERRORFIELD) docs.
 * public int $fetchType = pq\Result::FETCH_ARRAY  
   The [type of return value](pq/Result#Fetch.types:) the fetch methods should return when no fetch type argument was given. Defaults to pq\Connection::$defaultFetchType.
 * public int $autoConvert = pq\Result::CONV_ALL  
diff --git a/pq/Result/: Changelog.md b/pq/Result/: Changelog.md
new file mode 100644 (file)
index 0000000..b601a41
--- /dev/null
@@ -0,0 +1,5 @@
+# pq\Result Changelog
+
+0. v1.1.0, v2.1.0
+       * Added properties:
+               * pq\Result::$diag