sqlite> .v
SQLite 3.22.0 2018-01-12 23:38:10
dec3ea4e4e6c4b1761ddc883a29eaa50dcd663ce6199667cc0ff82f7849d4f2a

sqlite> WITH pointer_tab AS (SELECT pointer()pointer) SELECT
ispointer(pointer) FROM pointer_tab;
ispointer(pointer)
1

sqlite> WITH pointer_tab AS (SELECT pointer()pointer), other_tab(i) AS
(VALUES (1)) SELECT ispointer(pointer),i FROM pointer_tab,other_tab;
ispointer(pointer),i
0,1

--Expected 1,1.  sqlite3_value_pointer is constant.
--There is no sort here.  What happened to the pointer metadata?

listing of pointer.c testing extension:
--------------------------------------------
#include "sqlite3ext.h"
SQLITE_EXTENSION_INIT1
static void free(void*pointer) {if (pointer) sqlite3_free(pointer);}
/*return a test pointer to one byte.*/
static void pointer(sqlite3_context *context, int argc, sqlite3_value
**argv) {
  sqlite3_result_pointer(context, sqlite3_malloc(1), "pointer", free);
}
/*return 1 if arg0 is sqlite3 pointer. return 0 otherwise.*/
static void ispointer(sqlite3_context *context, int argc, sqlite3_value
**argv) {
  sqlite3_result_int(context,0!=sqlite3_value_pointer(argv[0],"pointer"));
}
int sqlite3_pointer_init(sqlite3 *db, char **pzErrMsg, const
sqlite3_api_routines *pApi) {
  SQLITE_EXTENSION_INIT2(pApi);
  int rc = sqlite3_create_function(db, "pointer", 0, SQLITE_UTF8, 0,
pointer, 0, 0);
  if (SQLITE_OK == rc) rc = sqlite3_create_function(db, "ispointer", 1,
SQLITE_UTF8, 0, ispointer, 0, 0);
  return rc;
}
--------------------------------------------
Peter
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to