[sqlite] problems on importing quoted csv files

2011-05-16 Thread jiajianying
Hello,

I'm using sqlite to process some csv files. It is very disappointing 
that sqlite's csv mode doesn't support quoted csv format. I tried 
spatialite which can only strip quote marks but can't parse it correctly.

Is there any suitable modules or tools for importing quoted csv files?

Thanks

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


Re: [sqlite] Compiling in Xcode 3.1.3

2011-05-16 Thread Simon Slavin

On 16 May 2011, at 10:48pm, john darnell wrote:

> sourcecode.c
> sourcecode.c.c
> sourcecode.c.h
> sourcecode.c.objc
> sourcecode.cpp
> sourcecode.cpp.cpp
> sourcecode.cpp.h
> sourcecode.cpp.objcpp
> 
> The default filetype for SQLite3.c was sourcecode.c.c.  The default filetype 
> for SQLite3.h was sourcode.c.c

Well, they should be options 1 and 3 respectively.  2 and 3 will also be fine.  
Anything else may cause problems.

> For grins I looked at a .CPP file and its file type was sourcecode.cpp.cpp

I hadn't come across the '.c.c' convention before but now I understand it.  
They're using it to distinguish between C (.c.) and C++ (.cpp.).  The 
confusions between them is what caused your errors in the first place.

Somewhere in the Developer tools you can find at least one example file in 
every language Xcode can handle, up to and including AppleScript.  Or maybe 
they've moved them to the downloadable sample files now.

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


Re: [sqlite] DB triggers: Initial patch

2011-05-16 Thread Nico Williams
A few more comments:

 - The patch adds just 8KB to libsqlite3.a and the shell, and this is
true regardless of whether the before and after compilations use -g or
not, -O0 vs. -O2, and -DSQLITE_DEBUG=1 or not.

 - I've tried to keep the SQLite3 C style as best I could.

 - My earlier characterization of performance and memory footprint
impact of this patch has not changed, but I can now also tell you that
the memory footprint (excluding cache and alignment effects) is two
bytes per-attached DB.

 - I will probably add a SQLITE_OMIT_DB_TRIGGERS #define so that DB
triggers can be omitted separately from triggers, just in case that
8KB of text is precious to folks who use triggers (anyone?).

 - There's a bug in my patch where the AFTER BEGIN triggers, if
defined, run before any AFTER CONNECT triggers, if defined.  I've got
a fix for that.

After I switch to Fossil, write tests, and cleanup, I'll stop there --
the unimplemented DB triggers can be added later, possibly by someone
else as I don't need them.

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


Re: [sqlite] Compiling in Xcode 3.1.3

2011-05-16 Thread john darnell
Thanks, Simon:

   In Xcode 3.1.3 when I highlight SQLite3.c, click the Info icon and look 
under the General Tab, and then click the File Type dropdown there are perhaps 
sixty to seventy choices I can make, but only a few make any sense, some more 
than others.  They are:

sourcecode.c
sourcecode.c.c
sourcecode.c.h
sourcecode.c.objc
sourcecode.cpp
sourcecode.cpp.cpp
sourcecode.cpp.h
sourcecode.cpp.objcpp

The default filetype for SQLite3.c was sourcecode.c.c.  The default filetype 
for SQLite3.h was sourcode.c.c

For grins I looked at a .CPP file and its file type was sourcecode.cpp.cpp

Any thoughts?

R,
John

.
> -Original Message-
> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org]
> On Behalf Of Simon Slavin
> Sent: Monday, May 16, 2011 4:32 PM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] Compiling in Xcode 3.1.3
> 
> 
> On 16 May 2011, at 10:09pm, john darnell wrote:
> 
> > I highlighted the file, clicked the information icon and then under the 
> > "General"
> category I changed the type of file from "sourcecode.c.c" to "sourcecode.c."
> When pressing Command-K I get no errors but one warning: "Warning, no rule to
> process sqlite3.c of type sourcecode.c for architecture i386"
> 
> I had no problems with compiling the Amalgamation source code under Xcode 3.x.
> I've since moved to Xcode 4.0 so I can no longer tell you what my settings 
> were
> but I never saw a '.c.c' extension, I just had to make sure the 'File Type' 
> for
> sqlite3.c was 'C source', not 'Objective-C++ source', and that similarly 
> 'File Type'
> for sqlite3.h was 'C header' not 'C++ header'.
> 
> The only thing I'm getting in Xcode 4.0 with LLVM GCC 4.2 is some 'Unused
> Entity' warnings and I have no problem with those: they're right, and they're 
> just
> warnings.
> 
> Simon.
> ___
> 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] Compiling in Xcode 3.1.3

2011-05-16 Thread Simon Slavin

On 16 May 2011, at 10:09pm, john darnell wrote:

> I highlighted the file, clicked the information icon and then under the 
> "General" category I changed the type of file from "sourcecode.c.c" to 
> "sourcecode.c."   When pressing Command-K I get no errors but one warning: 
> "Warning, no rule to process sqlite3.c of type sourcecode.c for architecture 
> i386"

I had no problems with compiling the Amalgamation source code under Xcode 3.x.  
I've since moved to Xcode 4.0 so I can no longer tell you what my settings were 
but I never saw a '.c.c' extension, I just had to make sure the 'File Type' for 
sqlite3.c was 'C source', not 'Objective-C++ source', and that similarly 'File 
Type' for sqlite3.h was 'C header' not 'C++ header'.

The only thing I'm getting in Xcode 4.0 with LLVM GCC 4.2 is some 'Unused 
Entity' warnings and I have no problem with those: they're right, and they're 
just warnings.

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


Re: [sqlite] Compiling in Xcode 3.1.3

2011-05-16 Thread john darnell
Okay,  I started looking at the code in SQLite3 and noticed that this is 
already done for me.  

Please have mercy on me,  I am on the road and do not have access to my usual 
resources.  What do I need to do to get Xcode to compile this code in 3.1.3?

R,
John

> -Original Message-
> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org]
> On Behalf Of john darnell
> Sent: Monday, May 16, 2011 4:09 PM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] Compiling in Xcode 3.1.3
> 
> Thanks again.
> 
> I highlighted the file, clicked the information icon and then under the 
> "General"
> category I changed the type of file from "sourcecode.c.c" to "sourcecode.c."
> When pressing Command-K I get no errors but one warning: "Warning, no rule to
> process sqlite3.c of type sourcecode.c for architecture i386"
> 
> I am going to try this next:
> 
> extern "C" {
>#include "sqlite3.h"
>  }
> 
> And see if that helps.
> > -Original Message-
> > From: sqlite-users-boun...@sqlite.org 
> > [mailto:sqlite-users-boun...@sqlite.org]
> > On Behalf Of Richard Hipp
> > Sent: Monday, May 16, 2011 3:45 PM
> > To: General Discussion of SQLite Database
> > Subject: Re: [sqlite] Compiling in Xcode 3.1.3
> >
> > On Mon, May 16, 2011 at 4:31 PM, john darnell
> > wrote:
> >
> > > Thanks for responding, Mr HIpp.
> > >
> > > There are 1265 errors in all, but most of them look very close to 
> > > something
> > > like this:
> > >
> > >Invalid conversion from void * to XXX *
> > >
> > > Or
> > >
> > >forward declaration of struct_ht
> > >
> > > I thought it might be a pathing error (I had not added the path to the
> > > directory where SQLite 3 is stored) but I did that and it didn't really
> > > resolve anything.
> > >
> >
> > SQLite is ANSI-C code.  Sounds to me like you are trying to compile it as
> > C++, or maybe Objective-C.
> >
> >
> > >
> > > R,
> > > John
> > >
> > > > -Original Message-
> > > > From: sqlite-users-boun...@sqlite.org [mailto:
> > > sqlite-users-boun...@sqlite.org]
> > > > On Behalf Of Richard Hipp
> > > > Sent: Monday, May 16, 2011 3:19 PM
> > > > To: General Discussion of SQLite Database
> > > > Subject: Re: [sqlite] Compiling in Xcode 3.1.3
> > > >
> > > > On Mon, May 16, 2011 at 4:01 PM, john darnell
> > > > wrote:
> > > >
> > > > > I have code that compiles just fine using Visual Studio 8 on Windows
> > > XP,
> > > > > but when I port SQLite over to a Mac OSX (Snow Leopard) platform
> > > using
> > > > > Xcode 3.1.3 I get roughly 1000 errors based upon SQLite.  Is there
> > > something
> > > > > I need to turn off/on when using SQLite on the Mac?
> > > > >
> > > >
> > > > No.  We compile SQLite on Macs with no problems.  What are the errors?
> > > >
> > > >
> > > > >
> > > > > R,
> > > > > John A.M. Darnell
> > > > > Senior Programmer
> > > > > Walsworth Publishing Company
> > > > > Brookfield, MO
> > > > > John may also be reached at johnamdarn...@gmail.com > > > > johnamdarn...@gmail.com>
> > > > >
> > > > > Trivia question Trivia question:  In The Lord of the Rings,Leglolas 
> > > > > was
> > > a
> > > > > prince among the Silvan Elves.  What was the name of his father the
> > > King?
> > > > >  For extra credit, what was his surname?
> > > > >
> > > > >
> > > > >
> > > > > ___
> > > > > sqlite-users mailing list
> > > > > sqlite-users@sqlite.org
> > > > > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > D. Richard Hipp
> > > > d...@sqlite.org
> > > > ___
> > > > 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
> > >
> >
> >
> >
> > --
> > D. Richard Hipp
> > d...@sqlite.org
> > ___
> > 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
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Compiling in Xcode 3.1.3

