Skip to content
Snippets Groups Projects
Commit 33b8e831 authored by Chris Sosnin's avatar Chris Sosnin Committed by Nikita Pettik
Browse files

sql: fix segfault in pragma table_info

We should first check that primary key is not NULL.

Closes #4745

(cherry picked from commit e9aa3784)
parent 128da252
No related branches found
No related tags found
No related merge requests found
......@@ -238,10 +238,10 @@ sql_pragma_table_info(struct Parse *parse, const char *tbl_name)
struct Vdbe *v = sqlGetVdbe(parse);
struct field_def *field = space->def->fields;
for (uint32_t i = 0, k; i < space->def->field_count; ++i, ++field) {
if (!sql_space_column_is_in_pk(space, i)) {
k = 0;
} else if (pk == NULL) {
if (pk == NULL) {
k = 1;
} else if (!sql_space_column_is_in_pk(space, i)) {
k = 0;
} else {
struct key_def *kdef = pk->def->key_def;
k = key_def_find_by_fieldno(kdef, i) - kdef->parts + 1;
......
-- test-run result file version 2
test_run = require('test_run').new()
| ---
| ...
engine = test_run:get_cfg('engine')
| ---
| ...
--
-- Make sure that 'pragma table_info()' correctly handles tables
-- without primary key.
--
T = box.schema.create_space('T', { \
engine = engine, \
format = {{'i', 'integer'}} \
})
| ---
| ...
_ = box.execute('pragma table_info(T)')
| ---
| ...
T:drop()
| ---
| ...
test_run = require('test_run').new()
engine = test_run:get_cfg('engine')
--
-- Make sure that 'pragma table_info()' correctly handles tables
-- without primary key.
--
T = box.schema.create_space('T', { \
engine = engine, \
format = {{'i', 'integer'}} \
})
_ = box.execute('pragma table_info(T)')
T:drop()
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