diff --git a/doc/user/stored-programs.xml b/doc/user/stored-programs.xml index fd580c25c1c14255240cc97d3f679a1d33af410f..50125bd4fa067df1320a44c25b12bbcbae95c5b9 100644 --- a/doc/user/stored-programs.xml +++ b/doc/user/stored-programs.xml @@ -515,6 +515,71 @@ localhost> lua box.select_range(4, 1, 2, '1') - '1': {'1'} - '2': {'2'} ... +</programlisting> + </para></listitem> + </varlistentry> + <varlistentry> + <term> + <emphasis role="lua">box.select_reverse_range(space_no, index_no, limit, key, ...)</emphasis> + </term> + <listitem><para> + Select a reverse range of tuples, starting from offset + specified by <code>key</code>. The key can be + multipart. + Limit selection with at most <code>limit</code> + tuples. + If no key is specified, start from the last key in + the index. + </para> + <para> + For TREE indexes, this returns tuples in sorted order. + HASH indexes reverse iteration is not supported. + If <code>key</code> is <code>nil</code> or unspecified, + the selection starts from end of the index. + <bridgehead renderas="sect4">Example</bridgehead> +<programlisting>localhost> show configuration +--- +... + space[4].cardinality: "-1" + space[4].estimated_rows: "0" + space[4].index[0].type: "HASH" + space[4].index[0].unique: "true" + space[4].index[0].key_field[0].fieldno: "0" + space[4].index[0].key_field[0].type: "STR" + space[4].index[1].type: "TREE" + space[4].index[1].unique: "false" + space[4].index[1].key_field[0].fieldno: "1" + space[4].index[1].key_field[0].type: "STR" +... +localhost> insert into t4 values ('0', '0') +Insert OK, 1 rows affected +localhost> insert into t4 values ('1', '1') +Insert OK, 1 rows affected +localhost> insert into t4 values ('2', '2') +Insert OK, 1 rows affected +localhost> insert into t4 values ('3', '3') +Insert OK, 1 rows affected +localhost> lua box.select_reverse_range(4, 0, 10) +--- + error: 'Illegal parameters, hash iterator is forward only +... +localhost> lua box.select_reverse_range(4, 1, 10) +--- + - '3': {'3'} + - '2': {'2'} + - '1': {'1'} + - '0': {'0'} +... +localhost> lua box.select_reverse_range(4, 1, 2) +--- + - '3': {'3'} + - '2': {'2'} +... +localhost> lua box.select_reverse_range(4, 1, 2, '1') +--- + - '1': {'1'} + - '0': {'0'} +... </programlisting> </para></listitem> </varlistentry> @@ -750,6 +815,13 @@ localhost> lua t:slice(1, -1) <listitem><simpara></simpara></listitem> </varlistentry> + <varlistentry> + <term> + <emphasis role="lua">space:select_reverse_range(index_no, limit, key, ...)</emphasis> + </term> + <listitem><simpara></simpara></listitem> + </varlistentry> + <varlistentry> <term> <emphasis role="lua">space:insert(...)</emphasis> @@ -881,6 +953,15 @@ xreflabel="box.index">box.index</code></title> </simpara></listitem> </varlistentry> + <varlistentry> + <term> + <emphasis role="lua">space:select_reverse_range(limit, key)</emphasis> + </term> + <listitem><simpara>Select a reverse range of tuples, limited by + <code>limit</code>, starting from <code>key</code>. + </simpara></listitem> + </varlistentry> + <varlistentry> <term> <emphasis role="lua">index:min()</emphasis>