2011-05-16 Thread john darnell
Thanks again.

I highlighted the file, clicked the information icon and then under the 
"General" category I changed the type of file from "sourcecode.c.c" to 
"sourcecode.c."   When pressing Command-K I get no errors but one warning: 
"Warning, no rule to process sqlite3.c of type sourcecode.c for architecture 
i386"

I am going to try this next:

extern "C" {
   #include "sqlite3.h"
 } 

And see if that helps.
> -Original Message-
> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org]
> On Behalf Of Richard Hipp
> Sent: Monday, May 16, 2011 3:45 PM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] Compiling in Xcode 3.1.3
> 
> On Mon, May 16, 2011 at 4:31 PM, john darnell
> wrote:
> 
> > Thanks for responding, Mr HIpp.
> >
> > There are 1265 errors in all, but most of them look very close to something
> > like this:
> >
> >Invalid conversion from void * to XXX *
> >
> > Or
> >
> >forward declaration of struct_ht
> >
> > I thought it might be a pathing error (I had not added the path to the
> > directory where SQLite 3 is stored) but I did that and it didn't really
> > resolve anything.
> >
> 
> SQLite is ANSI-C code.  Sounds to me like you are trying to compile it as
> C++, or maybe Objective-C.
> 
> 
> >
> > R,
> > John
> >
> > > -Original Message-
> > > From: sqlite-users-boun...@sqlite.org [mailto:
> > sqlite-users-boun...@sqlite.org]
> > > On Behalf Of Richard Hipp
> > > Sent: Monday, May 16, 2011 3:19 PM
> > > To: General Discussion of SQLite Database
> > > Subject: Re: [sqlite] Compiling in Xcode 3.1.3
> > >
> > > On Mon, May 16, 2011 at 4:01 PM, john darnell
> > > wrote:
> > >
> > > > I have code that compiles just fine using Visual Studio 8 on Windows
> > XP,
> > > > but when I port SQLite over to a Mac OSX (Snow Leopard) platform
> > using
> > > > Xcode 3.1.3 I get roughly 1000 errors based upon SQLite.  Is there
> > something
> > > > I need to turn off/on when using SQLite on the Mac?
> > > >
> > >
> > > No.  We compile SQLite on Macs with no problems.  What are the errors?
> > >
> > >
> > > >
> > > > R,
> > > > John A.M. Darnell
> > > > Senior Programmer
> > > > Walsworth Publishing Company
> > > > Brookfield, MO
> > > > John may also be reached at johnamdarn...@gmail.com > > > johnamdarn...@gmail.com>
> > > >
> > > > Trivia question Trivia question:  In The Lord of the Rings,Leglolas was
> > a
> > > > prince among the Silvan Elves.  What was the name of his father the
> > King?
> > > >  For extra credit, what was his surname?
> > > >
> > > >
> > > >
> > > > ___
> > > > sqlite-users mailing list
> > > > sqlite-users@sqlite.org
> > > > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> > > >
> > >
> > >
> > >
> > > --
> > > D. Richard Hipp
> > > d...@sqlite.org
> > > ___
> > > 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
> >
> 
> 
> 
> --
> D. Richard Hipp
> d...@sqlite.org
> ___
> 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] Compiling in Xcode 3.1.3

2011-05-16 Thread Richard Hipp
On Mon, May 16, 2011 at 4:31 PM, john darnell wrote:

> Thanks for responding, Mr HIpp.
>
> There are 1265 errors in all, but most of them look very close to something
> like this:
>
>Invalid conversion from void * to XXX *
>
> Or
>
>forward declaration of struct_ht
>
> I thought it might be a pathing error (I had not added the path to the
> directory where SQLite 3 is stored) but I did that and it didn't really
> resolve anything.
>

SQLite is ANSI-C code.  Sounds to me like you are trying to compile it as
C++, or maybe Objective-C.


>
> R,
> John
>
> > -Original Message-
> > From: sqlite-users-boun...@sqlite.org [mailto:
> sqlite-users-boun...@sqlite.org]
> > On Behalf Of Richard Hipp
> > Sent: Monday, May 16, 2011 3:19 PM
> > To: General Discussion of SQLite Database
> > Subject: Re: [sqlite] Compiling in Xcode 3.1.3
> >
> > On Mon, May 16, 2011 at 4:01 PM, john darnell
> > wrote:
> >
> > > I have code that compiles just fine using Visual Studio 8 on Windows
> XP,
> > > but when I port SQLite over to a Mac OSX (Snow Leopard) platform
> using
> > > Xcode 3.1.3 I get roughly 1000 errors based upon SQLite.  Is there
> something
> > > I need to turn off/on when using SQLite on the Mac?
> > >
> >
> > No.  We compile SQLite on Macs with no problems.  What are the errors?
> >
> >
> > >
> > > R,
> > > John A.M. Darnell
> > > Senior Programmer
> > > Walsworth Publishing Company
> > > Brookfield, MO
> > > John may also be reached at johnamdarn...@gmail.com > > johnamdarn...@gmail.com>
> > >
> > > Trivia question Trivia question:  In The Lord of the Rings,Leglolas was
> a
> > > prince among the Silvan Elves.  What was the name of his father the
> King?
> > >  For extra credit, what was his surname?
> > >
> > >
> > >
> > > ___
> > > sqlite-users mailing list
> > > sqlite-users@sqlite.org
> > > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> > >
> >
> >
> >
> > --
> > D. Richard Hipp
> > d...@sqlite.org
> > ___
> > 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
>



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


Re: [sqlite] Compiling in Xcode 3.1.3

2011-05-16 Thread john darnell
Thanks for responding, Mr HIpp.

There are 1265 errors in all, but most of them look very close to something 
like this:

Invalid conversion from void * to XXX *

Or

forward declaration of struct_ht

I thought it might be a pathing error (I had not added the path to the 
directory where SQLite 3 is stored) but I did that and it didn't really resolve 
anything.

R,
John

> -Original Message-
> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org]
> On Behalf Of Richard Hipp
> Sent: Monday, May 16, 2011 3:19 PM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] Compiling in Xcode 3.1.3
> 
> On Mon, May 16, 2011 at 4:01 PM, john darnell
> wrote:
> 
> > I have code that compiles just fine using Visual Studio 8 on Windows XP,
> > but when I port SQLite over to a Mac OSX (Snow Leopard) platform   using
> > Xcode 3.1.3 I get roughly 1000 errors based upon SQLite.  Is there something
> > I need to turn off/on when using SQLite on the Mac?
> >
> 
> No.  We compile SQLite on Macs with no problems.  What are the errors?
> 
> 
> >
> > R,
> > John A.M. Darnell
> > Senior Programmer
> > Walsworth Publishing Company
> > Brookfield, MO
> > John may also be reached at johnamdarn...@gmail.com > johnamdarn...@gmail.com>
> >
> > Trivia question Trivia question:  In The Lord of the Rings,Leglolas was a
> > prince among the Silvan Elves.  What was the name of his father the King?
> >  For extra credit, what was his surname?
> >
> >
> >
> > ___
> > sqlite-users mailing list
> > sqlite-users@sqlite.org
> > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> >
> 
> 
> 
> --
> D. Richard Hipp
> d...@sqlite.org
> ___
> 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] Compiling in Xcode 3.1.3

2011-05-16 Thread Richard Hipp
On Mon, May 16, 2011 at 4:01 PM, john darnell wrote:

> I have code that compiles just fine using Visual Studio 8 on Windows XP,
> but when I port SQLite over to a Mac OSX (Snow Leopard) platform   using
> Xcode 3.1.3 I get roughly 1000 errors based upon SQLite.  Is there something
> I need to turn off/on when using SQLite on the Mac?
>

No.  We compile SQLite on Macs with no problems.  What are the errors?


>
> R,
> John A.M. Darnell
> Senior Programmer
> Walsworth Publishing Company
> Brookfield, MO
> John may also be reached at johnamdarn...@gmail.com johnamdarn...@gmail.com>
>
> Trivia question Trivia question:  In The Lord of the Rings,Leglolas was a
> prince among the Silvan Elves.  What was the name of his father the King?
>  For extra credit, what was his surname?
>
>
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



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


[sqlite] Compiling in Xcode 3.1.3

2011-05-16 Thread john darnell
I have code that compiles just fine using Visual Studio 8 on Windows XP, but 
when I port SQLite over to a Mac OSX (Snow Leopard) platform   using Xcode 
3.1.3 I get roughly 1000 errors based upon SQLite.  Is there something I need 
to turn off/on when using SQLite on the Mac?

R,
John A.M. Darnell
Senior Programmer
Walsworth Publishing Company
Brookfield, MO
John may also be reached at 
johnamdarn...@gmail.com

Trivia question Trivia question:  In The Lord of the Rings,Leglolas was a 
prince among the Silvan Elves.  What was the name of his father the King?  For 
extra credit, what was his surname?



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


Re: [sqlite] Need to be able to rename attributes

2011-05-16 Thread Nico Williams
On Mon, May 16, 2011 at 1:29 PM, Simon Slavin  wrote:
> Yet strangely, the ability to obtain the statements used to create the schema 
> is something I find very useful in quite a few utilities.  If you could 
> depend on them being in a standard format they'd be even more useful.

I like the fact that SQLite3 preserves almost all of the CREATE
statements as in the original (only the first two keywords, and
whitespace around them, change at all).

But I think I too would appreciate a normalized form of create
statements.  Even more so I'd appreciate a relational view of the
schema.  But that's just pipe dream stuff.

> MySQL has a way to obtain the data in statement form too.  Imagine a command 
> like
>
> SELECT AS INSERT COMMANDS * FROM myTable WHERE joinDate > '2001'
>
> which returns one field of text per record, with each piece of text being the 
> INSERT command required to reproduce it:
>
> INSERT INTO myTable (id,name,address,joinDate) VALUES (123,'Fred Savage','12 
> Rowantree Crescent','20020115')

The SQLite3 shell lets you do this.  Use .mode insert!  I agree it's awesome.

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


Re: [sqlite] Need to be able to rename attributes

2011-05-16 Thread Simon Slavin

On 16 May 2011, at 7:18pm, Jay A. Kreibich wrote:

>  I think the bigger issue is that column rename requires full
>  understanding of the SQL statements stored in sqlite_master.  To
>  safely do a ALTER TABLE...RENAME COLUMN you have to understand the
>  context and parts of the CREATE TABLE statement (and triggers, and
>  indexes, and FKs of other tables).  This requires a close link between
>  the modification function, the parser, and the tokenizer.  You have to
>  scan the SQL statement and understand the different parts, and then
>  back-trace them to a specific character in the original statement,
>  so you know which substring to change.  While this is feasible, most
>  tokenizers and parsers are specifically designed to be abstract layers.

Yet strangely, the ability to obtain the statements used to create the schema 
is something I find very useful in quite a few utilities.  If you could depend 
on them being in a standard format they'd be even more useful.

MySQL has a way to obtain the data in statement form too.  Imagine a command 
like

SELECT AS INSERT COMMANDS * FROM myTable WHERE joinDate > '2001'

which returns one field of text per record, with each piece of text being the 
INSERT command required to reproduce it:

INSERT INTO myTable (id,name,address,joinDate) VALUES (123,'Fred Savage','12 
Rowantree Crescent','20020115')

It gives a great way to tokenise a record.

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


Re: [sqlite] Need to be able to rename attributes

2011-05-16 Thread Nico Williams
On Mon, May 16, 2011 at 1:18 PM, Jay A. Kreibich  wrote:
> On Mon, May 16, 2011 at 12:49:14PM -0500, Nico Williams scratched on the wall:
>> Nit: that's almost certainly the reason that SQLite3 doesn't support
>> column rename,
>
>  I think the bigger issue is that column rename requires full
>  understanding of the SQL statements stored in sqlite_master.  To
>  safely do a ALTER TABLE...RENAME COLUMN you have to understand the
>  context and parts of the CREATE TABLE statement (and triggers, and
>  indexes, and FKs of other tables).  This requires a close link between
>  the modification function, the parser, and the tokenizer.  You have to
>  scan the SQL statement and understand the different parts, and then
>  back-trace them to a specific character in the original statement,
>  so you know which substring to change.  While this is feasible, most
>  tokenizers and parsers are specifically designed to be abstract layers.

Of course that's the problem for column rename, and a problem for column drop.

If I were implementing this I'd consider generating new CREATE
statements while parsing old ones.  I'd either create a separate .y
file just for this, or I'd add logic to the existing code invoked from
parse.y to detect re-write context and re-write instead of generate
Vdbe code.  The former seems likely to be much easier, and yet it'd
still require much more code than the DB trigger patch I just posted
-- "column rename is hard".  I'd rather punt, not least because I
don't need this feature :(

>> The row data encoding is also the reason that new columns can only
>> be added and appear at the end of the new CREATE TABLE statement,
>
>  While I'm sure this is the major factor in that decision, the parsing
>  issue still exists.  Adding a column def to the end of a CREATE TABLE
>  statement is fairly easy... find the last ')' character in the whole
>  statement and insert "',' || " right before.  Even if the
>  encoding issue could be solved, inserting a column def anywhere else
>  requires context-aware parsing and understanding of the CREATE TABLE
>  statement, so it can be understood where the modifications have to be
>  made.

Agreed.  I just think that the row encoding issues are more
significant still than the CREATE TABLE statement re-write issues,
because overcoming the row encoding issue would require adding
annotations in sqlite_master, and to drop rows would require more than
that still: it'd require keeping historical schema metadata.

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


Re: [sqlite] Need to be able to rename attributes

2011-05-16 Thread Jay A. Kreibich
On Mon, May 16, 2011 at 12:49:14PM -0500, Nico Williams scratched on the wall:
> On May 16, 2011 9:33 AM, "Simon Slavin"  wrote:
> > On 16 May 2011, at 3:44am, romtek wrote:
> >
> > > Secondly, if I executed the above SQL code, what would happen to
> triggers,
> > > etc. that are associated with the original table?
> >
> > I suspect that's a major reason why SQLite doesn't support DROP COLUMN:
> it has to check for things that might depend on the column and refuse
> to DROP if it finds anything.
> 
> Nit: that's almost certainly the reason that SQLite3 doesn't support
> column rename,

  I think the bigger issue is that column rename requires full
  understanding of the SQL statements stored in sqlite_master.  To
  safely do a ALTER TABLE...RENAME COLUMN you have to understand the
  context and parts of the CREATE TABLE statement (and triggers, and
  indexes, and FKs of other tables).  This requires a close link between
  the modification function, the parser, and the tokenizer.  You have to
  scan the SQL statement and understand the different parts, and then
  back-trace them to a specific character in the original statement,
  so you know which substring to change.  While this is feasible, most
  tokenizers and parsers are specifically designed to be abstract layers.

> The row data encoding is also the reason that new columns can only
> be added and appear at the end of the new CREATE TABLE statement, 

  While I'm sure this is the major factor in that decision, the parsing
  issue still exists.  Adding a column def to the end of a CREATE TABLE
  statement is fairly easy... find the last ')' character in the whole
  statement and insert "',' || " right before.  Even if the
  encoding issue could be solved, inserting a column def anywhere else
  requires context-aware parsing and understanding of the CREATE TABLE
  statement, so it can be understood where the modifications have to be
  made.

   -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
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] DB triggers: Initial patch

2011-05-16 Thread Nico Williams
And here's the patch.  I should have been using Fossil all this time.
I'll switch to Fossil soon.  For now the patch is to
sqlite\-src\-3070602.

A few more notes on the patch besides the ones I posted earlier:

 - DB triggers are omitted by defining SQLITE_OMIT_TRIGGER
 - DB triggers are implemented under the hood as INSERT INTO
sqlite_intview_... DEFAULT VALUES.  I call these "crutch views".  This
means that there's a NEW.* row for DB triggers, but this must not be
used.
 - There are some XXX comments in my patch; I know how to resolve these.

The patch:

diff -ru sqlite-src-3070602-orig/src/btree.c sqlite-src-3070602/src/btree.c
--- sqlite-src-3070602-orig/src/btree.c 2011-04-17 12:53:51.0 -0500
+++ sqlite-src-3070602/src/btree.c  2011-05-14 17:54:12.588609187 -0500
@@ -2531,6 +2531,8 @@
   sqlite3BtreeEnter(p);
   btreeIntegrity(p);

+  assert( p->beginTrigFired==0 || p->inTrans==TRANS_WRITE );
+
   /* If the btree is already in a write-transaction, or it
   ** is already in a read-transaction and a read-transaction
   ** is requested, this is a no-op.
@@ -2539,6 +2541,8 @@
 goto trans_begun;
   }

+  p->beginTrigFired = 0;
+
   /* Write transactions are not possible on a read-only database */
   if( pBt->readOnly && wrflag ){
 rc = SQLITE_READONLY;
@@ -3142,6 +3146,7 @@
 /* Set the current transaction state to TRANS_NONE and unlock the
 ** pager if this call closed the only read or write transaction.  */
 p->inTrans = TRANS_NONE;
+p->beginTrigFired = 0;
 unlockBtreeIfUnused(pBt);
   }

@@ -8141,3 +8146,15 @@
   pBt->doNotUseWAL = 0;
   return rc;
 }
