Documentation Source Text

Check-in [70c4eaad4d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:More fixes to the virtual table documentation.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 70c4eaad4d2748d788dcd8f5870af441cdf4b80c6518393f768e2c6286ba60cf
User & Date: drh 2018-11-16 14:33:01
Context
2018-11-16
14:35
Add the SQLITE_CONSTRAINT return from xBestIndex to the change log. check-in: 14b1451274 user: drh tags: trunk
14:33
More fixes to the virtual table documentation. check-in: 70c4eaad4d user: drh tags: trunk
14:30
Explain the use of SQLITE_CONSTRAINT as a return value from xBestIndex. check-in: 52c277f049 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Show Whitespace Changes Patch

Changes to pages/vtab.in.

930
931
932
933
934
935
936
937

938
939

940
941


942
943
944
945
946
947
948
<li><p>Scan all rows of tablevalued func and for each row find rows
in realtab where x is equal to tablevaluedfunc.param1.
</ol>

<p>The xBestIndex method will be invoked once for each of the potential
plans above.  For plan 1, the aConstraint[].usable flag for for the
SQLITE_CONSTRAINT_EQ constraint on the param1 column will be true because
the right-hand side value for the "param1 = ?" constraint will be known.

But for plan 2, the aConstraint[].usable flag for "param1 = ?" will be false
because the right-hand side value is determined by an inner loop.  Hence,

the xBestIndex method should return SQLITE_CONSTRAINT when presented with
plan 2, forcing SQLite to choose plan 1.



<tcl>hd_fragment xdisconnect {sqlite3_module.xDisconnect} {xDisconnect}</tcl>
<h2>The xDisconnect Method</h2>

<codeblock>
  int (*xDisconnect)(sqlite3_vtab *pVTab);
</codeblock>







|
>

|
>
|
<
>
>







930
931
932
933
934
935
936
937
938
939
940
941
942

943
944
945
946
947
948
949
950
951
<li><p>Scan all rows of tablevalued func and for each row find rows
in realtab where x is equal to tablevaluedfunc.param1.
</ol>

<p>The xBestIndex method will be invoked once for each of the potential
plans above.  For plan 1, the aConstraint[].usable flag for for the
SQLITE_CONSTRAINT_EQ constraint on the param1 column will be true because
the right-hand side value for the "param1 = ?" constraint will be known,
since it is determined by the outer realtab loop.
But for plan 2, the aConstraint[].usable flag for "param1 = ?" will be false
because the right-hand side value is determined by an inner loop and is thus
an unknown quantity.  Because param1 is a required input to the table-valued
functions, the xBestIndex method should return SQLITE_CONSTRAINT when presented 

with plan 2, indicating that a required input is missing.  This forces the
query planner to select plan 1.

<tcl>hd_fragment xdisconnect {sqlite3_module.xDisconnect} {xDisconnect}</tcl>
<h2>The xDisconnect Method</h2>

<codeblock>
  int (*xDisconnect)(sqlite3_vtab *pVTab);
</codeblock>