commit - 6cb86dc1738d40d5aba3f3001a1e01b3dae5cd16
commit + 4f85d27efdf443cccf18ba29a3221f524904cce2
blob - 71de5a0fe99975c98114b162b4debd40bf63e7a8
blob + 48906542ebe563d3ccb92dde44e092299275a9c2
--- src/box/sql/resolve.c
+++ src/box/sql/resolve.c
static bool
nameInUsingClause(struct IdList *pUsing, const char *zCol, const char *old_col)
{
- if (pUsing) {
- for (int k = 0; k < pUsing->nId; k++) {
- if (strcmp(pUsing->a[k].zName, zCol) == 0)
- return true;
- }
- for (int i = 0; i < pUsing->nId; i++) {
- if (strcmp(pUsing->a[i].zName, old_col) == 0)
- return true;
- }
+ if (pUsing == NULL)
+ return false;
+ for (int k = 0; k < pUsing->nId; k++) {
+ if (strcmp(pUsing->a[k].zName, zCol) == 0)
+ return true;
}
+ if (old_col == NULL)
+ return false;
+ for (int i = 0; i < pUsing->nId; i++) {
+ if (strcmp(pUsing->a[i].zName, old_col) == 0)
+ return true;
+ }
return false;
}
blob - 47db22cd5546d67eb45e6eee579cbf9a15534bc1
blob + f17147cb8153acff6236540ea30e403d2c14f034
--- test/sql-luatest/gh_4467_sql_id_backwards_compatibility_test.lua
+++ test/sql-luatest/gh_4467_sql_id_backwards_compatibility_test.lua
box.func.check_ASD_THREE:drop()
end)
end
+
+-- Make sure USING in JOIN does not cause segfault.
+g.test_using_in_join = function()
+ g.server:exec(function()
+ box.execute([[CREATE TABLE T(I INT PRIMARY KEY, A INT);]])
+ box.execute([[SELECT * FROM T LEFT JOIN T USING(A);]])
+ box.execute([[DROP TABLE T;]])
+ end)
+end