[patches] [PATCH 2/3] sql: add type attribute to struct Column

Nikita Pettik korablev at tarantool.org
Wed Feb 14 15:38:11 MSK 2018


In order to remove colFlag from struct Column, it is necessary to delete
usages of this field as an indicator of column with specified type, i.e.
having set COLFLAG_HASTYPE.  This patch adds to struct Column new field
which represents column type.  In the nearest future, it should
substitute column affinity.  By default, type is SCALAR, except for
fields created as INT/INTEGER.  Moreover, column name doesn't contain
type encoded after name string anymore.
Removed unused sqlite3_table_column_metadata() function.

Part of #3118, #3104

Signed-off-by: Nikita Pettik <korablev at tarantool.org>
---
 src/box/sql.c                 |   4 +-
 src/box/sql/build.c           |  30 +++++++----
 src/box/sql/main.c            | 112 ------------------------------------------
 src/box/sql/pragma.c          |   4 +-
 src/box/sql/select.c          |  72 ++++-----------------------
 src/box/sql/sqlite3.h         |  73 ---------------------------
 src/box/sql/sqliteInt.h       |   6 +--
 src/box/sql/util.c            |  14 ++----
 src/box/sql/vdbeaux.c         |   1 +
 test/sql-tap/default.test.lua |   4 +-
 test/sql-tap/eqp.test.lua     |  14 +++---
 11 files changed, 51 insertions(+), 283 deletions(-)

diff --git a/src/box/sql.c b/src/box/sql.c
index f2ddccfa3..4ef05aaa4 100644
--- a/src/box/sql.c
+++ b/src/box/sql.c
@@ -1722,7 +1722,7 @@ int tarantoolSqlite3MakeTableFormat(Table *pTable, void *buf)
 	 * treat it as strict type, not affinity.  */
 	if (pk_idx && pk_idx->nKeyCol == 1) {
 		int pk = pk_idx->aiColumn[0];
-		if (pTable->aCol[pk].affinity == 'D')
+		if (pTable->aCol[pk].type == FIELD_TYPE_INTEGER)
 			pk_forced_int = pk;
 	}
 
@@ -1785,7 +1785,7 @@ int tarantoolSqlite3MakeIdxParts(SqliteIndex *pIndex, void *buf)
 	 * treat it as strict type, not affinity.  */
 	if (primary_index->nKeyCol == 1) {
 		int pk = primary_index->aiColumn[0];
-		if (aCol[pk].affinity == 'D')
+		if (aCol[pk].type == FIELD_TYPE_INTEGER)
 			pk_forced_int = pk;
 	}
 
diff --git a/src/box/sql/build.c b/src/box/sql/build.c
index ae140ee3c..851a8f760 100644
--- a/src/box/sql/build.c
+++ b/src/box/sql/build.c
@@ -785,7 +785,7 @@ sqlite3AddColumn(Parse * pParse, Token * pName, Token * pType)
 		return;
 	}
 #endif
-	z = sqlite3DbMallocRaw(db, pName->n + pType->n + 2);
+	z = sqlite3DbMallocRaw(db, pName->n + 1);
 	if (z == 0)
 		return;
 	memcpy(z, pName->z, pName->n);
