WL#9384: Prepare each DML statement once

Affects: Server-8.0   —   Status: Complete

This is part of Refactor DML statement preparation. It depends on the refactoring done in WL#5094: Create SQL command classes for DML statements.

WL#5094 created a uniform interface to all DML statements (except SET and CALL), which implemented a prepare() and an execute() interface for all such statements. Non-prepared statements are executed using the execute() interface, which internally calls the corresponding prepare() function before executing the statement.

However, prepared statements are still prepared once for every execution. The goal of this WL is that prepared statements are prepared only once: when the PREPARE command is performed on the statement. Likewise, statements inside stored procedures will also be prepared once, on their first execution.

The benefits of this work are:

  • performance enhancement: avoid costly preparation per execution.
  • code simplification: avoid tedious rollback of preparation structures, a source of several bugs.

As part of the work, the way dynamic parameters used in prepared statements are resolved will be changed. This will necessarily cause some behavioral changes in some prepared statement use cases, but we try to keep such changes at a minimum by performing dynamic repreparation of statements when actual dynamic parameter values are not in compliance with the resolved data types. The implementation is however tuned to avoid unnecessary repreparations, since they will affect performance negatively.