Skip to content
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

Fix select() by space_no and index_name #142

Merged
merged 1 commit into from
Jul 17, 2020

Conversation

bigbes
Copy link
Contributor

@bigbes bigbes commented Dec 2, 2018

When a space exists, but a client side schema does not know about it at
the moment (say, right after connection), and when a user calls select()
with a space id (number) and name of an index (string), the problem
appears: the client raises the following error:

TarantoolParsingException: Failed to parse schema (index)

However it should successfully perform the request.

The problem is that when there is no record for a space in client's
schema, it is not possible to save a record for an index of this space.

The idea of the fix is to verify whether we know about a space even when
a numeric ID is already provided. If a client has no record about the
space, it fetches a schema and verify whether the space appears. If so,
there is no more problem described above. Otherwise the client raises an
error that the space with given ID does not exist.

While we're here, ensure that return values of tarantool_schema_*() are
checked against -1, not Zend's FAILURE macro (which is only guaranteed
to be less than zero) in the modified code. Also ensure that the FAILURE
macro is returned from the get_spaceno_by_name() function, not -1.

Closes #42

Copy link
Member

@Totktonada Totktonada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay except minor comments.

src/tarantool_schema.c Outdated Show resolved Hide resolved
src/tarantool_schema.c Outdated Show resolved Hide resolved
@MariaHajdic MariaHajdic force-pushed the gh-42-fetch-schema-anyway branch 2 times, most recently from 4cb7778 to 8b8d09e Compare June 16, 2020 19:06
@MariaHajdic MariaHajdic force-pushed the gh-42-fetch-schema-anyway branch from bd6232c to f3ba38f Compare June 19, 2020 12:45
@Totktonada Totktonada changed the base branch from php7-v2 to master June 29, 2020 22:14
src/tarantool.c Outdated Show resolved Hide resolved
src/tarantool.c Outdated Show resolved Hide resolved
src/tarantool.c Outdated Show resolved Hide resolved
src/tarantool.c Outdated Show resolved Hide resolved
src/tarantool_schema.c Outdated Show resolved Hide resolved
test/DMLTest.php Outdated Show resolved Hide resolved
test/DMLTest.php Outdated Show resolved Hide resolved
src/tarantool.c Outdated Show resolved Hide resolved
test/DMLTest.php Outdated Show resolved Hide resolved
@Totktonada Totktonada changed the title Internal error on index schema fetch without schema space fetch Fix error on index schema fetch without schema space fetch Jul 13, 2020
@Totktonada Totktonada force-pushed the gh-42-fetch-schema-anyway branch from f3ba38f to fee11d4 Compare July 13, 2020 22:28
@Totktonada Totktonada requested a review from LeonidVas July 13, 2020 22:36
@Totktonada
Copy link
Member

@LeonidVas Please, look at this briefly if time permits. I think the patch in the good state now, but it would be good if you'll glance.

@LeonidVas
Copy link
Contributor

@LeonidVas Please, look at this briefly if time permits. I think the patch in the good state now, but it would be good if you'll glance.

Hi! @bigbes , thank you for the PR. Generally LGTM.
But I'm confused by mixing FAILURE from the ZEND_RESULT_CODE enum and -1.
We don't have any guarantee that it will always be -1 and can't check -1 == FAILURE. From a comment to ZEND_RESULT_CODE: "this MUST stay a negative number", not exactly -1. On the other hand, I agree that such things rarely change. So, Up to you @Totktonada .

When a space exists, but a client side schema does not know about it at
the moment (say, right after connection), and when a user calls select()
with a space id (number) and name of an index (string), the problem
appears: the client raises the following error:

 | TarantoolParsingException: Failed to parse schema (index)

However it should successfully perform the request.

The problem is that when there is no record for a space in client's
schema, it is not possible to save a record for an index of this space.

The idea of the fix is to verify whether we know about a space even when
a numeric ID is already provided. If a client has no record about the
space, it fetches a schema and verify whether the space appears. If so,
there is no more problem described above. Otherwise the client raises an
error that the space with given ID does not exist.

While we're here, ensure that return values of tarantool_schema_*() are
checked against -1, not Zend's FAILURE macro (which is only guaranteed
to be less than zero) in the modified code. Also ensure that the FAILURE
macro is returned from the get_spaceno_by_name() function, not -1.

Closes tarantool#42

@Totktonada: polish code, polish test, write the description.
@Totktonada Totktonada force-pushed the gh-42-fetch-schema-anyway branch from fee11d4 to 50d9e71 Compare July 17, 2020 08:56
@Totktonada Totktonada changed the title Fix error on index schema fetch without schema space fetch Fix select() by space_no and index_name Jul 17, 2020
@Totktonada
Copy link
Member

@LeonidVas I agree. Fixed and added the following paragraph into the commit message:

While we're here, ensure that return values of tarantool_schema_*() are
checked against -1, not Zend's FAILURE macro (which is only guaranteed
to be less than zero) in the modified code. Also ensure that the FAILURE
macro is returned from the get_spaceno_by_name() function, not -1.

@Totktonada Totktonada merged commit 5647d24 into tarantool:master Jul 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Internal error on select by a space id and an index name
4 participants