@@ -815,17 +815,28 @@ sqlite3AddColumn(Parse * pParse, Token * pName, Token * pType)
 
 	if (pType->n == 0) {
 		/* If there is no type specified, columns have the default affinity
-		 * 'BLOB'.
+		 * 'BLOB' and type SCALAR.
+		 * TODO: since SQL standart prohibits column creation without
+		 * specified type, the code below should emit an error.
 		 */
 		pCol->affinity = SQLITE_AFF_BLOB;
+		pCol->type = FIELD_TYPE_SCALAR;
 		pCol->szEst = 1;
 	} else {
-		zType = z + sqlite3Strlen30(z) + 1;
-		memcpy(zType, pType->z, pType->n);
-		zType[pType->n] = 0;
-		sqlite3Dequote(zType);
-		pCol->affinity = sqlite3AffinityType(zType, &pCol->szEst);
-		pCol->colFlags |= COLFLAG_HASTYPE;
+		/* TODO: convert string of type into runtime FIELD_TYPE value. */
+		if (sqlite3StrNICmp(pType->z, "INTEGER", 7) == 0 ||
+		    sqlite3StrNICmp(pType->z, "INT", 3) == 0) {
+			pCol->type = FIELD_TYPE_INTEGER;
+			pCol->affinity = SQLITE_AFF_INTEGER;
+		} else {
+			zType = sqlite3_malloc(pType->n + 1);
+			memcpy(zType, pType->z, pType->n);
+			zType[pType->n] = 0;
+			sqlite3Dequote(zType);
+			pCol->affinity = sqlite3AffinityType(zType, 0);
+			pCol->type = FIELD_TYPE_SCALAR;
+			sqlite3_free(zType);
+		}
 	}
 	p->nCol++;
 	pParse->constraintName.n = 0;
@@ -1056,8 +1067,7 @@ sqlite3AddPrimaryKey(Parse * pParse,	/* Parsing context */
 	}
 	if (nTerm == 1
 	    && pCol
-	    && (sqlite3StrICmp(sqlite3ColumnType(pCol, ""), "INTEGER") == 0
-		|| sqlite3StrICmp(sqlite3ColumnType(pCol, ""), "INT") == 0)
+	    && (sqlite3ColumnType(pCol) == FIELD_TYPE_INTEGER)
 	    && sortOrder != SQLITE_SO_DESC) {
 		assert(autoInc == 0 || autoInc == 1);
 		pTab->iPKey = iCol;
diff --git a/src/box/sql/main.c b/src/box/sql/main.c
index 4f43cd206..29c7df77d 100644
--- a/src/box/sql/main.c
+++ b/src/box/sql/main.c
@@ -2647,118 +2647,6 @@ sqlite3_thread_cleanup(void)
 }
 #endif
 
