summaryrefslogtreecommitdiff
path: root/ext/mysqli/tests/mysqli_constants.phpt
blob: 32a259350adab40589d526775556cc4ca748d934 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
--TEST--
Constants exported by ext/mysqli
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
	require("connect.inc");
	require("table.inc");

	$php_version = (int)str_replace('.', '', PHP_VERSION);
	$constants = get_defined_constants(true);
	sort($constants);

	$expected_constants = array(
		'MYSQLI_READ_DEFAULT_GROUP'			=> true,
		'MYSQLI_READ_DEFAULT_FILE'			=> true,
		'MYSQLI_OPT_CONNECT_TIMEOUT'		=> true,
		'MYSQLI_OPT_LOCAL_INFILE'			=> true,
		'MYSQLI_INIT_COMMAND'				=> true,
		'MYSQLI_CLIENT_SSL'					=> true,
		"MYSQLI_CLIENT_COMPRESS"			=> true,
		"MYSQLI_CLIENT_INTERACTIVE"			=> true,
		"MYSQLI_CLIENT_IGNORE_SPACE"		=> true,
		"MYSQLI_CLIENT_NO_SCHEMA"			=> true,
		"MYSQLI_CLIENT_FOUND_ROWS"			=> true,
		"MYSQLI_STORE_RESULT"				=> true,
		"MYSQLI_USE_RESULT"					=> true,
		"MYSQLI_ASSOC"						=> true,
		"MYSQLI_NUM"						=> true,
		"MYSQLI_BOTH"						=> true,
		"MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH"	=> true,
		"MYSQLI_NOT_NULL_FLAG"				=> true,
		"MYSQLI_PRI_KEY_FLAG"				=> true,
		"MYSQLI_UNIQUE_KEY_FLAG"			=> true,
		"MYSQLI_MULTIPLE_KEY_FLAG"			=> true,
		"MYSQLI_BLOB_FLAG"					=> true,
		"MYSQLI_UNSIGNED_FLAG"				=> true,
		"MYSQLI_ZEROFILL_FLAG"				=> true,
		"MYSQLI_AUTO_INCREMENT_FLAG"		=> true,
		"MYSQLI_TIMESTAMP_FLAG"				=> true,
		"MYSQLI_SET_FLAG"					=> true,
		"MYSQLI_NUM_FLAG"					=> true,
		"MYSQLI_ENUM_FLAG"					=> true,
		"MYSQLI_BINARY_FLAG"				=> true,
		"MYSQLI_PART_KEY_FLAG"				=> true,
		"MYSQLI_GROUP_FLAG"					=> true,
		"MYSQLI_SERVER_QUERY_NO_GOOD_INDEX_USED"=> true,
		"MYSQLI_SERVER_QUERY_NO_INDEX_USED"	=> true,

		"MYSQLI_TYPE_DECIMAL"				=> true,
		"MYSQLI_TYPE_TINY"					=> true,
		"MYSQLI_TYPE_SHORT"					=> true,
		"MYSQLI_TYPE_LONG"					=> true,
		"MYSQLI_TYPE_FLOAT"					=> true,
		"MYSQLI_TYPE_DOUBLE"				=> true,
		"MYSQLI_TYPE_NULL"					=> true,
		"MYSQLI_TYPE_TIMESTAMP"				=> true,
		"MYSQLI_TYPE_LONGLONG"				=> true,
		"MYSQLI_TYPE_INT24"					=> true,
		"MYSQLI_TYPE_DATE"					=> true,
		"MYSQLI_TYPE_TIME"					=> true,
		"MYSQLI_TYPE_DATETIME"				=> true,
		"MYSQLI_TYPE_YEAR"					=> true,
		"MYSQLI_TYPE_NEWDATE"				=> true,
		"MYSQLI_TYPE_ENUM"					=> true,
		"MYSQLI_TYPE_SET"					=> true,
		"MYSQLI_TYPE_TINY_BLOB"				=> true,
		"MYSQLI_TYPE_MEDIUM_BLOB"			=> true,
		"MYSQLI_TYPE_LONG_BLOB"				=> true,
		"MYSQLI_TYPE_BLOB"					=> true,
		"MYSQLI_TYPE_VAR_STRING"			=> true,
		"MYSQLI_TYPE_STRING"				=> true,
		"MYSQLI_TYPE_CHAR"					=> true,
		"MYSQLI_TYPE_INTERVAL"				=> true,
		"MYSQLI_TYPE_GEOMETRY"				=> true,
		"MYSQLI_NO_DATA"					=> true,
		"MYSQLI_REPORT_INDEX"				=> true,
		"MYSQLI_REPORT_STRICT"				=> true,
		"MYSQLI_REPORT_ALL"					=> true,
		"MYSQLI_REPORT_ERROR"				=> true,
		"MYSQLI_REPORT_OFF"					=> true,
		"MYSQLI_SET_CHARSET_NAME"			=> true,
		"MYSQLI_REFRESH_GRANT"				=> true,
		"MYSQLI_REFRESH_LOG"					=> true,
		"MYSQLI_REFRESH_TABLES"				=> true,
		"MYSQLI_REFRESH_HOSTS"				=> true,
		"MYSQLI_REFRESH_STATUS"				=> true,
		"MYSQLI_REFRESH_THREADS"			=> true,
		"MYSQLI_REFRESH_SLAVE"				=> true,
		"MYSQLI_REFRESH_MASTER"				=> true,
		"MYSQLI_DEBUG_TRACE_ENABLED"	=> true,
	);

	/* depends on the build - experimental */
	if ($IS_MYSQLND && defined('MYSQLI_OPT_INT_AND_FLOAT_NATIVE')) {
		$expected_constants['MYSQLI_OPT_INT_AND_FLOAT_NATIVE'] = true;
	}

	if ($IS_MYSQLND || defined('MYSQLI_REFRESH_BACKUP_LOG')) {
		$expected_constants['MYSQLI_REFRESH_BACKUP_LOG'] = true;
	}

	if ($IS_MYSQLND) {
		$version = 50007 + 1;
		$expected_constants['MYSQLI_OPT_NET_CMD_BUFFER_SIZE'] = true;
		$expected_constants['MYSQLI_OPT_NET_READ_BUFFER_SIZE'] = true;
		$expected_constants['MYSQLI_ASYNC'] = true;

	} else {
		$version = mysqli_get_client_version();
	}

	if (($version > 51122 && $version < 60000) || ($version > 60003) || $IS_MYSQLND) {
		$expected_constants['MYSQLI_ON_UPDATE_NOW_FLAG'] = true;
	}

	/* First introduced in MySQL 6.0, backported to MySQL 5.5 */
	if ($version >= 50500 || $IS_MYSQLND) {
		$expected_constants['MYSQLI_SERVER_QUERY_WAS_SLOW'] = true;
	}

	if ($version > 50002) {
		$expected_constants = array_merge($expected_constants, array(
			"MYSQLI_TYPE_NEWDECIMAL"	=> true,
			"MYSQLI_TYPE_BIT"			=> true,
		));
	}

	if ($version > 50002 || $IS_MYSQLND) {
		$expected_constants['MYSQLI_NO_DEFAULT_VALUE_FLAG'] = true;
	}

	if ($version > 50003) {
		$expected_constants = array_merge($expected_constants, array(
			"MYSQLI_STMT_ATTR_CURSOR_TYPE"		=> true,
			"MYSQLI_CURSOR_TYPE_NO_CURSOR"		=> true,
			"MYSQLI_CURSOR_TYPE_READ_ONLY"		=> true,
			"MYSQLI_CURSOR_TYPE_FOR_UPDATE"		=> true,
			"MYSQLI_CURSOR_TYPE_SCROLLABLE"		=> true,
		));
	}

	if ($version > 50007) {
		$expected_constants = array_merge($expected_constants, array(
			"MYSQLI_STMT_ATTR_PREFETCH_ROWS"	=> true,
		));
	}

	/* pretty dump test, but that is the best way to mimic mysql.c */
	if (defined('MYSQLI_DATA_TRUNCATED'))
		$expected_constants["MYSQLI_DATA_TRUNCATED"] = true;

	if ($IS_MYSQLND && $php_version >= 600) {
		/* mysqlnd only */
		$expected_constants["MYSQLI_OPT_NUMERIC_AND_DATETIME_AS_UNICODE"] = true;
	} else if (!$IS_MYSQLND) {
		/* libmysql only */

		/* are they available in all versions of ext/mysqli ?
		... no we must have removed them at some point - for BC, weakening the test
		*/
		if (defined("MYSQLI_RPL_MASTER")) {
			$expected_constants["MYSQLI_RPL_MASTER"]	= true;
			$expected_constants["MYSQLI_RPL_SLAVE"]		= true;
			$expected_constants["MYSQLI_RPL_ADMIN"]		= true;
		}
	}


	$unexpected_constants = array();

	foreach ($constants as $group => $consts) {
		foreach ($consts as $name => $value) {
			if (stristr($name, 'mysqli')) {
				$name = strtoupper($name);
				if (isset($expected_constants[$name])) {
					unset($expected_constants[$name]);
				} else {
					$unexpected_constants[$name] = $name;
				}
			}
		}
	}

	if (!empty($unexpected_constants)) {
		printf("Dumping list of unexpected constants\n");
		var_dump($unexpected_constants);
	}

	if (!empty($expected_constants)) {
		printf("Dumping list of missing constants\n");
		var_dump($expected_constants);
	}

	print "done!";
?>
--EXPECTF--
done!