Thanks for your suggestion Jay.

static sqlite3_module csvModule = {
  0,                        /* iVersion */
  csvCreate,                /* xCreate - create a table */
  csvConnect,               /* xConnect - connect to an existing table */
  csvBestIndex,             /* xBestIndex - Determine search strategy */
  csvDisconnect,            /* xDisconnect - Disconnect from a table */
  csvDestroy,               /* xDestroy - Drop a table */
  csvOpen,                  /* xOpen - open a cursor */
  csvClose,                 /* xClose - close a cursor */
  csvFilter,                /* xFilter - configure scan constraints */
  csvNext,                  /* xNext - advance a cursor */
  csvEof,                   /* xEof */
  csvColumn,                /* xColumn - read data */
  csvRowid,                 /* xRowid - read data */
  0,                        /* xUpdate - write data */
  0,                        /* xBegin - begin transaction */
  0,                        /* xSync - sync transaction */
  0,                        /* xCommit - commit transaction */
  0,                        /* xRollback - rollback transaction */
  0,                        /* xFindFunction - function overloading */
  0                         /* xRename - rename the table */
};

sqlite> .load ./csv.sqlext
sqlite> create virtual table test using csv(test1.csv, ',', USE_HEADER_ROW);
sqlite> select * from test;
1|2|3
a|b|c
a|b|c
a|b|c .. z
a|b|c,d
sqlite> alter table test rename to test1;
sqlite> select * from test;
Error: no such table: test
sqlite> select * from test1;
1|2|3
a|b|c
a|b|c
a|b|c .. z
a|b|c,d
sqlite>

So it's seems that SQLite properly handles virtual table rename even
when xRename is not specified by the module.
Regards.

On Tue, Oct 23, 2012 at 10:50 PM, Jay A. Kreibich <[email protected]> wrote:
> On Tue, Oct 23, 2012 at 10:16:07PM +0200, gwenn scratched on the wall:
>> Hello,
>>
>> The documentation says the xRename function is mandatory:
>> http://sqlite.org/vtab.html#xrename
>> "The xRename method is required for every virtual table implementation."
>>
>> But it seems possible to not specify it:
>>   static const sqlite3_module fts3aux_module = {
>> ...
>>      0,                           /* xRename       */
>> ...
>>   };
>
>
>   And when you attempt to rename the table, what happens?
>
>
>   The virtual table interface is advanced, in the sense that there are
>   very few safety nets or double-checks.  It is designed to be used by
>   an intelligent programmer that knows their stuff.  You need to do what
>   the docs say, exactly, or something bad can happen.  That's not to
>   say something bad will happen right away.  The fact that you can assign
>   a NULL function pointer to the xRename() function only means the system
>   is not double-checking your work when you pass in the structure... it
>   does not mean that passing a NULL is allowed.  I strongly suspect that
>   if you do not provide a xRename() function, and someone attempts to
>   rename the table, the whole application will simply crash.  Your fault.
>
>    -j
>
> --
> Jay A. Kreibich < J A Y  @  K R E I B I.C H >
>
> "Intelligence is like underwear: it is important that you have it,
>  but showing it to the wrong people has the tendency to make them
>  feel uncomfortable." -- Angela Johnson
> _______________________________________________
> sqlite-users mailing list
> [email protected]
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to