Tarantool development patches archive
 help / color / mirror / Atom feed
From: Kirill Shcherbatov <kshcherbatov@tarantool.org>
To: tarantool-patches@freelists.org
Cc: "v.shpilevoy@tarantool.org" <v.shpilevoy@tarantool.org>
Subject: [tarantool-patches] Re: [PATCH v7 6/7] sql: export funcs defined on Expr, ExprList to sql.h
Date: Fri, 25 May 2018 14:53:53 +0300	[thread overview]
Message-ID: <e44c0bc9-16df-24b1-1f4b-8b47551d4a5a@tarantool.org> (raw)
In-Reply-To: <c92e26a5-08d5-a7e2-3532-5789c264591c@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);

  reply	other threads:[~2018-05-25 11:53 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-23 14:05 [tarantool-patches] [PATCH v7 0/7] sql: remove Checks to server Kirill Shcherbatov
2018-05-23 14:05 ` [tarantool-patches] [PATCH v7 1/7] sql: remove parser construct, destruct to sql.h Kirill Shcherbatov
2018-05-23 17:46   ` [tarantool-patches] " Konstantin Osipov
2018-05-24 19:26   ` Vladislav Shpilevoy
2018-05-25 12:05     ` Kirill Shcherbatov
2018-05-23 14:05 ` [tarantool-patches] [PATCH v7 2/7] box: introduce OPT_ARRAY opt_type to decode arrays Kirill Shcherbatov
2018-05-23 17:53   ` [tarantool-patches] " Konstantin Osipov
2018-05-24  7:32     ` Kirill Shcherbatov
2018-05-24 19:26   ` Vladislav Shpilevoy
2018-05-25 11:54     ` Kirill Shcherbatov
2018-05-23 14:05 ` [tarantool-patches] [PATCH v7 3/7] sql: introduce expr_len for sql_expr_compile Kirill Shcherbatov
2018-05-24 19:26   ` [tarantool-patches] " Vladislav Shpilevoy
2018-05-25 11:54     ` Kirill Shcherbatov
2018-05-23 14:05 ` [tarantool-patches] [PATCH v7 4/7] sql: rename sql_expr_free to sql_expr_delete Kirill Shcherbatov
2018-05-23 18:00   ` [tarantool-patches] " Konstantin Osipov
2018-05-24 19:26   ` Vladislav Shpilevoy
2018-05-25 11:54     ` Kirill Shcherbatov
2018-05-23 14:05 ` [tarantool-patches] [PATCH v7 5/7] sql: change sqlite3AddCheckConstraint signature Kirill Shcherbatov
2018-05-23 18:01   ` [tarantool-patches] " Konstantin Osipov
2018-05-24 19:26   ` Vladislav Shpilevoy
2018-05-25 11:53     ` Kirill Shcherbatov
2018-05-29 11:51   ` n.pettik
2018-05-30  8:32     ` Kirill Shcherbatov
2018-05-23 14:05 ` [tarantool-patches] [PATCH v7 6/7] sql: export funcs defined on Expr, ExprList to sql.h Kirill Shcherbatov
2018-05-23 18:15   ` [tarantool-patches] " Konstantin Osipov
2018-05-24  7:33     ` Kirill Shcherbatov
2018-05-24 19:26   ` Vladislav Shpilevoy
2018-05-25 11:53     ` Kirill Shcherbatov [this message]
2018-05-28 11:19       ` Vladislav Shpilevoy
2018-05-28 14:59         ` Kirill Shcherbatov
2018-05-23 14:05 ` [tarantool-patches] [PATCH v7 7/7] sql: remove Checks to server Kirill Shcherbatov
2018-05-24 19:26   ` [tarantool-patches] " Vladislav Shpilevoy
2018-05-25 11:53     ` Kirill Shcherbatov
2018-05-28 11:19       ` Vladislav Shpilevoy
2018-05-28 14:59         ` Kirill Shcherbatov
2018-05-28 18:50           ` Vladislav Shpilevoy
2018-05-29 11:49   ` n.pettik
2018-05-30  8:32     ` Kirill Shcherbatov
2018-05-30 10:42       ` n.pettik
2018-05-25 12:04 ` [tarantool-patches] Re: [PATCH v7 0/7] " Kirill Shcherbatov
2018-05-28 11:19   ` Vladislav Shpilevoy
2018-05-30 11:03 ` n.pettik
2018-05-31 17:44   ` Kirill Yukhin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e44c0bc9-16df-24b1-1f4b-8b47551d4a5a@tarantool.org \
    --to=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='[tarantool-patches] Re: [PATCH v7 6/7] sql: export funcs defined on Expr, ExprList to sql.h' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox