Re: [sqlite] Using VACUUM on an empty file will create a defaultdatabase

2013-07-25 Thread Igor Tandetnik

On 7/25/2013 2:51 AM, sworddrag...@aol.com wrote:

I'm not sure what you want to say me. "echo 'garbage' > some/random/file"
will also overwrite non-empty files which is more problematic.


Precisely. So do you believe there should be an option to disable echo 
command? Or rm command? Or cp command? There are lots of ways a person 
could "destroy complete environments" - why are you singling out one of 
the more obscure and relatively harmless ones?

--
Igor Tandetnik

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Using VACUUM on an empty file will create a defaultdatabase

2013-07-25 Thread Paolo Bolzoni
I also have hard time follow...
My answer would be: "yes,"


What is the problem?

On Thu, Jul 25, 2013 at 8:51 AM,   wrote:
> I'm not sure what you want to say me. "echo 'garbage' > some/random/file"
> will also overwrite non-empty files which is more problematic.
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Using VACUUM on an empty file will create a defaultdatabase

2013-07-25 Thread sworddragon2
I'm not sure what you want to say me. "echo 'garbage' > some/random/file" 
will also overwrite non-empty files which is more problematic.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] How to create connection life-time object?

2013-07-25 Thread Dušan Paulovič
Hello, is there a way to somehow set a connection life-time object?

I mean something like:
Let's imagine you are working with some sqlite3 connection and want so
share same data with extensions, but must be guaranteed, that object gets
destroyed when connection is closed.

For now, I use creating function mechanism for it:
(pseudo - not tested code)
void return_user_data(sqlite3_context* ctxP, int argc, sqlite3_value** argv)
{
  void * ptr = sqlite3_user_data(ctxP);
  sqlite3_result_blob(ctxP, (void*), sizeof(void*));
}

int register_app_obj(sqlite3 * db)
{
  my_type *m_obj = (my_type*) sqlite3_malloc(sizeof(my_type));
  if (m_obj &&
SQLITE_OK != sqlite3_create_function_v2(
db, "app_obj", 0, SQLITE_ANY, m_obj,
return_user_data, NULL, NULL, sqlite3_free))
  {
sqlite3_free(m_obj);
m_obj = NULL;
return SQLITE_ERROR;
  }
  return SQLITE_OK;
}

Then if extension needs to get app_obj it queries "SELECT app_obj();" and
translates blob.
But this way it is too much of overhead and also there is a restriction,
that functions
can be registered only if there is no any active statement.

I have also made a complicated virtual table implementation of the same,
because
modules can be registered while statements are active, but it is much more
complicated
then such thing should be.

Do you have any idea?

It would be fine to have something like:
int sqlite3_set_lifetime_object(
  sqlite3 *db,  /*db connection*/
  const char *zObjectName,  /*utf8 name of object*/
  void *pObject,/*if NULL, object is removed*/
  void(*xDestroy)(void*)/*destructor*/
);

void * sqlite3_get_lifetime_object(
  sqlite3 *db,  /*db connection*/
  const char *zObjectName   /*utf8 name of object*/
);
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users