1--TEST-- 2Constants exported by ext/mysqli 3--SKIPIF-- 4<?php 5require_once('skipif.inc'); 6require_once('skipifemb.inc'); 7require_once('skipifconnectfailure.inc'); 8?> 9--FILE-- 10<?php 11 require("connect.inc"); 12 require("table.inc"); 13 14 $php_version = (int)str_replace('.', '', PHP_VERSION); 15 $constants = get_defined_constants(true); 16 sort($constants); 17 18 $expected_constants = array( 19 'MYSQLI_READ_DEFAULT_GROUP' => true, 20 'MYSQLI_READ_DEFAULT_FILE' => true, 21 'MYSQLI_OPT_CONNECT_TIMEOUT' => true, 22 'MYSQLI_OPT_LOCAL_INFILE' => true, 23 'MYSQLI_INIT_COMMAND' => true, 24 'MYSQLI_CLIENT_SSL' => true, 25 "MYSQLI_CLIENT_COMPRESS" => true, 26 "MYSQLI_CLIENT_INTERACTIVE" => true, 27 "MYSQLI_CLIENT_IGNORE_SPACE" => true, 28 "MYSQLI_CLIENT_NO_SCHEMA" => true, 29 "MYSQLI_CLIENT_FOUND_ROWS" => true, 30 "MYSQLI_STORE_RESULT" => true, 31 "MYSQLI_USE_RESULT" => true, 32 "MYSQLI_ASSOC" => true, 33 "MYSQLI_NUM" => true, 34 "MYSQLI_BOTH" => true, 35 "MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH"=> true, 36 "MYSQLI_NOT_NULL_FLAG" => true, 37 "MYSQLI_PRI_KEY_FLAG" => true, 38 "MYSQLI_UNIQUE_KEY_FLAG" => true, 39 "MYSQLI_MULTIPLE_KEY_FLAG" => true, 40 "MYSQLI_BLOB_FLAG" => true, 41 "MYSQLI_UNSIGNED_FLAG" => true, 42 "MYSQLI_ZEROFILL_FLAG" => true, 43 "MYSQLI_AUTO_INCREMENT_FLAG" => true, 44 "MYSQLI_TIMESTAMP_FLAG" => true, 45 "MYSQLI_SET_FLAG" => true, 46 "MYSQLI_NUM_FLAG" => true, 47 "MYSQLI_ENUM_FLAG" => true, 48 "MYSQLI_BINARY_FLAG" => true, 49 "MYSQLI_PART_KEY_FLAG" => true, 50 "MYSQLI_GROUP_FLAG" => true, 51 "MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED"=> true, 52 "MYSQLI_SERVER_QUERY_NO_INDEX_USED" => true, 53 54 "MYSQLI_TYPE_DECIMAL" => true, 55 "MYSQLI_TYPE_TINY" => true, 56 "MYSQLI_TYPE_SHORT" => true, 57 "MYSQLI_TYPE_LONG" => true, 58 "MYSQLI_TYPE_FLOAT" => true, 59 "MYSQLI_TYPE_DOUBLE" => true, 60 "MYSQLI_TYPE_NULL" => true, 61 "MYSQLI_TYPE_TIMESTAMP" => true, 62 "MYSQLI_TYPE_LONGLONG" => true, 63 "MYSQLI_TYPE_INT24" => true, 64 "MYSQLI_TYPE_DATE" => true, 65 "MYSQLI_TYPE_TIME" => true, 66 "MYSQLI_TYPE_DATETIME" => true, 67 "MYSQLI_TYPE_YEAR" => true, 68 "MYSQLI_TYPE_NEWDATE" => true, 69 "MYSQLI_TYPE_ENUM" => true, 70 "MYSQLI_TYPE_SET" => true, 71 "MYSQLI_TYPE_TINY_BLOB" => true, 72 "MYSQLI_TYPE_MEDIUM_BLOB" => true, 73 "MYSQLI_TYPE_LONG_BLOB" => true, 74 "MYSQLI_TYPE_BLOB" => true, 75 "MYSQLI_TYPE_VAR_STRING" => true, 76 "MYSQLI_TYPE_STRING" => true, 77 "MYSQLI_TYPE_CHAR" => true, 78 "MYSQLI_TYPE_INTERVAL" => true, 79 "MYSQLI_TYPE_GEOMETRY" => true, 80 "MYSQLI_NO_DATA" => true, 81 "MYSQLI_REPORT_INDEX" => true, 82 "MYSQLI_REPORT_STRICT" => true, 83 "MYSQLI_REPORT_ALL" => true, 84 "MYSQLI_REPORT_ERROR" => true, 85 "MYSQLI_REPORT_OFF" => true, 86 "MYSQLI_SET_CHARSET_NAME" => true, 87 "MYSQLI_SET_CHARSET_DIR" => true, 88 "MYSQLI_REFRESH_GRANT" => true, 89 "MYSQLI_REFRESH_LOG" => true, 90 "MYSQLI_REFRESH_TABLES" => true, 91 "MYSQLI_REFRESH_HOSTS" => true, 92 "MYSQLI_REFRESH_STATUS" => true, 93 "MYSQLI_REFRESH_THREADS" => true, 94 "MYSQLI_REFRESH_SLAVE" => true, 95 "MYSQLI_REFRESH_MASTER" => true, 96 "MYSQLI_DEBUG_TRACE_ENABLED" => true, 97 "MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT" => true, 98 "MYSQLI_TRANS_START_READ_WRITE" => true, 99 "MYSQLI_TRANS_START_READ_ONLY" => true, 100 "MYSQLI_TRANS_COR_AND_CHAIN" => true, 101 "MYSQLI_TRANS_COR_AND_NO_CHAIN" => true, 102 "MYSQLI_TRANS_COR_RELEASE" => true, 103 "MYSQLI_TRANS_COR_NO_RELEASE" => true, 104 ); 105 106 /* depends on the build - experimental */ 107 if ($IS_MYSQLND && defined('MYSQLI_OPT_INT_AND_FLOAT_NATIVE')) { 108 $expected_constants['MYSQLI_OPT_INT_AND_FLOAT_NATIVE'] = true; 109 } 110 111 if ($IS_MYSQLND && defined('MYSQLI_STORE_RESULT_COPY_DATA')) { 112 $expected_constants['MYSQLI_STORE_RESULT_COPY_DATA'] = true; 113 } 114 115 if ($IS_MYSQLND || defined('MYSQLI_REFRESH_BACKUP_LOG')) { 116 $expected_constants['MYSQLI_REFRESH_BACKUP_LOG'] = true; 117 } 118 119 if ($IS_MYSQLND) { 120 $version = 50007 + 1; 121 $expected_constants['MYSQLI_OPT_NET_CMD_BUFFER_SIZE'] = true; 122 $expected_constants['MYSQLI_OPT_NET_READ_BUFFER_SIZE'] = true; 123 $expected_constants['MYSQLI_ASYNC'] = true; 124 125 $expected_constants['MYSQLI_SERVER_PS_OUT_PARAMS'] = true; 126 } else { 127 $version = mysqli_get_client_version(); 128 } 129 130 if (($version > 51122 && $version < 60000) || ($version > 60003) || $IS_MYSQLND) { 131 $expected_constants['MYSQLI_ON_UPDATE_NOW_FLAG'] = true; 132 } 133 134 /* First introduced in MySQL 6.0, backported to MySQL 5.5 */ 135 if ($version >= 50500 || $IS_MYSQLND) { 136 $expected_constants['MYSQLI_SERVER_QUERY_WAS_SLOW'] = true; 137 } 138 139 if ($version >= 50033 || $IS_MYSQLND) { 140 $expected_constants['MYSQLI_CLIENT_SSL_VERIFY_SERVER_CERT'] = true; 141 } 142 if ($IS_MYSQLND) { 143 $expected_constants['MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT'] = true; 144 } 145 146 /* First introduced in MySQL 6.0, backported to MySQL 5.5 */ 147 if ($version >= 50606 || $IS_MYSQLND) { 148 $expected_constants['MYSQLI_SERVER_PUBLIC_KEY'] = true; 149 } 150 151 if ($version > 50002) { 152 $expected_constants = array_merge($expected_constants, array( 153 "MYSQLI_TYPE_NEWDECIMAL" => true, 154 "MYSQLI_TYPE_BIT" => true, 155 )); 156 } 157 158 if ($version > 50002 || $IS_MYSQLND) { 159 $expected_constants['MYSQLI_NO_DEFAULT_VALUE_FLAG'] = true; 160 } 161 162 if ($version > 50003) { 163 $expected_constants = array_merge($expected_constants, array( 164 "MYSQLI_STMT_ATTR_CURSOR_TYPE" => true, 165 "MYSQLI_CURSOR_TYPE_NO_CURSOR" => true, 166 "MYSQLI_CURSOR_TYPE_READ_ONLY" => true, 167 "MYSQLI_CURSOR_TYPE_FOR_UPDATE" => true, 168 "MYSQLI_CURSOR_TYPE_SCROLLABLE" => true, 169 )); 170 } 171 172 if ($version > 50007) { 173 $expected_constants = array_merge($expected_constants, array( 174 "MYSQLI_STMT_ATTR_PREFETCH_ROWS" => true, 175 )); 176 } 177 178 if ($version > 50110 || $IS_MYSQLND) { 179 $expected_constants['MYSQLI_OPT_SSL_VERIFY_SERVER_CERT'] = true; 180 } 181 182 /* pretty dump test, but that is the best way to mimic mysql.c */ 183 if (defined('MYSQLI_DATA_TRUNCATED')) 184 $expected_constants["MYSQLI_DATA_TRUNCATED"] = true; 185 186 if (defined('MYSQLI_SERVER_PS_OUT_PARAMS')) 187 $expected_constants["MYSQLI_SERVER_PS_OUT_PARAMS"] = true; 188 189 if (!$IS_MYSQLND) { 190 /* libmysql only */ 191 192 /* are they available in all versions of ext/mysqli ? 193 ... no we must have removed them at some point - for BC, weakening the test 194 */ 195 if (defined("MYSQLI_RPL_MASTER")) { 196 $expected_constants["MYSQLI_RPL_MASTER"] = true; 197 $expected_constants["MYSQLI_RPL_SLAVE"] = true; 198 $expected_constants["MYSQLI_RPL_ADMIN"] = true; 199 } 200 } 201 202 if (($IS_MYSQLND && version_compare(PHP_VERSION, ' 5.4.12-dev', '>=')) || (!$IS_MYSQLND && ($version > 50610))) { 203 /* could be that MySQL/libmysql 5.6.9 had the flag already but it was no stable release */ 204 $expected_constants["MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS"] = true; 205 $expected_constants["MYSQLI_CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS"] = true; 206 } 207 208 if ($IS_MYSQLND) { 209 $expected_constants["MYSQLI_TYPE_JSON"] = true; 210 } 211 212 $unexpected_constants = array(); 213 214 foreach ($constants as $group => $consts) { 215 foreach ($consts as $name => $value) { 216 if (stristr($name, 'mysqli')) { 217 $name = strtoupper($name); 218 if (isset($expected_constants[$name])) { 219 unset($expected_constants[$name]); 220 } else { 221 $unexpected_constants[$name] = $name; 222 } 223 } 224 } 225 } 226 227 if (!empty($unexpected_constants)) { 228 printf("Dumping list of unexpected constants\n"); 229 var_dump($unexpected_constants); 230 } 231 232 if (!empty($expected_constants)) { 233 printf("Dumping list of missing constants\n"); 234 var_dump($expected_constants); 235 } 236 237 print "done!"; 238?> 239--EXPECTF-- 240done! 241