浏览代码

- fixed a problem when commands created with unitialized contexts would crash

Jan Janak 17 年之前
父节点
当前提交
1f993b4cc9
共有 1 个文件被更改,包括 11 次插入0 次删除
  1. 11 0
      db/db_cmd.c

+ 11 - 0
db/db_cmd.c

@@ -79,6 +79,17 @@ db_cmd_t* db_cmd(enum db_cmd_type type, db_ctx_t* ctx, char* table,
 		if (newp->vals == NULL) goto err;
 		if (newp->vals == NULL) goto err;
 	}
 	}
 
 
+	/* FIXME: This should be redesigned so that we do not need to connect
+	 * connections in context before comands are created, this takes splitting
+	 * the command initializatio sequence in two steps, one would be creating
+	 * all the data structures and the second would be checking corresponding
+	 * fields and tables on the server.
+	 */
+	if (ctx->con_n == 0) {
+		ERR("No connections found in context %.*s\n", STR_FMT(&ctx->id));
+		goto err;
+	}
+
 	for(i = 0; i < ctx->con_n; i++) {
 	for(i = 0; i < ctx->con_n; i++) {
 		con = ctx->con[i];
 		con = ctx->con[i];