unfinished select with partition by median, fix a bug of using time()

Remember that on 64bit system, long is 64 bit and int is only 32 bit, so, if
you pass a pointer which points to int to a function which should be a long
pointer, the function would try to write to the upper 32bit, which would cause
a segment fault