+
+#ifndef SQLITE_OMIT_SHARED_TRIGGER
+int sqlite3BtreeAfterBeginTriggerFiredCheck(Btree *p){
+  assert( p->beginTrigFired==0 || p->inTrans==TRANS_WRITE );
+  return ( p->inTrans==TRANS_WRITE && p->beginTrigFired==1 );
+}
+
+void sqlite3BtreeAfterBeginTriggerFired(Btree *p){
+  assert( p->beginTrigFired==0 || p->inTrans==TRANS_WRITE );
+  p->beginTrigFired = 1;
+}
+#endif /* SQLITE_OMIT_TRIGGER */
diff -ru sqlite-src-3070602-orig/src/btree.h sqlite-src-3070602/src/btree.h
--- sqlite-src-3070602-orig/src/btree.h 2011-04-17 12:53:51.0 -0500
+++ sqlite-src-3070602/src/btree.h  2011-05-14 17:57:36.626577000 -0500
@@ -236,5 +236,9 @@
 # define sqlite3SchemaMutexHeld(X,Y,Z) 1
 #endif

+#ifdef SQLITE_OMIT_TRIGGER
+  int sqlite3BtreeAfterBeginTriggerFiredCheck(Btree *p);
+  void sqlite3BtreeAfterBeginTriggerFired(Btree *p);
+#endif /* SQLITE_OMIT_TRIGGER */

 #endif /* _BTREE_H_ */
diff -ru sqlite-src-3070602-orig/src/btreeInt.h
sqlite-src-3070602/src/btreeInt.h
--- sqlite-src-3070602-orig/src/btreeInt.h  2011-04-17 12:53:51.0 
-0500
+++ sqlite-src-3070602/src/btreeInt.h   2011-05-16 12:05:32.492119901 -0500
@@ -345,6 +345,9 @@
   u8 inTrans;/* TRANS_NONE, TRANS_READ or TRANS_WRITE */
   u8 sharable;   /* True if we can share pBt with another db */
   u8 locked; /* True if db currently has pBt locked */
+#ifndef SQLITE_OMIT_TRIGGER
+  u8 beginTrigFired; /* True if inTrans == TRANS_WRITE && BEGIN
trigger fired */
+#endif
   int wantToLock;/* Number of nested calls to sqlite3BtreeEnter() */
   int nBackup;   /* Number of backup operations reading this btree */
   Btree *pNext;  /* List of other sharable Btrees from the same db */
diff -ru sqlite-src-3070602-orig/src/build.c sqlite-src-3070602/src/build.c
--- sqlite-src-3070602-orig/src/build.c 2011-04-17 12:53:51.0 -0500
+++ sqlite-src-3070602/src/build.c  2011-05-16 12:07:53.916119901 -0500
@@ -155,6 +155,10 @@
 if( (mask & pParse->cookieMask)==0 ) continue;
 sqlite3VdbeUsesBtree(v, iDb);
 sqlite3VdbeAddOp2(v,OP_Transaction, iDb, (mask &
pParse->writeMask)!=0);
+#ifndef SQLITE_OMIT_TRIGGER
+   if( mask & pParse->writeMask )
+   sqlite3CodeDbTrigger(pParse, iDb, TK_AFTER, TK_BEGIN);
+#endif
 if( db->init.busy==0 ){
   assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
   sqlite3VdbeAddOp3(v, OP_VerifyCookie,
@@ -3362,6 +3366,10 @@
 for(i=0; inDb; i++){
   sqlite3VdbeAddOp2(v, OP_Transaction, i, (type==TK_EXCLUSIVE)+1);
   sqlite3VdbeUsesBtree(v, i);
+#ifndef SQLITE_OMIT_TRIGGER
+  if( ((type==TK_EXCLUSIVE)+1) )
+sqlite3CodeDbTrigger(pParse, i, TK_AFTER, TK_BEGIN);
+#endif
 }
   }
   sqlite3VdbeAddOp2(v, OP_AutoCommit, 0, 0);
@@ -3383,6 +3391,12 @@
   }
   v = sqlite3GetVdbe(pParse);
   if( v ){
+#ifndef SQLITE_OMIT_TRIGGER
+int i;
+
+for(i=0; inDb; i++)
+  sqlite3CodeDbTrigger(pParse, i, TK_BEFORE, TK_COMMIT);
+#endif
 sqlite3VdbeAddOp2(v, OP_AutoCommit, 1, 0);
   }
 }
diff -ru sqlite-src-3070602-orig/src/mutex.c sqlite-src-3070602/src/mutex.c
--- sqlite-src-3070602-orig/src/mutex.c 2011-04-17 12:53:51.0 -0500
+++ sqlite-src-3070602/src/mutex.c  2011-05-16 12:04:03.192119900 -0500
@@ -137,7 +137,7 @@
   }
 }

