[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
FORMAT(X,D)
X
to a format like '#,###,###.##'
, rounded
to D
decimals, and returns the result as a string.
If D
is 0
, the result will have no
decimal point or fractional part:
mysql> SELECT FORMAT(12332.123456, 4); -> '12,332.1235' mysql> SELECT FORMAT(12332.1,4); -> '12,332.1000' mysql> SELECT FORMAT(12332.2,0); -> '12,332' |
GET_LOCK(str,timeout)
str
, with a
timeout of timeout
seconds. Returns 1
if the lock was obtained
successfully, 0
if the attempt timed out (for example, because another
client has already locked the name), or NULL
if an error
occurred (such as running out of memory or the thread was killed with
mysqladmin kill
). A lock is released when you execute
RELEASE_LOCK()
, execute a new GET_LOCK()
, or the thread
terminates (either normally or abnormally).
This function can be used to implement application locks or to
simulate record locks. Names are locked on a server-wide basis.
If a name has been locked by one client, GET_LOCK()
blocks
any request by another client for a lock with the same name. This
allows clients that agree on a given lock name to use the name to
perform cooperative advisory locking:
mysql> SELECT GET_LOCK('lock1',10); -> 1 mysql> SELECT IS_FREE_LOCK('lock2'); -> 1 mysql> SELECT GET_LOCK('lock2',10); -> 1 mysql> SELECT RELEASE_LOCK('lock2'); -> 1 mysql> SELECT RELEASE_LOCK('lock1'); -> NULL |
Note that the second RELEASE_LOCK()
call returns NULL
because
the lock 'lock1'
was automatically released by the second
GET_LOCK()
call.
INET_ATON(expr)
mysql> SELECT INET_ATON('209.207.224.40'); -> 3520061480 |
The generated number is always in network byte order; for example the
above number is calculated as 209*256^3 + 207*256^2 + 224*256 +40
.
As of MySQL 4.1.2, INET_ATON()
also understands short-form IP
addresses:
mysql> SELECT INET_ATON('127.0.0.1'), INET_ATON('127.1'); -> 2130706433, 2130706433 |
INET_NTOA(expr)
mysql> SELECT INET_NTOA(3520061480); -> "209.207.224.40" |
IS_FREE_LOCK(str)
str
is free to use (that is, not locked).
Returns 1
if the lock is free (no one is using the lock),
0
if the lock is in use, and
NULL
on errors (such as incorrect arguments).
IS_FREE_LOCK()
was added in MySQL version 4.0.2.
IS_USED_LOCK(str)
str
is in use (that is, locked).
If so, it returns the connection identifier of the client that holds
the lock.
Otherwise, it returns NULL
.
IS_USED_LOCK()
was added in MySQL version 4.1.0.
MASTER_POS_WAIT(log_name, log_pos [, timeout])
Blocks until the slave reaches (that is, has read and applied all updates up
to) the specified position in the master log. If master information is
not initialized, or if the arguments are incorrect, returns
NULL
. If the slave is not running, will block and wait until it
is started and goes to or past the specified position. If the slave is
already past the specified position, returns immediately.
If timeout
(new in 4.0.10) is specified, will give up waiting
when timeout
seconds have elapsed. timeout
must be greater
than 0; a zero or negative timeout
means no timeout. The return
value is the number of log events it had to wait to get to the specified
position, or NULL
in case of error, or -1
if the timeout
has been exceeded.
This command is useful for control of master/slave synchronization.
RELEASE_LOCK(str)
str
that was obtained with
GET_LOCK()
. Returns 1
if the lock was released, 0
if the
lock wasn't locked by this thread (in which case the lock is not released),
and NULL
if the named lock didn't exist. (The lock will not exist if
it was never obtained by a call to GET_LOCK()
or if it already has
been released.)
The DO
statement is convenient to use with RELEASE_LOCK()
.
See section 13.1.2 DO
Syntax.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |