|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Just curious, is this expected behaviour?:
mysql> SELECT GREATEST(SLEEP(3),SLEEP(4)); +-----------------------------+ | GREATEST(SLEEP(3),SLEEP(4)) | +-----------------------------+ | 0 | +-----------------------------+ 1 row in set (8.71 sec) |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
strawberry wrote:
> Just curious, is this expected behaviour?: > > mysql> SELECT GREATEST(SLEEP(3),SLEEP(4)); > +-----------------------------+ >> GREATEST(SLEEP(3),SLEEP(4)) | > +-----------------------------+ >> 0 | > +-----------------------------+ > 1 row in set (8.71 sec) I guess it depends on what can "interrupt" SLEEP? I would expect SELECT GREATEST(LOUD_SNORE(),SLEEP(4)); to return 1 |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Paul Lautman wrote:
> strawberry wrote: >> Just curious, is this expected behaviour?: >> >> mysql> SELECT GREATEST(SLEEP(3),SLEEP(4)); >> +-----------------------------+ >>> GREATEST(SLEEP(3),SLEEP(4)) | >> +-----------------------------+ >>> 0 | >> +-----------------------------+ >> 1 row in set (8.71 sec) > > I guess it depends on what can "interrupt" SLEEP? > > I would expect > SELECT GREATEST(LOUD_SNORE(),SLEEP(4)); > to return 1 > > From the online manual http://dev.mysql.com/doc/refman/5.0/...function_sleep SLEEP(duration) Sleeps (pauses) for the number of seconds given by the duration argument, then returns 0. If SLEEP() is interrupted, it returns 1. The duration may have a fractional part given in microseconds. This function was added in MySQL 5.0.12. So, the results seems to be right. -- //Aho |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
strawberry wrote:
> Just curious, is this expected behaviour?: > > mysql> SELECT GREATEST(SLEEP(3),SLEEP(4)); > +-----------------------------+ > | GREATEST(SLEEP(3),SLEEP(4)) | > +-----------------------------+ > | 0 | > +-----------------------------+ > 1 row in set (8.71 sec) > Greatest can't guess the value that a function returns, it has to wait and see what happens, so it first waits 3 seconds for the first sleep to finish, and then 4 seconds for the second sleep to finish, none of the sleep functions will be interrupted (without outer interference) and therefore you get 0. I think you would see the pattern if you change the sleep values on a mysql server that runs on a low load machine. -- //Aho |
|
![]() |
| Outils de la discussion | |
|
|