From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id D196924C64 for ; Fri, 25 May 2018 07:53:55 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nKTUz05je77T for ; Fri, 25 May 2018 07:53:55 -0400 (EDT) Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 6480F24C57 for ; Fri, 25 May 2018 07:53:55 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH v7 6/7] sql: export funcs defined on Expr, ExprList to sql.h References: <26d7bf8070e9e573eb61897c34bf027a52eb8d66.1527084287.git.kshcherbatov@tarantool.org> From: Kirill Shcherbatov Message-ID: Date: Fri, 25 May 2018 14:53:53 +0300 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org Cc: "v.shpilevoy@tarantool.org" > 1. Please, do not put extra white space after *. > 2. Invalid indentation. > 3. No pParse. > 4. Wrong indentation. > 5. Same. > 6. Please, consider this diff: diff --git a/src/box/sql.h b/src/box/sql.h index ec4f298..2a87d14 100644 --- a/src/box/sql.h +++ b/src/box/sql.h @@ -190,7 +190,7 @@ sql_table_def_rebuild(struct sqlite3 *db, struct Table *table); * @retval not NULL on success. */ struct ExprList * -sql_expr_list_dup(struct sqlite3 * db, struct ExprList * p, int flags); +sql_expr_list_dup(struct sqlite3 *db, struct ExprList * p, int flags); /** * Free AST pointed by expr list. @@ -214,8 +214,8 @@ sql_expr_list_delete(struct sqlite3 *db, struct ExprList *expr_list); * @retval not NULL on success. */ struct ExprList * -sql_expr_list_append(struct sqlite3 * db, struct ExprList *expr_list, - struct Expr *expr); +sql_expr_list_append(struct sqlite3 *db, struct ExprList *expr_list, + struct Expr *expr); /** * Resolve names in expressions that can only reference a single table: @@ -223,7 +223,7 @@ sql_expr_list_append(struct sqlite3 * db, struct ExprList *expr_list, * * WHERE clauses on partial indices * The Expr.iTable value for Expr.op==TK_COLUMN nodes of the expression * is set to -1 and the Expr.iColumn value is set to the column number. - * Any errors cause an error message to be set in pParse. + * Any errors cause an error message to be set in parser. * @param parser Parsing context. * @param table The table being referenced. * @param type NC_IsCheck or NC_PartIdx or NC_IdxExpr. diff --git a/src/box/sql/build.c b/src/box/sql/build.c index 674f980..a30923c 100644 --- a/src/box/sql/build.c +++ b/src/box/sql/build.c @@ -2949,11 +2949,13 @@ sql_create_index(struct Parse *parse, struct Token *token, */ if (col_list == NULL) { Token prevCol; - sqlite3TokenInit(&prevCol, pTab->def->fields[ - pTab->def->field_count - 1].name); - col_list = sql_expr_list_append(parse->db, NULL, - sqlite3ExprAlloc(db, TK_ID, - &prevCol, 0)); + sqlite3TokenInit(&prevCol, + pTab->def->fields[ + pTab->def->field_count - 1].name); + col_list = + sql_expr_list_append(parse->db, NULL, + sqlite3ExprAlloc(db, TK_ID, + &prevCol, 0)); if (col_list == NULL) goto exit_create_index; assert(col_list->nExpr == 1); @@ -3023,7 +3025,7 @@ sql_create_index(struct Parse *parse, struct Token *token, i++, col_listItem++) { Expr *pCExpr; /* The i-th index expression */ sql_resolve_self_reference(parse, pTab, NC_IdxExpr, - col_listItem->pExpr, NULL); + col_listItem->pExpr, NULL); if (parse->nErr > 0) goto exit_create_index; pCExpr = sqlite3ExprSkipCollate(col_listItem->pExpr); diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c index 4771b69..f11e84a 100644 --- a/src/box/sql/expr.c +++ b/src/box/sql/expr.c @@ -1446,38 +1446,37 @@ sqlite3ExprDup(sqlite3 * db, Expr * p, int flags) struct ExprList * sql_expr_list_dup(struct sqlite3 * db, struct ExprList *p, int flags) { - ExprList *pNew; struct ExprList_item *pItem, *pOldItem; int i; - Expr *pPriorSelectCol = 0; - assert(db != 0); - if (p == 0) - return 0; - pNew = sqlite3DbMallocRawNN(db, sizeof(*pNew)); - if (pNew == 0) - return 0; + Expr *pPriorSelectCol = NULL; + assert(db != NULL); + if (p == NULL) + return NULL; + ExprList *pNew = sqlite3DbMallocRawNN(db, sizeof(*pNew)); + if (pNew == NULL) + return NULL; pNew->nExpr = i = p->nExpr; - if ((flags & EXPRDUP_REDUCE) == 0) + if ((flags & EXPRDUP_REDUCE) == 0) { for (i = 1; i < p->nExpr; i += i) { } + } pNew->a = pItem = sqlite3DbMallocRawNN(db, i * sizeof(p->a[0])); - if (pItem == 0) { + if (pItem == NULL) { sqlite3DbFree(db, pNew); - return 0; + return NULL; } pOldItem = p->a; for (i = 0; i < p->nExpr; i++, pItem++, pOldItem++) { Expr *pOldExpr = pOldItem->pExpr; Expr *pNewExpr; pItem->pExpr = sqlite3ExprDup(db, pOldExpr, flags); - if (pOldExpr - && pOldExpr->op == TK_SELECT_COLUMN - && (pNewExpr = pItem->pExpr) != 0) { + if (pOldExpr != NULL && pOldExpr->op == TK_SELECT_COLUMN && + (pNewExpr = pItem->pExpr) != NULL) { assert(pNewExpr->iColumn == 0 || i > 0); if (pNewExpr->iColumn == 0) { assert(pOldExpr->pLeft == pOldExpr->pRight); pPriorSelectCol = pNewExpr->pLeft = - pNewExpr->pRight; + pNewExpr->pRight; } else { assert(i > 0); assert(pItem[-1].pExpr != 0); @@ -1619,7 +1618,7 @@ sqlite3SelectDup(sqlite3 * db, Select * p, int flags) struct ExprList * sql_expr_list_append(struct sqlite3 * db, struct ExprList *expr_list, - struct Expr *expr) + struct Expr *expr) { assert(db != NULL); if (expr_list == NULL) { @@ -1650,7 +1649,7 @@ sql_expr_list_append(struct sqlite3 * db, struct ExprList *expr_list, /* Avoid leaking memory if malloc has failed. */ sql_expr_delete(db, expr, false); sql_expr_list_delete(db, expr_list); - return 0; + return NULL; } /* @@ -1836,7 +1835,7 @@ exprListDeleteNN(sqlite3 * db, ExprList * pList) void sql_expr_list_delete(sqlite3 *db, ExprList *expr_list) { - if (expr_list) + if (expr_list != NULL) exprListDeleteNN(db, expr_list); } diff --git a/src/box/sql/fkey.c b/src/box/sql/fkey.c index 3e30a44..ae3cc12 100644 --- a/src/box/sql/fkey.c +++ b/src/box/sql/fkey.c @@ -1378,8 +1378,8 @@ fkActionTrigger(Parse * pParse, /* Parse context */ } pSelect = sqlite3SelectNew(pParse, sql_expr_list_append(pParse->db, - 0, - pRaise), + NULL, + pRaise), sqlite3SrcListAppend(db, 0, &tFrom), pWhere, 0, 0, 0, 0, 0, 0); diff --git a/src/box/sql/resolve.c b/src/box/sql/resolve.c index fd82119..53b6c66 100644 --- a/src/box/sql/resolve.c +++ b/src/box/sql/resolve.c @@ -1582,9 +1582,9 @@ void sql_resolve_self_reference(struct Parse *parser, struct Table *table, int type, struct Expr *expr, struct ExprList *expr_list) { - /* Fake SrcList for pParse->pNewTable */ + /* Fake SrcList for parser->pNewTable */ SrcList sSrc; - /* Name context for pParse->pNewTable */ + /* Name context for parser->pNewTable */ NameContext sNC; assert(type == NC_IsCheck || type == NC_PartIdx || type == NC_IdxExpr); @@ -1597,7 +1597,7 @@ sql_resolve_self_reference(struct Parse *parser, struct Table *table, int type, sNC.pParse = parser; sNC.pSrcList = &sSrc; sNC.ncFlags = type; - if (sqlite3ResolveExprNames(&sNC, expr)) + if (sqlite3ResolveExprNames(&sNC, expr) != 0) return; if (expr_list != NULL) sqlite3ResolveExprListNames(&sNC, expr_list); diff --git a/src/box/sql/select.c b/src/box/sql/select.c index 41f0bf4..c8b37c6 100644 --- a/src/box/sql/select.c +++ b/src/box/sql/select.c @@ -150,9 +150,8 @@ sqlite3SelectNew(Parse * pParse, /* Parsing context */ pNew = &standin; } if (pEList == 0) { - pEList = - sql_expr_list_append(pParse->db, NULL, - sqlite3Expr(db, TK_ASTERISK, 0)); + pEList = sql_expr_list_append(pParse->db, NULL, + sqlite3Expr(db, TK_ASTERISK, 0)); } struct session MAYBE_UNUSED *user_session; user_session = current_session(); @@ -3190,9 +3189,8 @@ multiSelectOrderBy(Parse * pParse, /* Parsing context */ return SQLITE_NOMEM_BKPT; pNew->flags |= EP_IntValue; pNew->u.iValue = i; - pOrderBy = - sql_expr_list_append(pParse->db, pOrderBy, - pNew); + pOrderBy = sql_expr_list_append(pParse->db, + pOrderBy, pNew); if (pOrderBy) pOrderBy->a[nOrderBy++].u.x. iOrderByCol = (u16) i; @@ -4375,9 +4373,8 @@ convertCompoundSelectToSubquery(Walker * pWalker, Select * p) return WRC_Abort; *pNew = *p; p->pSrc = pNewSrc; - p->pEList = - sql_expr_list_append(pParse->db, NULL, - sqlite3Expr(db, TK_ASTERISK, 0)); + p->pEList = sql_expr_list_append(pParse->db, NULL, + sqlite3Expr(db, TK_ASTERISK, 0)); p->op = TK_SELECT; p->pWhere = 0; pNew->pGroupBy = 0; @@ -4817,10 +4814,9 @@ selectExpander(Walker * pWalker, Select * p) ) { /* This particular expression does not need to be expanded. */ - pNew = - sql_expr_list_append(pParse->db, pNew, - a[k].pExpr); - if (pNew) { + pNew = sql_expr_list_append(pParse->db, pNew, + a[k].pExpr); + if (pNew != NULL) { pNew->a[pNew->nExpr - 1].zName = a[k].zName; pNew->a[pNew->nExpr - 1].zSpan = @@ -4923,16 +4919,14 @@ selectExpander(Walker * pWalker, Select * p) } else { pExpr = pRight; } - pNew = - sql_expr_list_append( - pParse->db, - pNew, pExpr); + pNew = sql_expr_list_append( + pParse->db, pNew, pExpr); sqlite3TokenInit(&sColname, zColname); sqlite3ExprListSetName(pParse, pNew, &sColname, 0); - if (pNew + if (pNew != NULL && (p-> selFlags & SF_NestedFrom) != 0) { diff --git a/src/box/sql/trigger.c b/src/box/sql/trigger.c index 27902fd..ea35211 100644 --- a/src/box/sql/trigger.c +++ b/src/box/sql/trigger.c @@ -724,8 +724,8 @@ codeTriggerProgram(Parse * pParse, /* The parser context */ sqlite3Update(pParse, targetSrcList(pParse, pStep), sql_expr_list_dup(db, - pStep-> - pExprList, 0), + pStep->pExprList, + 0), sqlite3ExprDup(db, pStep->pWhere, 0), pParse->eOrconf); diff --git a/src/box/sql/whereexpr.c b/src/box/sql/whereexpr.c index d5a5b07..d1eca43 100644 --- a/src/box/sql/whereexpr.c +++ b/src/box/sql/whereexpr.c @@ -783,9 +783,8 @@ exprAnalyzeOrTerm(SrcList * pSrc, /* the FROM clause */ pDup = sqlite3ExprDup(db, pOrTerm->pExpr->pRight, 0); - pList = - sql_expr_list_append(pWInfo->pParse->db, - pList, pDup); + pList = sql_expr_list_append(pWInfo->pParse->db, + pList, pDup); pLeft = pOrTerm->pExpr->pLeft; } assert(pLeft != 0);