-#ifndef NDEBUG
+#if !defined(NDEBUG) || defined(SQLITE_DEBUG)
 /*
 ** The 

Re: [sqlite] Need to be able to rename attributes

2011-05-16 Thread Nico Williams
On May 16, 2011 9:33 AM, "Simon Slavin"  wrote:
> On 16 May 2011, at 3:44am, romtek wrote:
>
> > Secondly, if I executed the above SQL code, what would happen to
triggers,
> > etc. that are associated with the original table?
>
> I suspect that's a major reason why SQLite doesn't support DROP COLUMN: it
has to check for things that might depend on the column and refuse to DROP
if it finds anything.

Nit: that's almost certainly the reason that SQLite3 doesn't support column
rename, and one reason it doesn't support column  DROP, but column drop is
almost certainly not supported primarily because of the way SQLite3 encodes
row data (namely, as a type-length-value sort of sequrnce encoding, with
location in the sequence having to match up to the table's column order).
Existing rows would then be utterly confusing.  The row data encoding is
also the reason that new columns can only be added and appear at the end of
the new CREATE TABLE statement, and also why they can only be added only
without NOT NULL or with constant expression DEFAULT values (column value
absence implies default constant value if one was specified).  (The row
encoding could have included a table schema version number at the front, but
then SQLite3 would have to keep around historical schemata.  Too complicated
for something "Lite".)

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


Re: [sqlite] time in AM/PM?

2011-05-16 Thread Mr. Puneet Kishor

On May 15, 2011, at 9:24 PM, Igor Tandetnik wrote:

> Mr. Puneet Kishor  wrote:
>> I am trying to get time stamps to be reported as '10:33 AM' and '1:27 PM' 
>> instead of '10:33' or '13:27'. I don't see any
>> formatting options to return the time in 12-hour format with AM/PM suffixed. 
>> Am I missing something, or do I have to roll my own? 
> 
> You are not missing anything. You'll have to roll your own.

Assuming 't' is a DATETIME column, the following seems work --

CASE
WHEN CAST(strftime('%H', t, 'localtime') AS INTEGER) = 12 
THEN strftime('%H:%M', t, 'localtime') || ' PM'  
WHEN CAST(strftime('%H', t, 'localtime') AS INTEGER) > 12 
THEN strftime('%H:%M', t, '-12 Hours', 'localtime') || ' PM' 
ELSE strftime('%H:%M', t, 'localtime') || ' AM' 
END

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


[sqlite] DB triggers: Initial patch

2011-05-16 Thread Nico Williams
In my next post I'll post a [681 line, 28KB unified diff, or 504 line
regular diff] patch implements the following DB triggers:

 - AFTER DATABASE CONNECT
 - AFTER TRANSACTION BEGIN
 - BEFORE TRANSACTION COMMIT

These triggers do exactly what I want, and nothing more.  If anyone
wants to test this go ahead (well, wait for the patch); feedback will
be greatly appreciated.

The following DB triggers are parsed but not yet supported, and yield
a not supported error:

 - BEFORE DATABASE DISCONNECT
 - AFTER TRANSACTION COMMIT
 - AFTER TRANSACTION ROLLBACK

I'd like to get these last three to work eventually.

The connect trigger only fires after executing "PRAGMA
connect_triggers=on".  I've not yet added a compile-time option to
enable connect triggers by default.

Here's a schema for a demonstration:

sqlite> select sql || ';' from sqlite_master;
CREATE TABLE t(a);
CREATE VIEW sqlite_intview_begin AS SELECT 0 AS nothing;
CREATE VIEW sqlite_intview_bcommit AS SELECT 0 AS nothing;
CREATE TRIGGER ab after transaction begin begin insert into t select
'transaction started at ' || datetime('now'); end;
CREATE TRIGGER bc before transaction commit begin select raise(abort,
'Foo!') where (select max(a) from t where typeof(a) = 'integer') >
567;
select raise(fail, 'Bar!') where (select max(a) from t where typeof(a)
= 'integer') = 567;
select raise(rollback, 'FooBar!') where (select max(a) from t where
typeof(a) = 'integer') = 566;
insert into t select 'transaction started at ' || datetime('now'); end;
CREATE VIEW sqlite_intview_connect AS SELECT 0 AS nothing;
CREATE TRIGGER adc after database connect begin insert into t select
'connected at ' || datetime('now'); end;
sqlite>

And a quick demo.

1) Begin and commit triggers:

sqlite> begin;
sqlite> select * from t;
sqlite> insert into t values (123);
sqlite> select * from t;
transaction started at 2011-05-16 17:18:30
123
sqlite> insert into t values (234);
sqlite> select * from t;
transaction started at 2011-05-16 17:18:30
123
234
sqlite> rollback;
sqlite> select * from t;
sqlite> begin;
sqlite> insert into t values (123);
sqlite> insert into t values (234);
sqlite> commit;
sqlite> select * from t;
transaction started at 2011-05-16 17:18:48
123
234
transaction started at 2011-05-16 17:18:52
sqlite>

2) Commit trigger that raises ABORT or FAIL:

sqlite> delete from t;
sqlite> select * from t;
sqlite> begin;
sqlite> insert into t values (123);
sqlite> insert into t values (234);
sqlite> insert into t values (568);
sqlite> commit;
Error: Foo!
sqlite> select * from t;
123
234
568
sqlite> rollback;
sqlite>
sqlite> begin;
sqlite> insert into t values (123);
sqlite> insert into t values (234);
sqlite> insert into t values (567);
sqlite> commit;
Error: Bar!
sqlite> select * from t;
transaction started at 2011-05-16 17:23:15
123
234
567
sqlite> rollback;
sqlite> select * from t;
sqlite>
sqlite> begin;
sqlite> insert into t values (123);
sqlite> insert into t values (234);
sqlite> insert into t values (567);
sqlite> commit;
Error: Bar!
sqlite> select * from t;
transaction started at 2011-05-16 17:23:15
123
234
567
sqlite> rollback;
sqlite> select * from t;
sqlite>

3) Commit trigger that raises ROLLBACK:

sqlite> select * from t;
sqlite> begin;
sqlite> insert into t values (123);
sqlite> insert into t values (234);
sqlite> insert into t values (566);
sqlite> select * from t;
transaction started at 2011-05-16 17:24:44
123
234
566
sqlite> commit;
Error: FooBar!
sqlite> select * from t;
sqlite>
sqlite>
sqlite> rollback;
Error: cannot rollback - no transaction is active
sqlite>

4) Connect trigger:

sqlite> select * from t;
sqlite> pragma connect_triggers=on;
sqlite> select * from t;
transaction started at 2011-05-16 17:26:07
connected at 2011-05-16 17:26:07
transaction started at 2011-05-16 17:26:07
sqlite>
sqlite> rollback;
Error: cannot rollback - no transaction is active
sqlite>

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


[sqlite] two threads in differnet DB handler in the same process accesssing the same DB will cause mutex assert_fail in 3.7.5

2011-05-16 Thread ChingChang Hsiao

Please neglect the previous email. Two threads are in the different DB 
handler(FD).

I have sent the core dump in the previous email. And I found that one thread 
receives an event and access DB at the same time with another thread accesses 
the same DB. It happens in the heavy load for DB access. Is there a way to 
prevent this core dump?

ChingChang


Version is 3.7.5
journal mode = DELETE
SELECT sqlite_source_id(); 2011-01-28 17:03:50 
ed759d5a9edb3bba5f48f243df47be29e3fe8cd7

OTHER_FLAGS=-DSQLITE_THREADSAFE=2  -DSQLITE_THREAD_OVERRIDE_LOCK=-1 
-DSQLITE_DEBUG=1
CFLAGS += -O0 -w $(OTHER_FLAGS)
in Makefile

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


Re: [sqlite] two threads in the same process accesssing the same DB will cause mutex assert_fail in 3.7.5

2011-05-16 Thread Richard Hipp
On Mon, May 16, 2011 at 11:59 AM, ChingChang Hsiao <
chingchang.hs...@overturenetworks.com> wrote:

> I have sent the core dump in the previous email. And I found that one
> thread receives an event and access DB at the same time with another thread
> accesses the same DB. It happens in the heavy load for DB access. Is there a
> way to prevent this core dump?
>
> Use -DSQLITE_THREADSAFE=1.  The use of -DSQLITE_THREADSAFE=2 is not
sufficient if you have multiple threads using the same database connection.


> ChingChang
>
>
> Version is 3.7.5
> journal mode = DELETE
> SELECT sqlite_source_id(); 2011-01-28 17:03:50
> ed759d5a9edb3bba5f48f243df47be29e3fe8cd7
>
> OTHER_FLAGS=-DSQLITE_THREADSAFE=2  -DSQLITE_THREAD_OVERRIDE_LOCK=-1
> -DSQLITE_DEBUG=1
> CFLAGS += -O0 -w $(OTHER_FLAGS)
> in Makefile
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>



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


[sqlite] two threads in the same process accesssing the same DB will cause mutex assert_fail in 3.7.5

2011-05-16 Thread ChingChang Hsiao
I have sent the core dump in the previous email. And I found that one thread 
receives an event and access DB at the same time with another thread accesses 
the same DB. It happens in the heavy load for DB access. Is there a way to 
prevent this core dump?

ChingChang


Version is 3.7.5
journal mode = DELETE
SELECT sqlite_source_id(); 2011-01-28 17:03:50 
ed759d5a9edb3bba5f48f243df47be29e3fe8cd7

OTHER_FLAGS=-DSQLITE_THREADSAFE=2  -DSQLITE_THREAD_OVERRIDE_LOCK=-1 
-DSQLITE_DEBUG=1
CFLAGS += -O0 -w $(OTHER_FLAGS)
in Makefile

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


Re: [sqlite] Using SQLite with R*Tree and FTS3 support in iOS

2011-05-16 Thread Tito Ciuro
Hi Steven.

You're absolutely right.

Adding the sources to a real iOS project (standard Xcode 4, View-based iOS app) 
results in 885 KB. Great to see the linker/stripping process remove all this 
symbol info.

Thanks for the help,

-- Tito

On May 16, 2011, at 8:49 AM, Steven Parkes wrote:

> Well, for my part, I forgot that I'm not including the R-tree stuff at this 
> point. I do include FTS (that's why I have a custom build, not to mention the 
> latest WAL stuff.)
> 
> And to the extent it matters, I'm not using LLVM.
> 
> But I am building -O0 -ggdb. That doesn't do any inline or deadcode 
> elimination and it throws lots and lots and lots of symbol stuff in. Lots.  
> Really. Lots.
> 
> Unless I'm missing something, you're looking at something that doesn't 
> matter. The size of the .a is very weakly correlated to resulting size of the 
> executable. You don't ship the .a (or you certainly shouldn't be). It just 
> gets linked into your executable and then you strip your executable. Both the 
> linking and the stripping steps remove a ton of symbol information. Much of 
> the size of the sqlite .o's and .a's are symbols that are going to be dumped.
> 
> To give you an idea, as I said, my sqlite library is about 3M. My custom 
> openssl build is 17M. My own library is 37M. The final executable in 
> debugging mode is 7M before strip and 5M. Again, with -O0.
> 
> I'm pretty sure this is a non-issue.
> ___
> 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 SQLite with R*Tree and FTS3 support in iOS

2011-05-16 Thread Steven Parkes
Well, for my part, I forgot that I'm not including the R-tree stuff at this 
point. I do include FTS (that's why I have a custom build, not to mention the 
latest WAL stuff.)

And to the extent it matters, I'm not using LLVM.

But I am building -O0 -ggdb. That doesn't do any inline or deadcode elimination 
and it throws lots and lots and lots of symbol stuff in. Lots.  Really. Lots.

Unless I'm missing something, you're looking at something that doesn't matter. 
The size of the .a is very weakly correlated to resulting size of the 
executable. You don't ship the .a (or you certainly shouldn't be). It just gets 
linked into your executable and then you strip your executable. Both the 
linking and the stripping steps remove a ton of symbol information. Much of the 
size of the sqlite .o's and .a's are symbols that are going to be dumped.

To give you an idea, as I said, my sqlite library is about 3M. My custom 
openssl build is 17M. My own library is 37M. The final executable in debugging 
mode is 7M before strip and 5M. Again, with -O0.

I'm pretty sure this is a non-issue.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Using SQLite with R*Tree and FTS3 support in iOS

2011-05-16 Thread Tito Ciuro
Hi Richard,

On May 16, 2011, at 8:40 AM, Richard Hipp wrote:

> I took the amalgamation file (sqlite3.c) and compiled it thusly:
> 
>   gcc -Os -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE -c sqlite3.c
> 
> The resulting binary size (as reported by the "size" command) is 392,203
> bytes.  That's 383 KiB.  I don't know how you are getting multi-megabyte
> builds

Darn. I wonder what settings in Xcode 4 are generating this size. I'll 
investigate more.

Thanks for the help,

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


Re: [sqlite] unable to open database file - sqlite jdbc

2011-05-16 Thread Christoph P.U. Kukulies
Am 16.05.2011 07:56, schrieb Christoph P.U. Kukulies:
> Am 15.05.2011 16:04, schrieb Christoph P.U. Kukulies:
>> I keep getting an SQL error
>> "unable to open database file"
I solved it: The problem is netbeans (7.0 in this case). When I run the 
application outside
netbeans from the DOS prompt

C:\Users\kuku\testsuite>java -jar 
"C:\Users\kuku\Documents\NetBeansProjects\testsqlite\dist\testsqlite.jar"

it works fine.

So something must lock the database from within netbeans.

--
Christoph


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


Re: [sqlite] Using SQLite with R*Tree and FTS3 support in iOS

2011-05-16 Thread Richard Hipp
On Mon, May 16, 2011 at 11:32 AM, Tito Ciuro  wrote:

> Hi Steven,
>
> OK. First of all, I messed up by compiling shell.c (which is included in
> the SQLite amalgamated distro.) Removing it brings the size to:
>
> GCC:
> - Debug: 3.1 MB
> - Release: 3.4 MB
>
> LLVM Compiler 2.0:
> - Debug: 3.7 MB
> - Release: 4 MB
>

I took the amalgamation file (sqlite3.c) and compiled it thusly:

   gcc -Os -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE -c sqlite3.c

The resulting binary size (as reported by the "size" command) is 392,203
bytes.  That's 383 KiB.  I don't know how you are getting multi-megabyte
builds


>
> This is what I did:
>
> 1) Create a new project in Xcode, iOS static library
> 2) Add the SQLite amalgamation sources (sqlite3.c, sqlite3.h, sqlite3ext.h)
> 3) Choose GCC
> 4) Build for Run (uses the Debug config)
> 5) Build for Archive (uses the Release config)
> 6) Choose LLVM
> 7) Repeat steps 4 and 5
>
> If you want to check the project, please contact me off-list and I'll
> gladly send it to you.
>
> Cheers,
>
> -- Tito
>
> On May 16, 2011, at 8:18 AM, Steven Parkes wrote:
>
> >> Compiling a static library of SQLite's amalgamated version weighs at
> about 4.3 MB
> >
> > Where are you coming up with this number? My .a is 2792KB and that's with
> both armv6 and armv7, debugging, and full symbols.
> >
> > I pull in sqlite3, openssl, about a billion other things, and plenty of
> my own code and my post-strip size of the executable is still on the order
> of 5MB and that's still with debugging turned on.
> >
> > I may be missing something, but I can't believe this a real issue.
> > ___
> > 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
>



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


Re: [sqlite] Using SQLite with R*Tree and FTS3 support in iOS

2011-05-16 Thread Tito Ciuro
Hi Simon,

No, I don't need it... but someone else might. I was considering adding FTS3 to 
my library in case someone needs to search across several text records. 
Depending on the table size, LIKE or GLOB would be very expensive because doing 
a full table scan would not be the most optimal approach, even if the database 
is not that large on an iPhone.

To be honest, it's more of a curiosity than actual need. I would not add it 
until it was needed, but I'd like to know what lies ahead.

Thanks Simon,

-- Tito

On May 16, 2011, at 8:26 AM, Simon Slavin wrote:

> 
> On 16 May 2011, at 4:06pm, Marco Bambini wrote:
> 
>> 4.3 MB seems really too big... you are probably building a debug version of 
>> the library.
> 
> Agreed.  I don't know what's wrong but nothing should take 4Meg.
> 
> Also, do you really need FTS3 ?  Try a simple search using LIKE or GLOB.  
> With the small amount of data your app will have (since it has to fit within 
> an iPhone anyway), is your search really too slow for normal use ?
> 
> Simon.
> ___
> 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 SQLite with R*Tree and FTS3 support in iOS

2011-05-16 Thread Tito Ciuro
Hi Steven,

OK. First of all, I messed up by compiling shell.c (which is included in the 
SQLite amalgamated distro.) Removing it brings the size to:

GCC:
- Debug: 3.1 MB
- Release: 3.4 MB

LLVM Compiler 2.0:
- Debug: 3.7 MB
- Release: 4 MB

This is what I did:

1) Create a new project in Xcode, iOS static library
2) Add the SQLite amalgamation sources (sqlite3.c, sqlite3.h, sqlite3ext.h)
3) Choose GCC
4) Build for Run (uses the Debug config)
5) Build for Archive (uses the Release config)
6) Choose LLVM
7) Repeat steps 4 and 5

If you want to check the project, please contact me off-list and I'll gladly 
send it to you.

Cheers,

-- Tito

On May 16, 2011, at 8:18 AM, Steven Parkes wrote:

>> Compiling a static library of SQLite's amalgamated version weighs at about 
>> 4.3 MB
> 
> Where are you coming up with this number? My .a is 2792KB and that's with 
> both armv6 and armv7, debugging, and full symbols.
> 
> I pull in sqlite3, openssl, about a billion other things, and plenty of my 
> own code and my post-strip size of the executable is still on the order of 
> 5MB and that's still with debugging turned on.
> 
> I may be missing something, but I can't believe this a real issue.
> ___
> 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 SQLite with R*Tree and FTS3 support in iOS

2011-05-16 Thread Jean-Denis Muys

On 16 mai 2011, at 17:01, Tito Ciuro wrote:

> Hello,
> 
> I have a question about SQLite running on iOS. If I'm not mistaken, SQLite on 
> iOS is not compiled with R*Tree and FTS3. Compiling a static library of 
> SQLite's amalgamated version weighs at about 4.3 MB, which represents almost 
> 25% of the 20 MB-per-app allowed on the App Store. For many, this is a major 
> setback because many apps can easily reach this limit.
> 
> My question is: since a "light" version of SQLite is already included in iOS, 
> would it be too complicated to build a static library with only R*Tree and 
> FTS3 support? The idea being of course that the app would link against iOS' 
> SQLite and the app's R*Tree/FTS3 library, thus reducing the app's footprint 
> considerably.
> 
> Are there dependencies that would make this attempt a nightmare? Has anyone 
> gone through this?

I have considered this, but not done it as it turned out that I could do 
without R-Tree after all for the time being.

But my initial investigation suggested that it would be possible to do so. I 
simply went through the amalgamation source code where it registers the R-Tree 
extension, and I realize that I could simply do the same thing, but using the 
R-Tree source file from the canonic source code.

I didn't check for FTS3, but I suppose it's handled similarly.

I haven't done it, so I can't be sure there is not hidden trap, but I can think 
of at least one pitfall: version compatibility.

you must register with the iOS SQLite a R-Tree extension that is compatible 
with - if not exactly the same as - the iOS version of SQLite. It's unclear to 
me whether the *current* version of R-Tree is compatible with the *current* iOS 
SQLite version.

you could think that the best idea is to go back to the same R-Tree version as 
iOS's. But even that might be problematic, as iOS is a moving target, and you 
risk your app breaking on a future iOS version... if it is not rejected by 
Apple in the first place for registering an extension to the system SQLite (I 
don't know that as I haven't tried).

I am not knowledgeable enough with SQLite to understand what is the best way to 
minimize compatibility risks between different versions of the core Library and 
its standard extension.

But saving 4.3 MB of app size doesn't seem valuable enough to me to run those 
risks. Even if those 4.3 MB make you break the 20 MB threshold.

Sorry for not being more helpful.

Jean-Denis

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


Re: [sqlite] Using SQLite with R*Tree and FTS3 support in iOS

2011-05-16 Thread Simon Slavin

On 16 May 2011, at 4:06pm, Marco Bambini wrote:

> 4.3 MB seems really too big... you are probably building a debug version of 
> the library.

Agreed.  I don't know what's wrong but nothing should take 4Meg.

Also, do you really need FTS3 ?  Try a simple search using LIKE or GLOB.  With 
the small amount of data your app will have (since it has to fit within an 
iPhone anyway), is your search really too slow for normal use ?

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


Re: [sqlite] Using SQLite with R*Tree and FTS3 support in iOS

2011-05-16 Thread Tito Ciuro
Hi Marco,

Oops. My bad. Building for Archive (Release version) has a size of 3.6 MB.

-- Tito

On May 16, 2011, at 8:06 AM, Marco Bambini wrote:

> 4.3 MB seems really too big... you are probably building a debug version of 
> the library.
> 
> --
> Marco Bambini
> http://www.sqlabs.com
> 
> 
> 
> 
> 
> 
> On May 16, 2011, at 5:01 PM, Tito Ciuro wrote:
> 
>> Hello,
>> 
>> I have a question about SQLite running on iOS. If I'm not mistaken, SQLite 
>> on iOS is not compiled with R*Tree and FTS3. Compiling a static library of 
>> SQLite's amalgamated version weighs at about 4.3 MB, which represents almost 
>> 25% of the 20 MB-per-app allowed on the App Store. For many, this is a major 
>> setback because many apps can easily reach this limit.
>> 
>> My question is: since a "light" version of SQLite is already included in 
>> iOS, would it be too complicated to build a static library with only R*Tree 
>> and FTS3 support? The idea being of course that the app would link against 
>> iOS' SQLite and the app's R*Tree/FTS3 library, thus reducing the app's 
>> footprint considerably.
>> 
>> Are there dependencies that would make this attempt a nightmare? Has anyone 
>> gone through this?
>> 
>> Thanks in advance,
>> 
>> -- Tito
>> ___
>> 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

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


Re: [sqlite] Using SQLite with R*Tree and FTS3 support in iOS

2011-05-16 Thread Steven Parkes
> Compiling a static library of SQLite's amalgamated version weighs at about 
> 4.3 MB

Where are you coming up with this number? My .a is 2792KB and that's with both 
armv6 and armv7, debugging, and full symbols.

I pull in sqlite3, openssl, about a billion other things, and plenty of my own 
code and my post-strip size of the executable is still on the order of 5MB and 
that's still with debugging turned on.

I may be missing something, but I can't believe this a real issue.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Using SQLite with R*Tree and FTS3 support in iOS

2011-05-16 Thread Marco Bambini
4.3 MB seems really too big... you are probably building a debug version of the 
library.

--
Marco Bambini
http://www.sqlabs.com






On May 16, 2011, at 5:01 PM, Tito Ciuro wrote:

> Hello,
> 
> I have a question about SQLite running on iOS. If I'm not mistaken, SQLite on 
> iOS is not compiled with R*Tree and FTS3. Compiling a static library of 
> SQLite's amalgamated version weighs at about 4.3 MB, which represents almost 
> 25% of the 20 MB-per-app allowed on the App Store. For many, this is a major 
> setback because many apps can easily reach this limit.
> 
> My question is: since a "light" version of SQLite is already included in iOS, 
> would it be too complicated to build a static library with only R*Tree and 
> FTS3 support? The idea being of course that the app would link against iOS' 
> SQLite and the app's R*Tree/FTS3 library, thus reducing the app's footprint 
> considerably.
> 
> Are there dependencies that would make this attempt a nightmare? Has anyone 
> gone through this?
> 
> Thanks in advance,
> 
> -- Tito
> ___
> 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


[sqlite] Using SQLite with R*Tree and FTS3 support in iOS

2011-05-16 Thread Tito Ciuro
Hello,

I have a question about SQLite running on iOS. If I'm not mistaken, SQLite on 
iOS is not compiled with R*Tree and FTS3. Compiling a static library of 
SQLite's amalgamated version weighs at about 4.3 MB, which represents almost 
25% of the 20 MB-per-app allowed on the App Store. For many, this is a major 
setback because many apps can easily reach this limit.

My question is: since a "light" version of SQLite is already included in iOS, 
would it be too complicated to build a static library with only R*Tree and FTS3 
support? The idea being of course that the app would link against iOS' SQLite 
and the app's R*Tree/FTS3 library, thus reducing the app's footprint 
considerably.

Are there dependencies that would make this attempt a nightmare? Has anyone 
gone through this?

Thanks in advance,

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


Re: [sqlite] Need to be able to rename attributes

2011-05-16 Thread Simon Slavin

On 16 May 2011, at 3:44am, romtek wrote:

> Secondly, if I executed the above SQL code, what would happen to triggers,
> etc. that are associated with the original table?

I suspect that's a major reason why SQLite doesn't support DROP COLUMN: it has 
to check for things that might depend on the column and refuse to DROP if it 
finds anything.

The answer to your question can be found only by reading the documentation for 
TRIGGERs, etc..  FOREIGN KEYs will, for instance, be a problem.

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


Re: [sqlite] Insert a structure

2011-05-16 Thread Simon Slavin

On 16 May 2011, at 10:50am, Enrico Thierbach wrote:

> From my experience I would recommend you to convert your structure into some 
> kind text format. JSON, with the excellent and well-performing yajl library, 
> is usually my favorite choice here.

Enrico has a point.  JSON is excellent for such things especially since it also 
parses out embedded arrays and such substructures.  Of course, it's 
considerably slower than just BLOBbing the struct, but it has the additional 
advantage of yielding text code which is easier to handle.

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


Re: [sqlite] Insert a structure

2011-05-16 Thread Cousin Stanley

Enrico Thierbach wrote:

> From my experience I would recommend you to convert your structure 
> into some kind text format JSON, with the excellent and well-performing 
> yajl library, is usually my favorite choice here.

  Thanks for recommending yajl  

  The yajl-tools package under debian linux
  provides  json_reformat  and  json_verify
  both of which I think will be very useful 


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona


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


Re: [sqlite] IN clause in search query to search a single field containing comma delimited values

2011-05-16 Thread Pontiac
On 05/15/2011 09:14 AM, Igor Tandetnik wrote:
> Pontiac  wrote:
>> On 05/13/2011 03:15 PM, Trevor Borgmeier wrote:
>>> SELECT categories FROM myTable WHERE (","||categories||",") LIKE "%,7,%";
>> Careful with how you have your like.  As an added bonus, if you were to
>> hunt for category 1, your statement would be LIKE "%,1,%" which would
>> return no results.
> Will too. Note what's on the left hand side of LIKE.

My bad.  Eyes skipped right over that.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Insert a structure

2011-05-16 Thread Simon Slavin

On 16 May 2011, at 9:51am, StyveA wrote:

> I'm working on a code in C, and I would like to insert a structure into a
> table as BLOB type.
> 
> Is-it possible to pass it entirely in one time? Or should I insert each
> parameters of my structure independently?

Assuming that this is straight C, and that your structure is all in one piece 
of contiguous memory, it should work fine.  No reason why you can't do it all 
in one chunk, as long as the meaning of a BLOB you find in a database field is 
unambiguous.

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


Re: [sqlite] Insert a structure

2011-05-16 Thread StyveA



Enrico Thierbach-2 wrote:
> 
> From my experience I would recommend you to convert your structure into
> some kind text format. JSON, with the excellent and well-performing yajl
> library, is usually my favorite choice here.
> 
> /eno
> 
> 

I didn't know yajl, but I'll have a look at it, it may be nice and easier to
work with my structure I suppose.

Styve
-- 
View this message in context: 
http://old.nabble.com/Insert-a-structure-tp31627295p31627694.html
Sent from the SQLite mailing list archive at Nabble.com.

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


Re: [sqlite] Insert a structure

2011-05-16 Thread Enrico Thierbach
>From my experience I would recommend you to convert your structure into some 
>kind text format. JSON, with the excellent and well-performing yajl library, 
>is usually my favorite choice here.

/eno

On 16.05.2011, at 11:39, StyveA wrote:

> 
> 
> 
> Enrico Thierbach-2 wrote:
>> 
>> 
>> On 16.05.2011, at 11:08, Christoph P.U. Kukulies wrote:
>> 
>>> Am 16.05.2011 10:51, schrieb StyveA:
 Hi all,
 
 I'm working on a code in C, and I would like to insert a structure into
 a
 table as BLOB type.
 
 Is-it possible to pass it entirely in one time? Or should I insert each
 parameters of my structure independently?
>>> 
>>> A structure in C has a size and a storage address. So technically I see 
>>> no reason, why you can't do that. Just copy
>>> the BLOB like you do a memcpy().
>>> But as soon as you cross architectures (big-endian, little-endian) or 
>>> you have structure padding
>>> between different compilers etc., I would say you get into trouble.
>>> 
>>> --
>>> Christoph
>>> 
>> 
>> You should have no pointers in it also. And you should not reference it or
>> its members via pointers and expect it to be at the same memory location
>> ever again.
>> 
>> /eno
>> 
>> ___
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>> 
>> 
> 
> Hum.. this is more restrictive than what I thought..
> Thanks for the tips, it helps me.
> 
> Styve
> 
> -- 
> View this message in context: 
> http://old.nabble.com/Insert-a-structure-tp31627295p31627590.html
> Sent from the SQLite mailing list archive at Nabble.com.
> 
> ___
> 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] Insert a structure

2011-05-16 Thread StyveA



Enrico Thierbach-2 wrote:
> 
> 
> On 16.05.2011, at 11:08, Christoph P.U. Kukulies wrote:
> 
>> Am 16.05.2011 10:51, schrieb StyveA:
>>> Hi all,
>>> 
>>> I'm working on a code in C, and I would like to insert a structure into
>>> a
>>> table as BLOB type.
>>> 
>>> Is-it possible to pass it entirely in one time? Or should I insert each
>>> parameters of my structure independently?
>> 
>> A structure in C has a size and a storage address. So technically I see 
>> no reason, why you can't do that. Just copy
>> the BLOB like you do a memcpy().
>> But as soon as you cross architectures (big-endian, little-endian) or 
>> you have structure padding
>> between different compilers etc., I would say you get into trouble.
>> 
>> --
>> Christoph
>> 
> 
> You should have no pointers in it also. And you should not reference it or
> its members via pointers and expect it to be at the same memory location
> ever again.
> 
> /eno
> 
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 
> 

Hum.. this is more restrictive than what I thought..
Thanks for the tips, it helps me.

Styve

-- 
View this message in context: 
http://old.nabble.com/Insert-a-structure-tp31627295p31627590.html
Sent from the SQLite mailing list archive at Nabble.com.

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


Re: [sqlite] Insert a structure

2011-05-16 Thread Enrico Thierbach

On 16.05.2011, at 11:08, Christoph P.U. Kukulies wrote:

> Am 16.05.2011 10:51, schrieb StyveA:
>> Hi all,
>> 
>> I'm working on a code in C, and I would like to insert a structure into a
>> table as BLOB type.
>> 
>> Is-it possible to pass it entirely in one time? Or should I insert each
>> parameters of my structure independently?
> 
> A structure in C has a size and a storage address. So technically I see 
> no reason, why you can't do that. Just copy
> the BLOB like you do a memcpy().
> But as soon as you cross architectures (big-endian, little-endian) or 
> you have structure padding
> between different compilers etc., I would say you get into trouble.
> 
> --
> Christoph
> 

You should have no pointers in it also. And you should not reference it or its 
members via pointers and expect it to be at the same memory location ever again.

/eno

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


Re: [sqlite] Insert a structure

2011-05-16 Thread StyveA



Christoph Kukulies wrote:
> 
> Am 16.05.2011 10:51, schrieb StyveA:
> A structure in C has a size and a storage address. So technically I see 
> no reason, why you can't do that. Just copy
> the BLOB like you do a memcpy().
> But as soon as you cross architectures (big-endian, little-endian) or 
> you have structure padding
> between different compilers etc., I would say you get into trouble.
> 
> --
> Christoph
> 

Thanks for replying, for the moment I'm not going to cross architectures,
but I'll have a look at it. Thanks for your help !

Regards,

Styve
-- 
View this message in context: 
http://old.nabble.com/Insert-a-structure-tp31627295p31627454.html
Sent from the SQLite mailing list archive at Nabble.com.

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


Re: [sqlite] Insert a structure

2011-05-16 Thread Christoph P.U. Kukulies
Am 16.05.2011 10:51, schrieb StyveA:
> Hi all,
>
> I'm working on a code in C, and I would like to insert a structure into a
> table as BLOB type.
>
> Is-it possible to pass it entirely in one time? Or should I insert each
> parameters of my structure independently?

A structure in C has a size and a storage address. So technically I see 
no reason, why you can't do that. Just copy
the BLOB like you do a memcpy().
But as soon as you cross architectures (big-endian, little-endian) or 
you have structure padding
between different compilers etc., I would say you get into trouble.

--
Christoph

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


[sqlite] Insert a structure

2011-05-16 Thread StyveA

Hi all,

I'm working on a code in C, and I would like to insert a structure into a
table as BLOB type.

Is-it possible to pass it entirely in one time? Or should I insert each
parameters of my structure independently?

Regards,

StyveA
-- 
View this message in context: 
http://old.nabble.com/Insert-a-structure-tp31627295p31627295.html
Sent from the SQLite mailing list archive at Nabble.com.

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