Skip to content
Snippets Groups Projects
Commit df245de9 authored by Nikita Pettik's avatar Nikita Pettik Committed by Kirill Yukhin
Browse files

sql: remove redundant goto from VDBE prologue

Structure of VDBE prologue:

    0: OP_Init 0 N (address to start) 0 --|
|-> 1: ...                                |
|      ...                                |
|   N: OP_Transaction         <------------
|   N+1: (Constant expressions to be saved in registers)
|      ...
|-- M: OP_Goto 0 1 0

However, last opcode in VDBE program (i.e. OP_Goto) is generated always,
despite the existence of OP_Transaction or constant expressions.
Thus, VDBE program for queries like <SELECT * FROM table;> features
redundant jump. Such useless jump wastes exectuion time (although it is
executed once) and may affect jump prediction.

This patch adds conditional branch for generating jump opcode finishing
VDBE program: it is appended only if we need to start transaction or
code constrant expressions.

Closes #3231
parent e0ec7756
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment