Skip to content

Commit

Permalink
field type changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pgulutzan committed Aug 11, 2016
1 parent 1b0b8cc commit 1b14b2e
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 69 deletions.
7 changes: 3 additions & 4 deletions sphinx/book/administration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,7 @@ described in `Lua documentation`_. Examples: 'Hello, world', 'A', [[A\\B!]].
Numeric literals are: Character sequences containing only digits, optionally
preceded by + or -. Large or floating-point numeric
literals may include decimal points, exponential notation, or suffixes.
Examples: 500, -500, 5e2, 500.1, 5LL, 5ULL. Notes: Tarantool NUM data type is
unsigned, so -1 is understood as a large unsigned number.
Examples: 500, -500, 5e2, 500.1, 5LL, 5ULL.

Single-byte tokens are: , or ( or ) or arithmetic operators. Examples: * , ( ).

Expand Down Expand Up @@ -210,7 +209,7 @@ an interactive-mode tarantool client session:
[ tarantool may display an in-progress message here ]
---
...
tarantool> s:create_index('primary', {type = 'hash', parts = {1, 'NUM'}})
tarantool> s:create_index('primary', {type = 'hash', parts = {1, 'unsigned'}})
---
...
tarantool> box.space.tester:insert{1,'My first tuple'}
Expand Down Expand Up @@ -1306,7 +1305,7 @@ The request to make in this case is: :codenormal:`box.schema.upgrade()`.
For example, here is what happens when one runs :codenormal:`box.schema.upgrade()`
with a database that was created in early 2015. Only a small part of the output is shown. |br|
:codenormal:`tarantool>` :codebold:`box.schema.upgrade()` |br|
:codenormal:`alter index primary on _space set options to {"unique":true}, parts to [[0,"num"]]` |br|
:codenormal:`alter index primary on _space set options to {"unique":true}, parts to [[0,"unsigned"]]` |br|
:codenormal:`alter space _schema set options to {}` |br|
:codenormal:`create view _vindex...` |br|
:codenormal:`grant read access to 'public' role for _vindex view` |br|
Expand Down
10 changes: 5 additions & 5 deletions sphinx/book/app/c_lua_tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ defined the same way as the sandbox database that was introduced in
-- if tester is left over from some previous test, destroy it
box.space.tester:drop()
box.schema.space.create('tester')
box.space.tester:create_index('primary', {parts = {1, 'NUM'}})
box.space.tester:create_index('primary', {parts = {1, 'unsigned'}})
then add some tuples where the first field is a number and the second
field is a string.
Expand Down Expand Up @@ -642,8 +642,8 @@ explanations that follow the code.
if (box.space[space_name].index[i] == nil) then break end
if (box.space[space_name].index[i].type == "TREE"
and box.space[space_name].index[i].parts[1].fieldno == field_no
and (box.space[space_name].index[i].parts[1].type == "SCALAR"
or box.space[space_name].index[i].parts[1].type == "STR")) then
and (box.space[space_name].index[i].parts[1].type == "scalar"
or box.space[space_name].index[i].parts[1].type == "string")) then
index_no = i
break
end
Expand Down Expand Up @@ -728,7 +728,7 @@ The requirements are: |br|
will not return strings in order by string value; |br|
(b) field_no must be the first index part; |br|
(c) the field must contain strings, because for other data types
(such as "NUM") pattern searches are not possible; |br|
(such as "unsigned") pattern searches are not possible; |br|
If these requirements are not met by any index, then
print an error message and return nil.

