--disable_warnings DROP FUNCTION IF EXISTS sequence; DROP TABLE IF EXISTS t1; --enable_warnings --source include/have_udf.inc --replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB eval CREATE FUNCTION sequence RETURNS INTEGER SONAME "$UDF_EXAMPLE_LIB"; CREATE TABLE t1 (x INT); INSERT INTO t1 VALUES (4),(3),(2),(1); SELECT sequence() AS seq, x FROM t1 ORDER BY seq ASC; SELECT sequence() AS seq, x FROM t1 ORDER BY seq DESC; DROP FUNCTION sequence; DROP TABLE t1;