diff --git a/doc/user/data-model.xml b/doc/user/data-model.xml index 48d89c623e80b99cff973b4937d58ee356e4010d..c2da2ab668dc0cfdda86457c96e75b4a92e10a71 100644 --- a/doc/user/data-model.xml +++ b/doc/user/data-model.xml @@ -44,7 +44,7 @@ derived from distributed computing</alt></emphasis> -- 'space0' in the example - When Tarantool is being used to store data, there is always at least one space. There can be many spaces. Each space has a unique name specified by the user. -Each space has a unique numeric identifier which can be specified the user but usually is assigned automatically by Tarantool. +Each space has a unique numeric identifier which can be specified by the user but usually is assigned automatically by Tarantool. Spaces always contain one tuple set and one or more indexes. </para> @@ -77,14 +77,8 @@ The identifier of a field is the field's number, base 1. For example <quote>1</quote> can be used in some contexts to refer to the first field of a tuple. </para> -<note><para>This manual is following the tarantool client convention by -using the names that are specified by the user at time of creation, -which is the name that's stored on the server. -Other clients follow different conventions, -and may even have sophisticated ways of mapping meaningful names -to numbers.</para></note> <para> -When the tarantool client displays a tuple, it surrounds +When Tarantool returns a tuple value, it surrounds strings with single quotes, separates fields with commas, and encloses the tuple inside square brackets. For example: <computeroutput>[ 3, 'length', 93 ]</computeroutput>. @@ -155,33 +149,32 @@ when traversing TREE indexes.) <para> Five examples of basic operations: <programlisting> -/* Add a new tuple to tuple set space0. - The first field, field[1], will be 999 (type is NUM). - The second field, field[2], will be 'Taranto' (type is STR). */ +-- Add a new tuple to tuple set space0. +-- The first field, field[1], will be 999 (type is NUM). +-- The second field, field[2], will be 'Taranto' (type is STR). box.space.space0:insert{999, 'Taranto'} -/* Update the tuple, changing field field[2]. - The clause "{999}", which has the value to look up in - the index of the tuple's primary-key field, is mandatory - because update() requests must always have a clause that - specifies the primary key, which in this case is field[1]. - The clause "{{'=', 2, 'Tarantino'}}" specifies that assignment - will happen to field[2] with the new value. - */ +-- Update the tuple, changing field field[2]. +-- The clause "{999}", which has the value to look up in +-- the index of the tuple's primary-key field, is mandatory +-- because update() requests must always have a clause that +-- specifies the primary key, which in this case is field[1]. +-- The clause "{{'=', 2, 'Tarantino'}}" specifies that assignment +-- will happen to field[2] with the new value. box.space.space0:update({999}, {{'=', 2, 'Tarantino'}}) -/* Replace the tuple, adding a new field. - This is also possible with the update() request but - the update() request is usually more complicated. */ +-- Replace the tuple, adding a new field. +-- This is also possible with the update() request but +-- the update() request is usually more complicated. box.space.space0:replace{999, 'Tarantella', 'Tarantula'} -/* Retrieve the tuple. - The clause "{999}" is still mandatory, although it does not have to - mention the primary key. */ +-- Retrieve the tuple. +-- The clause "{999}" is still mandatory, although it does not have to +-- mention the primary key. */ box.space.space0:select{999} -/* Delete the tuple. - Once again the clause to identify the primary-key field is mandatory. */ +-- Delete the tuple. +-- Once again the clause to identify the primary-key field is mandatory. box.space.space0:delete{999} </programlisting> </para> @@ -251,9 +244,9 @@ Since all data-change operations end with an implicit yield and an implicit commit, and since no data-change operation can change more than one tuple, there is no need for any locking. Consider, for example, a Lua function that does three Tarantool operations:<programlisting> -SELECT /* this does not yield and does not commit */ -UPDATE /* this yields and commits */ -SELECT /* this does not yield and does not commit */</programlisting> +s:sel...{999} -- this does not yield and does not commit +s:update({...},{{...}}) -- this yields and commits +s:select{999} -- this does not yield and does not commit */</programlisting> The combination <quote>SELECT plus UPDATE</quote> is an atomic transaction: the function holds a consistent view of the database until the UPDATE ends. For the combination <quote>UPDATE plus SELECT</quote> @@ -273,7 +266,7 @@ server on the same processor without ill effects. xlink:href="https://github.com/tarantool/tarantool/tree/master/test/box" xlink:title="Tarantool regression test suite">Tarantool regression test suite</citetitle>. A complete grammar of - supported data-manipulation functions is provided in the <olink targetdoc="tarantool-user-guide" targetptr="language-reference">Language reference</olink> chapter. + supported data-manipulation functions will come later in this chapter. </para> <para> Since not all Tarantool operations can be expressed with the diff --git a/doc/user/databases.xml b/doc/user/databases.xml index 5a374138550f31c667ec93f2d7b580feb18cf9f0..9826456d1e8aba0e60a5f303b8fc6a07bb3b82d0 100644 --- a/doc/user/databases.xml +++ b/doc/user/databases.xml @@ -422,7 +422,7 @@ tarantool> <userinput>table_of_tuples[1]</userinput> Possible errors: If space-name does not exist. <bridgehead renderas="sect4">Example</bridgehead> <programlisting> -tarantool> <userinput>box.space.space_that_does_not_exist_drop()</userinput> +tarantool> <userinput>box.space.space_that_does_not_exist:drop()</userinput> </programlisting> </para> </listitem> @@ -451,6 +451,9 @@ tarantool> <userinput>box.space.space_that_does_not_exist_drop()</userinput> tarantool> <userinput>box.space.space55:rename('space56')</userinput> --- ... +tarantool> box.space.space56:rename('space55') +--- +... </programlisting> </para> </listitem> @@ -628,10 +631,10 @@ tarantool> <userinput>box.space.space55.index.primary:rename('secondary')</useri # primary key value = 999 # The third argument is '=p', that is, there is one operation, assignment # to a field -# The fourth argument is 1, that is, the affected field is field[1] -# The fifth argument is 'B', that is, field[1] contents change to 'B' +# The fourth argument is 2, that is, the affected field is field[2] +# The fifth argument is 'B', that is, field[2] contents change to 'B' # Therefore, after the following update, field[1] = 999 and field[2] = 'B'. -box.space.space0:update(999, {{'=p', 1, 'B'}}) +box.space.space0:update(999, {{'=', 2, 'B'}}) #In the following update, the arguments are the same, except that ... # the key is passed as a Lua table (inside braces). This is unnecessary @@ -639,17 +642,17 @@ box.space.space0:update(999, {{'=p', 1, 'B'}}) # primary key had more than one field. # Therefore, after the following update, field[1] = 999 and field[2] = 'B' # (no change). -box.space.space0:update({999}, {{'=p', 1, 'B'}}) +box.space.space0:update({999}, {{'=', 2, 'B'}}) #In the following update, the arguments are the same, except that ... # The fourth argument is 3, that is, the affected field is field[3]. # It is okay that, until now, field[3] has not existed. It gets added. # Therefore, after the following update, field[1] = 999, field[2] = 'B', # field[3] = 1. -box.space.space0:update({999}, {{'=p', 3, 1}}) +box.space.space0:update({999}, {{'=', 3, 1}}) #In the following update, the arguments are the same, except that ... -# The third argument is '+p', that is, the operation is addition rather +# The third argument is '+', that is, the operation is addition rather # than assignment. # Since field[3] previously contained 1, this means we're adding 1 to 1. # Therefore, after the following update, field[1] = 999, field[2] = 'B', @@ -658,33 +661,33 @@ box.space.space0:update({999}, {{'+p', 3, 1}}) #In the following update ... # The idea is to modify two fields at once. -# The formats are '|p' and '=p', that is, there are two operations, OR and +# The formats are '|' and '=', that is, there are two operations, OR and # assignment. # The fourth and fifth arguments mean that field[3] gets ORed with 1. # The fifth and sixth arguments mean that field[2] gets assigned 'C'. # Therefore, after the following update, field[1] = 999, field[2] = 'C', # field[3] = 3. -box.space.space0:update({999}, {{'|p', 3, 1}, {'=p', 2, 'C'}}) +box.space.space0:update({999}, {{'|', 3, 1}, {'=', 2, 'C'}}) #In the following update ... # The idea is to delete field[2], then subtract 3 from field[3], but ... # after the delete, there is a renumbering -- so field[3] becomes field[2] # before we subtract 3 from it, and that's why the sixth argument is 2 not 3. # Therefore, after the following update, field[1] = 999, field[2] = 0. -box.space.space0:update({999}, {{'#p', 2, 0}, {'-p', 2, 3}}) +box.space.space0:update({999}, {{'#', 2, 0}, {'-', 2, 3}}) #In the following update ... # We're making a long string so that splice will work in the next example. # Therefore, after the following update, field[1] = 999, field[2] = 'XYZ'. -box.space.space0:update({999}, {{'=p', 2, 'XYZ'}}) +box.space.space0:update({999}, {{'=', 2, 'XYZ'}}) #In the following update ... -# The third argument is ':p', that is, this is the example of splice. +# The third argument is ':', that is, this is the example of splice. # The fifth argument is actually four arguments packed together ... # a filler, an offset, the number of bytes to cut (1), and the string # to add ('!') # Therefore, after the following update, field[1] = 999, field[2] = 'X!Z'. -box.space.space0:update({999}, {{':p', 2, pickle.pack('iiA', 1, 1, '!')}}) +box.space.space0:update({999}, {{':', 2, pickle.pack('iiA', 1, 1, '!')}}) </programlisting> </para> @@ -847,7 +850,7 @@ tarantool> <userinput>box.space.space0:len()</userinput> <prompt>tarantool></prompt> <userinput>s:insert{0,'Hello my '}; s:insert{1,'Lua world'}</userinput> --- ... -<prompt>tarantool></prompt> <userinput>tmp = ''; for k, v in s:pairs() do tmp = tmp .. v[1] end</userinput> +<prompt>tarantool></prompt> <userinput>tmp = ''; for k, v in s:pairs() do tmp = tmp .. v[2] end</userinput> --- ... <prompt>tarantool></prompt> <userinput>tmp</userinput> @@ -904,9 +907,9 @@ session = require('session'); session.delimiter('!') function example() local ta = {}, i, line for k, v in box.space._schema:pairs() do - i = 0 + i = 1 line = '' - while i < #v do line = line .. v[i] .. ' ' i = i + 1 end + while i <= #v do line = line .. v[i] .. ' ' i = i + 1 end table.insert(ta, line) end return ta @@ -940,9 +943,9 @@ session.delimiter('')!</programlisting> function example() local ta = {}, i, line for k, v in box.space._space:pairs() do - i = 0 + i = 1 line = '' - while i < #v do line = line .. v[i] .. ' ' i = i + 1 end + while i <= #v do line = line .. v[i] .. ' ' i = i + 1 end table.insert(ta, line) end return ta @@ -983,9 +986,9 @@ session.delimiter('')!</programlisting> function example() local ta = {}, i, line for k, v in box.space._index:pairs() do - i = 0 + i = 1 line = '' - while i < #v do line = line .. v[i] .. ' ' i = i + 1 end + while i <= #v do line = line .. v[i] .. ' ' i = i + 1 end table.insert(ta, line) end return ta @@ -1060,7 +1063,7 @@ how many tuples it contains, and the first field of its first tuple. The function uses Tarantool box.space functions len() and pairs(). The iteration through the spaces is coded as a scan of the _space system tuple set, which contains metadata. The third field in -_space contains the space name, so the key instruction "space_name = v[2]" +_space contains the space name, so the key instruction "space_name = v[3]" means "space_name = the space_name field in the tuple of _space that we've just fetched with pairs()". The function returns a table. </para> @@ -1070,7 +1073,7 @@ function example() local tuple_count, space_name, line local ta = {} for k, v in box.space._space:pairs() do - space_name = v[2] + space_name = v[3] if box.space[space_name].index[0] ~= nil then tuple_count = box.space[space_name]:len() else @@ -1273,7 +1276,7 @@ tarantool> <userinput>box.space.space19:dec{1,'a'}</userinput> <para xml:id="box-function-example" xreflabel="box-function-example"> This example will work with the sandbox configuration described in the preface. That is, there is a space named space0 with a numeric primary key. -The example function will: (1) select a tuple the tuple whose key value is 1000; +The example function will: (1) select a tuple whose key value is 1000; (2) return an error if the tuple already exists and already has 3 fields; (3) Insert or replace the tuple with: field[1] = 1000, field[2] = a uuid, field[3] = number of seconds since 1970-01-01; (4) Get field[3] from what was replaced; @@ -1490,12 +1493,12 @@ tarantool> <userinput>t[2]</userinput> ... tarantool> <userinput>t:find('a')</userinput> --- -- 0 +- 1 ... tarantool> <userinput>t:findall('a')</userinput> --- -- 0 -- 3 +- 1 +- 4 ... tarantool> <userinput>t:findall(2, 'a')</userinput> --- @@ -1529,7 +1532,7 @@ tarantool> <userinput>t:findall(2, 'a')</userinput> <programlisting>tarantool> <userinput>t = box.tuple.new({'Fld#1','Fld#2','Fld#3','Fld#4','Fld#5'})</userinput> --- ... -tarantool> <userinput>t:transform(2,3,'x')</userinput> +tarantool> <userinput>t:transform(2,2,'x')</userinput> --- - ['Fld#1', 'x', 'Fld#4', 'Fld#5'] ...</programlisting> @@ -2339,6 +2342,26 @@ tarantool> <userinput>box.cfg</userinput> The box.info package provides access to information about server variables -- pid, uptime, version and others. </para> + + <para> + <emphasis role="strong">recovery_lag</emphasis> holds the + difference (in seconds) between the current time on the + machine (wall clock time) and the time stamp of the last + applied record. In replication setup, this difference can + indicate the delay taking place before a change is + applied to a replica. + </para> + <para> + <emphasis role="strong">recovery_last_update</emphasis> is + the wall clock time of the last change recorded in the + write-ahead log. To convert it to human-readable time, + you can use <command>date -d@<replaceable>1306964594.980</replaceable></command>. + </para> + <para> + <emphasis role="strong">status</emphasis> is + either "primary" or "replica/<hostname>". + </para> + <varlistentry> <term> <emphasis role="lua">box.info()</emphasis> @@ -2422,15 +2445,39 @@ tarantool> <userinput>box.info.build</userinput> </programlisting> </listitem> </varlistentry> + </variablelist> <variablelist> <title>Package <code>box.slab</code></title> <para> The box.slab package provides access to slab allocator statistics. + The slab + allocator is the main allocator used to store tuples. + This can be used to monitor the total memory use and + memory fragmentation. </para> + <para> + The display of slabs is broken down by the slab size -- + 64-byte, 136-byte, and so on. The example omits the slabs + which are empty. The example display is saying that: + there are 16 items stored + in the 64-byte slab (and 16*64=1024 so + bytes_used = 1024); there is 1 item + stored in the 136-byte slab (and + 136*1=136 so bytes_used = 136); the + arena_used value is the total of all the bytes_used + values (1024+136 = 1160); the + arena_size value is the arena_used value + plus the total of all the bytes_free values + (1160+4193200+4194088 = 8388448). The + arena_size and arena_used values are the amount of + the % of <olink targetptr="slab_alloc_arena"/> that is + already distributed to the slab allocator. + </para> <varlistentry> - <term><emphasis role="lua">box.slab</emphasis></term> + <term xml:id="box.slab.info" xreflabel="box.slab.info()"> + <emphasis role="lua">box.slab</emphasis></term> <listitem><bridgehead renderas="sect4">Example</bridgehead><programlisting> tarantool> <userinput>box.slab.info().arena_used</userinput> --- @@ -2461,10 +2508,13 @@ tarantool> <userinput>box.slab.info().slabs[64]</userinput> <title>Package <code>box.stat</code></title> <para> The box.stat package provides access to request - statistics. + statistics. Show the average number of requests per second, and the + total number of requests since startup, broken down by + request type. </para> <varlistentry> - <term><emphasis role="lua">box.stat</emphasis></term> + <term xml:id="box.stat" xreflabel="box.stat"> + <emphasis role="lua">box.stat</emphasis></term> <listitem><bridgehead renderas="sect4">Example</bridgehead><programlisting> tarantool> <userinput>box.stat, type(box.stat) -- a virtual table</userinput> --- @@ -2474,23 +2524,23 @@ tarantool> <userinput>box.stat, type(box.stat) -- a virtual table</userinput> tarantool> <userinput>box.stat() -- the full contents of the table</userinput> --- - DELETE: - total: 33 - rps: 0 + total: 48902544 + rps: 147 SELECT: - total: 4 - rps: 0 + total: 388322317 + rps: 1246 REPLACE: total: 4 rps: 0 INSERT: - total: 17 - rps: 0 + total: 48207694 + rps: 139 CALL: total: 8 rps: 0 UPDATE: - total: 8 - rps: 0 + total: 743350520 + rps: 1874 ... tarantool> <userinput>box.stat().DELETE -- a selected item of the table</userinput> --- @@ -2838,11 +2888,11 @@ Otherwise, use the box.net.box package to pass the function to the host and port ... tarantool> <userinput>box.snapshot()</userinput> --- -ok +- ok ... tarantool> <userinput>box.snapshot()</userinput> --- -fail: can't save snapshot, errno 17 (File exists) +error: can't save snapshot, errno 17 (File exists) ... </programlisting> </para> @@ -2866,147 +2916,6 @@ fail: can't save snapshot, errno 17 (File exists) </listitem> </varlistentry> - <varlistentry> - <term xml:id="box.info" xreflabel="box.info()"> - <emphasis role="lua">box.info()</emphasis> - </term> - <listitem><para> -<programlisting> -<prompt>tarantool></prompt> <userinput>box.info()</userinput> -- version: 1.6.0-805-g4a7e71d - status: primary - pid: 12315 - lsn: 15481913304 - snapshot_pid: 0 - recovery_last_update: 1306964594 - recovery_lag: 0 - uptime: 441524 - build: - flags: ' -fno-omit-frame-pointer -fno-stack-protector -fexceptions - -funwind-tables -msse2 -std=gnu99 -Wall -Wextra -Wno-sign-compare - -Wno-strict-aliasing -fopenmp -pthread' - target: Linux-x86_64-Debug - compiler: /usr/bin/cc /usr/bin/c++ - options: cmake . -DCMAKE_INSTALL_PREFIX=/usr/local -DENABLE_STATIC=OFF - -DENABLE_TRACE=ON -DENABLE_BACKTRACE=ON -DENABLE_CLIENT=true - logger_pid: 12316 - config: /usr/local/etc/tarantool.cfg -</programlisting> - </para> - <para> - <emphasis role="strong">recovery_lag</emphasis> holds the - difference (in seconds) between the current time on the - machine (wall clock time) and the time stamp of the last - applied record. In replication setup, this difference can - indicate the delay taking place before a change is - applied to a replica. - </para> - <para> - <emphasis role="strong">recovery_last_update</emphasis> is - the wall clock time of the last change recorded in the - write-ahead log. To convert it to human-readable time, - you can use <command>date -d@<replaceable>1306964594.980</replaceable></command>. - </para> - <para> - <emphasis role="strong">status</emphasis> is - either "primary" or "replica/<hostname>". - </para> - - </listitem> - </varlistentry> - - <varlistentry> - <term xml:id="box.stat" xreflabel="box.stat"> - <emphasis role="lua">box.stat()</emphasis> - </term> - <listitem><para> - Show the average number of requests per second, and the - total number of requests since startup, broken down by - request type. -<programlisting> -tarantool> <userinput>box.stat()</userinput> ---- -- DELETE: - total: 48902544 - rps: 147 - SELECT: - total: 388322317 - rps: 1246 - REPLACE: - total: 0 - rps: 0 - INSERT: - total: 48207694 - rps: 139 - AUTH: - total: 0 - rps: 0 - CALL: - total: 0 - rps: 0 - UPDATE: - total: 743350520 - rps: 1874 -... -</programlisting> - </para></listitem> - </varlistentry> - - <varlistentry> - <term xml:id="box.slab.info" xreflabel="box.slab.info()"> - <emphasis role="lua">box.slab()</emphasis> - </term> - <listitem> - <para> - Show the statistics of the slab allocator. The slab - allocator is the main allocator used to store tuples. - This can be used to monitor the total memory use and - memory fragmentation. For example: - </para> -<programlisting> -<prompt>tarantool></prompt> <userinput>box.slab.info()</userinput> ---- -- slabs: - 64: - items: 16 - bytes_used: 1024 - item_size: 64 - slabs: 1 - bytes_free: 4193200 - ... - 136: - items: 1 - bytes_used: 136 - item_size: 136 - slabs: 1 - bytes_free: 4194088 - ... - arena_size: 8388448 - arena_used: 1160 -</programlisting> - <para> - The display of slabs is broken down by the slab size -- - 64-byte, 136-byte, and so on. The example omits the slabs - which are empty. The example display is saying that: - there are 16 items stored - in the 64-byte slab (and 16*64=1024 so - bytes_used = 1024); there is 1 item - stored in the 136-byte slab (and - 136*1=136 so bytes_used = 136); the - arena_used value is the total of all the bytes_used - values (1024+136 = 1160); the - arena_size value is the arena_used value - plus the total of all the bytes_free values - (1160+4193200+4194088 = 8388448). The - arena_size and arena_used values are the amount of - the % of <olink targetptr="slab_alloc_arena"/> that is - already distributed to the slab allocator. - </para> - <para> - </para> - </listitem> - </varlistentry> - <varlistentry> <term xml:id="coredump" xreflabel="coredump()"> <emphasis role="lua">coredump()</emphasis> diff --git a/doc/user/plugins.xml b/doc/user/plugins.xml index 7618fe169b9145e18805628ded141425d8348974..fa9756cfb76e5b3cf527226caa96acf8752f509a 100644 --- a/doc/user/plugins.xml +++ b/doc/user/plugins.xml @@ -138,15 +138,15 @@ Linking CXX shared library libmysql.so <prompt>$ </prompt><userinput>~/tarantool/src/tarantool</userinput> ~/tarantool/src/tarantool: version 1.6.0-1085-gf6d30a5 -<prompt>tarantool> </prompt> - +<prompt>tarantool> </prompt> <userinput>box.cfg{}</userinput> +... # Enter the following lines on the prompt (again, change "/home/pgulutzan" # to whatever the real directory is that contains tarantool): package.path = "/home/pgulutzan/tarantool/src/module/sql/?.lua;"..package.path require("sql") if type(box.net.sql) ~= "table" then error("net.sql load failed") end require("box.net.mysql") -# ... Make sure that tarantool replies "true" for the calls to "require()". +# ... Make sure that tarantool replies "true" for both calls to "require()". # Create a Lua function that will connect to the MySQL server, # (using some factory default values for the port and user and password), @@ -261,7 +261,7 @@ Linking CXX shared library libpg.so <prompt>$ </prompt><userinput>~/tarantool/src/tarantool</userinput> ~/tarantool/src/tarantool: version 1.6.0-1085-gf6d30a5 -<prompt>tarantool> </prompt> +<prompt>tarantool> </prompt> <userinput>box.cfg{}</userinput> # Enter the following lines on the prompt (again, change "/home/pgulutzan" # to whatever the real directory is that contains tarantool): diff --git a/doc/user/server-administration.xml b/doc/user/server-administration.xml index a0062a218ad69915921a9f27c19854ea94de36c1..ab02132be9309f98551fa6069177761203ddbc1d 100644 --- a/doc/user/server-administration.xml +++ b/doc/user/server-administration.xml @@ -364,7 +364,7 @@ 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 string, the user name, and the optional password. +a numeric id, a number, the user name, and the optional password. </para> <para> @@ -381,7 +381,7 @@ For example, here is what happens with a select for user id = 0, which is the 'guest' user, without a password: <programlisting><prompt>tarantool></prompt> box.space._user:select{0} --- -- - [0, '', 'guest'] +- - [0, 1, 'guest'] ...</programlisting></para> <para> @@ -406,14 +406,14 @@ To drop a user, say For example, here is a session which creates a new user with a strong password, selects from the tuple in the _user space, and then drops the user. -<programlisting><prompt>tarantool></prompt> box.schema.user.create('Elizabeth Browning', {password = 'Iwtso65$SDS?'}) +<programlisting><prompt>tarantool></prompt> box.schema.user.create('ElizabethBrowning', {password = 'Iwtso65$SDS?'}) --- ... <prompt>tarantool></prompt> box.space._user:select{4} --- -- - [4, '', 'Elizabeth Browning', {'chap-sha1': 'zyy3yArGOQ4T40PnsL6yPGlgYrU='}] +- - [4, 1, 'ElizabethBrowning', {'chap-sha1': 'zyy3yArGOQ4T40PnsL6yPGlgYrU='}] ... -<prompt>tarantool></prompt> box.schema.user.drop('Elizabeth Browning') +<prompt>tarantool></prompt> box.schema.user.drop('ElizabethBrowning') --- ...</programlisting></para> @@ -491,16 +491,19 @@ The function for dropping a _func tuple is: In the following example, a function named 'f7' is created, then it is put in the _func space, then it is used in a box.schema.user.grant function, then it is dropped: -<programlisting><prompt>tarantool></prompt> function f7() session.uid() end +<programlisting><prompt>tarantool></prompt> <userinput>function f7() session.uid() end</userinput> --- ... -<prompt>tarantool></prompt> box.schema.func.create('f7') +<prompt>tarantool></prompt> <userinput>box.schema.func.create('f7')</userinput> --- ... -<prompt>tarantool></prompt> box.schema.user.grant('guest', 'execute', 'function', 'f7') +<prompt>tarantool></prompt> <userinput>box.schema.user.grant('guest', 'execute', 'function', 'f7')</userinput> --- ... -<prompt>tarantool></prompt> box.schema.func.drop('f7') +<prompt>tarantool></prompt> <userinput>box.schema.user.revoke('guest', 'execute', 'function', 'f7')</userinput> +--- +... +<prompt>tarantool></prompt> <userinput>box.schema.func.drop('f7')</userinput> --- ...</programlisting></para> @@ -524,7 +527,7 @@ privileges. Typically an admin user will set up and configure objects, then grant privileges to appropriate non-admin users. Typically a guest user will use <code>session.su()</code> to change into a non-generic user to whom admin has granted more than the default privileges. For example, admin might say:<programlisting> -box.space._user:insert{123456,'','manager'} +box.space._user:insert{123456,0,'manager'} box.schema.user.grant('manager', 'read', 'space', '_space') box.schema.user.grant('manager', 'read', 'space', 'payroll')</programlisting> and later a guest user, who wishes to see the payroll, might say:<programlisting> diff --git a/doc/user/stored-procedures.xml b/doc/user/stored-procedures.xml index bad290f7dcb8f6af6909cbd0c06f5a659ffbf406..00379b6a8b67a1c8a90ee2f840e8517c9351de56 100644 --- a/doc/user/stored-procedures.xml +++ b/doc/user/stored-procedures.xml @@ -317,7 +317,7 @@ tarantool> <userinput>dostring('return ...', 'hello', 'world')</userinput> - world ... tarantool> <userinput>session = require('session'); session.delimiter('!') --<link linkend="utility-tarantool-delim">this</link> means ignore line feeds until next '!'</userinput> -tarantool> <userinput>-- Use <link xlink:href="http://www.lua.org/pil/2.4.html">double square brackets</link> to enclose multi-line literal here.</userinput> +tarantool> <userinput>-- Use <link xlink:href="http://www.lua.org/pil/2.4.html">double square brackets</link> to enclose multi-line literal here!</userinput> tarantool> <userinput>dostring([[local f = function(key)</userinput> -> <userinput> t = box.space.space0:select(key);</userinput> -> <userinput> if t ~= nil then return t[1] else return nil end</userinput> @@ -418,23 +418,23 @@ tarantool> <userinput>box.space.space0:insert{0, 'hello world'}</userinput> --- - [0, 'hello world'] ... -tarantool> <userinput>box.space.space0:update({0}, {{'=p', 1, 'bye world'}})</userinput> +tarantool> <userinput>box.space.space0:update({0}, {{'=', 2, 'bye world'}})</userinput> --- - [0, 'bye world'] ... -tarantool> <userinput>box.space.space0:update({0}, {{'=p', 1, pickle.pack('iiA', 0, 3, 'hello')}})</userinput> +tarantool> <userinput>box.space.space0:update({0}, {{'=', 2, pickle.pack('iiA', 0, 3, 'hello')}})</userinput> --- - [0, "\0\0\0\0\x03\0\0\0hello"] ... -tarantool> <userinput>box.space.space0:update({0}, {{'=p', 1, 4}})</userinput> +tarantool> <userinput>box.space.space0:update({0}, {{'=', 2, 4}})</userinput> --- - [0, 4] ... -tarantool> <userinput>box.space.space0:update({0}, {{'+p', 1, 4}})</userinput> +tarantool> <userinput>box.space.space0:update({0}, {{'+', 2, 4}})</userinput> --- - [0, 8] ... -tarantool> <userinput>box.space.space0:update({0}, {{'^p', 1, 4}})</userinput> +tarantool> <userinput>box.space.space0:update({0}, {{'^', 2, 4}})</userinput> --- - [0, 12] ... @@ -494,7 +494,7 @@ tarantool> <userinput>box.space.space0:update({0}, {{'^p', 1, 4}})</userinput> - string - 666666666666666 ... -<prompt>tarantool></prompt> <userinput>session.delimiter('')! #back to normal: commands end with line feed!</userinput> +<prompt>tarantool></prompt> <userinput>session.delimiter('') -- back to normal: commands end with line feed!</userinput> </programlisting> </para> </listitem> @@ -544,16 +544,16 @@ tarantool> <userinput>box.space.space0:update({0}, {{'^p', 1, 4}})</userinput> which inserts a SHA-1 digest of the word "^S^e^c^ret Wordpass" into a tuple set, and password_check() which requires input of a password.<programlisting> <prompt>localhost></prompt> <userinput>digest = require('digest')</userinput> -<prompt>localhost></prompt> <userinput>setopt delimiter='!' #this means following commands must end with '!'</userinput> +<prompt>localhost></prompt> <userinput>session = require('session'); session.delimiter('!') --this means ignore line feeds until next '!'</userinput> <prompt>localhost></prompt> <userinput>function password_insert()</userinput> - <prompt>-></prompt> <userinput> space0:insert{12345,digest.sha1('^S^e^c^ret Wordpass')}</userinput> + <prompt>-></prompt> <userinput> box.space.space0:insert{12345,digest.sha1('^S^e^c^ret Wordpass')}</userinput> <prompt>-></prompt> <userinput> return 'OK'</userinput> <prompt>-></prompt> <userinput> end!</userinput> --- ... <prompt>localhost></prompt> <userinput>function password_check(password)</userinput> <prompt>-></prompt> <userinput> local t</userinput> - <prompt>-></prompt> <userinput> t=box.select{12345}</userinput> + <prompt>-></prompt> <userinput> t=box.space.space0:select{12345}</userinput> <prompt>-></prompt> <userinput> if (digest.sha1(password)==t[2]) then</userinput> <prompt>-></prompt> <userinput> print('Password is valid')</userinput> <prompt>-></prompt> <userinput> else</userinput> @@ -562,15 +562,15 @@ tarantool> <userinput>box.space.space0:update({0}, {{'^p', 1, 4}})</userinput> <prompt>-></prompt> <userinput>end!</userinput> --- ... -<prompt>localhost></prompt> <userinput>call password_insert()!</userinput> +<prompt>localhost></prompt> <userinput>password_insert()!</userinput> Call OK, 1 rows affected ['OK'] -<prompt>localhost></prompt> <userinput>setopt delimiter='' #back to normal: commands end with line feed!</userinput> +<prompt>localhost></prompt> <userinput>session.delimiter('') -- back to normal: commands end with line feed!</userinput> </programlisting></para> <para> If a later user calls the password_check() function and enters the wrong password, the result is an - error.<programlisting><prompt>localhost></prompt> <userinput>lua password_check ('Secret Password')</userinput> + error.<programlisting><prompt>localhost></prompt> <userinput>password_check ('Secret Password')</userinput> --- Password is not valid ...</programlisting></para> @@ -592,7 +592,7 @@ Password is not valid 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>require('uuid')</userinput> +<programlisting>tarantool> <userinput>uuid=require('uuid')</userinput> --- ... tarantool> <userinput>uuid.bin() == uuid.bin() -- Comment: == means "are they equal?"</userinput> @@ -614,7 +614,7 @@ tarantool> <userinput>uuid.bin() == uuid.bin() -- Comment: == means "are they </para> <bridgehead renderas="sect4">Example</bridgehead> <programlisting> -tarantool> <userinput>require('uuid')</userinput> +tarantool> <userinput>uuid=require('uuid')</userinput> --- ... tarantool> <userinput>uuid.hex()</userinput> @@ -652,7 +652,7 @@ tarantool> <userinput>uuid.hex()</userinput> </para> <bridgehead renderas="sect4">Example</bridgehead> <programlisting> -tarantool> <userinput>require('json')</userinput> +tarantool> <userinput>json=require('json')</userinput> --- ... tarantool> <userinput>json.encode(123)</userinput> @@ -691,7 +691,7 @@ tarantool> <userinput>json.encode({hello = {'world'}})</userinput> Returns: (type = Lua table) the original contents formatted as a Lua table. </para> <bridgehead renderas="sect4">Example</bridgehead> -<programlisting>tarantool> <userinput>require('json')</userinput> +<programlisting>tarantool> <userinput>json=require('json')</userinput> --- ... tarantool> <userinput>json.decode('123')</userinput> @@ -779,6 +779,9 @@ tarantool> <userinput>json.decode('{"hello": "world"}').hello</userinput> <para> <bridgehead renderas="sect4">Example</bridgehead> <programlisting> +tarantool> yaml = require('yaml') +--- +... tarantool> y = yaml.encode({'a',1,'b',2}) --- ... @@ -853,6 +856,9 @@ hi <para> <bridgehead renderas="sect4">Example</bridgehead> <programlisting> +tarantool> msgpack = require('msgpack') +--- +... tarantool> y = msgpack.encode({'a',1,'b',2}) --- ... @@ -1228,6 +1234,8 @@ Display the fiber id, the fiber status, and gvar (gvar will have gone up a bit more depending how long the pause lasted). This time the status is dead because the cancel worked.<programlisting> <prompt>tarantool></prompt><userinput> fiber.cancel(fiber_of_x)</userinput> +... fiber `lua' has been cancelled +... fiber `lua': exiting --- ... <prompt>tarantool></prompt><userinput> '#',fid,'. ',fiber.status(fiber_of_x),'. gvar=',gvar</userinput>