-
Notifications
You must be signed in to change notification settings - Fork 24
Updated PHPUnit to version 7 + gh-24 + gh-42 + gh-85 + gh-83 + gh-71 #134
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
Changes from 3 commits
108b658
e93c8ed
e50e288
35daa0a
bf6ef57
13d2653
4567e20
6453c4b
dd8b8fe
5546eae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ Makefile.in | |
/config.nice | ||
/config.status | ||
/config.sub | ||
/configure.ac | ||
/configure.in | ||
/libtool | ||
/ltmain.sh | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -391,6 +391,7 @@ static zend_object *tarantool_create(zend_class_entry *entry) { | |
obj = (tarantool_object *)pecalloc(1, sizeof(tarantool_object) + | ||
sizeof(zval) * (entry->default_properties_count - 1), 0); | ||
zend_object_std_init(&obj->zo, entry); | ||
object_properties_init(&obj->zo, entry); | ||
obj->zo.handlers = &tarantool_obj_handlers; | ||
|
||
return &obj->zo; | ||
|
@@ -628,6 +629,55 @@ int convert_iterator(zval *iter, int all) { | |
return -1; | ||
} | ||
|
||
int obtain_space_by_spaceno(tarantool_connection *obj, uint32_t space_no) { | ||
if (tarantool_schema_has_space_no(obj->schema, space_no)) { | ||
return 0; | ||
} | ||
|
||
tarantool_tp_update(obj->tps); | ||
tp_select(obj->tps, SPACE_SPACE, INDEX_SPACE_NO, 0, 4096); | ||
tp_key(obj->tps, 1); | ||
tp_encode_uint(obj->tps, space_no); | ||
tp_reqid(obj->tps, TARANTOOL_G(sync_counter)++); | ||
|
||
obj->value->len = tp_used(obj->tps); | ||
tarantool_tp_flush(obj->tps); | ||
|
||
if (tarantool_stream_send(obj) == FAILURE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This block (here and below) was mostly copy-pasted from |
||
return FAILURE; | ||
|
||
char pack_len[5] = {0, 0, 0, 0, 0}; | ||
if (tarantool_stream_read(obj, pack_len, 5) == FAILURE) | ||
return FAILURE; | ||
size_t body_size = php_mp_unpack_package_size(pack_len); | ||
smart_string_ensure(obj->value, body_size); | ||
if (tarantool_stream_read(obj, obj->value->c, | ||
body_size) == FAILURE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Underindented. |
||
return FAILURE; | ||
|
||
struct tnt_response resp; memset(&resp, 0, sizeof(struct tnt_response)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: two operators on the same line. |
||
if (php_tp_response(&resp, obj->value->c, body_size) == -1) { | ||
tarantool_throw_parsingexception("query"); | ||
return FAILURE; | ||
} | ||
|
||
if (resp.error) { | ||
tarantool_throw_clienterror(resp.code, resp.error, | ||
resp.error_len); | ||
return FAILURE; | ||
} | ||
|
||
if (tarantool_schema_add_spaces(obj->schema, resp.data, resp.data_len)) { | ||
tarantool_throw_parsingexception("schema (space)"); | ||
return FAILURE; | ||
} | ||
if (!tarantool_schema_has_space_no(obj->schema, space_no)) { | ||
THROW_EXC("No space %u defined", space_no); | ||
return FAILURE; | ||
} | ||
return 0; | ||
} | ||
|
||
int get_spaceno_by_name(tarantool_connection *obj, zval *name) { | ||
if (Z_TYPE_P(name) == IS_LONG) | ||
return Z_LVAL_P(name); | ||
|
@@ -694,6 +744,11 @@ int get_indexno_by_name(tarantool_connection *obj, int space_no, | |
THROW_EXC("Index ID must be String or Long"); | ||
return FAILURE; | ||
} | ||
|
||
if (obtain_space_by_spaceno(obj, space_no) == FAILURE) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this call should be a part of get_spaceno_by_name. |
||
return FAILURE; | ||
} | ||
|
||
int32_t index_no = tarantool_schema_get_iid_by_string(obj->schema, | ||
space_no, Z_STRVAL_P(name), Z_STRLEN_P(name)); | ||
if (index_no != FAILURE) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,27 +14,41 @@ | |
#define MUR_SEED 13 | ||
#include "third_party/msgpuck.h" | ||
|
||
int mh_indexcmp_eq( | ||
const struct schema_index_value **lval, | ||
const struct schema_index_value **rval, | ||
void *arg | ||
) { | ||
(void )arg; | ||
if ((*lval)->key.id_len != (*rval)->key.id_len) | ||
return 0; | ||
return !memcmp((*lval)->key.id, (*rval)->key.id, (*rval)->key.id_len); | ||
} | ||
#define MH_DEFINE_CMPFUNC(NAME, TYPE) \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I trying to retain myself from formatting nitpicking, but here the entire block formatted with exceeding 80 symbols limit. |
||
int mh_##NAME##cmp_eq(const TYPE **lval, const TYPE **rval, void *arg) { \ | ||
(void *) arg; \ | ||
if ((*lval)->key.id_len != (*rval)->key.id_len) \ | ||
return 0; \ | ||
return !memcmp((*lval)->key.id, (*rval)->key.id, (*rval)->key.id_len); \ | ||
} \ | ||
\ | ||
int mh_##NAME##cmp_key_eq(const struct schema_key *key, const TYPE **val, void *arg) { \ | ||
(void *) arg; \ | ||
if (key->id_len != (*val)->key.id_len) \ | ||
return 0; \ | ||
return !memcmp(key->id, (*val)->key.id, key->id_len); \ | ||
} | ||
MH_DEFINE_CMPFUNC(field, struct schema_field_value); | ||
MH_DEFINE_CMPFUNC(index, struct schema_index_value); | ||
MH_DEFINE_CMPFUNC(space, struct schema_space_value); | ||
#undef MH_DEFINE_CMPFUNC | ||
|
||
int mh_indexcmp_key_eq( | ||
const struct schema_key *key, | ||
const struct schema_index_value **val, | ||
void *arg | ||
) { | ||
(void )arg; | ||
if (key->id_len != (*val)->key.id_len) | ||
return 0; | ||
return !memcmp(key->id, (*val)->key.id, key->id_len); | ||
} | ||
#define mh_arg_t void * | ||
|
||
#define mh_eq(a, b, arg) mh_fieldcmp_eq(a, b, arg) | ||
#define mh_eq_key(a, b, arg) mh_fieldcmp_key_eq(a, b, arg) | ||
#define mh_hash(x, arg) PMurHash32(MUR_SEED, (*x)->key.id, (*x)->key.id_len) | ||
#define mh_hash_key(x, arg) PMurHash32(MUR_SEED, (x)->id, (x)->id_len); | ||
|
||
#define mh_node_t struct schema_field_value * | ||
#define mh_key_t struct schema_key * | ||
|
||
#define MH_CALLOC(x, y) pecalloc((x), (y), 1) | ||
#define MH_FREE(x) pefree((x), 1) | ||
|
||
#define mh_name _schema_field | ||
#define MH_SOURCE 1 | ||
#include "third_party/mhash.h" | ||
|
||
#define mh_arg_t void * | ||
|
||
|
@@ -79,7 +93,7 @@ schema_index_free(struct mh_schema_index_t *schema) { | |
do { | ||
struct schema_key key_number = { | ||
(void *)&(ivalue->index_number), | ||
sizeof(uint32_t), 0 | ||
sizeof(ivalue->index_number), 0 | ||
}; | ||
index_slot = mh_schema_index_find(schema, &key_number, | ||
NULL); | ||
|
@@ -106,28 +120,6 @@ schema_index_free(struct mh_schema_index_t *schema) { | |
} | ||
} | ||
|
||
int | ||
mh_spacecmp_eq( | ||
const struct schema_space_value **lval, | ||
const struct schema_space_value **rval, | ||
void *arg) { | ||
(void )arg; | ||
if ((*lval)->key.id_len != (*rval)->key.id_len) | ||
return 0; | ||
return !memcmp((*lval)->key.id, (*rval)->key.id, (*rval)->key.id_len); | ||
} | ||
|
||
int | ||
mh_spacecmp_key_eq( | ||
const struct schema_key *key, | ||
const struct schema_space_value **val, | ||
void *arg) { | ||
(void )arg; | ||
if (key->id_len != (*val)->key.id_len) | ||
return 0; | ||
return !memcmp(key->id, (*val)->key.id, key->id_len); | ||
} | ||
|
||
#define mh_arg_t void * | ||
|
||
#define mh_eq(a, b, arg) mh_spacecmp_eq(a, b, arg) | ||
|
@@ -158,6 +150,9 @@ schema_space_value_free(const struct schema_space_value *val) { | |
schema_index_free(val->index_hash); | ||
mh_schema_index_delete(val->index_hash); | ||
} | ||
if (val->schema_hash) { | ||
mh_schema_field_delete(val->schema_hash); | ||
} | ||
} | ||
} | ||
|
||
|
@@ -263,6 +258,11 @@ parse_schema_space_value(struct schema_space_value *space_string, | |
goto error; | ||
} | ||
val->field_number = i; | ||
val->key.id = val->field_name; | ||
val->key.id_len = val->field_name_len; | ||
mh_schema_field_put(space_string->schema_hash, | ||
(const struct schema_field_value **)&val, | ||
NULL, NULL); | ||
} | ||
return 0; | ||
error: | ||
|
@@ -367,6 +367,7 @@ schema_add_space( | |
* } | ||
*/ | ||
case 6: | ||
space_string->schema_hash = mh_schema_field_new(); | ||
if (parse_schema_space_value(space_string, &tuple) < 0) | ||
goto error; | ||
break; | ||
|
@@ -398,6 +399,21 @@ schema_add_space( | |
return -1; | ||
} | ||
|
||
int | ||
tarantool_schema_has_space_no( | ||
struct tarantool_schema *schema_obj, | ||
uint32_t space_no) { | ||
/* Prepare key for space search */ | ||
struct schema_key space_key; | ||
space_key.number = space_no; | ||
space_key.id = (void *)&(space_key.number); | ||
space_key.id_len = sizeof(uint32_t); | ||
|
||
struct mh_schema_space_t *schema = schema_obj->space_hash; | ||
mh_int_t space_slot = mh_schema_space_find(schema, &space_key, NULL); | ||
return (space_slot != mh_end(schema)); | ||
} | ||
|
||
int | ||
tarantool_schema_add_spaces( | ||
struct tarantool_schema *schema_obj, | ||
|
@@ -590,23 +606,21 @@ tarantool_schema_get_fid_by_string( | |
struct tarantool_schema *schema_obj, uint32_t sid, | ||
const char *field_name, uint32_t field_name_len | ||
) { | ||
struct mh_schema_space_t *schema = schema_obj->space_hash; | ||
struct schema_key space_key = { | ||
(void *)&sid, | ||
sizeof(uint32_t), 0 | ||
}; | ||
mh_int_t space_slot = mh_schema_space_find(schema, &space_key, NULL); | ||
if (space_slot == mh_end(schema)) | ||
struct mh_schema_space_t *sschema = schema_obj->space_hash; | ||
struct schema_key space_key = { (void *)&sid, sizeof(uint32_t), 0 }; | ||
mh_int_t space_slot = mh_schema_space_find(sschema, &space_key, NULL); | ||
if (space_slot == mh_end(sschema)) | ||
return -1; | ||
const struct schema_space_value *space = *mh_schema_space_node(schema, | ||
const struct schema_space_value *space = *mh_schema_space_node(sschema, | ||
space_slot); | ||
int i = 0; | ||
for (i = 0; i < space->schema_list_len; ++i) { | ||
struct schema_field_value *val = &space->schema_list[i]; | ||
if (strncmp(val->field_name, field_name, field_name_len) == 0) | ||
return val->field_number; | ||
} | ||
return -1; | ||
struct schema_key field_key = { field_name, field_name_len, 0 }; | ||
struct mh_schema_field_t *fschema = space->schema_hash; | ||
mh_int_t field_slot = mh_schema_field_find(fschema, &field_key, NULL); | ||
if (field_slot == mh_end(fschema)) | ||
return -1; | ||
const struct schema_field_value *field = *mh_schema_field_node(fschema, | ||
field_slot); | ||
return field->field_number; | ||
} | ||
|
||
struct tarantool_schema *tarantool_schema_new(int is_persistent) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to use
0o777
, should work with python2 and python3 both.