SQLite

Check-in [f13ef591]
Login

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

Overview
Comment:Demonstration of how to extend the if() and iif() SQL functions to support more than 3 arguments.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | if-many-args
Files: files | file ages | folders
SHA3-256: f13ef591848e7c69694c0af5778dae4d04a071a2f95192fb1dc9d6978dc87c0c
User & Date: drh 2025-01-21 12:33:00
Context
2025-01-21
12:33
Demonstration of how to extend the if() and iif() SQL functions to support more than 3 arguments. (Leaf check-in: f13ef591 user: drh tags: if-many-args)
11:10
Use Tcl_GetString() instead of Tcl_GetCharLength() to test for a zero-length string in the TCL interface, since that is much more efficient. (check-in: a8d9dcfd user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/func.c.
2811
2812
2813
2814
2815
2816
2817
2818
2819

2820
2821

2822
2823
2824
2825
2826
2827
2828
    MFUNCTION(sqrt,              1, sqrt,      math1Func   ),
    MFUNCTION(radians,           1, degToRad,  math1Func   ),
    MFUNCTION(degrees,           1, radToDeg,  math1Func   ),
    MFUNCTION(pi,                0, 0,         piFunc      ),
#endif /* SQLITE_ENABLE_MATH_FUNCTIONS */
    FUNCTION(sign,               1, 0, 0,      signFunc    ),
    INLINE_FUNC(coalesce,       -1, INLINEFUNC_coalesce, 0 ),
    INLINE_FUNC(iif,             2, INLINEFUNC_iif,      0 ),
    INLINE_FUNC(iif,             3, INLINEFUNC_iif,      0 ),

    INLINE_FUNC(if,              2, INLINEFUNC_iif,      0 ),
    INLINE_FUNC(if,              3, INLINEFUNC_iif,      0 ),

  };
#ifndef SQLITE_OMIT_ALTERTABLE
  sqlite3AlterFunctions();
#endif
  sqlite3WindowFunctions();
  sqlite3RegisterDateTimeFunctions();
  sqlite3RegisterJsonFunctions();







|
|
>
|
|
>







2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
    MFUNCTION(sqrt,              1, sqrt,      math1Func   ),
    MFUNCTION(radians,           1, degToRad,  math1Func   ),
    MFUNCTION(degrees,           1, radToDeg,  math1Func   ),
    MFUNCTION(pi,                0, 0,         piFunc      ),
#endif /* SQLITE_ENABLE_MATH_FUNCTIONS */
    FUNCTION(sign,               1, 0, 0,      signFunc    ),
    INLINE_FUNC(coalesce,       -1, INLINEFUNC_coalesce, 0 ),
    INLINE_FUNC(iif,             0, 0, 0 ),
    INLINE_FUNC(iif,             1, 0, 0 ),
    INLINE_FUNC(iif,            -1, INLINEFUNC_iif,      0 ),
    INLINE_FUNC(if,              0, 0, 0 ),
    INLINE_FUNC(if,              1, 0, 0 ),
    INLINE_FUNC(if,             -1, INLINEFUNC_iif,      0 ),
  };
#ifndef SQLITE_OMIT_ALTERTABLE
  sqlite3AlterFunctions();
#endif
  sqlite3WindowFunctions();
  sqlite3RegisterDateTimeFunctions();
  sqlite3RegisterJsonFunctions();