Annotation of embedaddon/php/ext/mysqli/tests/mysqli_change_user_locks_temporary.phpt, revision 1.1

1.1     ! misho       1: --TEST--
        !             2: mysqli_change_user() - table locks, GET_LOCK(), temporary tables
        !             3: --SKIPIF--
        !             4: <?php
        !             5: require_once('skipif.inc');
        !             6: require_once('skipifemb.inc');
        !             7: require_once('skipifconnectfailure.inc');
        !             8: die("skip - is the server still buggy?");
        !             9: ?>
        !            10: --FILE--
        !            11: <?php
        !            12:        require_once('connect.inc');
        !            13:        require_once('table.inc');
        !            14: 
        !            15:        if (!$link2 = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
        !            16:                printf("[001] Cannot create second connection handle, [%d] %s\n",
        !            17:                        mysqli_connect_errno(), mysqli_connect_error());
        !            18: 
        !            19:        if (!mysqli_query($link, 'LOCK TABLE test WRITE'))
        !            20:                printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
        !            21: 
        !            22:        /*
        !            23:        if ($res = mysqli_query($link2, 'SELECT COUNT(*) AS _num FROM test')) {
        !            24:                printf("[003] Reading from test should not be possible due to a lock, [%d] %s\n",
        !            25:                        mysqli_errno($link2), mysqli_error($link2));
        !            26:                mysqli_free_result($res);
        !            27:        }
        !            28:        */
        !            29: 
        !            30:        // LOCKS should be removed
        !            31:        mysqli_change_user($link, $user, $passwd, $db);
        !            32: 
        !            33:        if (!$res = mysqli_query($link2, 'SELECT COUNT(*) AS _num FROM test'))
        !            34:                printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
        !            35: 
        !            36:        if (!$row = mysqli_fetch_assoc($res))
        !            37:                printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
        !            38: 
        !            39:        if ($row['_num'] < 1)
        !            40:                printf("[005] There should be some rows in the table test\n");
        !            41: 
        !            42:        mysqli_free_result($res);
        !            43:        mysqli_close($link2);
        !            44: 
        !            45:        if (!mysqli_query($link, 'DROP TABLE test'))
        !            46:                printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
        !            47: 
        !            48:        if (!mysqli_query($link, 'CREATE TEMPORARY TABLE test(id INT)'))
        !            49:                printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
        !            50: 
        !            51:        if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1), (2), (3)'))
        !            52:                printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
        !            53: 
        !            54:        if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS _num FROM test'))
        !            55:                printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
        !            56: 
        !            57:        if (!$row = mysqli_fetch_assoc($res))
        !            58:                printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
        !            59: 
        !            60:        if ($row['_num'] != 3)
        !            61:                printf("[011] There should be three rows in the table test\n");
        !            62: 
        !            63:        mysqli_free_result($res);
        !            64: 
        !            65:        // Temporary tables should be dropped
        !            66:        mysqli_change_user($link, $user, $passwd, $db);
        !            67: 
        !            68:        if ($res = mysqli_query($link, 'SELECT COUNT(*) AS _num FROM test')) {
        !            69:                printf("[012] There should be no table test any more, [%d] %s\n",
        !            70:                        mysqli_errno($link), mysqli_error($link));
        !            71:                mysqli_free_result($res);
        !            72:        }
        !            73: 
        !            74:        if (!$res = mysqli_query($link, 'SELECT GET_LOCK("phptest", 2) AS _ok'))
        !            75:                printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
        !            76: 
        !            77:        if (!$row = mysqli_fetch_assoc($res))
        !            78:                printf("[014] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
        !            79: 
        !            80:        if ($row['_ok'] != 1)
        !            81:                printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
        !            82: 
        !            83:        mysqli_free_result($res);
        !            84: 
        !            85:        // GET_LOCK("phptest") should be released
        !            86:        mysqli_change_user($link, $user, $passwd, $db);
        !            87: 
        !            88:        if (!$res = mysqli_query($link, 'SELECT IS_FREE_LOCK("phptest") AS _ok'))
        !            89:                printf("[016] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
        !            90: 
        !            91:        if (!$row = mysqli_fetch_assoc($res))
        !            92:                printf("[017] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
        !            93: 
        !            94:        if ($row['_ok'] != 1)
        !            95:                printf("[018] Lock 'phptest' should have been released, [%d] %s\n",
        !            96:                        mysqli_errno($link), mysqli_error($link));
        !            97: 
        !            98:        mysqli_free_result($res);
        !            99:        mysqli_close($link);
        !           100:        print "done!";
        !           101: ?>
        !           102: --CLEAN--
        !           103: <?php
        !           104:        require_once("clean_table.inc");
        !           105: ?>
        !           106: --EXPECTF--
        !           107: done!

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>