[tarantool-patches] Re: [PATCH 5/8] sql: replace field type with affinity for VDBE runtime

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Tue Feb 5 18:08:18 MSK 2019


Hi! Thanks for the fixes!

>>> diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
>>> index 24d992284..80d2fd0aa 100644
>>> --- a/src/box/sql/vdbe.c
>>> +++ b/src/box/sql/vdbe.c
>>> @@ -2881,7 +2873,7 @@ case OP_MakeRecord: {
>>> 	 * of the record to data0.
>>> 	 */
>>> 	nField = pOp->p1;
>>> -	zAffinity = pOp->p4.z;
>>> +	enum field_type *types = (enum field_type *)pOp->p4.z;
>>
>> 2. Maybe, it is worth adding enum field_type *types into VdbeOp.p4union
>> and do not cast. Like we did with many other pointers.
> 
> Thanks for suggestion, but I guess it is not necessary now.
> Lets consider this refactoring a bit later.
> 

Space * and other members of p4union also were not
necessary, but they make it easier to understand what can
be stored in p4, when you look at struct VdbeOp. So please,
apply this:

diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c
index 80d2fd0aa..5e685389b 100644
--- a/src/box/sql/vdbe.c
+++ b/src/box/sql/vdbe.c
@@ -2814,7 +2814,7 @@ case OP_Column: {
   * memory cell in the range.
   */
  case OP_ApplyType: {
-	enum field_type *type_str = (enum field_type *)pOp->p4.z;
+	enum field_type *type_str = pOp->p4.types;
  	assert(type_str != NULL);
  	assert(type_str[pOp->p2] == field_type_MAX);
  	pIn1 = &aMem[pOp->p1];
@@ -2873,7 +2873,7 @@ case OP_MakeRecord: {
  	 * of the record to data0.
  	 */
  	nField = pOp->p1;
-	enum field_type *types = (enum field_type *)pOp->p4.z;
+	enum field_type *types = pOp->p4.types;
  	bIsEphemeral = pOp->p5;
  	assert(nField>0 && pOp->p2>0 && pOp->p2+nField<=(p->nMem+1 - p->nCursor)+1);
  	pData0 = &aMem[nField];
diff --git a/src/box/sql/vdbe.h b/src/box/sql/vdbe.h
index dcf974c51..088f24d0e 100644
--- a/src/box/sql/vdbe.h
+++ b/src/box/sql/vdbe.h
@@ -84,6 +84,11 @@ struct VdbeOp {
  		struct sql_key_info *key_info;
  		/** Used when p4type is P4_SPACEPTR. */
  		struct space *space;
+		/**
+		 * Used to apply types when making a record, or
+		 * doing a cast.
+		 */
+		enum field_type *types;
  	} p4;
  #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
  	char *zComment;		/* Comment to improve readability */




More information about the Tarantool-patches mailing list