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