-/*
- * Return meta information about a specific column of a database table.
- * See comment in sqlite3.h (sqlite.h.in) for details.
- */
-int
-sqlite3_table_column_metadata(sqlite3 * db,		/* Connection handle */
-			      const char *zTableName,	/* Table name */
-			      const char *zColumnName,	/* Column name */
-			      char const **pzDataType,	/* OUTPUT: Declared data type */
-			      char const **pzCollSeq,	/* OUTPUT: Collation sequence name */
-			      int *pNotNull,		/* OUTPUT: True if NOT NULL constraint exists */
-			      int *pPrimaryKey,		/* OUTPUT: True if column part of PK */
-			      int *pAutoinc)		/* OUTPUT: True if column is auto-increment */
-{
-	int rc;
-	char *zErrMsg = 0;
-	Table *pTab = 0;
-	Column *pCol = 0;
-	int iCol = 0;
-	char const *zDataType = 0;
-	char const *zCollSeq = 0;
-	int notnull = 0;
-	int primarykey = 0;
-	int autoinc = 0;
-
-#ifdef SQLITE_ENABLE_API_ARMOR
-	if (!sqlite3SafetyCheckOk(db) || zTableName == 0) {
-		return SQLITE_MISUSE_BKPT;
-	}
-#endif
-
-	/* Ensure the database schema has been loaded */
-	sqlite3_mutex_enter(db->mutex);
-	rc = sqlite3Init(db);
-	if (SQLITE_OK != rc) {
-		goto error_out;
-	}
-
-	/* Locate the table in question */
-	pTab = sqlite3FindTable(db, zTableName);
-	if (!pTab || pTab->pSelect) {
-		pTab = 0;
-		goto error_out;
-	}
-
-	/* Find the column for which info is requested */
-	if (zColumnName == 0) {
-		/* Query for existance of table only */
-	} else {
-		for (iCol = 0; iCol < pTab->nCol; iCol++) {
-			pCol = &pTab->aCol[iCol];
-			if (0 == strcmp(pCol->zName, zColumnName)) {
-				break;
-			}
-		}
-		if (iCol == pTab->nCol) {
-				pTab = 0;
-				goto error_out;
-		}
-	}
-
-	/* The following block stores the meta information that will be returned
-	 * to the caller in local variables zDataType, zCollSeq, notnull, primarykey
-	 * and autoinc. At this the table is not a view and the column name
-	 * identified an explicitly declared column.
-	 * Copy meta information from *pCol.
-	 */
-	if (pCol) {
-		zDataType = sqlite3ColumnType(pCol, 0);
-		zCollSeq = pCol->zColl;
-		notnull = pCol->notNull != 0;
-		primarykey = (pCol->colFlags & COLFLAG_PRIMKEY) != 0;
-		autoinc = pTab->iPKey == iCol
-		    && (pTab->tabFlags & TF_Autoincrement) != 0;
-	} else {
-		zDataType = "INTEGER";
-		primarykey = 1;
-	}
-	if (!zCollSeq) {
-		zCollSeq = sqlite3StrBINARY;
-	}
-
- error_out:
-	/* Whether the function call succeeded or failed, set the output parameters
-	 * to whatever their local counterparts contain. If an error did occur,
-	 * this has the effect of zeroing all output parameters.
-	 */
-	if (pzDataType)
-		*pzDataType = zDataType;
-	if (pzCollSeq)
-		*pzCollSeq = zCollSeq;
-	if (pNotNull)
-		*pNotNull = notnull;
-	if (pPrimaryKey)
-		*pPrimaryKey = primarykey;
-	if (pAutoinc)
-		*pAutoinc = autoinc;
-
-	if (SQLITE_OK == rc && !pTab) {
-		sqlite3DbFree(db, zErrMsg);
-		zErrMsg =
-		    sqlite3MPrintf(db, "no such table column: %s.%s",
-				   zTableName, zColumnName);
-		rc = SQLITE_ERROR;
-	}
-	sqlite3ErrorWithMsg(db, rc, (zErrMsg ? "%s" : 0), zErrMsg);
-	sqlite3DbFree(db, zErrMsg);
-	rc = sqlite3ApiExit(db, rc);
-	sqlite3_mutex_leave(db->mutex);
-	return rc;
-}
-
 /*
  * Sleep for a little while.  Return the amount of time slept.
  */
