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,
	Kirill Shcherbatov <kshcherbatov@tarantool.org>
Subject: [tarantool-patches] [PATCH v2 1/3] sql: Fixed disgusting code format in sqlite3Pragma
Date: Mon, 23 Apr 2018 13:20:28 +0300	[thread overview]
Message-ID: <bdb58a54b4ef52deb8f06e3d9a8072f76288e6a9.1524478734.git.kshcherbatov@tarantool.org> (raw)
In-Reply-To: <cover.1524478734.git.kshcherbatov@tarantool.org>
In-Reply-To: <cover.1524478734.git.kshcherbatov@tarantool.org>

---
 src/box/sql/pragma.c | 56 +++++++++++++++++++++++++---------------------------
 1 file changed, 27 insertions(+), 29 deletions(-)

diff --git a/src/box/sql/pragma.c b/src/box/sql/pragma.c
index e41f69b..4a68cad 100644
--- a/src/box/sql/pragma.c
+++ b/src/box/sql/pragma.c
@@ -544,37 +544,35 @@ sqlite3Pragma(Parse * pParse, Token * pId,	/* First part of [schema.]id field */
 
 #ifndef SQLITE_OMIT_FOREIGN_KEY
 	case PragTyp_FOREIGN_KEY_LIST:{
-			if (zRight) {
-				FKey *pFK;
-				Table *pTab;
-				pTab = sqlite3HashFind(&db->pSchema->tblHash,
-						       zRight);
-				if (pTab != NULL) {
-					pFK = pTab->pFKey;
-					if (pFK) {
-						int i = 0;
-						pParse->nMem = 8;
-						while (pFK) {
-							int j;
-							for (j = 0;
-							     j < pFK->nCol;
-							     j++) {
-								sqlite3VdbeMultiLoad(v, 1, "iissssss", i, j, pFK->zTo, pTab->aCol[pFK->aCol[j].iFrom].zName, pFK->aCol[j].zCol, actionName(pFK->aAction[1]),	/* ON UPDATE */
-										     actionName(pFK->aAction[0]),	/* ON DELETE */
-										     "NONE");
-								sqlite3VdbeAddOp2
-								    (v,
-								     OP_ResultRow,
-								     1, 8);
-							}
-							++i;
-							pFK = pFK->pNextFrom;
-						}
-					}
-				}
-			}
+		if (!zRight)
+			break;
+		FKey *pFK;
+		Table *pTab;
+		pTab = sqlite3HashFind(&db->pSchema->tblHash, zRight);
+		if (pTab == NULL)
 			break;
+		pFK = pTab->pFKey;
+		if (!pFK)
+			break;
+		int i = 0;
+		pParse->nMem = 8;
+		while (pFK) {
+			for (int j = 0; j < pFK->nCol; j++) {
+				const char *name =
+					pTab->aCol[pFK->aCol[j].iFrom].zName;
+				sqlite3VdbeMultiLoad(v, 1, "iissssss", i, j,
+						     pFK->zTo, name,
+						     pFK->aCol[j].zCol,
+						     actionName(pFK->aAction[1]),
+						     actionName(pFK->aAction[0]),
+						     "NONE");
+				sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 8);
+			}
+			++i;
+			pFK = pFK->pNextFrom;
 		}
+		break;
+	}
 #endif				/* !defined(SQLITE_OMIT_FOREIGN_KEY) */
 
 #ifndef SQLITE_OMIT_FOREIGN_KEY
-- 
2.7.4

  reply	other threads:[~2018-04-23 10:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-17 15:01 [tarantool-patches] [PATCH v2 1/1] sql: remove ephemeral Expr from AddDefaultValue Kirill Shcherbatov
2018-04-17 18:45 ` [tarantool-patches] " Vladislav Shpilevoy
2018-04-19 12:47 ` [tarantool-patches] [PATCH v2 1/1] sql: remove zName and nColumn from SQL Kirill Shcherbatov
2018-04-19 15:25   ` [tarantool-patches] " Vladislav Shpilevoy
2018-04-23 10:20     ` [tarantool-patches] [PATCH v2 0/3] " Kirill Shcherbatov
2018-04-23 10:20       ` Kirill Shcherbatov [this message]
2018-04-23 10:20       ` [tarantool-patches] [PATCH v2 2/3] " Kirill Shcherbatov
2018-04-23 10:20       ` [tarantool-patches] [PATCH v2 3/3] sql: removed type field in server Kirill Shcherbatov

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=bdb58a54b4ef52deb8f06e3d9a8072f76288e6a9.1524478734.git.kshcherbatov@tarantool.org \
    --to=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [tarantool-patches] [PATCH v2 1/3] sql: Fixed disgusting code format in sqlite3Pragma' \
    /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