Lines Matching refs:link

13 if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
18 if ($link->server_version < 50610)
19 die(sprintf("SKIP Needs MySQL 5.6.10 or newer, found MySQL %s\n", $link->server_info));
25 mysqli_query($link, 'DROP USER expiretest');
26 mysqli_query($link, 'DROP USER expiretest@localhost');
28 if (!mysqli_query($link, 'CREATE USER expiretest@"%"') ||
29 !mysqli_query($link, 'CREATE USER expiretest@"localhost"')) {
30 printf("skip Cannot create second DB user [%d] %s", mysqli_errno($link), mysqli_error($link));
31 mysqli_close($link);
35 if (!mysqli_query($link, 'ALTER USER expiretest@"%" PASSWORD EXPIRE') ||
36 !mysqli_query($link, 'ALTER USER expiretest@"localhost" PASSWORD EXPIRE')) {
37 printf("skip Cannot modify second DB user [%d] %s", mysqli_errno($link), mysqli_error($link));
38 mysqli_close($link);
42 if (!$link->query("DROP TABLE IF EXISTS test") ||
43 !$link->query("CREATE TABLE test (id INT)") || !$link->query("INSERT INTO test(id) VALUES (1)"))
44 die(sprintf("SKIP [%d] %s\n", $link->errno, $link->error));
48 if (!mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO expiretest@'%%'", $db)) ||
49 !mysqli_query($link, sprintf("GRANT SELECT ON TABLE %s.test TO expiretest@'localhost'", $db))) {
50 printf("skip Cannot grant SELECT to user [%d] %s", mysqli_errno($link), mysqli_error($link));
51 mysqli_close($link);
61 if (!$link = my_mysqli_connect($host, 'expiretest', "", $db, $port, $socket)) {
65 $link->query("SELECT id FROM test WHERE id = 1");
66 printf("[002] Connect should fail, [%d] %s\n", $link->errno, $link->error);
70 $link = mysqli_init();
71 $link->options(MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, 0);
72 if (!my_mysqli_real_connect($link, $host, 'expiretest', "", $db, $port, $socket)) {
76 $link->query("SELECT id FROM test WHERE id = 1");
77 printf("[004] Connect should fail, [%d] %s\n", $link->errno, $link->error);
81 $link = mysqli_init();
82 $link->options(MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, 1);
83 if (!my_mysqli_real_connect($link, $host, 'expiretest', "", $db, $port, $socket)) {
87 $link->query("SELECT id FROM test WHERE id = 1");
88 printf("[006] Connect allowed, query fail, [%d] %s\n", $link->errno, $link->error);
89 $link->close();
93 $link = mysqli_init();
94 $link->options(MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, 1);
95 if (!my_mysqli_real_connect($link, $host, 'expiretest', "", $db, $port, $socket)) {
99 $link->query("SET PASSWORD=PASSWORD('expiretest')");
100 printf("[008] Connect allowed, pw set, [%d] %s\n", $link->errno, $link->error);
101 if ($res = $link->query("SELECT id FROM test WHERE id = 1"))
103 $link->close();
108 if (!$link = my_mysqli_connect($host, 'expiretest', "expiretest", $db, $port, $socket)) {
112 $link->query("SELECT id FROM test WHERE id = 1");
113 if ($res = $link->query("SELECT id FROM test WHERE id = 1"))
115 $link->close();
125 mysqli_query($link, 'DROP USER expiretest');
126 mysqli_query($link, 'DROP USER expiretest@localhost');