diff --git a/doc/user/databases.xml b/doc/user/databases.xml index e5d9ce75eed98ff20527d60214626efd7a60f261..57477de80f947a7de44b30630dc137a8e5fad50d 100644 --- a/doc/user/databases.xml +++ b/doc/user/databases.xml @@ -3209,17 +3209,35 @@ To see more about the details of the algorithm for the purpose of writing a new <para> <bridgehead renderas="sect4">Users and the _user space</bridgehead> The fields in the _user space are: -a numeric id, a number, the user name, and the optional password. +a numeric id, a number, the user name, the type, and the optional password. </para> <para> -There are two special users: 'guest' (user id = 0) and 'admin' (user id = 1). -They are defined in advance. -They cannot be dropped. -(The 'guest' user is a default which usually has minimum privileges; -the 'admin' user is an administrator which always has maximum privileges.) +There are three special users: 'guest', 'admin', and 'public'. </para> + <para> + <table> + <title>The system users</title> + <tgroup cols="4" align="left" colsep="1" rowsep="1"> + <tbody> + <row> + <entry>NAME</entry><entry>ID</entry><entry>TYPE</entry><entry>DESCRIPTION</entry> + </row> + <row> + <entry>guest</entry><entry>0</entry><entry>user</entry><entry>Default when connecting remotely. Usually an untrusted user with few privileges.</entry> + </row> + <row> + <entry>admin</entry><entry>1</entry><entry>user</entry><entry>Default when using sys/tarantool as a console. Usually an administrative user with all privileges.</entry> + </row> + <row> + <entry>public</entry><entry>2</entry><entry>role</entry><entry>Not a user in the usual sense. A role is a container for privileges which can be granted to regular users. </entry> + </row> + </tbody> + </tgroup> + </table> + </para> + <para> To select a row from the _user space, use <code>box.select</code>. For example, here is what happens with a select for user id = 0, @@ -3239,7 +3257,12 @@ there are special functions which have appropriate error checking. To create a new user, say <code>box.schema.user.create(<replaceable>user-name</replaceable>)</code> or -<code>box.schema.user.create(<replaceable>user-name</replaceable>', {password=<replaceable>password</replaceable>})</code>. +<code>box.schema.user.create(<replaceable>user-name</replaceable>, {password=<replaceable>password</replaceable>})</code>. +</para> + +<para> +To change the current user's password, say +<code>box.schema.user.passwd(<replaceable>password</replaceable>)</code>. </para> <para> @@ -3249,7 +3272,7 @@ To drop a user, say <para> For example, here is a session which creates a new user with -a strong password, selects from the tuple in +a strong password, selects a tuple in the _user space, and then drops the user. <programlisting><prompt>tarantool></prompt> box.schema.user.create('ElizabethBrowning', {password = 'Iwtso65$SDS?'}) --- diff --git a/doc/user/stored-procedures.xml b/doc/user/stored-procedures.xml index 14d006ebc5055f76e517156ec777d03276256fe4..7ec2ed0fefdf3ad833bf17a2b3da95c87e832821 100644 --- a/doc/user/stored-procedures.xml +++ b/doc/user/stored-procedures.xml @@ -508,53 +508,150 @@ Password is not valid <section xml:id="sp-box-uuid"> <title>Package <code>uuid</code></title> + +<para> + A "UUID" is a + <link xlink:href="https://en.wikipedia.org/wiki/Universally_unique_identifier">Universally unique identifier</link>. + If an application requires that a value be unique only within a single computer or + on a single database, then a simple counter is better than a UUID, because getting + a UUID is time-consuming (it requires a + <link xlink:href="https://en.wikipedia.org/wiki/Syscall">syscall</link>). + For clusters of computers, or widely distributed applications, UUIDs are better. +</para> +<para> + The functions that can return a UUID are: <code>uuid()</code>, <code>uuid.bin()</code>, <code>uuid.str()</code>. + The functions that can convert between different types of UUID are: <code>:bin()</code>, <code>:str()</code>, <code>uuid.fromstr()</code>, <code>uuid.frombin()</code>. + The function that can determine whether a UUID is an all-zero value is: <code>:isnil()</code>. +</para> + <variablelist xml:id="x-uuid" xreflabel="x-uuid"> + + <varlistentry> + <term> + <emphasis role="lua">uuid()</emphasis> + </term> + <listitem> + <para> + Returns: a UUID with type = cdata. + </para> + </listitem> + </varlistentry> + <varlistentry> <term> <emphasis role="lua">uuid.bin()</emphasis> </term> <listitem> <para> - Returns: a 128-bit (16-byte) unique id in binary form. + Returns: a UUID with type = 16-byte binary string. </para> + </listitem> + </varlistentry> + + <varlistentry> + <term> + <emphasis role="lua">uuid.str()</emphasis> + </term> + <listitem> <para> - Possible errors: The server tries to load the <emphasis>libuuid</emphasis> library - when it starts. If the library is not available, which can happen if it was not - found when the server was built from source, then uuid.bin() returns an error. - <bridgehead renderas="sect4">Example</bridgehead> -<programlisting>tarantool> <userinput>uuid=require('uuid')</userinput> ---- -... -tarantool> <userinput>uuid.bin() == uuid.bin() -- Comment: == means "are they equal?"</userinput> ---- - - false -... -</programlisting> + Returns: a UUID with type = 36-byte hexadecimal string. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term> + <emphasis role="lua"><replaceable>uuid_with_type_cdata</replaceable>:bin([<replaceable>byte-order</replaceable>])</emphasis> + </term> + <listitem> + <para> + Parameters: byte-order can be 'l' (little-endian), 'b' (big-endian), 'h' (endianness depends on host) (default), or 'n' (endiannes depends on network). + </para> + <para> + Returns: UUID with type = 16-byte binary string converted from cdata input value. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term> + <emphasis role="lua"> <replaceable>uuid_with_type_cdata</replaceable>:str()</emphasis> + </term> + <listitem> + <para> + Returns: UUID with type = 36-byte hexadecimal string converted from cdata input value. + </para> + </listitem> + </varlistentry> + + <varlistentry> + <term> + <emphasis role="lua"> uuid.fromstr(<replaceable>uuid_with_type_string</replaceable>)</emphasis> + </term> + <listitem> + <para> + Returns: UUID with type = cdata converted from 36-byte hexadecimal string input value. </para> </listitem> </varlistentry> + <varlistentry> <term> - <emphasis role="lua">uuid.hex()</emphasis> + <emphasis role="lua">uuid.frombin(<replaceable>uuid_with_type_binary_string</replaceable>)</emphasis> </term> <listitem> <para> - Returns: a 32-byte hexadecimal conversion of a 128-bit - unique id, as a string. + Returns: UUID with type = cdata converted from 16-byte binary string input value. </para> + </listitem> + </varlistentry> + + <varlistentry> + <term> + <emphasis role="lua">:isnil(<replaceable>uuid_with_type_cdata</replaceable>)</emphasis> + </term> + <listitem> + <para> + Returns: true if the value is all zero, otherwise false. + The all-zero UUID value can be expressed as <code>uuid.NULL</code>, or as + uuid.fromstr('00000000-0000-0000-0000-000000000000'). + The comparison with an all-zero value can also be expressed as + <replaceable>uuid_with_type_cdata</replaceable> == uuid.NULL. + </para> + </listitem> + </varlistentry> + +</variablelist> +<para> <bridgehead renderas="sect4">Example</bridgehead> <programlisting> -tarantool> <userinput>uuid=require('uuid')</userinput> +tarantool> <userinput>uuid = require('uuid')</userinput> +--- +... +tarantool> <userinput>uuid(), uuid.bin(), uuid.str()</userinput> --- +- 16ffedc8-cbae-4f93-a05e-349f3ab70baa +- !!binary FvG+Vy1MfUC6kIyeM81DYw== +- 67c999d2-5dce-4e58-be16-ac1bcb93160f ... -tarantool> <userinput>uuid.hex()</userinput> +tarantool> <userinput>uu = uuid()</userinput> --- - - b8eadcb078b54bed8fa8425d129b10e8 +... +tarantool> <userinput>#uu:bin(), #uu:str(), type(uu), uu:isnil()</userinput> +--- +- 16 +- 36 +- cdata +- false ... </programlisting> - </listitem> - </varlistentry> -</variablelist> +</para> +<para> + Possible errors: The server tries to load the <emphasis>libuuid</emphasis> library + when it starts. If the library is not available, which can happen if it was not + found when the server was built from source, then require('uuid') returns an error. +</para> + </section> <section xml:id="sp-box-cjson">