diff --git a/src/box/sql/pragma.c b/src/box/sql/pragma.c
index 3eb3248c6..4aa3b2961 100644
--- a/src/box/sql/pragma.c
+++ b/src/box/sql/pragma.c
@@ -368,8 +368,8 @@ sqlite3Pragma(Parse * pParse, Token * pId,	/* First part of [schema.]id field */
 					       || pCol->pDflt->op == TK_SPAN);
 					sqlite3VdbeMultiLoad(v, 1, "issisi",
 							     i, pCol->zName,
-							     sqlite3ColumnType
-							     (pCol, ""),
+							     field_type_strs[sqlite3ColumnType
+							     (pCol)],
 							     pCol->
 							     notNull ? 1 : 0,
 							     pCol->
diff --git a/src/box/sql/select.c b/src/box/sql/select.c
index acc0a8ad9..9a7032d71 100644
--- a/src/box/sql/select.c
+++ b/src/box/sql/select.c
@@ -1593,14 +1593,14 @@ generateSortTail(Parse * pParse,	/* Parsing context */
 #else				/* if !defined(SQLITE_ENABLE_COLUMN_METADATA) */
 #define columnType(A,B,C,D,E,F) columnTypeImpl(A,B,F)
 #endif
-static const char *
+static enum field_type
 columnTypeImpl(NameContext * pNC, Expr * pExpr,
 #ifdef SQLITE_ENABLE_COLUMN_METADATA
 	       const char **pzOrigTab, const char **pzOrigCol,
 #endif
 	       u8 * pEstWidth)
 {
-	char const *zType = 0;
+	enum field_type column_type = FIELD_TYPE_SCALAR;
 	int j;
 	u8 estWidth = 1;
 #ifdef SQLITE_ENABLE_COLUMN_METADATA
@@ -1675,7 +1675,7 @@ columnTypeImpl(NameContext * pNC, Expr * pExpr,
 					sNC.pSrcList = pS->pSrc;
 					sNC.pNext = pNC;
 					sNC.pParse = pNC->pParse;
-					zType =
+					column_type =
 					    columnType(&sNC, p, 0,
 						       &zOrigTab, &zOrigCol,
 						       &estWidth);
@@ -1690,7 +1690,7 @@ columnTypeImpl(NameContext * pNC, Expr * pExpr,
 				estWidth = pTab->aCol[iCol].szEst;
 				zOrigTab = pTab->zName;
 #else
-				zType = sqlite3ColumnType(&pTab->aCol[iCol], 0);
+				column_type = sqlite3ColumnType(&pTab->aCol[iCol]);
 				estWidth = pTab->aCol[iCol].szEst;
 #endif
 			}
@@ -1709,7 +1709,7 @@ columnTypeImpl(NameContext * pNC, Expr * pExpr,
 			sNC.pSrcList = pS->pSrc;
 			sNC.pNext = pNC;
 			sNC.pParse = pNC->pParse;
-			zType =
+			column_type =
 			    columnType(&sNC, p, 0, &zOrigTab, &zOrigCol,
 				       &estWidth);
 			break;
@@ -1726,50 +1726,7 @@ columnTypeImpl(NameContext * pNC, Expr * pExpr,
 #endif
 	if (pEstWidth)
 		*pEstWidth = estWidth;
-	return zType;
-}
-
-/*
- * Generate code that will tell the VDBE the declaration types of columns
- * in the result set.
- */
-static void
-generateColumnTypes(Parse * pParse,	/* Parser context */
-		    SrcList * pTabList,	/* List of tables */
-		    ExprList * pEList)	/* Expressions defining the result set */
-{
-#ifndef SQLITE_OMIT_DECLTYPE
-	Vdbe *v = pParse->pVdbe;
-	int i;
-	NameContext sNC;
-	sNC.pSrcList = pTabList;
-	sNC.pParse = pParse;
-	for (i = 0; i < pEList->nExpr; i++) {
-		Expr *p = pEList->a[i].pExpr;
-		const char *zType;
-#ifdef SQLITE_ENABLE_COLUMN_METADATA
-		const char *zOrigDb = 0;
-		const char *zOrigTab = 0;
-		const char *zOrigCol = 0;
-		zType = columnType(&sNC, p, &zOrigDb, &zOrigTab, &zOrigCol, 0);
-
-		/* The vdbe must make its own copy of the column-type and other
-		 * column specific strings, in case the schema is reset before this
-		 * virtual machine is deleted.
-		 */
-		sqlite3VdbeSetColName(v, i, COLNAME_DATABASE, zOrigDb,
-				      SQLITE_TRANSIENT);
-		sqlite3VdbeSetColName(v, i, COLNAME_TABLE, zOrigTab,
-				      SQLITE_TRANSIENT);
-		sqlite3VdbeSetColName(v, i, COLNAME_COLUMN, zOrigCol,
-				      SQLITE_TRANSIENT);
-#else
-		zType = columnType(&sNC, p, 0, 0, 0, 0);
-#endif
-		sqlite3VdbeSetColName(v, i, COLNAME_DECLTYPE, zType,
-				      SQLITE_TRANSIENT);
-	}
-#endif				/* !defined(SQLITE_OMIT_DECLTYPE) */
+	return column_type;
 }
 
 /*
@@ -1851,7 +1808,6 @@ generateColumnNames(Parse * pParse,	/* Parser context */
 					      SQLITE_DYNAMIC);
 		}
 	}
-	generateColumnTypes(pParse, pTabList, pEList);
 }
 
 /*
@@ -1997,21 +1953,13 @@ sqlite3SelectAddColumnTypeAndCollation(Parse * pParse,		/* Parsing contexts */
 	sNC.pSrcList = pSelect->pSrc;
 	a = pSelect->pEList->a;
 	for (i = 0, pCol = pTab->aCol; i < pTab->nCol; i++, pCol++) {
-		const char *zType;
-		int n, m;
+		enum field_type type;
 		p = a[i].pExpr;
-		zType = columnType(&sNC, p, 0, 0, 0, &pCol->szEst);
+		type = columnType(&sNC, p, 0, 0, 0, &pCol->szEst);
 		szAll += pCol->szEst;
 		pCol->affinity = sqlite3ExprAffinity(p);
-		if (zType && (m = sqlite3Strlen30(zType)) > 0) {
-			n = sqlite3Strlen30(pCol->zName);
-			pCol->zName =
-			    sqlite3DbReallocOrFree(db, pCol->zName, n + m + 2);
-			if (pCol->zName) {
-				memcpy(&pCol->zName[n + 1], zType, m + 1);
-				pCol->colFlags |= COLFLAG_HASTYPE;
-			}
-		}
+		pCol->type = type;
+
 		if (pCol->affinity == 0)
 			pCol->affinity = SQLITE_AFF_BLOB;
 		pColl = sqlite3ExprCollSeq(pParse, p);
diff --git a/src/box/sql/sqlite3.h b/src/box/sql/sqlite3.h
index a89d5405d..a94e4c0d3 100644
--- a/src/box/sql/sqlite3.h
+++ b/src/box/sql/sqlite3.h
@@ -5402,79 +5402,6 @@ sqlite3_soft_heap_limit64(sqlite3_int64 N);
 SQLITE_API SQLITE_DEPRECATED
 void sqlite3_soft_heap_limit(int N);
 
-/*
- * CAPI3REF: Extract Metadata About A Column Of A Table
- * METHOD: sqlite3
- *
- * ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns
- * information about column C of table T in database D
- * on [database connection] X.)^  ^The sqlite3_table_column_metadata()
- * interface returns SQLITE_OK and fills in the non-NULL pointers in
- * the final five arguments with appropriate values if the specified
- * column exists.  ^The sqlite3_table_column_metadata() interface returns
- * SQLITE_ERROR and if the specified column does not exist.
- * ^If the column-name parameter to sqlite3_table_column_metadata() is a
- * NULL pointer, then this routine simply checks for the existence of the
- * table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
- * does not.
- *
- * ^The column is identified by the second, third and fourth parameters to
- * this function. ^(The second parameter is either the name of the database
- * (i.e. "main", "temp", or an attached database) containing the specified
- * table or NULL.)^ ^If it is NULL, then all attached databases are searched
- * for the table using the same algorithm used by the database engine to
- * resolve unqualified table references.
- *
- * ^The third and fourth parameters to this function are the table and column
- * name of the desired column, respectively.
- *
- * ^Metadata is returned by writing to the memory locations passed as the 5th
- * and subsequent parameters to this function. ^Any of these arguments may be
- * NULL, in which case the corresponding element of metadata is omitted.
- *
- * ^(<blockquote>
- * <table border="1">
- * <tr><th> Parameter <th> Output<br>Type <th>  Description
- *
- * <tr><td> 5th <td> const char* <td> Data type
- * <tr><td> 6th <td> const char* <td> Name of default collation sequence
- * <tr><td> 7th <td> int         <td> True if column has a NOT NULL constraint
- * <tr><td> 8th <td> int         <td> True if column is part of the PRIMARY KEY
- * <tr><td> 9th <td> int         <td> True if column is [AUTOINCREMENT]
- * </table>
- * </blockquote>)^
- *
- * ^The memory pointed to by the character pointers returned for the
- * declaration type and collation sequence is valid until the next
- * call to any SQLite API function.
- *
- * ^If the specified table is actually a view, an [error code] is returned.
- *
- * ^This function causes all database schemas to be read from disk and
- * parsed, if that has not already been done, and returns an error if
- * any errors are encountered while loading the schema.
-*/
-SQLITE_API int
-sqlite3_table_column_metadata(sqlite3 * db,	/* Connection handle */
-			      const char *zTableName,	/* Table name */
-			      const char *zColumnName,	/* Column name */
-			      char const **pzDataType,	/* OUTPUT: Declared data type */
-			      char const **pzCollSeq,	/* OUTPUT: Collation sequence name */
-			      int *pNotNull,	/* OUTPUT: True if NOT NULL constraint exists */
-			      int *pPrimaryKey,	/* OUTPUT: True if column part of PK */
-			      int *pAutoinc	/* OUTPUT: True if column is auto-increment */
-	);
-
-SQLITE_API int
-sqlite3_table_column_metadata(sqlite3 * db,
-			      const char *zTableName,
-			      const char *zColumnName,
-			      char const **pzDataType,
-			      char const **pzCollSeq,
-			      int *pNotNull,
-			      int *pPrimaryKey,
-			      int *pAutoinc);
-
 /*
  * CAPI3REF: A Handle To An Open BLOB
  * KEYWORDS: {BLOB handle} {BLOB handles}
diff --git a/src/box/sql/sqliteInt.h b/src/box/sql/sqliteInt.h
index 46b94430e..5fc612dea 100644
--- a/src/box/sql/sqliteInt.h
+++ b/src/box/sql/sqliteInt.h
@@ -1347,7 +1347,8 @@ struct Savepoint {
  * of this structure.
  */
 struct Column {
-	char *zName;		/* Name of this column, \000, then the type */
+	char *zName;		/* Name of this column */
+	enum field_type type;	/* Column type. */
 	Expr *pDflt;		/* Default value of this column */
 	char *zColl;		/* Collating sequence.  If NULL, use the default */
 	u8 notNull;		/* An OE_ code for handling a NOT NULL constraint */
@@ -1359,7 +1360,6 @@ struct Column {
 /* Allowed values for Column.colFlags:
  */
 #define COLFLAG_PRIMKEY  0x0001	/* Column is part of the primary key */
-#define COLFLAG_HASTYPE  0x0004	/* Type name follows column name */
 
 /*
  * A sort order can be either ASC or DESC.
@@ -2946,7 +2946,7 @@ int sqlite3IoerrnomemError(int);
  */
 int sqlite3StrICmp(const char *, const char *);
 unsigned sqlite3Strlen30(const char *);
-char *sqlite3ColumnType(Column *, char *);
+enum field_type sqlite3ColumnType(Column *);
 #define sqlite3StrNICmp sqlite3_strnicmp
 
 int sqlite3MallocInit(void);
diff --git a/src/box/sql/util.c b/src/box/sql/util.c
index 2b7f2c48d..0de90ac54 100644
--- a/src/box/sql/util.c
+++ b/src/box/sql/util.c
@@ -130,18 +130,12 @@ sqlite3Strlen30(const char *z)
 }
 
 /*
- * Return the declared type of a column.  Or return zDflt if the column
- * has no declared type.
- *
- * The column type is an extra string stored after the zero-terminator on
- * the column name if and only if the COLFLAG_HASTYPE flag is set.
+ * Return the declared type of a column.
  */
-char *
-sqlite3ColumnType(Column * pCol, char *zDflt)
+enum field_type
+sqlite3ColumnType(Column * pCol)
 {
-	if ((pCol->colFlags & COLFLAG_HASTYPE) == 0)
-		return zDflt;
-	return pCol->zName + strlen(pCol->zName) + 1;
+	return pCol->type;
 }
 
 /*
diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c
index df6881488..17ba61b94 100644
--- a/src/box/sql/vdbeaux.c
+++ b/src/box/sql/vdbeaux.c
@@ -2411,6 +2411,7 @@ sqlite3VdbeSetColName(Vdbe * p,			/* Vdbe being configured */
 		return SQLITE_NOMEM_BKPT;
 	}
 	assert(p->aColName != 0);
+	assert(var == COLNAME_NAME);
 	pColName = &(p->aColName[idx + var * p->nResColumn]);
 	rc = sqlite3VdbeMemSetStr(pColName, zName, -1, 1, xDel);
 	assert(rc != 0 || !zName || (pColName->flags & MEM_Term) != 0);
diff --git a/test/sql-tap/default.test.lua b/test/sql-tap/default.test.lua
index 2be1411e1..31a91bd14 100755
--- a/test/sql-tap/default.test.lua
+++ b/test/sql-tap/default.test.lua
@@ -80,7 +80,7 @@ test:do_execsql_test(
 	PRAGMA table_info(t4);
 	]], {
 	-- <default-2.1>
-	0,"ROWID","INTEGER",1,"",1,1,"C","",0,"'abc'",0
+	0,"ROWID","integer",1,"",1,1,"C","scalar",0,"'abc'",0
 	-- </default-2.1>
 })
 
