From: Kirill Shcherbatov <kshcherbatov@tarantool.org> To: tarantool-patches@freelists.org Subject: [tarantool-patches] Re: [PATCH v5 2/3] sql: remove SQL fields from Table and Column Date: Tue, 15 May 2018 18:56:03 +0300 [thread overview] Message-ID: <6f7cfd9a-422b-2cf3-11a1-1ef567aead9a@tarantool.org> (raw) In-Reply-To: <f3eda3b5-5f77-42be-1853-6730faed1b95@tarantool.org> > 1. Wrong fix. As I can see sql_table_def_rebuild does not depend on allocation > way of its arguments. So the function declaration comment must be fixed too.@@ -166,8 +166,7 @@ sql_ephemeral_space_def_new(struct Parse *parser, const char *name); /** * Rebuild struct def in Table with memory allocated on a single - * malloc. Fields and strings are expected to be allocated with - * sqlite3DbMalloc. + * malloc. > 2. OutOfMemory takes variable name in the last argument. Not caller function name. > 3. Same. @@ -661,7 +661,7 @@ sqlite3AddColumn(Parse * pParse, Token * pName, Token * pType) diag_set(OutOfMemory, pName->n + 1, - "region_alloc", "sqlite3AddColumn"); + "region_alloc", "z"); pParse->rc = SQL_TARANTOOL_ERROR; pParse->nErr++; return; @@ -871,7 +871,7 @@ sqlite3AddDefaultValue(Parse * pParse, ExprSpan * pSpan) diag_set(OutOfMemory, default_length + 1, "region_alloc", - "sqlite3AddDefaultValue"); + "field->default_value"); > 4. Looks like you removed sql_column_collation. It would be good to see the diff > under the comment. @@ -1053,45 +1030,13 @@ sqlite3AddCollateType(Parse * pParse, Token * pToken) - if (pIdx->aiColumn[0] == i) - pIdx->coll_array[0] = sql_column_collation(p, i); + if (pIdx->aiColumn[0] == i) { + pIdx->coll_array[0] = + coll_by_id(p->def->fields[i].coll_id); + } } @@ -3066,7 +3074,7 @@ sqlite3CreateIndex(Parse * pParse, /* All information about this parse */ - coll = sql_column_collation(pTab, j); + coll = coll_by_id(pTab->def->fields[j].coll_id); @@ -179,13 +182,14 @@ sql_expr_coll(Parse *parse, Expr *p, bool *is_found) - coll = sql_column_collation(p->pTab, j); + coll = coll_by_id( + p->space_def->fields[j].coll_id); @@ -298,14 +299,14 @@ sqlite3FkLocateIndex(Parse * pParse, /* Parse context to store any error in */ - def_coll = sql_column_collation(pParent, - iCol); + def_coll = coll_by_id( + pParent->def->fields[iCol].coll_id); @@ -298,14 +299,14 @@ sqlite3FkLocateIndex(Parse * pParse, /* Parse context to store any error in */ - def_coll = sql_column_collation(pParent, - iCol); + def_coll = coll_by_id( + pParent->def->fields[iCol].coll_id); @@ -1784,26 +1795,29 @@ xferOptimization(Parse * pParse, /* Parser context */ - if (sql_column_collation(pDest, i) != - sql_column_collation(pSrc, i)) { + if (coll_by_id(pDest->def->fields[i].coll_id) != + coll_by_id(pSrc->def->fields[i].coll_id)) @@ -3529,8 +3499,6 @@ void sqlite3AddCollateType(Parse *, Token *); -struct coll * -sql_column_collation(Table *, uint32_t); > 5. Out of 80 symbols. Please, do self-review of a patch before sending. @@ -2110,7 +2110,8 @@ sqlite3ViewGetColumnNames(Parse * pParse, Table * pTable) - sqlite3ColumnsFromExprList(pParse, pTable->pCheck, pTable); + sqlite3ColumnsFromExprList(pParse, pTable->pCheck, + pTable); > 6. I looked at sqlite3ColumnsFromExprList, and looks like it does not use > opts.temporary flag. So you can remove this opts.temporary flag manipulation, it is not? @@ -1742,7 +1742,6 @@ sql_ephemeral_table_new(Parse *parser, const char *name) int sql_table_def_rebuild(struct sqlite3 *db, struct Table *pTable) { - assert(pTable->def->opts.temporary); struct space_def *old_def = pTable->def; @@ -2108,12 +2108,9 @@ sqlite3ViewGetColumnNames(Parse * pParse, Table * pTable) * a VIEW it holds the list of column names. */ struct space_def *old_def = pTable->def; - /* Manage def memory manually. */ - old_def->opts.temporary = true; sqlite3ColumnsFromExprList(pParse, pTable->pCheck, pTable); if (sql_table_def_rebuild(db, pTable) != 0) { - old_def->opts.temporary = false; > > Here I meant this: @@ -2131,8 +2131,7 @@ sqlite3ViewGetColumnNames(Parse * pParse, Table * pTable) - struct space_def *new_def; - new_def = + struct space_def *new_def = sql_ephemeral_space_def_new(pParse, > 7. Apply this: @@ -2969,10 +2968,9 @@ sqlite3CreateIndex(Parse * pParse, /* All information about this parse */ */ if (pList == 0) { Token prevCol; - sqlite3TokenInit(&prevCol, - pTab->def->fields[ - pTab->def->field_count - 1]. - name); + struct field_def *field = + &pTab->def->fields[pTab->def->field_count - 1]; + sqlite3TokenInit(&prevCol, field->name); > 8. When you added cleanup label, you can reuse it for another OOM on line 1904. @@ -1842,7 +1842,7 @@ sqlite3ColumnsFromExprList(Parse * pParse, /* Parsing context */ - for (i = 0, pCol = aCol; i < nCol && !db->mallocFailed; i++, pCol++) { + for (i = 0, pCol = aCol; i < nCol; i++, pCol++) { @@ -1902,6 +1902,7 @@ sqlite3ColumnsFromExprList(Parse * pParse, /* Parsing context */ if (pTable->def->fields[i].name == NULL) { sqlite3OomFault(db); + goto cleanup; } else { > 9. Please, do not ignore comments. > Looks like it can be on malloc sometimes, so you should write a comment about it - > why do you need this cleaning. @@ -1912,6 +1912,10 @@ cleanup: sqlite3HashClear(&ht); int rc = db->mallocFailed ? SQLITE_NOMEM_BKPT : SQLITE_OK; if (rc != SQLITE_OK) { + /* + * pTable->def could be not temporal in + * sqlite3ViewGetColumnNames so we need clean-up. + */ > 10. Still out of 66. And wrong end: '* */' must be '*/'.@@ -4714,9 +4718,9 @@ selectExpander(Walker * pWalker, Select * p) - * Will be overwritten with pointer as unique - * identifier. - * */ + * Will be overwritten with pointer as + * unique identifier. + */ > 11. Out of 66. @@ -4729,15 +4732,17 @@ selectExpander(Walker * pWalker, Select * p) - /* Rewrite old name with correct pointer. */ + /* + * Rewrite old name with correct pointer. + */
next prev parent reply other threads:[~2018-05-15 15:56 UTC|newest] Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-05-11 8:49 [tarantool-patches] [PATCH v5 0/3] sql: refactor SQL Parser structures Kirill Shcherbatov 2018-05-11 8:49 ` [tarantool-patches] [PATCH v5 1/3] sql: fix code style in sqlite3Pragma Kirill Shcherbatov 2018-05-11 20:59 ` [tarantool-patches] " Vladislav Shpilevoy 2018-05-11 8:49 ` [tarantool-patches] [PATCH v5 2/3] sql: remove SQL fields from Table and Column Kirill Shcherbatov 2018-05-11 20:59 ` [tarantool-patches] " Vladislav Shpilevoy 2018-05-14 11:20 ` Kirill Shcherbatov 2018-05-14 13:39 ` Vladislav Shpilevoy 2018-05-15 15:56 ` Kirill Shcherbatov [this message] 2018-05-11 8:49 ` [tarantool-patches] [PATCH v5 3/3] sql: space_def* instead of Table* in Expr Kirill Shcherbatov 2018-05-11 20:59 ` [tarantool-patches] " Vladislav Shpilevoy 2018-05-14 11:20 ` Kirill Shcherbatov 2018-05-11 8:58 ` [tarantool-patches] Re: [PATCH v5 0/3] sql: refactor SQL Parser structures Vladislav Shpilevoy 2018-05-11 19:40 ` [tarantool-patches] Re[2]: [tarantool-patches] " 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=6f7cfd9a-422b-2cf3-11a1-1ef567aead9a@tarantool.org \ --to=kshcherbatov@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='[tarantool-patches] Re: [PATCH v5 2/3] sql: remove SQL fields from Table and Column' \ /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