RE: [sqlite] Multi-threading.

2005-07-29 Thread Tim McDaniel
K. Haley wrote:
> Argh...  gtk+ uses threads on windows.  The g_io_channel 
> async api is implemented this way.  This is done because 
> windows has no async file io api.  There may be other 
> places/platforms where glib/gtk+ uses threads.

Not to nitpick, but since everyone else is, Win32 absolutely does have
async io.


RE: [sqlite] Multi-threading.

2005-07-22 Thread Tim McDaniel
> -Original Message-
> From: Mrs. Brisby [mailto:[EMAIL PROTECTED] 
> Sent: Friday, July 22, 2005 3:07 PM
> To: sqlite-users@sqlite.org
> Subject: Re: [sqlite] Multi-threading.
> 
> > However the need for multi-threads is compelling.  
> Especially in a GUI 
> > environment.  For instance a Mail reader.  Where one thread 
> is needed 
> > to ensure the GUI is drawn correctly and respond to GUI events.  
> > Another to download and dispatch mail.  (My Thunderbird has 10 
> > threads.  This may be a bit of overkill :)
> 
> No. Threads are not a need. They allow you to use blocking 
> system calls in parallel without extra page table loads.
> 
> History has demonstrated that programmers building 
> multithreaded applications tend to produce buggier code, and 
> code that touches more pages than a non-threaded version. As 
> a result, the non-threaded version is easier to write, safer, 
> and runs faster.

So, what's your point?  That writing things the easy way leads to safer,
less buggy, faster code?  That's hardly a point.  The original poster
presented one of the more compelling reasons for multi-threading in
modern apps, the GUI.  It is hard, if not impossible, with modern GUI
systems to write any relatively complex app that is both performant and
graphically responsive without using threads.

At least for the short term, Moore's Law is slowing down, we might as
well start calling it Moore's Dream.  All main CPUs are going multicore,
even game consoles, and one of the only realistic ways to take advantage
of that is through multi-threading.  Saying it is hard doesn't change
reality.

> 
> 
> > As another user also mentioned, a Windows system works 
> better with few 
> > processes with many threads.
> 
> Windows uses threads because x86 page tables are expensive to 
> load. It doesn't help: the system-call method Windows uses 
> eats any benefit that it has, again producing net-zero.

This being THE reason Windows emphasizes threads over processes is hard
to swallow.

> 
> > I am also interested in your comments on Pointers and GoTo.  I note 
> > that Java is 100% pointers.  Apart from basic types, all 
> object access 
> > is by pointer.
> 
> Java uses references, not pointers.

This is purely semantic nit picking.

> 
> > Using Exceptions correctly, I have never felt the need for a GoTo.
> > Exceptions do the same as GoTo, accept, maybe, in a slightly more 
> > developed and useful way.
> 
> Exceptions are slower than goto. They are also less 
> straightforward when deeply nested (long chains of throws XYZ 
> come to mind...)
> 

I would agree that exceptions are not a good replacement for gotos.
However, having been a professional C++ programmer for over 10 years, I
have never needed a goto.  This probably stems more from the fact that
with C++/Java/C# you don't really need gotos, but with C/Basic/etc there
are arguably things that you can't do, or would be quite hard to do,
without gotos.

> > These are just my opinions :)
> 
> They are wrong.
> 

I hope there was a hint of sarcasm in that last comment.  The original
poster obviously didn't hit everything on the nail, but there is a whole
world of gray between right and wrong.

Tim


RE: [sqlite] Newbie Help Please

2005-07-18 Thread Tim McDaniel

