Documentation Source Text

Check-in [e16ada80d6]
Login

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

Overview
Comment:Back out the previous change. We are instead going to modify the code to match the documentation.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e16ada80d643aa072ae0ce0daf8c35383b43c96ec03c8a032698c9d0455e5b65
User & Date: drh 2019-08-05 20:39:24
Context
2019-08-07
21:59
Fix typo in comment. check-in: b0c5406903 user: mistachkin tags: trunk
2019-08-05
20:39
Back out the previous change. We are instead going to modify the code to match the documentation. check-in: 3578d6c47b user: drh tags: branch-3.29
20:39
Back out the previous change. We are instead going to modify the code to match the documentation. check-in: e16ada80d6 user: drh tags: trunk
12:54
Update the documentation on the affinity of the columns of VIEWs and subqueries that are generated from expressions to match the actual implementation of 10 years standing - namely such columns have BLOB affinity, not no affinity. Ticket https://www.sqlite.org/src/info/d52a29a9e6bc55c5 check-in: 07b7749da8 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to pages/datatype3.in.

   312    312   
   313    313     <li><p>^Otherwise, an expression has no affinity.
   314    314   </ul>
   315    315   
   316    316   <tcl>hd_fragment affview {rules for determining column affinity in VIEWs}</tcl>
   317    317   <h2>Column Affinity For Views And Subqueries</h2>
   318    318   
   319         -<p>The columns of a [VIEW] or FROM-clause subquery have the same affinity
   320         -as the expressions in the result set of the [SELECT] statement that implements the VIEW
   321         -or subquery.  Except, column of a VIEW or subquery that are generated by expressions
   322         -that have no affinity are assigned an affinity of BLOB.
          319  +<p>The "columns" of a [VIEW] or FROM-clause subquery are really
          320  +the expressions
          321  +in the result set of the [SELECT] statement that implements the VIEW
          322  +or subquery.  Thus, the affinity for columns of a VIEW or subquery
          323  +are determined by the expression affinity rules above.
   323    324   Consider an example:
   324    325   
   325    326   <blockquote><pre>
   326    327   CREATE TABLE t1(a INT, b TEXT, c REAL);
   327    328   CREATE VIEW v1(x,y,z) AS SELECT b, a+c, 42 FROM t1 WHERE b!=11;
   328    329   </pre></blockquote>
   329    330   
   330    331   <p>The affinity of the v1.x column will be the same as the affinity
   331    332   of t1.b (TEXT), since v1.x maps directly into t1.b.  But
   332    333   columns v1.y and v1.z both have no affinity, since those columns
   333    334   map into expression a+c and 42, and expressions always have no
   334         -affinity, so that v1.y and v1.z columns have an affinity of BLOB.
          335  +affinity.
   335    336   
   336    337   <p>When the [SELECT] statement that implements a [VIEW] or 
   337    338   FROM-clause subquery is a [compound SELECT] then the affinity of 
   338    339   each supposed column of the VIEW or subquery will
   339    340   be the affinity of the corresponding result column for
   340    341   one of the individual SELECT statements that make up 
   341    342   the compound.