SQLite

Changes On Branch affinity-sql-func
Login

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

Changes In Branch affinity-sql-func Excluding Merge-Ins

This is equivalent to a diff from 36944be6 to f778f58a

2017-01-03
15:59
Defer size checking on row-value assignments for when the RHS is a SELECT until after the "*" wildcards have been expanded. (check-in: 5c892938 user: drh tags: branch-3.16)
14:45
Add the experimental affinity() SQL function when SQLITE_DEBUG is defined. (check-in: bed0eaa5 user: drh tags: trunk)
14:39
Put the affinity() function implementation inside of #ifdef SQLITE_DEBUG. (Closed-Leaf check-in: f778f58a user: drh tags: affinity-sql-func)
14:30
Merge all the latest changes from trunk. (check-in: c27cd8a8 user: drh tags: affinity-sql-func)
13:45
Defer size checking on row-value assignments for when the RHS is a SELECT until after the "*" wildcards have been expanded. (check-in: 36944be6 user: drh tags: trunk)
11:59
Fix a typo on a comment. No code changes. (check-in: abc27b60 user: drh tags: trunk)
02:58
Improvements to the way vector assignment size checking is done. Size checks when the RHS is a SELECT are deferred until after "*" wildcards are expanded. (Closed-Leaf check-in: 696219b1 user: drh tags: vector-size-check)

Changes to src/expr.c.

3655
3656
3657
3658
3659
3660
3661
















3662
3663
3664
3665
3666
3667
3668
3655
3656
3657
3658
3659
3660
3661
3662
3663
3664
3665
3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
3679
3680
3681
3682
3683
3684







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







      /* The UNLIKELY() function is a no-op.  The result is the value
      ** of the first argument.
      */
      if( pDef->funcFlags & SQLITE_FUNC_UNLIKELY ){
        assert( nFarg>=1 );
        return sqlite3ExprCodeTarget(pParse, pFarg->a[0].pExpr, target);
      }

#ifdef SQLITE_DEBUG
      /* The AFFINITY() function evaluates to a string that describes
      ** the type affinity of the argument.  This is used for testing of
      ** the SQLite type logic.
      */
      if( pDef->funcFlags & SQLITE_FUNC_AFFINITY ){
        const char *azAff[] = { "blob", "text", "numeric", "integer", "real" };
        char aff;
        assert( nFarg==1 );
        aff = sqlite3ExprAffinity(pFarg->a[0].pExpr);
        sqlite3VdbeLoadString(v, target, 
                              aff ? azAff[aff-SQLITE_AFF_BLOB] : "none");
        return target;
      }
#endif

      for(i=0; i<nFarg; i++){
        if( i<32 && sqlite3ExprIsConstant(pFarg->a[i].pExpr) ){
          testcase( i==31 );
          constMask |= MASKBIT32(i);
        }
        if( (pDef->funcFlags & SQLITE_FUNC_NEEDCOLL)!=0 && !pColl ){

Changes to src/func.c.

1771
1772
1773
1774
1775
1776
1777



1778
1779
1780
1781
1782
1783
1784
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787







+
+
+







#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
    DFUNCTION(sqlite_compileoption_used,1, 0, 0, compileoptionusedFunc  ),
    DFUNCTION(sqlite_compileoption_get, 1, 0, 0, compileoptiongetFunc  ),
#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
    FUNCTION2(unlikely,          1, 0, 0, noopFunc,  SQLITE_FUNC_UNLIKELY),
    FUNCTION2(likelihood,        2, 0, 0, noopFunc,  SQLITE_FUNC_UNLIKELY),
    FUNCTION2(likely,            1, 0, 0, noopFunc,  SQLITE_FUNC_UNLIKELY),
#ifdef SQLITE_DEBUG
    FUNCTION2(affinity,          1, 0, 0, noopFunc,  SQLITE_FUNC_AFFINITY),
#endif
    FUNCTION(ltrim,              1, 1, 0, trimFunc         ),
    FUNCTION(ltrim,              2, 1, 0, trimFunc         ),
    FUNCTION(rtrim,              1, 2, 0, trimFunc         ),
    FUNCTION(rtrim,              2, 2, 0, trimFunc         ),
    FUNCTION(trim,               1, 3, 0, trimFunc         ),
    FUNCTION(trim,               2, 3, 0, trimFunc         ),
    FUNCTION(min,               -1, 0, 1, minmaxFunc       ),

Changes to src/sqliteInt.h.

1561
1562
1563
1564
1565
1566
1567

1568
1569
1570
1571
1572
1573
1574
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575







+







#define SQLITE_FUNC_COUNT    0x0100 /* Built-in count(*) aggregate */
#define SQLITE_FUNC_COALESCE 0x0200 /* Built-in coalesce() or ifnull() */
#define SQLITE_FUNC_UNLIKELY 0x0400 /* Built-in unlikely() function */
#define SQLITE_FUNC_CONSTANT 0x0800 /* Constant inputs give a constant output */
#define SQLITE_FUNC_MINMAX   0x1000 /* True for min() and max() aggregates */
#define SQLITE_FUNC_SLOCHNG  0x2000 /* "Slow Change". Value constant during a
                                    ** single query - might change over time */
#define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */

/*
** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
** used to create the initializers for the FuncDef structures.
**
**   FUNCTION(zName, nArg, iArg, bNC, xFunc)
**     Used to create a scalar function definition of a function zName