Expand Down Expand Up @@ -817,7 +817,7 @@ and try the following: |br|
:codebold:`box.space.t:drop()` |br|
:codebold:`box.schema.space.create('t')` |br|
:codebold:`box.space.t:create_index('primary',{})` |br|
:codebold:`box.space.t:create_index('secondary',{unique=false,parts={2,'STR',3,'STR'}})` |br|
:codebold:`box.space.t:create_index('secondary',{unique=false,parts={2,'string',3,'string'}})` |br|
:codebold:`box.space.t:insert{1,'A','a'}` |br|
:codebold:`box.space.t:insert{2,'AB',''}` |br|
:codebold:`box.space.t:insert{3,'ABC','a'}` |br|
Expand Down
2 changes: 1 addition & 1 deletion sphinx/book/app/e_cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Then use :ref:`console.start() <console-start>` to start interactive mode.
box.once("bootstrap", function()
box.schema.space.create('tweedledum')
box.space.tweedledum:create_index('primary',
{ type = 'TREE', parts = {1, 'NUM'}})
{ type = 'TREE', parts = {1, 'unsigned'}})
end)
require('console').start()
Expand Down
20 changes: 10 additions & 10 deletions sphinx/book/box/box_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ API is a direct binding to corresponding methods of index objects of type
---
- unique: true
parts:
- type: NUM
- type: unsigned
fieldno: 1
id: 0
space_id: 513
Expand Down Expand Up @@ -315,7 +315,7 @@ API is a direct binding to corresponding methods of index objects of type
---
...
tarantool> s:create_index('primary', {
> parts = {1, 'STR', 2, 'STR'}
> parts = {1, 'string', 2, 'string'}
> })
---
...
Expand Down Expand Up @@ -423,13 +423,13 @@ API is a direct binding to corresponding methods of index objects of type
tarantool> sp = box.schema.space.create('tester')
-- Create a unique index 'primary'
-- which won't be needed for this example.
tarantool> sp:create_index('primary', {parts = {1, 'NUM' }})
tarantool> sp:create_index('primary', {parts = {1, 'unsigned' }})
-- Create a non-unique index 'secondary'
-- with an index on the second field.
tarantool> sp:create_index('secondary', {
> type = 'tree',
> unique = false,
> parts = {2, 'STR'}
> parts = {2, 'string'}
> })
-- Insert three tuples, values in field[2]
-- equal to 'X', 'Y', and 'Z'.
Expand Down Expand Up @@ -494,12 +494,12 @@ API is a direct binding to corresponding methods of index objects of type
tarantool> s = box.schema.space.create('space_with_bitset')
tarantool> s:create_index('primary_index', {
> parts = {1, 'STR'},
> parts = {1, 'string'},
> unique = true,
> type = 'TREE'
> })
tarantool> s:create_index('bitset_index', {
> parts = {2, 'NUM'},
> parts = {2, 'unsigned'},
> unique = false,
> type = 'BITSET'
> })
Expand Down Expand Up @@ -882,7 +882,7 @@ manual section
It does paginated retrievals, that is, it returns 10
tuples at a time from a table named "t", whose
primary key was defined with
:codenormal:`create_index('primary',{parts={1,'STR'}})`.
:codenormal:`create_index('primary',{parts={1,'string'}})`.

