PHP  
 PHP_HEAD
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Test Failure Report for ext/pdo_pgsql/tests/bug75402.phpt ('PDO PgSQL Bug #75402 Possible Memory Leak using PDO::CURSOR_SCROLL option')

Script

1: <?php
2:
require __DIR__ '/../../../ext/pdo/tests/pdo_test.inc';
3:
$db PDOTest::test_factory(__DIR__ '/common.phpt');
4:
5:
$resp = new \stdClass();
6:
$resp->entries = [];
7:
8:
$db->query('DROP TABLE IF EXISTS bug75402 CASCADE');
9:
$db->query('CREATE TABLE bug75402 (
10:     "id" character varying(64) NOT NULL,
11:     "group_id" character varying(64) NOT NULL,
12:     "submitter" character varying(320) NOT NULL,
13:     "operation" character varying(32) NOT NULL,
14:     "description" character varying(320) NOT NULL,
15:     "stage" character varying(16) NOT NULL,
16:     "status" character varying(64) NOT NULL,
17:     "progress" integer NOT NULL,
18:     "insert_datetime" timestamp(3) NOT NULL,
19:     "begin_datetime" timestamp(3),
20:     "end_datetime" timestamp(3),
21:     "life_hours" integer NOT NULL,
22:     "family" character varying(32) NOT NULL,
23:     "parallelism_group" character varying(32) NOT NULL,
24:     "max_parallelism" integer NOT NULL,
25:     "hidden" boolean NOT NULL,
26:     "abort" boolean NOT NULL,
27:     "order_folder_pathname" character varying(320),
28:     "worker" character varying(32) NOT NULL,
29:     CONSTRAINT "pk_bug75402" PRIMARY KEY ("id")
30: ) WITH (oids = false);'
);
31:
32:
33:
34:
$db->query("INSERT INTO bug75402 (\"id\", \"group_id\", \"submitter\", \"operation\", \"description\", \"stage\", \"status\", \"progress\", \"insert_datetime\", \"begin_datetime\", \"end_datetime\", \"life_hours\", \"family\", \"parallelism_group\", \"max_parallelism\", \"hidden\", \"abort\", \"order_folder_pathname\", \"worker\") VALUES
35: ('20171016083645_5337',    'G_20171016083645_5337',    'TESTPetunia',    'IMPORT',    '',    'DON',    'Completed',    100,    '2017-10-16 08:36:45',    '2017-10-16 08:36:46',    '2017-10-16 08:36:46',    96,    'IMPORT',    '',    -1,    'f',    'f',    'C:\ProgramData\TestPath\TestApp\Jobs\Jobs\\20171016083645_5337',    'MainService')"
);
36:
37:
38:
39:
$sql "SELECT 
40:             ID as \"sID\",
41:             GROUP_ID as \"sGroupID\",
42:             SUBMITTER as \"sOwner\",
43:             OPERATION as \"sOperation\",
44:             DESCRIPTION as \"sInfo\",
45:             STAGE as \"sShortStatus\",
46:             STATUS as \"sStatus\",
47:             PROGRESS as \"sProgress\",
48:             HIDDEN as \"bHidden\",
49:             to_char(INSERT_DATETIME, 'IYYY.MM.DD HH24:MI:SS')  as \"sDatetime\" 
50:           FROM bug75402 
51:           ORDER BY INSERT_DATETIME DESC"
;
52:
53: if (
$db) {
54:     
$stmt $db->prepare($sql,
55:         array(
56:             
// With the following options memory is not being
57:             // deallocated
58:               
\PDO::ATTR_CURSOR => \PDO::CURSOR_SCROLL
59:             
// With the following option memory is de-allocated
60:             // \PDO::ATTR_CURSOR => \PDO::CURSOR_FWDONLY
61:         
)
62:     );
63:     
$stmt->execute();
64:
65:     while (
$entry $stmt->fetchObject()) {
66:       
$resp->entries [] = $entry;
67:     }
68:     
$stmt->closeCursor();
69:     
$stmt null;
70:     
$db null;
71: }
72:
73:
var_dump($resp);
74:

Expected

object(stdClass)#2 (1) {
  ["entries"]=>
  array(1) {
    [0]=>
    object(stdClass)#4 (10) {
      ["sid"]=>
      string(19) "20171016083645_5337"
      ["sgroupid"]=>
      string(21) "G_20171016083645_5337"
      ["sowner"]=>
      string(11) "TESTPetunia"
      ["soperation"]=>
      string(6) "IMPORT"
      ["sinfo"]=>
      string(0) ""
      ["sshortstatus"]=>
      string(3) "DON"
      ["sstatus"]=>
      string(9) "Completed"
      ["sprogress"]=>
      string(3) "100"
      ["bhidden"]=>
      bool(false)
      ["sdatetime"]=>
      string(19) "2017.10.16 08:36:45"
    }
  }
}

Output

Warning: PDO::query(): SQLSTATE[22021]: Character not in repertoire: 7 ERROR:  invalid byte sequence for encoding "UTF8": 0x81
HINT:  This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding". in /var/php_gcov/PHP_HEAD/ext/pdo_pgsql/tests/bug75402.php on line 34
object(stdClass)#2 (1) {
  ["entries"]=>
  array(0) {
  }
}

Diff

001+ Warning: PDO::query(): SQLSTATE[22021]: Character not in repertoire: 7 ERROR:  invalid byte sequence for encoding "UTF8": 0x81
002+ HINT:  This error can also happen if the byte sequence does not match the encoding expected by the server, which is controlled by "client_encoding". in /var/php_gcov/PHP_HEAD/ext/pdo_pgsql/tests/bug75402.php on line 34
003-   array(1) {
004-     [0]=>
005-     object(stdClass)#4 (10) {
005+   array(0) {
006+   }
007+ }
006-       ["sid"]=>
007-       string(19) "20171016083645_5337"
008-       ["sgroupid"]=>
009-       string(21) "G_20171016083645_5337"
010-       ["sowner"]=>
011-       string(11) "TESTPetunia"
012-       ["soperation"]=>
013-       string(6) "IMPORT"
014-       ["sinfo"]=>
015-       string(0) ""
016-       ["sshortstatus"]=>
017-       string(3) "DON"
018-       ["sstatus"]=>
019-       string(9) "Completed"
020-       ["sprogress"]=>
021-       string(3) "100"
022-       ["bhidden"]=>
023-       bool(false)
024-       ["sdatetime"]=>
025-       string(19) "2017.10.16 08:36:45"
026-     }
027-   }
028- }

 

Generated at Mon, 06 May 2019 17:58:35 +0000 (50 days ago)

Copyright © 2005-2019 The PHP Group
All rights reserved.