Skip to content

Update SQL IPROTO codes #467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Gerold103 opened this issue Mar 20, 2018 · 6 comments
Closed

Update SQL IPROTO codes #467

Gerold103 opened this issue Mar 20, 2018 · 6 comments
Labels
low_priority [prio] Background task reference [location] Tarantool manual, Reference part server [area] Task relates to Tarantool's server (core) functionality
Milestone

Comments

@Gerold103
Copy link
Contributor

After tarantool/tarantool@43e03e6 IPROTO_FIELD_NAME has code 0 instead of 0x29.

@lenkis lenkis added reference [location] Tarantool manual, Reference part server [area] Task relates to Tarantool's server (core) functionality 2.0 low_priority [prio] Background task labels Mar 21, 2018
@lenkis lenkis assigned lenkis and unassigned llelik8 Apr 19, 2018
@lenkis lenkis added the blocked Not ready to be implemented label Apr 20, 2018
@lenkis
Copy link
Contributor

lenkis commented Apr 20, 2018

To be documented when this RFC is fully implemented:
https://github.com/tarantool/tarantool/blob/gh-3328-new-iproto/doc/rfc/3328-wire_protocol.md

At that point we'll need to add new info to "Internals":

(1) universal response packet structure (sent in response to both SQL and non-SQL queries) that will contain new fields:

+----------------------------------------------+
| IPROTO_BODY: {                               |
|     IPROTO_METADATA: [                       |
|         {                                    |
|             IPROTO_FIELD_NAME: string,       |
|             IPROTO_FIELD_TYPE: number,       |
|             IPROTO_FIELD_FLAGS: number,      |
|         },                                   |
|         ...                                  |
|     ],                                       |
|                                              |
|     IPROTO_SQL_INFO: {                       |
|         SQL_INFO_ROW_COUNT: number,          |
|         SQL_INFO_LAST_ID: number,            |
|         ...                                  |
|     },                                       |
|                                              |
|     IPROTO_DATA: [                           |
|         tuple/scalar,                        |
|         ...                                  |
|     ]                                        |
| }                                            |
+----------------------------------------------+

New fields are: IPROTO_METADATA with nested fields + IPROTO_SQL_INFO with nested fields.

(2) example of a multi-packet response to SQL queries
Query example:

FUNCTION my_sql_func(a1, a2, a3, a4) BEGIN
    SELECT my_lua_func(a1);
    SELECT * FROM table1;
    SELECT my_c_func(a2);
    INSERT INTO table1 VALUES (1, 2, 3);
    RETURN a4;
END

Response example (split into several packets if SQL reply data is too big):

/* Push from my_lua_func(a1). */
+----------------------------------------------+
| HEADER: IPROTO_CHUNK                         |
+- - - - - - - - - - - - - - - - - - - - - - - +
| BODY: {                                      |
|     IPROTO_DATA: [ a1 ]                      |
| }                                            |
+----------------------------------------------+

/* Result of SELECT my_lua_func(a1). */
+----------------------------------------------+
| HEADER: IPROTO_CHUNK                         |
+- - - - - - - - - - - - - - - - - - - - - - - +
| BODY: {                                      |
|     IPROTO_DATA: [ [ a1 ] ],                 |
|     IPROTO_METADATA: [                       |
|         { /* field name, type ... */ }       |
|     ]                                        |
| }                                            |
+----------------------------------------------+

/* First chunk of SELECT * FROM table1. */
+----------------------------------------------+
| HEADER: IPROTO_CHUNK, IPROTO_CHUNK_ID = <id1>|
+- - - - - - - - - - - - - - - - - - - - - - - +
| BODY: {                                      |
|    IPROTO_DATA: [ tuple1, tuple2, ... ]      |
|    IPROTO_METADATA: [                        |
|        { /* field1 name, type ... */ },      |
|        { /* field2 name, type ... */ },      |
|        ...                                   |
|    ]                                         |
| }                                            |
+----------------------------------------------+

        /* From second to next to last chunk. */
	+----------------------------------------------+
	| HEADER: IPROTO_CHUNK, IPROTO_CHUNK_ID = <id1>|
	+- - - - - - - - - - - - - - - - - - - - - - - +
	| BODY: {                                      |
	|    IPROTO_DATA: [ tuple1, tuple2, ... ]      |
	| }                                            |
	+----------------------------------------------+

	/* Last chunk. */
	+----------------------------------------------+
	| HEADER: IPROTO_CHUNK, IPROTO_CHUNK_ID = <id1>|
	+- - - - - - - - - - - - - - - - - - - - - - - +
	| BODY: {                                      |
	|    IPROTO_DATA: [ tuple1, tuple2, ... ]      |
	| }                                            |
	+----------------------------------------------+

/* Result of SELECT my_c_func(a2). */
+----------------------------------------------+
| HEADER: IPROTO_CHUNK                         |
+- - - - - - - - - - - - - - - - - - - - - - - +
| BODY: {                                      |
|     IPROTO_DATA: [ [ tuple ] ],              |
|     IPROTO_METADATA: [                       |
|         { /* field name, type ... */ }       |
|     ]                                        |
| }                                            |
+----------------------------------------------+

/* Result of INSERT INTO table1 VALUES (1, 2, 3). */
+----------------------------------------------+
| HEADER: IPROTO_CHUNK                         |
+- - - - - - - - - - - - - - - - - - - - - - - +
| BODY: {                                      |
|     IPROTO_SQL_INFO: {                       |
|         SQL_INFO_ROW_COUNT: number,          |
|         SQL_INFO_LAST_ID: number,            |
|     }                                        |
| }                                            |
+----------------------------------------------+

/* Result of RETURN a4 */
+----------------------------------------------+
| HEADER: IPROTO_OK                            |
+- - - - - - - - - - - - - - - - - - - - - - - +
| BODY: {                                      |
|     IPROTO_DATA: [ a4 ]                      |
| }                                            |
+----------------------------------------------+

(3) state machine diagram: https://github.com/tarantool/tarantool/blob/gh-3328-new-iproto/doc/rfc/3328-wire_protocol_img1.svg

@lenkis lenkis assigned llelik8 and unassigned lenkis Apr 20, 2018
@Gerold103
Copy link
Contributor Author

Please, update the link to the state machine image - I have uploaded svg instead of png right now.

@lenkis
Copy link
Contributor

lenkis commented Apr 20, 2018

done

@lenkis lenkis added this to the August2018 milestone Jul 9, 2018
@lenkis lenkis assigned lenkis and unassigned llelik8 Nov 19, 2018
@Totktonada
Copy link
Member

Note: We have SQL_INFO_AUTOINCREMENT_IDS instead of SQL_INFO_LAST_ID now.

@Totktonada
Copy link
Member

It seems it is done.

@lenkis lenkis assigned veod32 and unassigned lenkis Dec 25, 2019
@lenkis lenkis removed the blocked Not ready to be implemented label Dec 25, 2019
@lenkis
Copy link
Contributor

lenkis commented Dec 25, 2019

@veod32 please double-check what is done and add everything what is still missing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
low_priority [prio] Background task reference [location] Tarantool manual, Reference part server [area] Task relates to Tarantool's server (core) functionality
Projects
None yet
Development

No branches or pull requests

6 participants