.. code-block:: lua
Expand Down Expand Up @@ -968,7 +968,7 @@ Now let us create a space and add an RTREE index.
tarantool> s = box.schema.space.create('rectangles')
tarantool> i = s:create_index('primary', {
> type = 'HASH',
> parts = {1, 'NUM'}
> parts = {1, 'unsigned'}
> })
tarantool> r = s:create_index('rtree', {
> type = 'RTREE',
Expand Down Expand Up @@ -1022,7 +1022,7 @@ Now let us create a space and index for cuboids, which are rectangle-or-boxes th
.. code-block:: tarantoolsession
tarantool> s = box.schema.space.create('R')
tarantool> i = s:create_index('primary', {parts = {1, 'NUM'}})
tarantool> i = s:create_index('primary', {parts = {1, 'unsigned'}})
tarantool> r = s:create_index('S', {
> type = 'RTREE',
> unique = false,
Expand All @@ -1045,7 +1045,7 @@ a different way to calculate neighbors.
.. code-block:: tarantoolsession
tarantool> s = box.schema.space.create('R')
tarantool> i = s:create_index('primary', {parts = {1, 'NUM'}})
tarantool> i = s:create_index('primary', {parts = {1, 'unsigned'}})
tarantool> r = s:create_index('S', {
> type = 'RTREE',
> unique = false,
Expand Down
52 changes: 28 additions & 24 deletions sphinx/book/box/box_space.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,10 @@ A list of all ``box.space`` functions follows, then comes a list of all
| if_not_exists | no error if | boolean | ``false`` |
| | duplicate name | | |
+---------------+--------------------+-----------------------------+---------------------+
| parts | field-numbers + | {field_no, 'NUM' or 'STR' | ``{1, 'NUM'}`` |
| | types | or 'INT' or 'NUMBER' or | |
| | | 'ARRAY' or 'SCALAR'} | |
| parts | field-numbers + | {field_no, 'unsigned' or | ``{1, 'unsigned'}`` |
| | types | 'string' or 'integer' or | |
| | | 'number' or 'array' or | |
| | | 'scalar'} | |
+---------------+--------------------+-----------------------------+---------------------+

Possible errors: too many parts. Index '...' already exists. Primary key must be unique.
Expand All @@ -164,27 +165,30 @@ A list of all ``box.space`` functions follows, then comes a list of all
tarantool> s = box.space.space55
---
...
tarantool> s:create_index('primary', {unique = true, parts = {1, 'NUM', 2, 'STR'}})
tarantool> s:create_index('primary', {unique = true, parts = {1, 'unsigned', 2, 'string'}})
---
...
.. _details_about_index_field_types:

Details about index field types: |br|
The six index field types (NUM | STR | INT | NUMBER | ARRAY | SCALAR)
The six index field types (unsigned | string | integer | number | array | scalar)
differ depending on what values are allowed, and what index types are allowed. |br|
NUM: unsigned integers between 0 and 18446744073709551615, about 18 quintillion.
**unsigned**: unsigned integers between 0 and 18446744073709551615, about 18 quintillion.
May also be called 'uint' or 'num', but 'num' is deprecated.
Legal in memtx TREE or HASH indexes, and in vinyl TREE indexes. |br|
STR: strings -- any set of octets, up to the :ref:`maximum length <limitations_bytes_in_index_key>`.
**string**: any set of octets, up to the :ref:`maximum length <limitations_bytes_in_index_key>`.
May also be called 'str'.
Legal in memtx TREE or HASH or BITSET indexes, and in vinyl TREE indexes. |br|
INT: integers between -9223372036854775808 and 18446744073709551615.
**integer**: integers between -9223372036854775808 and 18446744073709551615.
May also be called 'int'.
Legal in memtx TREE or HASH indexes, and in vinyl TREE indexes. |br|
NUMBER: integers between -9223372036854775808 and 18446744073709551615,
**number**: integers between -9223372036854775808 and 18446744073709551615,
single-precision floating point numbers, or double-precision floating point numbers.
Legal in memtx TREE or HASH indexes, and in vinyl TREE indexes. |br|
ARRAY: array of integers between -9223372036854775808 and 9223372036854775807.
**array**: array of integers between -9223372036854775808 and 9223372036854775807.
Legal in memtx RTREE indexes. |br|
SCALAR: booleans (true or false), or integers between -9223372036854775808 and 18446744073709551615,
**scalar**: booleans (true or false), or integers between -9223372036854775808 and 18446744073709551615,
or single-precision floating point numbers, or double-precison floating-point numbers,
or strings. When there is a mix of types, the key order is: booleans, then numbers, then strings.
Legal in memtx TREE or HASH indexes, and in vinyl TREE indexes.
Expand All @@ -202,30 +206,30 @@ A list of all ``box.space`` functions follows, then comes a list of all
+------------------+---------------------------+---------------------------------------+-------------------+
| Index field type | What can be in it | Where is it legal | Examples |
+------------------+---------------------------+---------------------------------------+-------------------+
| **NUM** | integers between 0 and | memtx TREE or HASH | 123456 |br| |
| **unsigned** | integers between 0 and | memtx TREE or HASH | 123456 |br| |
| | 18446744073709551615 | indexes, |br| | |
| | | vinyl TREE indexes | |
+------------------+---------------------------+---------------------------------------+-------------------+
| **STR** | strings -- any set of | memtx TREE or HASH indexes |br| | 'A B C' |br| |
| **string** | strings -- any set of | memtx TREE or HASH indexes |br| | 'A B C' |br| |
| | octets | vinyl TREE indexes | '\\65 \\66 \\67' |
+------------------+---------------------------+---------------------------------------+-------------------+
| **INT** | integers between | memtx TREE or HASH indexes, |br| | -2^63 |br| |
| **integer** | integers between | memtx TREE or HASH indexes, |br| | -2^63 |br| |
| | -9223372036854775808 and | vinyl TREE indexes | |
| | 18446744073709551615 | | |
+------------------+---------------------------+---------------------------------------+-------------------+
| **NUMBER** | integers between | memtx TREE or HASH indexes, |br| | 1.234 |br| |
| **number** | integers between | memtx TREE or HASH indexes, |br| | 1.234 |br| |
| | -9223372036854775808 and | vinyl TREE indexes | -44 |br| |
| | 18446744073709551615, | | 1.447e+44 |
| | single-precision | | |
| | floating point numbers, | | |
| | double-precision | | |
| | floating point numbers | | |
+------------------+---------------------------+---------------------------------------+-------------------+
| **ARRAY** | array of integers between | memtx RTREE indexes | {10, 11} |br| |
| **array** | array of integers between | memtx RTREE indexes | {10, 11} |br| |
| | -9223372036854775808 and | | {3, 5, 9, 10} |
| | 9223372036854775807 | | |
+------------------+---------------------------+---------------------------------------+-------------------+
| **SCALAR** | booleans (true or false), | memtx TREE or HASH indexes, |br| | true |br| |
| **scalar** | booleans (true or false), | memtx TREE or HASH indexes, |br| | true |br| |
| | integers between | vinyl TREE indexes | -1 |br| |
| | -9223372036854775808 and | | 1.234 |br| |
| | 18446744073709551615, | | '' |br| |
Expand Down Expand Up @@ -287,7 +291,7 @@ A list of all ``box.space`` functions follows, then comes a list of all
tarantool> s = box.schema.space.create('tmp', {temporary=true})
---
...
tarantool> s:create_index('primary',{parts = {1,'NUM', 2, 'STR'}})
tarantool> s:create_index('primary',{parts = {1,'unsigned', 2, 'string'}})
---
...
tarantool> s:insert{1,'A'}
Expand Down Expand Up @@ -505,7 +509,7 @@ A list of all ``box.space`` functions follows, then comes a list of all
**Example:**

Assume that the initial state of the database is ``tester`` that has
one tuple set and one primary key whose type is ``NUM``.
one tuple set and one primary key whose type is ``unsigned``.
There is one tuple, with ``field[1]`` = ``999`` and ``field[2]`` = ``'A'``.

In the update:
Expand Down Expand Up @@ -676,7 +680,7 @@ A list of all ``box.space`` functions follows, then comes a list of all
tarantool> box.space.tester:delete('a')
---
- error: 'Supplied key type of part 0 does not match index part type:
expected NUM'
expected unsigned'
...
.. _box_space-id:
Expand Down Expand Up @@ -840,7 +844,7 @@ A list of all ``box.space`` functions follows, then comes a list of all
.. method:: auto_increment{field-value [, field-value ...]}

Insert a new tuple using an auto-increment primary key. The space specified
by space_object must have a ``NUM`` primary key index of type ``TREE``. The
by space_object must have an ``unsigned`` or ``integer`` or ``numeric`` primary key index of type ``TREE``. The
primary-key field will be incremented before the insert.

.. NOTE::Note re storage engine (vinyl)
Expand Down Expand Up @@ -889,7 +893,7 @@ A list of all ``box.space`` functions follows, then comes a list of all
tarantool> s = box.schema.space.create('space33')
---
...
tarantool> -- index 'X' has default parts {1, 'NUM'}
tarantool> -- index 'X' has default parts {1, 'unsigned'}
tarantool> s:create_index('X', {})
---
...
Expand Down Expand Up @@ -1015,7 +1019,7 @@ A list of all ``box.space`` functions follows, then comes a list of all
tarantool> box.schema.space.create('TM', {
> format = {
> [1] = {["name"] = "field#1"},
> [2] = {["type"] = "num"}
> [2] = {["type"] = "unsigned"}
> }
> })
---
Expand All @@ -1031,7 +1035,7 @@ A list of all ``box.space`` functions follows, then comes a list of all
...
tarantool> box.space._space:select(522)
---
- - [522, 1, 'TM', 'memtx', 0, '', [{'name': 'field#1'}, {'type': 'num'}]]
- - [522, 1, 'TM', 'memtx', 0, {}, [{'name': 'field#1'}, {'type': 'unsigned'}]]
...
.. _box_space-index:
Expand Down
Loading

0 comments on commit 1b14b2e

Please sign in to comment.