/ Check-in [55f53965]
Login

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

Overview
Comment:Update header comments on the carray() and remember() extensions to bring out the fact that the pointer arguments must be bound using sqlite3_bind_pointer().
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256:55f5396576d186f310cb0fa66fbdb8ea68c18a3d0fe5de4b395ea03c7aa04c9e
User & Date: drh 2017-07-13 19:11:13
Context
2017-07-13
20:11
Fix documentation typo. No changes to code. check-in: 9319f7b7 user: drh tags: trunk
19:11
Update header comments on the carray() and remember() extensions to bring out the fact that the pointer arguments must be bound using sqlite3_bind_pointer(). check-in: 55f53965 user: drh tags: trunk
18:09
Add new interfaces sqlite3_bind_pointer(), sqlite3_result_pointer(), and sqlite3_value_pointer() used to safely move pointer values through SQL without exposing underlying memory address information. check-in: 72de49f2 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/misc/carray.c.

13
14
15
16
17
18
19
20
21

22
23
24
25
26
27
28
** This file demonstrates how to create a table-valued-function that
** returns the values in a C-language array.
** Examples:
**
**      SELECT * FROM carray($ptr,5)
**
** The query above returns 5 integers contained in a C-language array
** at the address $ptr.  $ptr is a pointer to the array of integers that
** has been cast to an integer.

**
** There is an optional third parameter to determine the datatype of
** the C-language array.  Allowed values of the third parameter are
** 'int32', 'int64', 'double', 'char*'.  Example:
**
**      SELECT * FROM carray($ptr,10,'char*');
**







|
|
>







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
** This file demonstrates how to create a table-valued-function that
** returns the values in a C-language array.
** Examples:
**
**      SELECT * FROM carray($ptr,5)
**
** The query above returns 5 integers contained in a C-language array
** at the address $ptr.  $ptr is a pointer to the array of integers.
** The pointer value must be assigned to $ptr using the
** sqlite3_bind_pointer() interface.
**
** There is an optional third parameter to determine the datatype of
** the C-language array.  Allowed values of the third parameter are
** 'int32', 'int64', 'double', 'char*'.  Example:
**
**      SELECT * FROM carray($ptr,10,'char*');
**

Changes to ext/misc/remember.c.

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
**
** This allows, for example, a counter to incremented and the original
** value retrieved, atomically, using a single statement:
**
**    UPDATE counterTab SET cnt=remember(cnt,$PTR)+1 WHERE id=$ID
**
** Prepare the above statement once.  Then to use it, bind the address
** of the output variable to $PTR and the id of the counter to $ID and
** run the prepared statement.
**
** One can imagine doing similar things with floating-point values and
** strings, but this demonstration extension will stick to using just
** integers.
*/
#include "sqlite3ext.h"
SQLITE_EXTENSION_INIT1







|
|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
**
** This allows, for example, a counter to incremented and the original
** value retrieved, atomically, using a single statement:
**
**    UPDATE counterTab SET cnt=remember(cnt,$PTR)+1 WHERE id=$ID
**
** Prepare the above statement once.  Then to use it, bind the address
** of the output variable to $PTR (using sqlite3_binary_pointer()) and
** bind the id of the counter to $ID and run the prepared statement.
**
** One can imagine doing similar things with floating-point values and
** strings, but this demonstration extension will stick to using just
** integers.
*/
#include "sqlite3ext.h"
SQLITE_EXTENSION_INIT1