@@ -91,7 +91,7 @@ test:do_execsql_test(
 	PRAGMA table_info(t4);
 	]], {
 	-- <default-2.2>
-	0,"ROWID","INTEGER",1,"",1,1,"C","",0,"'abc'",0
+	0,"ROWID","integer",1,"",1,1,"C","scalar",0,"'abc'",0
 	-- </default-2.2>
 })
 
diff --git a/test/sql-tap/eqp.test.lua b/test/sql-tap/eqp.test.lua
index a54e7ed3e..7d6ad8cd1 100755
--- a/test/sql-tap/eqp.test.lua
+++ b/test/sql-tap/eqp.test.lua
@@ -551,8 +551,8 @@ test:do_execsql_test(
 test:do_eqp_test("5.3.1", "SELECT a, b FROM t1 WHERE a=1", {
     -- It is equal for tarantol wheather to use i1 or i2
     -- because both of them are covering
-    --{0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX i2 (a=?)"},
-    {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX I1 (A=?)"},
+    {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX I2 (A=?)"},
+    --{0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX I1 (A=?)"},
 })
 -- EVIDENCE-OF: R-09991-48941 sqlite> EXPLAIN QUERY PLAN
 -- SELECT t1.*, t2.* FROM t1, t2 WHERE t1.a=1 AND t1.b>2;
@@ -592,8 +592,8 @@ test:do_execsql_test(
 test:do_eqp_test("5.6.1", "SELECT a, b FROM t1 WHERE a=1 OR b=2", {
     -- It is equal for tarantol wheather to use i1 or i2
     -- because both of them are covering
-    --{0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX i2 (a=?)"},
-    {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX I1 (A=?)"},
+    {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX I2 (A=?)"},
+    --{0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX I1 (A=?)"},
     {0, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX I3 (B=?)"},
 })
 -- EVIDENCE-OF: R-24577-38891 sqlite> EXPLAIN QUERY PLAN
@@ -633,8 +633,8 @@ test:do_eqp_test(5.9, [[
     {0, 0, 0, "EXECUTE SCALAR SUBQUERY 1"},
     -- It is equally for tarantol wheather to use i1 or i2
     -- because both of them are covering
-    --{1, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX i2 (a=?)"},
-    {1, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX I1 (A=?)"},
+    {1, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX I2 (A=?)"},
+    --{1, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX I1 (A=?)"},
     {0, 0, 0, "EXECUTE CORRELATED SCALAR SUBQUERY 2"},
     {2, 0, 0, "SEARCH TABLE T1 USING COVERING INDEX I3 (B=?)"},
 })
@@ -736,7 +736,7 @@ test:do_eqp_test(7.1, "SELECT count(*) FROM t1", {
     {0, 0, 0, "SCAN TABLE T1"},
 })
 test:do_eqp_test(7.2, "SELECT count(*) FROM t2", {
-    {0, 0, 0, "SCAN TABLE T2"},
+    {0, 0, 0, "SCAN TABLE T2 USING COVERING INDEX I1"},
 })
 -- MUST_WORK_TEST
 if (0 > 0)
-- 
2.15.1




More information about the Tarantool-patches mailing list