> -Original Message-
> From: Dennis Cote [mailto:[EMAIL PROTECTED] 
> Sent: Monday, July 18, 2005 11:55 AM
> To: sqlite-users@sqlite.org
> Subject: Re: [sqlite] Newbie Help Please
> 
> Wood, Lee wrote:
> 
> >I tried to do the quick-start example and I could not get it 
> to work. It is not explicit enough for some like me. First 
> off, the quickstart doesn't specify that you need to include 
> the source (just the external interface header). But since it 
> does not come with a *.lib I tried to include the source 
> files and I get a bunch of unresolved external dependencies 
> (can't find some function definitions). I even removed the 
> tcl*.c files and still got the errors. I'm compiling in 
> Visual C++ 7.1.
> > 
> >Also, I tried to build with the *.dll but the *.dll file 
> doesn't come with a header for it or static *.lib to link 
> against. If I use the *.dll do I have to fn* every function I 
> wish to use?
> >
> >  
> >
> Lee,
> 
> You need to use the LIB command line utility that comes with 
> VC++ to generate an sqlite3.lib file which will let you use 
> the sqlite3.dll library. You need to feed the sqlite3.def 
> file into the LIB utility and it will generate an sqlite3.lib 
> which you can link with your project. 
> The following command is used in the Makefile.
> 
>   lib /machine:i386 /def:sqlite3.def
> 
> HTH
> Dennis Cote
> 

This might help...
I created a Wiki page with a VS.NET 2003 Solution to compile SQLite.
http://www.sqlite.org/cvstrac/wiki?p=VsNetSolution



RE: [sqlite] sqlite 3.x and Win Server 2003 SP1 not working

2005-07-12 Thread Tim McDaniel
Which version of VC++ do you have?  I'm using VS.NET 2003.
In any case, it isn't diffcult.  You can download the "pre-processed"
source for Windows from sqlite.org.  Create a dll project, and add the
source files, including sqlite3.def, and excluding shell.c.  I specify
the NO_TCL macro to omit any TCL related stuff, but I don't remember if
that is essential.

> -Original Message-
> From: Derek Shaw [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, July 12, 2005 5:01 PM
> To: sqlite-users@sqlite.org
> Subject: RE: [sqlite] sqlite 3.x and Win Server 2003 SP1 not working
> 
> That would be great for me... How are you building it? Just 
> down load the source and point a project at it? I can imagine 
> its going to be that easy? I could not find any documentation 
> on building with VC++. 
> 
> I am working on upgrading to 3.2.2, I doubt its going to make 
> a difference, but you never know. I just download the dll and 
> run lib against it to get the lib and such. Then soft link to 
> it that way.
> 
> I would not be surprised to find out that it has something to 
> do with the gcc build...
> 
> ~derek.
> 
> -Original Message-
> From: Tim McDaniel [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, July 12, 2005 2:54 PM
> To: sqlite-users@sqlite.org
> Subject: RE: [sqlite] sqlite 3.x and Win Server 2003 SP1 not working
> 
> 
> > -Original Message-
> > From: D. Richard Hipp [mailto:[EMAIL PROTECTED] 
> > Sent: Tuesday, July 12, 2005 1:20 PM
> > To: sqlite-users@sqlite.org
> > Subject: Re: [sqlite] sqlite 3.x and Win Server 2003 SP1 not working
> > 
> > On Tue, 2005-07-12 at 11:01 -0700, Derek Shaw wrote:
> > > SQLite 3 relocates 2 addresses out of its memory bounds 
> > when it loads.
> > 
> > Can you explan in more detail what this means?
> > --
> > D. Richard Hipp <[EMAIL PROTECTED]>
> > 
> 
> If this is really the problem, then it's probably some "problem" with
> GCC compiling for Win32, or maybe some compile switch needs to be
> adjusted.  I don't have any details, I've only compiled sqlite with
> Visual C++.
> 


RE: [sqlite] sqlite 3.x and Win Server 2003 SP1 not working

2005-07-12 Thread Tim McDaniel

> -Original Message-
> From: D. Richard Hipp [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, July 12, 2005 1:20 PM
> To: sqlite-users@sqlite.org
> Subject: Re: [sqlite] sqlite 3.x and Win Server 2003 SP1 not working
> 
> On Tue, 2005-07-12 at 11:01 -0700, Derek Shaw wrote:
> > SQLite 3 relocates 2 addresses out of its memory bounds 
> when it loads.
> 
> Can you explan in more detail what this means?
> --
> D. Richard Hipp <[EMAIL PROTECTED]>
> 

If this is really the problem, then it's probably some "problem" with
GCC compiling for Win32, or maybe some compile switch needs to be
adjusted.  I don't have any details, I've only compiled sqlite with
Visual C++.


RE: [sqlite] Binding a column name?

2005-07-11 Thread Tim McDaniel


> -Original Message-
> From: D. Richard Hipp [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, July 10, 2005 6:01 PM
> To: sqlite-users@sqlite.org
> Subject: RE: [sqlite] Binding a column name?
> 
> On Sun, 2005-07-10 at 15:34 -0700, Tim McDaniel wrote:
> > > 
> > > If another thread or process VACUUMs the database or 
> creates a new 
> > > table or makes any other structure changes to the 
> database file, all 
> > > of your prepared statements will be invalided and you 
> will have to 
> > > rerun sqlite3_prepare().
> > > Since you generally have no control over when another 
> process might 
> > > VACUUM the database, you should always be prepared to rerun 
> > > sqlite3_prepare() if necessary.  This is true even if you 
> are only 
> > > running your SQL statement once and then finalizing it because 
> > > another process might VACUUM and invalidate your statement in the 
> > > very brief window of time between your calls to sqlite3_prepare() 
> > > and sqlite3_step().
> > > 
> > > Your best bet it to use a wrapper class of some sort that 
> automates 
> > > the task of rerunning sqlite3_prepare() when necessary.
> > > 
> > 
> > Does sqlite store the SQL text passed into sqlite3_prepare?
> > If not, then I assume this means that any time we use 
> sqlite3_prepare, 
> > we should cache the SQL text "in the wrapper" in case we need to 
> > re-prepare it.
> 
> Yes.  The wrapper needs to keep the SQL text because SQLite does not.
> 
> > Along the same line, I suppose we have to cache all the bound 
> > parameters, since they will have to re-bound as well.
> 
> You can do that.  Or you can keep the old prepared statement 
> around until after the new one is ready, then use the
> sqlite3_transfer_bindings() API to transfer all your bindings 
> from the old to the new, then finalize the old.
> 
> > 
> > Is it possible to get the SQLITE_SCHEMA error after the first 
> > sqlite3_step call, while iterating throw the rows?
> > 
> 
> No.  SQLITE_SCHEMA will always appear immediately or not at all.
> --

Is there any advantage to using sqlite3_expired() vs just
sqlite3_step(), since you have to check for SQLITE_SCHEMA anyway?


RE: [sqlite] Binding a column name?

2005-07-10 Thread Tim McDaniel
> -Original Message-
> From: D. Richard Hipp [mailto:[EMAIL PROTECTED] 
> Sent: Sunday, July 10, 2005 6:12 AM
> To: sqlite-users@sqlite.org
> Subject: RE: [sqlite] Binding a column name?
> 
> On Sun, 2005-07-10 at 00:23 -0700, Brown, Dave wrote:
> > That is what I do. But that also means I have to call 
> sqlite_prepare() 
> > each time, instead of just once. I was originally hoping I could 
> > prepare() once and just bind.
> > 
> 
> If another thread or process VACUUMs the database or creates 
> a new table or makes any other structure changes to the 
> database file, all of your prepared statements will be 
> invalided and you will have to rerun sqlite3_prepare().  
> Since you generally have no control over when another process 
> might VACUUM the database, you should always be prepared to 
> rerun sqlite3_prepare() if necessary.  This is true even if 
> you are only running your SQL statement once and then 
> finalizing it because another process might VACUUM and 
> invalidate your statement in the very brief window of time 
> between your calls to sqlite3_prepare() and sqlite3_step().
> 
> Your best bet it to use a wrapper class of some sort that 
> automates the task of rerunning sqlite3_prepare() when necessary.
> 

Does sqlite store the SQL text passed into sqlite3_prepare?
If not, then I assume this means that any time we use sqlite3_prepare,
we should cache the SQL text "in the wrapper" in case we need to
re-prepare it.
Along the same line, I suppose we have to cache all the bound
parameters, since they will have to re-bound as well.

Is it possible to get the SQLITE_SCHEMA error after the first
sqlite3_step call, while iterating throw the rows?

Tim


[sqlite] Attached databases & locking

2005-06-23 Thread Tim McDaniel
Question...

Two database files, say A & B.
Open A.
Attach B.
Write to a table in A.
Write to a table in B.

During the writes, is the file not being written to locked?

Thanks,
Tim


RE: [sqlite] Re: upgrade from 2 to 3

2005-05-21 Thread Tim McDaniel
I would file that as a bug, or at least as needing to be documented. 

> -Original Message-
> From: Cronos [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, May 21, 2005 12:49 PM
> To: sqlite-users@sqlite.org
> Subject: [sqlite] Re: upgrade from 2 to 3
> 
> Nevermind, it seems I have found the cause, I was doing:
>   sqlthread->exec("PRAGMA synchronous = 0;",NULL,NULL);
>   sqlthread->exec("PRAGMA cache_size = 4000;",NULL,NULL);
> 
> but changing it to this has sorted the problem out:
>   sqlthread->exec("PRAGMA cache_size = 4000;",NULL,NULL);
>   sqlthread->exec("PRAGMA synchronous = 0;",NULL,NULL);
> 
> It seems the value of synchronous gets changed back to full 
> if you change the cache_size.
> 
> 


RE: [sqlite] Is 'full_column_names' still broken?

2005-05-20 Thread Tim McDaniel
> -Original Message-
> From: Tito Ciuro [mailto:[EMAIL PROTECTED] 
> Sent: Friday, May 20, 2005 1:07 PM
> To: sqlite-users@sqlite.org
> Subject: Re: [sqlite] Is 'full_column_names' still broken?
> 
> Hello Tiago,
> 
> On 20/05/2005, at 7:08, Tiago Dionizio wrote:
> 
> > On 5/20/05, Tito Ciuro <[EMAIL PROTECTED]> wrote:
> >
> >> What am I missing?
> >>
> >
> > This post?
> >
> > http://www.mail-archive.com/sqlite-users%40sqlite.org/msg07743.html
> 
> 
> I have looked at the document, but it just doesn't work. My 
> code relies on full column names and was working fine before 
> upgrading to 3.2.1. I've written a very simple program to 
> populate a table and read the contents back in full column 
> name mode, like this:
> 
> // Assume the table has been created and contains some data...
> 
> // Retrieve the data from the db...
> PRAGMA short_column_names = OFF;
> PRAGMA full_column_names = ON;
> SELECT * FROM people;
> 
> The columns are constructed in short column mode, and there 
> seems no way to force full_column_names to be activated. I'm 
> working with SQLite 3.2.1 on Mac OS X Tiger (10.4.1). Has 
> anyone been able to make it work?
> 
> Thanks again,
> 
> -- Tito
> 

You're not missing anything.  It does NOT work as documented.
Why?  That's a good question.

Tim


RE: [sqlite] Does SQLite.NET not support AUTOINCREMENT

2005-03-01 Thread Tim McDaniel
This question is probably better asked on the SQLite.NET sourceforge
forum.
By the way, I don't know the answer.

Tim 

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] 
> Sent: Monday, February 28, 2005 10:22 PM
> To: sqlite-users@sqlite.org
> Subject: [sqlite] Does SQLite.NET not support AUTOINCREMENT
> 
> I used this SQL:
> 
> CREATE TABLE NewEmployees(EmployeeID INTEGER PRIMARY KEY 
> AUTOINCREMENT, LastName TEXT, FirstName TEXT);
> 
> and using SQLite3.exe did this
> 
> SQLite3 employees.db
> .read create.sql
> .exit
> 
> which created my database but no tools nor the SQLite.NET 
> provider can read it, I get the error "malformed database 
> schema near AUTOINCREMENT?
> 
> 
> 
> 


RE: [sqlite] new API for query column sources (was Re: ticket 1147)

2005-02-28 Thread Tim McDaniel
> -Original Message-
> From: Darren Duncan [mailto:[EMAIL PROTECTED] 
> Sent: Monday, February 28, 2005 10:29 PM
> To: sqlite-users@sqlite.org
> Subject: [sqlite] new API for query column sources (was Re: 
> ticket 1147)
> 
> Here are some alternate API naming suggestions, that I have 
> thought through at length and believe will work.
> 
> Since the proposed new functions are all related and talk 
> about the source table or view columns for the query, they 
> should all have the word 'source' in their names.  Here are 
> my suggestions for new functions (and we keep the old ones as 
> they are):
> 
>sqlite3_column_source() or sqlite3_column_source_column()
>sqlite3_column_source_table()
>sqlite3_column_source_database()
> 
> All 3 of the above functions return null values for a 
> calculated field, and non-null values for a non-calculated 
> field.  The first function gives the source table or view 
> field/column name, and is the same as many databases return 
> when you say "select *".  The second function gives the name 
> of the table or view; since another name for a "view" is a 
> "viewed table" (see SQL:2003), that name isn't inappropriate 
> when the source is a view.  And the third function is the 
> database containing the source table.  If desired, pair each 
> one with a second version for UTF16.
> 

I think your proposed functions are fine.
However, I don't know if returning the view name for a column from a
view is useful.  I think always returning the source table is the way to
go, since one of the driving reasons for these functions is the ability
to update the source table from the result set, and views are read-only.

Tim


RE: [sqlite] Good Graphical Tool for 3.x

2005-02-28 Thread Tim McDaniel

> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] 
> Sent: Monday, February 28, 2005 12:43 PM
> To: sqlite-users@sqlite.org
> Subject: [sqlite] Good Graphical Tool for 3.x
> 
> Is there a good enterprise manager like tool for SQLite 3.0?  
> I'm a windows guy and command line impaired, what I'm really 
> after is a database with a column in it that use the new 
> AUTOINCREMENT keyword, we're adding support for SQLite 3.x in 
> MyGeneration, we'll also be releasing an instance of our 
> dOOdads .NET architecture (C# and VB.NET) for SQLite in about a week.
> 
> Anyway, can anybody help me ? Graphical Tool or db with 
> AUTOINCREMENT column in it.
> 
> Mike Griffin
> MyGeneration Software
> http://www.mygenerationsoftware.com
> 

Here's the best three that I found, though still not terribly
exciting...

http://www.dbtools.com.br/EN/index.php

http://sqlite.org/contrib/download/sqlite3Explorer.zip?get=5

SQLiteCC (Can't find where I got it from, maybe Googling will turn it
up)


RE: [sqlite] ticket 1147

2005-02-28 Thread Tim McDaniel
> I'll third Dr. Hipp's statement.
> 
> I have my own wrappers (in Perl), made for public 
> consumption, and never had problems with returned column names.
> 
> Simply put, the elegant solution for wrapper authors is to 
> always use 'as' to explicitly define the column names you 
> want.  You always know how these names map to original table 
> columns because you explicitly said so.
> 
> Insisting on using default names all the time is for uber-lazy users.
> 
> -- Darren Duncan
> 

As a wrapper writer, I cannot control the SQL that a user of my wrapper
is passing in.

Tim


RE: [sqlite] ticket 1147

2005-02-28 Thread Tim McDaniel
> -Original Message-
> From: Robert Simpson [mailto:[EMAIL PROTECTED] 
> Sent: Monday, February 28, 2005 12:55 PM
> To: sqlite-users@sqlite.org
> Subject: RE: [sqlite] ticket 1147
> 
> > -Original Message-
> > From: Andrew Piskorski [mailto:[EMAIL PROTECTED]
> > Sent: Monday, February 28, 2005 11:34 AM
> > To: sqlite-users@sqlite.org
> > Subject: Re: [sqlite] ticket 1147
> > 
> > On Mon, Feb 28, 2005 at 11:16:33AM -0700, Robert Simpson wrote:
> > 
> > > Here are just a few things I can think of off the top of my
> > head that I
> > > cannot do right now for a resultset, but that I *can* do
> > with additional
> > > schema information:
> > 
> > Do you mean that you would like additional schema 
> information added to 
> > the system tables, so that you could separately figure this sort of 
> > stuff out by querying them?
> 
> No.  There is sufficient information there already.
> 
> > Or do you want this metadata returned with each and every resultset?
> > Meaning, essentially, have the db (optionally) return a metadata 
> > resultset along with each normal data resultset.  Is there some 
> > standard precisely specifying what this metadata resultset 
> should look 
> > like?
> 
> Metadata should be on-demand, and not automatically returned. 
>  As far as a standard is concerned, OLEDB and ODBC do it 
> differently and I'd have to look it up.  At a minimum the 
> only columns required to implement this are:
> 
> Column Name - The name of the column as specified in the 
> SELECT clause and what SQLite already generates Base Table - 
> The base table the column came from or NULL if the column was 
> computed Base Column - The base column of the table the 
> column came from or NULL if the column was computed Catalog - 
> The database the column came from or NULL if the column was computed.
> 
> Given the above, where base column is not null, one can 
> retrieve the extended properties of those column(s) and build 
> the extended metadata for them.
> 
> In a way, it's almost like a deviation from the EXPLAIN 
> keyword.  Call it "METADATA" and it returns a row for each 
> column in the select clause containing the above information.
> 
> Robert

Although I know nothing of the SQLite implementation details, it seems
that this could be an extension along the lines of the existing
sqlite3_column_decltype() function.  sqlite3_column_decltype() returns
the type, as a string, of a result column exactly as it was declared in
the CREATE statement.

Something like sqlite3_column_origname() could return the originating
"..".  Or it could be split up into 3
functions: sqlite3_column_origdatabase(), sqlite3_column_origtable(),
and sqlite3_column_origname().

Tim


RE: [sqlite] ticket 1147

2005-02-28 Thread Tim McDaniel
> -Original Message-
> From: D. Richard Hipp [mailto:[EMAIL PROTECTED] 
> Sent: Monday, February 28, 2005 11:30 AM
> To: sqlite-users@sqlite.org
> Subject: RE: [sqlite] ticket 1147
> 
> On Mon, 2005-02-28 at 08:48 -0700, Robert Simpson wrote:
> > 5.  What we do with the schema information or how well we 
> compute it 
> > is irrelevant.
> > 
> 
> No.  It is exceedingly relevant if you want any cooperation 
> from me in addressing the issue.
> 
> There seem to be a lot of people who are emphatic about 
> knowing which column in which table a value in the result set 
> originated from.  This makes no sense to me.  Why do they 
> care?  What do these people do with result set values that 
> originate from expressions or which are constants?  What 
> about the result set of compound selects or of natural joins 
> where the origin column is ambiguous?  If knowing the 
> original column is so important, what do people do with those 
> cases?  Disallow them?  What do other database engines 
> (PostgreSQL, Oracle, MySQL) do in the way of revealing the 
> originating column for result set values?  Do they have some 
> mysterious API that I have never seen?
> 
> And why do people care?  Can nobody give me a use case where 
> it is important to know what the originating column for a 
> result set value is?
> 

One example, ADO.NET (Robert S., correct me if I'm wrong here):

Given a specific SELECT statement, ADO.NET has the capability to
automatically build the corresponding INSERT, UPDATE, and DELETE
statements, so the user can insert/update/delete values/rows in the
resultset and have those modifications sent back to the database.  But
in order to facilitate this, it must have a direct mapping between
resultset columns and the originating columns in the database.

Tim McDaniel
(I wrote the original ADO.NET SQLite wrapper on sourceforge)


[sqlite] Column Names, Again

2005-02-23 Thread Tim McDaniel
Recently, there have been several threads regarding the desired ability
to get fully-qualified and original column names from a query result.
At the very least, this is useful for dynamic queries and for wrapper
writers.  There have been at least a couple of proposed solutions, one
involving a new pragma "real_column_names", and another involving a new
API function sqlite3_table_name.  Neither solution feels quite right,
IMHO, but I won't confuse the issue by proposing another, yet. :)

DRH, since I couldn't find any replies from you on the subject, I wonder
if you have any thoughts on the matter, or any plans to address the
issue.

Regards,
Tim McDaniel


[sqlite] Parameter syntax

2004-12-06 Thread Tim McDaniel
Sorry if this has been answered previously, but I couldn't find the
answer searching the mailing list archive...

What are the implemented syntax for specifying parameters in an SQL
statement for sqlite3_prepare?  Apparently the sqlite3.h header file and
the online documentation are out of sync, and neither is 100% correct.

Thanks,
Tim


RE: [sqlite] SQL help

2004-10-04 Thread Tim McDaniel
Dennis Cote came up with this, which I think will work...

select t.* from t join (select max(a) as a, b from t group by b) as key
where t.a=key.a and t.b=key.b;

Thanks for all the suggestions.
Tim


RE: [sqlite] SQL help

2004-10-04 Thread Tim McDaniel
> The statement proposed by Lawrence (copied below) will work 
> if your table has only these two columns, A and B.
> 
> SELECT MAX(A) AS A , B
> FROM T
> GROUP BY B
> 
> From your question I got the imprssion you may have other 
> columns as well.
> 
> For a table t like this;
> 
> a|b|c
> 1|5|6
> 2|5|7
> 3|5|8
> 10|6|7
> 4|6|10
> 3|2|5
> 4|2|6
> 7|6|13
> 
> An extended version of Lawrence's query gives;
> 
> sqlite> select max(a), b,c from t group by b;
> max(a)|b|c
> 4|2|5
> 3|5|6
> 10|6|7
> 
> Which has the wrong values for the column c. It uses the 
> value of c from the first record in each group. There is no 
> record with values 4, 2, 5.
> 
> You can get the correct rows with the following query which 
> is similar to Eric's proposal except that it is combined into 
> a single SQL statement.
> 
> select t.* from t join (select max(a) as a, b from t group by 
> b) as key where t.a=key.a and t.b=key.b;
> 
> Which will give the rows
> 
> t.a|t.b|t.c
> 3|5|8
> 10|6|7
> 4|2|6
> 
> This works, but I suspect there is probably a better way to do it.
> 

Thanks!  I think that will work.  At least it points me in the right
direction.
Tim


RE: [sqlite] SQL help

2004-10-04 Thread Tim McDaniel
> 
> > Given a table T like this:
> 
> > A B
> > -
> >  1 5
> >  2 5
> >  3 5
> > 
> > I need a query to give me just the row with the largest A 
> value, within
> > a group defined by B.  In this case, it would be the row with A = 3.
> 
> SELECT MAX(A) AS A , B
> FROM T
> GROUP BY B
> 
> 

Thanks, this does give me the max value of A within a group, but any
remaining column values still come from the row with A = 1.  For example

table T:

 A B C
---
 1 5 3
 2 5 2
 3 5 1

SELECT MAX(A) AS A, B, C
FROM T
GROUP BY B

gives:

 A B C
---
 3 5 3

But what I need is:

 A B C
---
 3 5 1


[sqlite] SQL help

2004-10-04 Thread Tim McDaniel
All,

This should be easy, but this non SQL guru can't figure it out...

Given a table T like this:

 A B
-
 1 5
 2 5
 3 5

I need a query to give me just the row with the largest A value, within
a group defined by B.  In this case, it would be the row with A = 3.
Something like:

SELECT * FROM T
GROUP BY B
ORDER BY A;

It doesn't seem to matter if I use ASC or DESC for the ordering, it
always gives me the row with A = 1.

Any ideas?

Thanks,
Tim McDaniel


RE: [sqlite] A proposal for SQLite version 3.0

2004-04-08 Thread Tim McDaniel
> > 
> > A statement's parameter values would be reset to null 
> values when the 
> > statement is reset.
> > 
> 
> Is that really the desired behavior?  If you want to reset 
> parameters on a statement reset, wouldn't it be better to do 
> so explicitly.  That way, if a statement has 10 parameters, 
> and you want to execute it 10 times, and only one parameter 
> changes between each run, you do not have to reinitialize the 
> other 9 every time.
> 

You could add an option to the reset function to specify whether the
parameters should be reset.

Tim McDaniel

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [sqlite] how can I use sqlite within windows managed code?

2003-12-19 Thread Tim McDaniel
The code example you give does not look like managed code, if by "managed code" you 
mean .NET code.
Your example looks like plain Windows C++ code.

> -Original Message-
> From: Kayhan Yuksel [mailto:[EMAIL PROTECTED] 
> Sent: Friday, December 19, 2003 10:33 AM
> To: '[EMAIL PROTECTED]'
> Subject: [sqlite] how can I use sqlite within windows managed code?
> 
> 
> To whom it may concern,
> I would like to know how can I use sqlite in a windows 
> managed code ?I am trying to modify the code at 
> "..\Dev-Cpp\Examples\WinMenut" that comes with the devcpp  
> 4.9.8.0 I have copied the sqlite.h to include directory, 
> included the sqlite.h as  modified some part of the 
> code to something like that : case IDM_DOSYAYENI:
>   {
>   sqlite* p_db = sqlite_open("c:\test.sdb", 0777, 0);
>   MessageBox( hwnd, (LPSTR) " 'test' 
> Veritabanı hazır.",
>   (LPSTR) szClassName,
>   MB_ICONINFORMATION | MB_OK );
>   return 0;
>   } 
> and I got this error : 
> [Linker error] undefined reference to `sqlite_open'
> 
> Is there an example that uses  with sqlite?
> 
> Yours sincerely+happy new year,
> 
> Kayhan YUKSEL
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [sqlite] Win32 coders: change os.c?

2003-11-21 Thread Tim McDaniel
Maybe there needs to be some clarification here.  All the sqlite
functions take const char* for string parameters.  What I'm not
clear on is the intended effect of the SQLITE_UTF8 macro.  Which
string parameters of which functions are intended to be UTF-8 encoded
if the SQLITE_UTF8 macro is defined?  I have assumed that
it is only those string parameters which are SQL statements.

Tim

> -Original Message-
> From: Rob Fowler [mailto:[EMAIL PROTECTED] 
> Sent: Friday, November 21, 2003 3:14 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [sqlite] Win32 coders: change os.c?
> 
> 
> Thanks for your thoughts.  Your first proposal (as I 
> understand it) creates unnecessary steps to end up with data 
> that Sqlite can use.  Here's an example of the round trip 
> flow of data in your proposal:
> 
>   User input (UTF-16)
>   -> UTF16_To_UTF8()
>   -> sqlite_function()
>   -> MultiByteToWideChar()
>   -> Win32FunctionW()
>   -> WideCharToMultiByte()
>   -> Data Sqlite can use
> 
> Why the conversion back to wide characters within SQLite?  In 
> my proposal, the flow is as follows:
> 
>   User input (UTF-16)
>   -> UTF16_To_UTF8()
>   -> sqlite_function()
>   -> Win32FunctionA()
>   -> Data Sqlite can use
> 
> Your second proposal is to prevent me from using UNICODE 
> within my parent application?  Can't do that.  Naïve 
> programmers will already know something needs to be done 
> (convert UTF-16 to UTF-8) in order to use the sqlite 
> functions in the first place.  Their app won't compile if 
> they try to feed in wide strings.
> 
> Any follow-up thoughts?
> 
> Rob
> 
> -Original Message-
> From: Arthur Hsu [mailto:[EMAIL PROTECTED] 
> Sent: Friday, November 21, 2003 2:24 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [sqlite] Win32 coders: change os.c?
> Importance: Low
> 
> 
> Not quite.  IMHO, it's better that os.c catches this UNICODE 
> macro, and then
> 
> uses MultiByteToWideChar and WideCharToMultiByte inside.  The 
> other way is
> 
> to use an assert(FALSE) to prevent compilation using UNICODE, 
> then the naive
> 
> programmers like me will know something needs to be taken care of.
> 
> 
> 
> -Arthur
> 
> 
> 
> - Original Message - 
> 
> I think you can see where I'm going with this.  To fix the problem, I
> 
> propose that for the functions listed above, os.c should 
> always call the
> 
> 'real' function name, and it should be the one ending with an 
> 'A'.  As it
> 
> stands, the os.c has no ability to deal with wide characters, 
> so there is no
> 
> reason it should ever call the wide version of these Win32 functions.
> 
> 
> 
> Thoughts?
> 
> 
> 
> Regards,
> 
> Rob Fowler
> 
> 
> 
> 
> 
> 
> 
> -
> 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> 
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [sqlite] In-memory DB performance tuning

2003-11-18 Thread Tim McDaniel
Arthur,
Full source and a small test app are at
http://sourceforge.net/projects/adodotnetsqlite

> -Original Message-
> From: Arthur C. Hsu [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, November 18, 2003 2:22 AM
> To: Tim McDaniel; [EMAIL PROTECTED]
> Subject: RE: [sqlite] In-memory DB performance tuning
> 
> 
> Thanks for the quick response.  Any samples that I can reference?
> 
> -Arthur 
> 
> -----Original Message-
> From: Tim McDaniel [mailto:[EMAIL PROTECTED] 
> Sent: Monday, November 17, 2003 11:54 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [sqlite] In-memory DB performance tuning
> 
> Arthur,
> 
> I've just done some performance tests using our ADO.NET 
> provider for SQLite. On a 2GHz P4 system, we get about 35000 
> inserts/sec and 175000 reads/sec. This is with a file db 
> using a transaction, or an in-memory db without transaction, 
> they both perform the same.  The performance is linear, I've 
> done 10k, 100k, 500k, and 1 million row tests, the insert and 
> read rate is the same for all.  If you are using the C 
> interface, your results should be comparable (scaled to your 
> system speed of course), especially considering the slight 
> interop hit we take for ADO.NET.
> 
> Tim
> 
> > -Original Message-
> > From: Arthur C. Hsu [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, November 18, 2003 1:16 AM
> > To: 'Steve Dekorte'
> > Cc: [EMAIL PROTECTED]
> > Subject: RE: [sqlite] In-memory DB performance tuning
> > 
> > 
> > Yes I know the Berkeley DB or gdbm solutions out there.
> > However, I need multicolumns and I need more sophiscated 
> feature like 
> > ORDER BY and GROUP BY.
> > 
> > -Arthur
> > 
> > -Original Message-
> > From: Steve Dekorte [mailto:[EMAIL PROTECTED]
> > Sent: Monday, November 17, 2003 10:38 PM
> > To: Arthur C. Hsu
> > Cc: [EMAIL PROTECTED]
> > Subject: Re: [sqlite] In-memory DB performance tuning
> > 
> > 
> > On Nov 17, 2003, at 9:55 PM, Arthur C. Hsu wrote:
> > > Any clues that I can further squeeze the performance?  Or the
> > > limitation is by design?  I just can't realize why the
> > first 6000 rows
> > > are amazing fast but later the speed drops down so dramatically.
> > 
> > Hi Arthur,
> > 
> > If you really need performance and can model your data as key/value
> > pairs, then you might consider something like SleepyCat. If 
> I remember 
> > correctly, it can read/write around 50K rows per second.
> > 
> > -- Steve
> > 
> > 
> > 
> > 
> -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [sqlite] In-memory DB performance tuning

2003-11-18 Thread Tim McDaniel
Arthur,

I've just done some performance tests using our ADO.NET provider for
SQLite.  On a 2GHz P4 system, we get about 35000 inserts/sec and 175000
reads/sec.  This is with a file db using a transaction, or an in-memory
db without transaction, they both perform the same.  The performance is
linear, I've done 10k, 100k, 500k, and 1 million row tests, the insert
and read rate is the same for all.  If you are using the C interface,
your results should be comparable (scaled to your system speed of
course), especially considering the slight interop hit we take for
ADO.NET.

Tim

> -Original Message-
> From: Arthur C. Hsu [mailto:[EMAIL PROTECTED] 
> Sent: Tuesday, November 18, 2003 1:16 AM
> To: 'Steve Dekorte'
> Cc: [EMAIL PROTECTED]
> Subject: RE: [sqlite] In-memory DB performance tuning
> 
> 
> Yes I know the Berkeley DB or gdbm solutions out there.  
> However, I need multicolumns and I need more sophiscated 
> feature like ORDER BY and GROUP BY.
> 
> -Arthur 
> 
> -Original Message-
> From: Steve Dekorte [mailto:[EMAIL PROTECTED] 
> Sent: Monday, November 17, 2003 10:38 PM
> To: Arthur C. Hsu
> Cc: [EMAIL PROTECTED]
> Subject: Re: [sqlite] In-memory DB performance tuning
> 
> 
> On Nov 17, 2003, at 9:55 PM, Arthur C. Hsu wrote:
> > Any clues that I can further squeeze the performance?  Or the
> > limitation is by design?  I just can't realize why the 
> first 6000 rows 
> > are amazing fast but later the speed drops down so dramatically.
> 
> Hi Arthur,
> 
> If you really need performance and can model your data as 
> key/value pairs, then you might consider something like 
> SleepyCat. If I remember correctly, it can read/write around 
> 50K rows per second.
> 
> -- Steve
> 
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [sqlite] Performance tuning question

2003-11-15 Thread Tim McDaniel
It isn't clear what you are trying to determine.

What provider are you using for ADO.NET (eg Jet, SQL Server, etc)?

Are your inserts for SQLite inside a transaction?  This makes a huge
difference.

If you are using ADO.NET, you might look at
http://sourceforge.net/projects/adodotnetsqlite



> -Original Message-
> From: Arthur Hsu [mailto:[EMAIL PROTECTED] 
> Sent: Friday, November 14, 2003 6:29 PM
> To: Andrew Shakinovsky; [EMAIL PROTECTED]
> Subject: Re: [sqlite] Performance tuning question
> 
> 
> Hello,
> 
> I managed to download new CVS versions (by hand ...) and 
> compile them on Win32 platform (finally).  Following are my 
> test results:
> 
> Time elapsedADO.NetSQLite 2.8.6SQLite CVS
> 0   0  0   0
> 30  7419   57297920
> 60  14176  801310711
> 90  20760  986913147
> 120 26623  11033   14944
> 150 32862  12633   16598
> 180 38783  13044   17878
> 210 44472  13098   19609
> 240 49873  14120   20711
> 
> The CVS version is quite linear after the first 30 seconds.  
> I'm still digging the reason for the performance difference 
> between 0-30 and 30-60. Any ideas?
> 
> -Arthur
> 
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [sqlite] Performance tuning question

2003-11-14 Thread Tim McDaniel
Arthur,

sqlite_bind and sqlite_reset are part of an "experimental" API in the
latest SQLite source code in CVS, but it isn't part of an official
release yet.  However, I use them, and they work very well.

Tim

> -Original Message-
> From: Arthur Hsu [mailto:[EMAIL PROTECTED] 
> Sent: Friday, November 14, 2003 2:04 PM
> To: Andrew Shakinovsky; [EMAIL PROTECTED]
> Subject: Re: [sqlite] Performance tuning question
> 
> 
> Hello Andrew,
> 
> I'm a little confused about the precompiled SQL.  According 
> to Wiki, there should be something like sqlite_bind() that I 
> can use.  However, I can't find sqlite_bind() in my sqlite source ...
> 
> I'll try the sqlite_create_function().  Thanks.
> 
> Regards,
> 
> Arthur
> 
> - Original Message - 
> From: "Andrew Shakinovsky" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, November 14, 2003 7:24 AM
> Subject: RE: [sqlite] Performance tuning question
> 
> 
> > Arthur,
> > For pre-compiled execution in SQLite, try using the sqlite_reset()
> function.
> > It allows you to avoid having to re-compile your SQL every time you
> execute
> > it. You can use sqlite_create_function() to do the equivalent of 
> > "parameterized" queries by creating a function which takes 
> a parameter 
> > position and and returns the parameter value. I use this a 
> lot in my 
> > code since I do a lot of inserts and want them to
> run
> > fast without invoking the query compiler for each one.
> >
> >
> > -Original Message-
> > From: Arthur C. Hsu [mailto:[EMAIL PROTECTED]
> > Sent: Friday, November 14, 2003 3:50 AM
> > To: 'Greg Obleshchuk'; [EMAIL PROTECTED]
> > Subject: RE: [sqlite] Performance tuning question
> >
> >
> > Hello Greg,
> >
> > The insert is not in transaction.  I do the insert and update like
> >
> > CCriticalSection cs;
> >
> > void CDB::insert()
> > {
> > cs.Lock();
> > sqlite_exec_printf(pDB, "insert into db values(%d, %q, 
> null, null, 0, 
> > null", 0, 0, 1, "A"); cs.Unlock();
> > }
> >
> > void CDB::update()
> > {
> > cs.Lock();
> > sqlite_exec_printf(pDB, "update db set str=%q where id=%d", 
> 0, 0, "A", 
> > 1); cs.Unlock();
> > }
> >
> > As described in my previous mail, I have two threads that 
> > simultaneously accessing this in-mem DB.  Thus I have to 
> use locks to 
> > be sure of thread-safety.  I keep pumping data into DB via 
> insert from 
> > one thread.
> My
> > sqlite version is 2.8.6 and I didn't compile it with 
> -DTHREAD_SAFE=1.
> >
> > I have 1G bytes of memory in my development machine and it's hard to
> believe
> > that I didn't have enough memory for a 50M database :)
> >
> > I use MDAC via .Net framework.  I use ADO.Net in-memory table
> > (System.Data.DataTable) and does not connect to any data source.
> >
> > BTW, I use Intel VTune and try to find out the bottleneck of my 
> > program. Execution of sqlite vbe is the most time-consuming (55%).  
> > However,
> yyparser
> > of sqlite contributes 30% of load.  I tend to believe this explains 
> > why
> the
> > first 30 seconds the ADO.Net is faster than sqlite.  SQL 
> statements in 
> > ADO.Net always run precompiled, thus it saves time for parsing SQL
> commands.
> > I'm trying to do precompiled execution in sqlite, and getting 
> > frustrated about that.
> >
> > The decaying phoenomenon is quite weird.  My wild guesses are
> >
> > A. Issues of memory indexing: page index table grows bigger and 
> > bigger,
> thus
> > indirection of memory tends to slow down B. SQLite try to do "safe" 
> > memory allocations, that is, malloc new memory block, 
> memcpy old data, 
> > then free old memory block.
> >
> > These are just guesses.  I'm trying to dig out why.  Maybe you guys 
> > who
> are
> > more familiar with sqlite internals can show me the answer :)
> >
> > Regards,
> >
> > Arthur
> >
> >
> > 
> -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> 
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: [sqlite] LoadLibrary, ERROR_NOACCESS

2003-11-10 Thread Tim McDaniel
>From the Microsoft Platform SDK documentation concerning LoadLibrary:
"Note that two DLLs that have the same base file name and extension but
are found in different directories are not considered to be the same
DLL."

Loading two DLL's with the same name shouldn't be a problem.  Try
loading the custom dll first.  You may have a problem with the custom
dll itself, at least that's what the ERROR_NOACCESS points to.

> -Original Message-
> From: Lindsay Mathieson [mailto:[EMAIL PROTECTED] 
> Sent: Monday, November 10, 2003 6:03 PM
> To: Sergey Startsev; SQLite
> Subject: Re: [sqlite] LoadLibrary, ERROR_NOACCESS
> 
> 
> Sergey Startsev wrote:
> 
> >Hello!
> >
> >  I am trying to load two copies of sqlite.dll at one time.  One - 
> > version 2.8.4, two - version 2.8.6
> >
> >  handle1:= loadlibrary('c:\2.8.4\sqlite.dll');
> >  // this loaded OK
> >
> >  handle2:= loadlibrary('c:\custom\sqlite.dll');
> >  // this return error
> >  ERROR_NOACCESS (Invalid access to memory location)
> >  
> >  Why I can't load two copies of sqlite.dll?
> >  
> >
> Because *windows* will not let you load the two copies of a 
> dll with the 
> same name - can't be done. Try renaming the dll, preferably with its 
> version, e.g.
> 
>   handle1:= loadlibrary('c:\2.8.4\sqlite_2.8.4.dll');
>   // this loaded OK
> 
>   handle2:= loadlibrary('c:\custom\sqlite_custom.dll');
> 
> 
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[sqlite] Ann: ADO.NET Data Provider for SQLite

2003-11-08 Thread Tim McDaniel
Released:
The 0.1 (pre-alpha) version of the free, open source ADO.NET Data
Provider for SQLite.

http://sourceforge.net/projects/adodotnetsqlite

Any feedback is more than welcome.

Cheers,
Tim

(sorry if this is a duplicate message, i don't know if it went through
the first time)

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[sqlite] commercial usage of sqlite

2003-11-04 Thread Tim McDaniel
I am trying to use SQLite in a commercial application, but I am getting
resistance from the company lawyer:

"It is a risk to incorporate SQLite in the [product].  No indemnity
comes with it.  We are exposed to third party claims of infringement."

Has anyone else been in this position?  Any advice?

Thanks,
Tim McDaniel



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]