Skip to content
Snippets Groups Projects
Commit 30d9ae98 authored by Nick's avatar Nick
Browse files

add upsert information

parent df638557
No related merge requests found
...@@ -109,6 +109,7 @@ Let's list them here too: ...@@ -109,6 +109,7 @@ Let's list them here too:
<function_name> ::= 0x22 <function_name> ::= 0x22
<username> ::= 0x23 <username> ::= 0x23
<expression> ::= 0x27 <expression> ::= 0x27
<def_tuple> ::= 0x28
<data> ::= 0x30 <data> ::= 0x30
<error> ::= 0x31 <error> ::= 0x31
...@@ -124,6 +125,7 @@ Let's list them here too: ...@@ -124,6 +125,7 @@ Let's list them here too:
<call> ::= 0x06 <call> ::= 0x06
<auth> ::= 0x07 <auth> ::= 0x07
<eval> ::= 0x08 <eval> ::= 0x08
<upsert> ::= 0x09
-- Admin command codes -- Admin command codes
<ping> ::= 0x40 <ping> ::= 0x40
...@@ -378,6 +380,48 @@ It's an error to specify an argument of a type that differs from expected type. ...@@ -378,6 +380,48 @@ It's an error to specify an argument of a type that differs from expected type.
MP_MAP MP_MAP
* UPSERT: CODE - 0x09
Update tuple if it would be found elsewhere try to insert tuple. Always use primary index for key.
.. code-block:: bash
UPSERT BODY:
+==================+==========================+
| | |
| 0x10: SPACE_ID | 0x20: KEY |
| MP_INT: MP_INT | MP_INT: MP_ARRAY |
| | |
+==================+==========================+
| | +~~~~~~~~~~+ |
| | | | |
| | (DEF_TUPLE) | OP | |
| 0x21: TUPLE | 0x28: | | |
| MP_INT: MP_ARRAY | MP_INT: +~~~~~~~~~~+ |
| | MP_ARRAY |
+==================+==========================+
MP_MAP
Operations structure same as for UPDATE operation.
0 2
+-----------+==========+==========+
| | | |
| OP | FIELD_NO | ARGUMENT |
| MP_FIXSTR | MP_INT | MP_INT |
| | | |
+-----------+==========+==========+
MP_ARRAY
Support operations:
'+' - add a value to a numeric field. If the filed is not numeric, it's changed to 0 first. If the field does not exist, the operation is skipped. There is no error in case of overflow either, the value simply wraps around in C style. The range of the integer is MsgPack: from -2^63 to 2^64-1
'-' - same as the previous, but subtract a value
'=' - assign a field to a value. The field must exist, if it does not exist, the operation is skipped.
'!' - insert a field. It's only possible to insert a field if this create no nil "gaps" between fields. E.g. it's possible to add a field between existing fields or as the last field of the tuple.
'#' - delete a field. If the field does not exist, the operation is skipped. It's not possible to change with update operations a part of the primary key (this is validated before performing upsert).
================================================================================ ================================================================================
Response packet structure Response packet structure
================================================================================ ================================================================================
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment