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