Skip to content

Commit 3820b83

Browse files
authored
Merge pull request tarantool#132 from bigbes/php7-v2
Fixing problem caused by non-server fields in space `:format()`
2 parents 99ffbd0 + d0f1a59 commit 3820b83

File tree

4 files changed

+68
-50
lines changed

4 files changed

+68
-50
lines changed

src/tarantool.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ static int __tarantool_connect(tarantool_object *t_obj) {
271271
while (count > 0) {
272272
--count;
273273
if (err) {
274-
/* If we're here, then there war error */
274+
/* If we're here, then there was error */
275275
nanosleep(&sleep_time, NULL);
276276
efree(err);
277277
err = NULL;
@@ -301,7 +301,6 @@ static int __tarantool_connect(tarantool_object *t_obj) {
301301
}
302302
if (count == 0) {
303303
ioexception:
304-
// raise (SIGABRT);
305304
tarantool_throw_ioexception("%s", err);
306305
efree(err);
307306
return FAILURE;

src/tarantool_schema.c

+2
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ parse_schema_space_value_value(struct schema_field_value *fld,
232232
goto error;
233233
sfield = mp_decode_str(tuple, &sfield_len);
234234
fld->field_type = parse_field_type(sfield, sfield_len);
235+
} else {
236+
mp_next(tuple);
235237
}
236238
return 0;
237239
error:

test/DMLTest.php

+36-36
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public function test_16_hash_select() {
342342
self::$tarantool->select("test_hash", null, null, null, null, TARANTOOL::ITERATOR_EQ);
343343
$this->assertFalse(True);
344344
} catch (TarantoolClientError $e) {
345-
$this->assertContains('Invalid key part', $e->getMessage());
345+
$this->assertRegExp('(Invalid key part|via a partial key)', $e->getMessage());
346346
}
347347
}
348348

@@ -354,7 +354,7 @@ public function test_17_01_it_clienterror($spc, $itype, $xcmsg) {
354354
self::$tarantool->select($spc, null, null, null, null, $itype);
355355
$this->assertFalse(True);
356356
} catch (TarantoolClientError $e) {
357-
$this->assertContains($xcmsg, $e->getMessage());
357+
$this->assertRegExp($xcmsg, $e->getMessage());
358358
}
359359
}
360360

@@ -384,40 +384,40 @@ public function test_17_03_it_good($spc, $itype) {
384384

385385
public static function provideIteratorClientError() {
386386
return [
387-
['test_hash', 'EQ' ,'Invalid key part'],
388-
['test_hash', 'REQ' ,'Invalid key part'],
389-
['test_hash', 'LT' ,'Invalid key part'],
390-
['test_hash', 'LE' ,'Invalid key part'],
391-
['test_hash', 'GE' ,'Invalid key part'],
392-
['test_hash', 'BITSET_ALL_SET' ,'Invalid key part'],
393-
['test_hash', 'BITSET_ANY_SET' ,'Invalid key part'],
394-
['test_hash', 'BITSET_ALL_NOT_SET','Invalid key part'],
395-
['test_hash', 'BITS_ALL_SET' ,'Invalid key part'],
396-
['test_hash', 'BITS_ANY_SET' ,'Invalid key part'],
397-
['test_hash', 'BITS_ALL_NOT_SET' ,'Invalid key part'],
398-
['test_hash', 'OVERLAPS' ,'Invalid key part'],
399-
['test_hash', 'NEIGHBOR' ,'Invalid key part'],
400-
['test_hash', 'eq' ,'Invalid key part'],
401-
['test_hash', 'req' ,'Invalid key part'],
402-
['test_hash', 'lt' ,'Invalid key part'],
403-
['test_hash', 'le' ,'Invalid key part'],
404-
['test_hash', 'ge' ,'Invalid key part'],
405-
['test_hash', 'bitset_all_set' ,'Invalid key part'],
406-
['test_hash', 'bitset_any_set' ,'Invalid key part'],
407-
['test_hash', 'bitset_all_not_set','Invalid key part'],
408-
['test_hash', 'bits_all_set' ,'Invalid key part'],
409-
['test_hash', 'bits_any_set' ,'Invalid key part'],
410-
['test_hash', 'bits_all_not_set' ,'Invalid key part'],
411-
['test_hash', 'overlaps' ,'Invalid key part'],
412-
['test_hash', 'neighbor' ,'Invalid key part'],
413-
['test' , 'bitset_all_set' ,'does not support requested iterator type'],
414-
['test' , 'bitset_any_set' ,'does not support requested iterator type'],
415-
['test' , 'bitset_all_not_set','does not support requested iterator type'],
416-
['test' , 'bits_all_set' ,'does not support requested iterator type'],
417-
['test' , 'bits_any_set' ,'does not support requested iterator type'],
418-
['test' , 'bits_all_not_set' ,'does not support requested iterator type'],
419-
['test' , 'overlaps' ,'does not support requested iterator type'],
420-
['test' , 'neighbor' ,'does not support requested iterator type'],
387+
['test_hash', 'EQ' ,'(Invalid key part|via a partial key)'],
388+
['test_hash', 'REQ' ,'(Invalid key part|via a partial key)'],
389+
['test_hash', 'LT' ,'(Invalid key part|via a partial key)'],
390+
['test_hash', 'LE' ,'(Invalid key part|via a partial key)'],
391+
['test_hash', 'GE' ,'(Invalid key part|via a partial key)'],
392+
['test_hash', 'BITSET_ALL_SET' ,'(Invalid key part|via a partial key)'],
393+
['test_hash', 'BITSET_ANY_SET' ,'(Invalid key part|via a partial key)'],
394+
['test_hash', 'BITSET_ALL_NOT_SET','(Invalid key part|via a partial key)'],
395+
['test_hash', 'BITS_ALL_SET' ,'(Invalid key part|via a partial key)'],
396+
['test_hash', 'BITS_ANY_SET' ,'(Invalid key part|via a partial key)'],
397+
['test_hash', 'BITS_ALL_NOT_SET' ,'(Invalid key part|via a partial key)'],
398+
['test_hash', 'OVERLAPS' ,'(Invalid key part|via a partial key)'],
399+
['test_hash', 'NEIGHBOR' ,'(Invalid key part|via a partial key)'],
400+
['test_hash', 'eq' ,'(Invalid key part|via a partial key)'],
401+
['test_hash', 'req' ,'(Invalid key part|via a partial key)'],
402+
['test_hash', 'lt' ,'(Invalid key part|via a partial key)'],
403+
['test_hash', 'le' ,'(Invalid key part|via a partial key)'],
404+
['test_hash', 'ge' ,'(Invalid key part|via a partial key)'],
405+
['test_hash', 'bitset_all_set' ,'(Invalid key part|via a partial key)'],
406+
['test_hash', 'bitset_any_set' ,'(Invalid key part|via a partial key)'],
407+
['test_hash', 'bitset_all_not_set','(Invalid key part|via a partial key)'],
408+
['test_hash', 'bits_all_set' ,'(Invalid key part|via a partial key)'],
409+
['test_hash', 'bits_any_set' ,'(Invalid key part|via a partial key)'],
410+
['test_hash', 'bits_all_not_set' ,'(Invalid key part|via a partial key)'],
411+
['test_hash', 'overlaps' ,'(Invalid key part|via a partial key)'],
412+
['test_hash', 'neighbor' ,'(Invalid key part|via a partial key)'],
413+
['test' , 'bitset_all_set' ,'(does not support requested iterator type)'],
414+
['test' , 'bitset_any_set' ,'(does not support requested iterator type)'],
415+
['test' , 'bitset_all_not_set','(does not support requested iterator type)'],
416+
['test' , 'bits_all_set' ,'(does not support requested iterator type)'],
417+
['test' , 'bits_any_set' ,'(does not support requested iterator type)'],
418+
['test' , 'bits_all_not_set' ,'(does not support requested iterator type)'],
419+
['test' , 'overlaps' ,'(does not support requested iterator type)'],
420+
['test' , 'neighbor' ,'(does not support requested iterator type)'],
421421
];
422422
}
423423

test/shared/box.lua

+29-12
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,27 @@ local json = require('json')
88
local yaml = require('yaml')
99

1010
log.info(fio.cwd())
11+
log.info("admin: %s, primary: %s", os.getenv('ADMIN_PORT'), os.getenv('PRIMARY_PORT'))
12+
13+
local compat = {
14+
log = 'log',
15+
memtx_memory = 'memtx_memory',
16+
unsigned = 'unsigned',
17+
string = 'string',
18+
}
19+
20+
if (tonumber(_TARANTOOL:split('-')[1]:split('.')[2]) < 7) then
21+
compat.log = 'logger'
22+
compat.memtx_memory = 'slab_alloc_arena'
23+
compat.unsigned = 'NUM'
24+
compat.string = 'STR'
25+
end
1126

12-
require('console').listen(os.getenv('ADMIN_PORT'))
1327
box.cfg{
14-
listen = os.getenv('PRIMARY_PORT'),
15-
log_level = 5,
16-
logger = 'tarantool.log',
17-
slab_alloc_arena = 0.2
28+
listen = os.getenv('PRIMARY_PORT'),
29+
log_level = 5,
30+
[compat.log] = 'tarantool.log',
31+
[compat.memtx_memory] = 400 * 1024 * 1024
1832
}
1933

2034
box.once('initialization', function()
@@ -27,25 +41,25 @@ box.once('initialization', function()
2741

2842
local space = box.schema.space.create('test', {
2943
format = {
30-
{type = 'STR', name = 'name'},
31-
{type = 'NUM', name = 's1'},
32-
{type = 'STR', name = 's2'},
44+
{ type = compat.unsigned, name = 'field1', add_field = 1 },
45+
{ type = compat.unsigned, name = 's1' },
46+
{ type = compat.string, name = 's2' },
3347
}
3448
})
3549
space:create_index('primary', {
3650
type = 'TREE',
3751
unique = true,
38-
parts = {1, 'NUM'}
52+
parts = {1, compat.unsigned}
3953
})
4054
space:create_index('secondary', {
4155
type = 'TREE',
4256
unique = false,
43-
parts = {2, 'NUM', 3, 'STR'}
57+
parts = {2, compat.unsigned, 3, compat.string}
4458
})
4559

4660
local space = box.schema.space.create('msgpack')
4761
space:create_index('primary', {
48-
parts = {1, 'NUM'}
62+
parts = {1, compat.unsigned}
4963
})
5064
space:insert{1, 'float as key', {
5165
[2.7] = {1, 2, 3}
@@ -74,7 +88,7 @@ box.once('initialization', function()
7488

7589
local space = box.schema.space.create('pstring')
7690
space:create_index('primary', {
77-
parts = {1, 'STR'}
91+
parts = {1, compat.string}
7892
})
7993
local yml = io.open(fio.pathjoin(fio.cwd(), "../test/shared/queue.yml")):read("*a")
8094
local tuple = yaml.decode(yml)[1]
@@ -125,3 +139,6 @@ end
125139
function test_6(...)
126140
return ...
127141
end
142+
143+
require('console').listen(os.getenv('ADMIN_PORT'))
144+

0 commit comments

Comments
 (0)