1--TEST--
2Constants exported by ext/mysqli
3--EXTENSIONS--
4mysqli
5--INI--
6mysqli.allow_local_infile=1
7--FILE--
8<?php
9
10$constants = get_defined_constants(true);
11sort($constants);
12
13$expected_constants = array(
14    'MYSQLI_READ_DEFAULT_GROUP'			=> true,
15    'MYSQLI_READ_DEFAULT_FILE'			=> true,
16    'MYSQLI_OPT_CONNECT_TIMEOUT'		=> true,
17    'MYSQLI_OPT_LOCAL_INFILE'			=> true,
18    'MYSQLI_OPT_READ_TIMEOUT'			=> true,
19    'MYSQLI_INIT_COMMAND'				=> true,
20    'MYSQLI_CLIENT_SSL'					=> true,
21    "MYSQLI_CLIENT_COMPRESS"			=> true,
22    "MYSQLI_CLIENT_INTERACTIVE"			=> true,
23    "MYSQLI_CLIENT_IGNORE_SPACE"		=> true,
24    "MYSQLI_CLIENT_NO_SCHEMA"			=> true,
25    "MYSQLI_CLIENT_FOUND_ROWS"			=> true,
26    "MYSQLI_STORE_RESULT"				=> true,
27    "MYSQLI_USE_RESULT"					=> true,
28    "MYSQLI_ASSOC"						=> true,
29    "MYSQLI_NUM"						=> true,
30    "MYSQLI_BOTH"						=> true,
31    "MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH"=> true,
32    "MYSQLI_NOT_NULL_FLAG"				=> true,
33    "MYSQLI_PRI_KEY_FLAG"				=> true,
34    "MYSQLI_UNIQUE_KEY_FLAG"			=> true,
35    "MYSQLI_MULTIPLE_KEY_FLAG"			=> true,
36    "MYSQLI_BLOB_FLAG"					=> true,
37    "MYSQLI_UNSIGNED_FLAG"				=> true,
38    "MYSQLI_ZEROFILL_FLAG"				=> true,
39    "MYSQLI_AUTO_INCREMENT_FLAG"		=> true,
40    "MYSQLI_TIMESTAMP_FLAG"				=> true,
41    "MYSQLI_SET_FLAG"					=> true,
42    "MYSQLI_NUM_FLAG"					=> true,
43    "MYSQLI_ENUM_FLAG"					=> true,
44    "MYSQLI_BINARY_FLAG"				=> true,
45    "MYSQLI_PART_KEY_FLAG"				=> true,
46    "MYSQLI_GROUP_FLAG" 				=> true,
47    "MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED"=> true,
48    "MYSQLI_SERVER_QUERY_NO_INDEX_USED"	=> true,
49    "MYSQLI_OPT_LOAD_DATA_LOCAL_DIR"    => true,
50    "MYSQLI_IS_MARIADB"                 => true,
51
52    "MYSQLI_TYPE_DECIMAL"				=> true,
53    "MYSQLI_TYPE_TINY"					=> true,
54    "MYSQLI_TYPE_SHORT"					=> true,
55    "MYSQLI_TYPE_LONG"					=> true,
56    "MYSQLI_TYPE_FLOAT"					=> true,
57    "MYSQLI_TYPE_DOUBLE"				=> true,
58    "MYSQLI_TYPE_NULL"					=> true,
59    "MYSQLI_TYPE_TIMESTAMP"				=> true,
60    "MYSQLI_TYPE_LONGLONG"				=> true,
61    "MYSQLI_TYPE_INT24"					=> true,
62    "MYSQLI_TYPE_DATE"					=> true,
63    "MYSQLI_TYPE_TIME"					=> true,
64    "MYSQLI_TYPE_DATETIME"				=> true,
65    "MYSQLI_TYPE_YEAR"					=> true,
66    "MYSQLI_TYPE_NEWDATE"				=> true,
67    "MYSQLI_TYPE_ENUM"					=> true,
68    "MYSQLI_TYPE_SET"					=> true,
69    "MYSQLI_TYPE_TINY_BLOB"				=> true,
70    "MYSQLI_TYPE_MEDIUM_BLOB"			=> true,
71    "MYSQLI_TYPE_LONG_BLOB"				=> true,
72    "MYSQLI_TYPE_BLOB"					=> true,
73    "MYSQLI_TYPE_VAR_STRING"			=> true,
74    "MYSQLI_TYPE_STRING"				=> true,
75    "MYSQLI_TYPE_CHAR"					=> true,
76    "MYSQLI_TYPE_INTERVAL"				=> true,
77    "MYSQLI_TYPE_GEOMETRY"				=> true,
78    "MYSQLI_NO_DATA"					=> true,
79    "MYSQLI_REPORT_INDEX"				=> true,
80    "MYSQLI_REPORT_STRICT"				=> true,
81    "MYSQLI_REPORT_ALL"					=> true,
82    "MYSQLI_REPORT_ERROR"				=> true,
83    "MYSQLI_REPORT_OFF"					=> true,
84    "MYSQLI_SET_CHARSET_NAME"			=> true,
85    "MYSQLI_SET_CHARSET_DIR"			=> true,
86    "MYSQLI_REFRESH_GRANT"				=> true,
87    "MYSQLI_REFRESH_LOG"				=> true,
88    "MYSQLI_REFRESH_TABLES"				=> true,
89    "MYSQLI_REFRESH_HOSTS"				=> true,
90    "MYSQLI_REFRESH_STATUS"				=> true,
91    "MYSQLI_REFRESH_THREADS"			=> true,
92    "MYSQLI_REFRESH_REPLICA"			=> true,
93    "MYSQLI_REFRESH_SLAVE"				=> true,
94    "MYSQLI_REFRESH_MASTER"				=> true,
95    "MYSQLI_DEBUG_TRACE_ENABLED"		=> true,
96    "MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT" => true,
97    "MYSQLI_TRANS_START_READ_WRITE"		=> true,
98    "MYSQLI_TRANS_START_READ_ONLY"		=> true,
99    "MYSQLI_TRANS_COR_AND_CHAIN"		=> true,
100    "MYSQLI_TRANS_COR_AND_NO_CHAIN"		=> true,
101    "MYSQLI_TRANS_COR_RELEASE"			=> true,
102    "MYSQLI_TRANS_COR_NO_RELEASE"		=> true,
103);
104
105$expected_constants['MYSQLI_OPT_INT_AND_FLOAT_NATIVE'] = true;
106
107$expected_constants['MYSQLI_STORE_RESULT_COPY_DATA'] = true;
108
109$expected_constants['MYSQLI_REFRESH_BACKUP_LOG'] = true;
110
111$version = 50007 + 1;
112$expected_constants['MYSQLI_OPT_NET_CMD_BUFFER_SIZE'] = true;
113$expected_constants['MYSQLI_OPT_NET_READ_BUFFER_SIZE'] = true;
114$expected_constants['MYSQLI_ASYNC'] = true;
115
116$expected_constants['MYSQLI_SERVER_PS_OUT_PARAMS'] = true;
117
118$expected_constants['MYSQLI_ON_UPDATE_NOW_FLAG'] = true;
119
120$expected_constants['MYSQLI_SERVER_QUERY_WAS_SLOW'] = true;
121
122$expected_constants['MYSQLI_CLIENT_SSL_VERIFY_SERVER_CERT'] = true;
123$expected_constants['MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT'] = true;
124
125$expected_constants['MYSQLI_SERVER_PUBLIC_KEY'] = true;
126
127$expected_constants = array_merge($expected_constants, array(
128    "MYSQLI_TYPE_NEWDECIMAL"	=> true,
129    "MYSQLI_TYPE_BIT"			=> true,
130));
131
132$expected_constants['MYSQLI_NO_DEFAULT_VALUE_FLAG'] = true;
133
134$expected_constants = array_merge($expected_constants, array(
135    "MYSQLI_STMT_ATTR_CURSOR_TYPE"		=> true,
136    "MYSQLI_CURSOR_TYPE_NO_CURSOR"		=> true,
137    "MYSQLI_CURSOR_TYPE_READ_ONLY"		=> true,
138    "MYSQLI_CURSOR_TYPE_FOR_UPDATE"		=> true,
139    "MYSQLI_CURSOR_TYPE_SCROLLABLE"		=> true,
140));
141
142$expected_constants = array_merge($expected_constants, array(
143    "MYSQLI_STMT_ATTR_PREFETCH_ROWS"	=> true,
144));
145
146$expected_constants['MYSQLI_OPT_SSL_VERIFY_SERVER_CERT'] = true;
147
148/* pretty dump test, but that is the best way to mimic mysql.c */
149$expected_constants["MYSQLI_DATA_TRUNCATED"] = true;
150
151$expected_constants["MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS"] = true;
152$expected_constants["MYSQLI_CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS"] = true;
153
154$expected_constants["MYSQLI_TYPE_JSON"]	= true;
155
156$unexpected_constants = array();
157
158foreach ($constants as $group => $consts) {
159    foreach ($consts as $name => $value) {
160        if (stristr($name, 'mysqli')) {
161            $name = strtoupper($name);
162            if (isset($expected_constants[$name])) {
163                unset($expected_constants[$name]);
164            } else {
165                $unexpected_constants[$name] = $name;
166            }
167        }
168    }
169}
170
171if (!empty($unexpected_constants)) {
172    printf("Dumping list of unexpected constants\n");
173    var_dump($unexpected_constants);
174}
175
176if (!empty($expected_constants)) {
177    printf("Dumping list of missing constants\n");
178    var_dump($expected_constants);
179}
180?>
181--EXPECT--
182