/ Check-in [e4579e50]
Login

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

Overview
Comment:Comment changes clarifying details of the pointer-type parameter. No changes to code.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | branch-3.20
Files: files | file ages | folders
SHA3-256: e4579e50a1ece4f65dfdae39d5c1670f0e3f7d4824e7d242f07ec9859d15155f
User & Date: drh 2017-07-17 12:41:29
Context
2017-07-17
15:38
Improved the interface to the fts5() extension mechanism for enhanced security. check-in: bc78235f user: drh tags: branch-3.20
13:37
Merge the pointer-type enhancement from the 3.20 branch. check-in: 9e8e1c4a user: drh tags: trunk
12:41
Comment changes clarifying details of the pointer-type parameter. No changes to code. check-in: e4579e50 user: drh tags: branch-3.20
12:27
Add the pointer-type parameter to sqlite3_bind_pointer(), sqlite3_result_pointer(), and sqlite3_value_pointer(). The pointer type is a static string that must match (according to strcmp()) or else the pointer is passed as a NULL. This is a security measure to prevent crossing pointers between different extensions. check-in: e1196567 user: drh tags: branch-3.20
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/misc/remember.c.

    21     21   **    UPDATE counterTab SET cnt=remember(cnt,$PTR)+1 WHERE id=$ID
    22     22   **
    23     23   ** Prepare the above statement once.  Then to use it, bind the address
    24     24   ** of the output variable to $PTR using sqlite3_bind_pointer() with a
    25     25   ** pointer type of "carray" and bind the id of the counter to $ID and
    26     26   ** run the prepared statement.
    27     27   **
           28  +** This implementation of the remember() function uses a "carray"
           29  +** pointer so that it can share pointers with the carray() extension.
           30  +**
    28     31   ** One can imagine doing similar things with floating-point values and
    29     32   ** strings, but this demonstration extension will stick to using just
    30     33   ** integers.
    31     34   */
    32     35   #include "sqlite3ext.h"
    33     36   SQLITE_EXTENSION_INIT1
    34     37   #include <assert.h>

Changes to src/sqlite.h.in.

  3886   3886   ** ^The sqlite3_bind_pointer(S,I,P,T) routine causes the I-th parameter in
  3887   3887   ** [prepared statement] S to have an SQL value of NULL, but to also be
  3888   3888   ** associated with the pointer P of type T.
  3889   3889   ** ^The sqlite3_bind_pointer() routine can be used to pass
  3890   3890   ** host-language pointers into [application-defined SQL functions].
  3891   3891   ** ^A parameter that is initialized using [sqlite3_bind_pointer()] appears
  3892   3892   ** to be an ordinary SQL NULL value to everything other than
  3893         -** [sqlite3_value_pointer()].
         3893  +** [sqlite3_value_pointer()].  The T parameter should be a static string.
  3894   3894   **
  3895   3895   ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
  3896   3896   ** for the [prepared statement] or with a prepared statement for which
  3897   3897   ** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
  3898   3898   ** then the call will return [SQLITE_MISUSE].  If any sqlite3_bind_()
  3899   3899   ** routine is passed a [prepared statement] that has been finalized, the
  3900   3900   ** result is undefined and probably harmful.
................................................................................
  5097   5097   ** kind of [sqlite3_value] object can be used with this interface.
  5098   5098   **
  5099   5099   ** ^The sqlite3_result_pointer(C,P,T) interface sets the result to an
  5100   5100   ** SQL NULL value, just like [sqlite3_result_null(C)], except that it
  5101   5101   ** also associates the host-language pointer P or type T with that 
  5102   5102   ** NULL value such that the pointer can be retrieved within an
  5103   5103   ** [application-defined SQL function] using [sqlite3_value_pointer()].
         5104  +** The T parameter should be a static string.
  5104   5105   ** This mechanism can be used to pass non-SQL values between
  5105   5106   ** application-defined functions.
  5106   5107   **
  5107   5108   ** If these routines are called from within the different thread
  5108   5109   ** than the one containing the application-defined function that received
  5109   5110   ** the [sqlite3_context] pointer, the results are undefined.
  5110   5111   */