[Tarantool-patches] [PATCH v4 05/53] sql: move MEM-related functions to mem.c/mem.h

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Tue Mar 30 01:58:17 MSK 2021


Thanks for the patch!

I didn't compare each line of each moved function with its
original code, so I trust you didn't make any functional
changes.

See 2 comments below.

> diff --git a/src/box/sql/mem.c b/src/box/sql/mem.c
> new file mode 100644
> index 000000000..62338e1db
> --- /dev/null
> +++ b/src/box/sql/mem.c
> @@ -0,0 +1,2376 @@

<...>

> +
> +
> +#ifdef SQL_DEBUG
> +/*
> + * This routine prepares a memory cell for modification by breaking
> + * its link to a shallow copy and by marking any current shallow
> + * copies of this cell as invalid.
> + *
> + * This is used for testing and debugging only - to make sure shallow
> + * copies are not misused.
> + */
> +void
> +sqlVdbeMemAboutToChange(Vdbe * pVdbe, Mem * pMem)

1. This is a vdbe method, not mem. It takes mem as an argument, but
is a method of vdbe struct. Lets keep it in the old place.

> +{
> +	int i;
> +	Mem *pX;
> +	for (i = 0, pX = pVdbe->aMem; i < pVdbe->nMem; i++, pX++) {
> +		if (pX->pScopyFrom == pMem) {
> +			pX->flags |= MEM_Undefined;
> +			pX->pScopyFrom = 0;
> +		}
> +	}
> +	pMem->pScopyFrom = 0;
> +}

<...>

> +
> +/*
> + * Print the SQL that was used to generate a VDBE program.
> + */
> +void
> +sqlVdbePrintSql(Vdbe * p)

2. Ditto. Such functions should be moved to vdbe.h/vdbe.c eventually.
And ideally mem.h/mem.c should not know about vdbe anything (probably
can't be done now).

> +{
> +	const char *z = 0;
> +	if (p->zSql) {
> +		z = p->zSql;
> +	} else if (p->nOp >= 1) {
> +		const VdbeOp *pOp = &p->aOp[0];
> +		if (pOp->opcode == OP_Init && pOp->p4.z != 0) {
> +			z = pOp->p4.z;
> +			while (sqlIsspace(*z))
> +				z++;
> +		}
> +	}
> +	if (z)
> +		printf("SQL: [%s]\n", z);
> +}


More information about the Tarantool-patches mailing list