1--TEST-- 2Bug #48764 (PDO_pgsql::query always uses implicit prepared statements if v3 proto available) 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(); 12 13$client_version = $db->getAttribute(PDO::ATTR_CLIENT_VERSION); 14$server_version = $db->getAttribute(PDO::ATTR_SERVER_VERSION); 15 16if (version_compare($server_version, '10', '>=')) { 17 die('skip'); 18} 19 20?> 21--FILE-- 22<?php 23require __DIR__ . '/../../../ext/pdo/tests/pdo_test.inc'; 24$db = PDOTest::test_factory(__DIR__ . '/common.phpt'); 25$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 26 27echo "Test 1\n"; 28bug($db); 29 30echo "Test 2\n"; 31bug($db, array(PDO::ATTR_EMULATE_PREPARES => 0)); 32bug($db, array(PDO::ATTR_EMULATE_PREPARES => 1)); 33 34echo "Test 3\n"; 35$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 1); 36bug($db); 37$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0); 38bug($db); 39 40putenv('PDOTEST_ATTR='.serialize(array( 41 PDO::ATTR_EMULATE_PREPARES => 1, 42))); 43$db = PDOTest::factory('PDO', false); 44$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 45 46echo "Test 4\n"; 47bug($db); 48bug($db, array(PDO::ATTR_EMULATE_PREPARES => 0)); 49 50putenv('PDOTEST_ATTR'); 51 52 53function bug($db, $options = array()) { 54 try { 55 $stmt = $db->prepare("SELECT ?", $options); 56 $stmt->execute(array(1)); 57 echo "OK\n"; 58 } catch (PDOException $e) { 59 // Indetermined data type when using native prepared statements 60 echo $e->getCode()."\n"; 61 } 62} 63?> 64--EXPECT-- 65Test 1 6642P18 67Test 2 6842P18 69OK 70Test 3 71OK 7242P18 73Test 4 74OK 7542P18 76