1--TEST-- 2Bug #68199 (PDO::pgsqlGetNotify doesn't support NOTIFY payloads) 3--EXTENSIONS-- 4pdo_pgsql 5--SKIPIF-- 6<?php 7require __DIR__ . '/config.inc'; 8require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc'; 9PDOTest::skip(); 10 11$db = PDOTest::factory(); 12if (version_compare($db->getAttribute(PDO::ATTR_SERVER_VERSION), '9.0.0') < 0) { 13 die("skip Requires 9.0+"); 14} 15 16?> 17--FILE-- 18<?php 19require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc'; 20$db = PDOTest::test_factory(__DIR__ . '/common.phpt'); 21$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 22 23// pgsqlGetPid should return something meaningful 24$pid = $db->pgsqlGetPid(); 25var_dump($pid > 0); 26 27// No listen, no notifies 28var_dump($db->pgsqlGetNotify()); 29 30// Listen started, no notifies 31$db->exec("LISTEN channel_bug68199"); 32var_dump($db->pgsqlGetNotify()); 33 34// No parameters with payload, use default PDO::FETCH_NUM 35$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_NUM); 36$db->exec("NOTIFY channel_bug68199, 'payload'"); 37$notify = $db->pgsqlGetNotify(); 38var_dump(count($notify)); 39var_dump($notify[0]); 40var_dump($notify[1] == $pid); 41var_dump($notify[2]); 42 43// No parameters with payload, use default PDO::FETCH_ASSOC 44$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); 45$db->exec("NOTIFY channel_bug68199, 'payload'"); 46$notify = $db->pgsqlGetNotify(); 47var_dump(count($notify)); 48var_dump($notify['message']); 49var_dump($notify['pid'] == $pid); 50var_dump($notify['payload']); 51 52// Test PDO::FETCH_NUM as parameter with payload 53$db->exec("NOTIFY channel_bug68199, 'payload'"); 54$notify = $db->pgsqlGetNotify(PDO::FETCH_NUM); 55var_dump(count($notify)); 56var_dump($notify[0]); 57var_dump($notify[1] == $pid); 58var_dump($notify[2]); 59 60// Test PDO::FETCH_ASSOC as parameter with payload 61$db->exec("NOTIFY channel_bug68199, 'payload'"); 62$notify = $db->pgsqlGetNotify(PDO::FETCH_ASSOC); 63var_dump(count($notify)); 64var_dump($notify['message']); 65var_dump($notify['pid'] == $pid); 66var_dump($notify['payload']); 67 68// Test PDO::FETCH_BOTH as parameter with payload 69$db->exec("NOTIFY channel_bug68199, 'payload'"); 70$notify = $db->pgsqlGetNotify(PDO::FETCH_BOTH); 71var_dump(count($notify)); 72var_dump($notify['message']); 73var_dump($notify['pid'] == $pid); 74var_dump($notify['payload']); 75var_dump($notify[0]); 76var_dump($notify[1] == $pid); 77var_dump($notify[2]); 78 79// Verify that there are no notifies queued 80var_dump($db->pgsqlGetNotify()); 81 82?> 83--EXPECT-- 84bool(true) 85bool(false) 86bool(false) 87int(3) 88string(16) "channel_bug68199" 89bool(true) 90string(7) "payload" 91int(3) 92string(16) "channel_bug68199" 93bool(true) 94string(7) "payload" 95int(3) 96string(16) "channel_bug68199" 97bool(true) 98string(7) "payload" 99int(3) 100string(16) "channel_bug68199" 101bool(true) 102string(7) "payload" 103int(6) 104string(16) "channel_bug68199" 105bool(true) 106string(7) "payload" 107string(16) "channel_bug68199" 108bool(true) 109string(7) "payload" 110bool(false) 111