Re: [sqlite] Request for help with SQLite Query to return missing Date/Time Ranges

2011-04-20 Thread Oliver Peters
Andrew Lindsay  writes:

[...]

> I am trying to search an SQL database that is meant to have entries logged
> every minute for a period of approximately 15 months.
> 
> I want to create a query that will search through the database and tell me
> for which periods I do not have any entries.
> 
[...]

very easy:

1. calculation
60*24=   1,440 minutes ( 1 day)
1,440  * 31  =  44,640 minutes ( 1 month, only an approximation
 because not every month has 31 days)
44,640 * 15  = 669,600 minutes (15 months)

-> produce ~669,600 entries that represent your minutes of a day

assuming you have a timestamp like -MM-DD HH:MM:SS in your database
your 669,600 look like this:
2011-04-21 00:00
2011-04-21 00:01
...

you can produce this very simply with a spreadsheet program like
OpenOffice Calc (the latest version has more than 1,000,000 rows)


2. Import the whole thing in a sqlite table
CREATE Table check(
minute TEXT,
PRIMARY KEY(minute)
);


3. EXCEPT
SELECT minute
FROM check
EXCEPT
SELECT substr(timestamp,1,16)
FROM
yourtable
;


That's it - I assume here that you want to check every minute but it's
easy to adapt this

greetings
oliver

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


Re: [sqlite] just fyi: iPhone and iPad 3G's tracking their owners' movements and saving to sqlite db

2011-04-20 Thread Simon Slavin

On 21 Apr 2011, at 3:53am, Donald Griggs wrote:

> Re: *SQLite is not really related to this*
>  I wasn't really posing an issue for the list, just an fyi, such as is
> often done when an sqlite application is in the news.

Hadn't seen many articles like that but now you've raised the idea I see it 
makes sense.  Sorry: I didn't mean to reprove you, just to comment that there 
was nothing inherently SQLite-ish about what was being done.

> Re:  *...as is almost all database-suitable data  in an iPhone.*
>  Didn't realize it was so extensive in the iPhone.  Sorry for the list
> noise.

Well, I obviously felt it was worthwhile answering, just to as a piece of 
rumour control.

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


Re: [sqlite] just fyi: iPhone and iPad 3G's tracking their owners' movements and saving to sqlite db

2011-04-20 Thread Donald Griggs
Re: *SQLite is not really related to this*
  I wasn't really posing an issue for the list, just an fyi, such as is
often done when an sqlite application is in the news.


Re:  *...as is almost all database-suitable data  in an iPhone.*
  Didn't realize it was so extensive in the iPhone.  Sorry for the list
noise.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Security issues with SQLite3.6.23.1

2011-04-20 Thread Roger Binns
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 04/20/2011 06:54 AM, thilo wrote:
> They are a great tool ensuring programs have fewer memory leaks, thread
> issues and the like and if one has access to their results, please USE
> it and judge the false positives with human eyes - strcpy & fprintf are
> not security risks by themselves but only in an application context. 
> Reviews (human & automated) are always a good step towards a stable
> codebase!

What you have missed is that the tool you pointed to is crap.  It gives
noisy useless results.

In addition to their brains the SQLite team also uses other tools such as
the compiler, Coverity, clang etc.  Then they have a test suite with full
MCDC coverage which means all code has to be read to be tested that much (on
several platforms).  All changes are public (see the timeline) and on rare
occasions other people may have observations.

In other words the existing tools and brains are orders of magnitude better
than that tool.  No one is against tools to improve the integrity of
products but that one contributes nothing.

If you believe it shows things existing tools don't then please enlighten
us.  The evidence at the moment is that it wastes time better spent with
other tools and human review.

Roger
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2vj4QACgkQmOOfHg372QR2SgCfXXogHwGyUfGEWHRXDUWZlAJr
gToAoLuOKGs5nvIRJJb5ur9hKgxCtQ7v
=zvtr
-END PGP SIGNATURE-
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Request for help with SQLite Query to return missingDate/Time Ranges

2011-04-20 Thread Igor Tandetnik
Andrew Lindsay  wrote:
> I am trying to search an SQL database that is meant to have entries logged
> every minute for a period of approximately 15 months.
> 
> I want to create a query that will search through the database and tell me
> for which periods I do not have any entries.

Something like this perhaps:

select * from (
select *, julianday(t1.timestamp) - julianday(
(select t2.timestamp from MyTable t2
 where t2.timestamp < t1.timestamp order by t2.timestamp desc limit 1)
) as Gap
from MyTable t1
)
where Gap > 1.0/1440.0 order by Gap desc;

(1.0/1440.0) is one minute (there are 1440 minutes in a day).
-- 
Igor Tandetnik

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


Re: [sqlite] Request for help with SQLite Query to return missingDate/Time Ranges

2011-04-20 Thread Tom Holden
Could you not do this:

Select A.time + 1 minute, B.time - 1 minute from log as A, log as B where 
A.RowID=B.RowID+1 and B.time-A.time > 1 minute

Tom

-Original Message- 
From: Andrew Lindsay
Sent: Wednesday, April 20, 2011 7:34 PM
To: sqlite-users@sqlite.org
Subject: [sqlite] Request for help with SQLite Query to return 
missingDate/Time Ranges

Dear Group,



I am trying to search an SQL database that is meant to have entries logged
every minute for a period of approximately 15 months.



I want to create a query that will search through the database and tell me
for which periods I do not have any entries.



Any assistance would be greatly appreciated.



Regards



Andrew Lindsay

___
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] Request for help with SQLite Query to return missing Date/Time Ranges

2011-04-20 Thread David Garfield
Actually, with this criteria, you can -- in a roundabout way.

select the timestamps by a large period, perhaps daily or monthly.
aggregate on that rough timestamp, and also select the count.
Anywhere the count is lower than expected, you are missing data.

You can then repeat over relevant ranges with finer aggregation to
identify exactly what is missing.

A completely missing block might not be noticed, but unless the stop
and start exactly matched the missing data, you would see the border
anomalies.

A having clause would be useful for selecting just the anomalous
aggregations (provided they are uniform).

--David Garfield


Simon Slavin writes:
> 
> On 21 Apr 2011, at 12:34am, Andrew Lindsay wrote:
> 
> > I am trying to search an SQL database that is meant to have entries logged
> > every minute for a period of approximately 15 months.
> > 
> > 
> > 
> > I want to create a query that will search through the database and tell me
> > for which periods I do not have any entries.
> 
> You can't find missing data.  Your fastest way to do it would just be to 
> write code retrieve all the datastamps, turn them into period numbers, then 
> look down the list for missing ones.  A slower way would be to use a SELECT 
> which retrieved all entries, with a sub-SELECT which looked for all entries 
> in the following period.
> 
> 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] Request for help with SQLite Query to return missing Date/Time Ranges

2011-04-20 Thread Simon Slavin

On 21 Apr 2011, at 12:34am, Andrew Lindsay wrote:

> I am trying to search an SQL database that is meant to have entries logged
> every minute for a period of approximately 15 months.
> 
> 
> 
> I want to create a query that will search through the database and tell me
> for which periods I do not have any entries.

You can't find missing data.  Your fastest way to do it would just be to write 
code retrieve all the datastamps, turn them into period numbers, then look down 
the list for missing ones.  A slower way would be to use a SELECT which 
retrieved all entries, with a sub-SELECT which looked for all entries in the 
following period.

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


[sqlite] Request for help with SQLite Query to return missing Date/Time Ranges

2011-04-20 Thread Andrew Lindsay
Dear Group,

 

I am trying to search an SQL database that is meant to have entries logged
every minute for a period of approximately 15 months.

 

I want to create a query that will search through the database and tell me
for which periods I do not have any entries.

 

Any assistance would be greatly appreciated.

 

Regards

 

Andrew Lindsay

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


Re: [sqlite] just fyi: iPhone and iPad 3G's tracking their owners' movements and saving to sqlite db

2011-04-20 Thread Simon Slavin

On 21 Apr 2011, at 12:03am, Donald Griggs wrote:

> The video mentions that the file "consolidated.db" is an ordinary sqlite
> file, containing latitude, longitude, and timestamps.   The data they
> examined went back several months.
> 
> http://radar.oreilly.com/2011/04/apple-location-tracking.html
> 
> There's no allegation the data is *transmitted* to Apple or anyone else, but
> this is intriguing nonetheless.

SQLite is not really related to this, other than the data is held in an SQLite 
database file, as is almost all database-suitable data (rows and columns) in an 
iPhone.

Technically, the data referred to is as follows.  An iPhone logs details of 
which phone base stations it connects to, and the 'status' data obtained from 
the base station when it was connected.  The location (long & lat) of the base 
station is part of the base station's status string.  That is all.  Many phones 
for many manufacturers do this: it's a vital part of the information used when 
looking at poor signal strengths and dropped calls.

I am not at all surprised that this data is collected, since it's invaluable 
when diagnosing problems with the phone functions.  What surprises me is that 
entries in that database are not deleted after, say, a month.

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


[sqlite] just fyi: iPhone and iPad 3G's tracking their owners' movements and saving to sqlite db

2011-04-20 Thread Donald Griggs
The video mentions that the file "consolidated.db" is an ordinary sqlite
file, containing latitude, longitude, and timestamps.   The data they
examined went back several months.

http://radar.oreilly.com/2011/04/apple-location-tracking.html

There's no allegation the data is *transmitted* to Apple or anyone else, but
this is intriguing nonetheless.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Building managed only System.Data.SQLite

2011-04-20 Thread Shane Harrelson
Remember that System.Data.SQLite.dll needs to be able to find the
SQLite.Interop.dll.
There's a post-build step that attempts to copy the Interop DLL to the
appropriate debug directory.
You may still need to copy into your debug directory for your test purposes.



On Wed, Apr 20, 2011 at 3:04 PM, Rich Rattanni  wrote:

> Shane:
>
> I downloaded http://system.data.sqlite.org/sqlite-dotnetsrc-1006900.zip
> and changed SQLite.NET.Settings.targets as per your recommendation.
> It did not appear to solve my problem since my application threw an
> exception stating that Sqlite.Interop was missing.  To be complete I
> tried 3 permutations of the two options UseInteropDll and
> UseSqliteStandard ( I did not try false, false).
>
> All resulting System.Data.SQLite.DLLs threw exceptions due to a
> missing InterOp DLL.  I pulled down a copy of System.Data.SQLite
> 1.0.66.0 and built the Managed Only version, and it appeared to work.
>
> I will mess around some more with the project to see if I can build
> the managed only version.  I was hoping to get my hands on the latest
> so I was not fighting issues that may have been fixed by a release.
> Thank you again for trying to help, rest assured it was appreciated.
>
> --
> Rich
>
> On Tue, Apr 19, 2011 at 5:36 PM, Rich Rattanni  wrote:
> > Daniel:
> >
> > I have not tried Csharp-sqlite, it looks interesting but I do not know
> > if that is right for me at this moment.
> >
> > Shane:
> >
> > I will try what you recommend tomorrow, thank you.
> >
> > --
> > Rich
> >
> > On Tue, Apr 19, 2011 at 4:47 PM, Shane Harrelson
> >  wrote:
> >> The target build settings can be controlled from
> SQLite.NET.Settings.targets
> >> - in particular, you should probably look at UseInteropDll and
> >> UseSqliteStandard.
> >> To override the USE_INTEROP_DLL setting, try copying
> >> SQLite.NET.Settings.targets to SQLite.NET.Settings.targets.user and make
> the
> >> settings changes there.
> >> This should work with VS2008 and VS2010.
> >>
> >> HTH.
> >> -Shane
> >>
> >>
> >> On Tue, Apr 19, 2011 at 3:09 PM, Rich Rattanni 
> wrote:
> >>
> >>> I was wondering if anyone has had any luck building the Managed-Only
> >>> System.Data.SQLite .NET adapter for SQLite from the source provided at
> >>> system.data.sqlite.org?  I downloaded the pre-built binaries but they
> >>> appear to rely on the InterOp assembly.  My current project is running
> >>> under Linux 2.6 on an ARM processor, and uses managed-only copy of the
> >>> System.Data.SQLite adapter + SQLite 3.5.0 + mono to run my .NET app.
> >>> I am looking to do some bug tracing / upgrading so I would like to
> >>> build my own copy from source.
> >>>
> >>> --
> >>> Rich
> >>> ___
> >>> 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
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] insert help

2011-04-20 Thread Petite Abeille

On Apr 20, 2011, at 10:25 PM, ArbolOne wrote:

> Hell! any body?

http://tinyurl.com/4yxf2gc

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


Re: [sqlite] insert help

2011-04-20 Thread ArbolOne
Hell! any body?

-
Hey folks.
I would like to use sqlite in a C++ program.
Is there a place in the internet where I can see  C/C++ examples of sqlite?
TIA

-- 
All things in life are temporary.  If going well enjoy it, they will not last 
forever. If going wrong don't worry, they can't last long either.

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


Re: [sqlite] Building managed only System.Data.SQLite

2011-04-20 Thread Rich Rattanni
Shane:

I downloaded http://system.data.sqlite.org/sqlite-dotnetsrc-1006900.zip
and changed SQLite.NET.Settings.targets as per your recommendation.
It did not appear to solve my problem since my application threw an
exception stating that Sqlite.Interop was missing.  To be complete I
tried 3 permutations of the two options UseInteropDll and
UseSqliteStandard ( I did not try false, false).

All resulting System.Data.SQLite.DLLs threw exceptions due to a
missing InterOp DLL.  I pulled down a copy of System.Data.SQLite
1.0.66.0 and built the Managed Only version, and it appeared to work.

I will mess around some more with the project to see if I can build
the managed only version.  I was hoping to get my hands on the latest
so I was not fighting issues that may have been fixed by a release.
Thank you again for trying to help, rest assured it was appreciated.

--
Rich

On Tue, Apr 19, 2011 at 5:36 PM, Rich Rattanni  wrote:
> Daniel:
>
> I have not tried Csharp-sqlite, it looks interesting but I do not know
> if that is right for me at this moment.
>
> Shane:
>
> I will try what you recommend tomorrow, thank you.
>
> --
> Rich
>
> On Tue, Apr 19, 2011 at 4:47 PM, Shane Harrelson
>  wrote:
>> The target build settings can be controlled from SQLite.NET.Settings.targets
>> - in particular, you should probably look at UseInteropDll and
>> UseSqliteStandard.
>> To override the USE_INTEROP_DLL setting, try copying
>> SQLite.NET.Settings.targets to SQLite.NET.Settings.targets.user and make the
>> settings changes there.
>> This should work with VS2008 and VS2010.
>>
>> HTH.
>> -Shane
>>
>>
>> On Tue, Apr 19, 2011 at 3:09 PM, Rich Rattanni  wrote:
>>
>>> I was wondering if anyone has had any luck building the Managed-Only
>>> System.Data.SQLite .NET adapter for SQLite from the source provided at
>>> system.data.sqlite.org?  I downloaded the pre-built binaries but they
>>> appear to rely on the InterOp assembly.  My current project is running
>>> under Linux 2.6 on an ARM processor, and uses managed-only copy of the
>>> System.Data.SQLite adapter + SQLite 3.5.0 + mono to run my .NET app.
>>> I am looking to do some bug tracing / upgrading so I would like to
>>> build my own copy from source.
>>>
>>> --
>>> Rich
>>> ___
>>> 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] A real newbie question: why brackets?

2011-04-20 Thread Richard Hipp
On Wed, Apr 20, 2011 at 2:58 PM, Jonathan Allin
wrote:

> The "Chinook" SQL script for creating the database contains many commands
> with brackets, eg
>
>
>
> DROP TABLE IF EXISTS [Album];
>
>
>
> What do the brackets do?


The [...] quote the identifier they contain, thus allowing the identifier to
be a keyword or to contain non-alphanumeric characters.

The [...] are not standard SQL.  Standard SQL to do the same thing would be
to enclose the identifier in double-quotes:  "Album".  The support for [...]
in SQLite for compatibility with MS Sql Server.  SQLite also supports
grave-accent quoting:  `Album` for compatibility with MySQL.


-- 
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] A real newbie question: why brackets?

2011-04-20 Thread Jonathan Allin
The "Chinook" SQL script for creating the database contains many commands
with brackets, eg

 

DROP TABLE IF EXISTS [Album];

 

What do the brackets do? I've not seen any examples with brackets, but on
the other hand SQLite seems to ignore them. In other words the above
statement seems to be equivalent to

 

DROP TABLE IF EXISTS Album;

 

Many thanks,

 

¬Jonathan

 

 

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


Re: [sqlite] SQLite3 memory leaks in my c++ dll application

2011-04-20 Thread Teg
Hello Khanh,

Until you confirm the memory leak, I doubt anyone will respond. For
example, when my program exits, I abandon a bunch of allocated memory
to speed exit. VC says that's a memory leak but, it's not, because
it's not leaking memory while I'm using it. I purposely abandon
allocated memory on exit to speed exit processing (deallocating 2 gigs
of RAM when I'm exiting anyway is pointless).

The question is whether it's leaking RAM while you use it, not if it
leaks it when you exit (which is when VC checks).

C

Wednesday, April 20, 2011, 12:00:57 PM, you wrote:

KN> Hi SQLite3 community,

KN> Please forgive me this panic, incorrect bug report. The cause of memory
KN> leaks was from another my software component. The SQLite3.dll is working
KN> greatly with my solution. However, it was memory leaks detection from VS2008
KN> when I built the SQLite3 with Sqlite3.c in my solution.

KN> If you know about this, please give me some hints on how to set flags in my
KN> database module(vcproj) to eliminate the memory leaks. I would greatly
KN> appreciate your kindness.

KN> The database vcproj DLL built with VS2008 C++ with this flag: Multi-threaded
KN> Debug DLL (/MDd). Accessing the DLL via GetProcAddress() calls.

KN> Sincerely and Thank you,

KN> Khanh


KN> On Mon, Apr 18, 2011 at 8:56 AM, Khanh Nguyen  wrote:

>> Hi,
>>
>>
>>
>> My name is Khanh Nguyen and currently using SQLite3.DLL 3.7.6 in my
>> application (DLL built with VS2008 C++ with this flag: Multi-threaded Debug
>> DLL (/MDd). This DLL is called by other DLL via GetProcAddress to access a
>> blob database. The access and blob database is in very good operation.
>> However, whenever I exited the application, the VS2008 debugger reported
>> this memory leak dectection:
>>
>>
>>
>> The DLL has some memory leaks that I have captured here:
>>
>>
>>
>> The thread 'Win32 Thread' (0x368) has exited with code 0 (0x0).
>>
>> Detected memory leaks!
>>
>> Dumping objects ->
>>
>> {8390} normal block at 0x01364C70, 64 bytes long.
>>
>>  Data:  63 3A 2F 44 45 56 2F 50 6C 61 74 66 6F 72 6D 2F
>>
>> {8382} normal block at 0x0138C9C0, 32 bytes long.
>>
>>  Data: <7Zl7ji/F9x+bOgbG> 37 5A 6C 37 6A 69 2F 46 39 78 2B 62 4F 67 62 47
>>
>> {8380} normal block at 0x0138B938, 32 bytes long.
>>
>>  Data:  50 6F 6C 69 63 79 44 61 74 61 50 61 63 6B 2E 69
>>
>> {8377} normal block at 0x01391F48, 448 bytes long.
>>
>>  Data: <> 10 1F F3 02 00 00 00 00 00 00 00 00 CD CD CD CD
>>
>> {7174} normal block at 0x01391DC8, 64 bytes long.
>>
>>  Data:  63 3A 2F 44 45 56 2F 50 6C 61 74 66 6F 72 6D 2F
>>
>> {7166} normal block at 0x013621D8, 32 bytes long.
>>
>>  Data: <7Zl7ji/F9x+bOgbG> 37 5A 6C 37 6A 69 2F 46 39 78 2B 62 4F 67 62 47
>>
>> {7164} normal block at 0x01386690, 32 bytes long.
>>
>>  Data:  50 6F 6C 69 63 79 44 61 74 61 50 61 63 6B 2E 69
>>
>> {7161} normal block at 0x01390430, 448 bytes long.
>>
>>  Data: <> 10 1F F3 02 00 00 00 00 00 00 00 00 CD CD CD CD
>>
>> {7108} normal block at 0x0138CDC8, 64 bytes long.
>>
>>  Data:  63 3A 2F 44 45 56 2F 50 6C 61 74 66 6F 72 6D 2F
>>
>> {7100} normal block at 0x01386320, 32 bytes long.
>>
>>  Data:  45 4E 74 35 4B 6B 59 48 52 71 65 55 2F 69 4C 52
>>
>> {7098} normal block at 0x0138BCD8, 32 bytes long.
>>
>>  Data:  50 6F 6C 69 63 79 44 61 74 61 50 61 63 6B 2E 62
>>
>> {7095} normal block at 0x0138D530, 448 bytes long.
>>
>>  Data: <> 10 1F F3 02 00 00 00 00 00 00 00 00 CD CD CD CD
>>
>> {7033} normal block at 0x013796D8, 64 bytes long.
>>
>>  Data:  63 3A 2F 44 45 56 2F 50 6C 61 74 66 6F 72 6D 2F
>>
>> {7025} normal block at 0x0136DED0, 32 bytes long.
>>
>>  Data: <5U/jyx2txHeUQUe/> 35 55 2F 6A 79 78 32 74 78 48 65 55 51 55 65 2F
>>
>> {7023} normal block at 0x013658D0, 32 bytes long.
>>
>>  Data:  4E 65 74 77 6F 72 6B 53 65 74 74 69 6E 67 33 2E
>>
>> {7020} normal block at 0x01389BF0, 448 bytes long.
>>
>>  Data: <> 10 1F F3 02 00 00 00 00 00 00 00 00 CD CD CD CD
>>
>> Object dump complete.
>>
>> The program '[5432] DebugConsole.exe: Native' has exited with code 0 (0x0).
>>
>>
>> Please help me resolve this memory leak issue.
>>
>> Sincerely,
>>
>> Khanh
>>
KN> ___
KN> sqlite-users mailing list
KN> sqlite-users@sqlite.org
KN> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users



-- 
Best regards,
 Tegmailto:t...@djii.com

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


Re: [sqlite] How to handle SQLITE_MISUSE in Android ?

2011-04-20 Thread Richard Hipp
On Wed, Apr 20, 2011 at 8:34 AM, sajnank  wrote:

> sqlite3_prepare_v2() is giving SQLITE_MISUSE error(error code 21) after
> running the application for several times. Once SQLITE_MISUSE is
> returned all sqlite queries are failing and they return the same error
> code. In our application, native layer opens the DB for writing(which
> include: sqlite3_prepare_v2, sqlite3_step, sqlite3_exec, sqlite3_reset,
> sqlite3_finalize ) and the above java layer open the DB for reading.
>
> The SQLITE_MISUSE error is thrown from the native layer when we do
> sqlite3_prepare_v2 after exiting from the application and then
> re-entering... Actually, the same scenario was working for more than
> 15-20 times, but after that SQLITE_MISUSE comes and thereafter system
> crashes with a signal11
>

My guess is that you are somehow calling sqlite3_prepare_v2() on a database
connection that has already been closed, possibly by a different thread.

If you can set a breakpoint on the function sqlite3CorruptError() and
provide a backtrace when the breakpoint is hit, that would be a big hint.


>
>
> --
> Regards,
> Sajna Nazeer.K
>
>
> ___
> 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] SQLite3 memory leaks in my c++ dll application

2011-04-20 Thread Khanh Nguyen
Hi SQLite3 community,

Please forgive me this panic, incorrect bug report. The cause of memory
leaks was from another my software component. The SQLite3.dll is working
greatly with my solution. However, it was memory leaks detection from VS2008
when I built the SQLite3 with Sqlite3.c in my solution.

If you know about this, please give me some hints on how to set flags in my
database module(vcproj) to eliminate the memory leaks. I would greatly
appreciate your kindness.

The database vcproj DLL built with VS2008 C++ with this flag: Multi-threaded
Debug DLL (/MDd). Accessing the DLL via GetProcAddress() calls.

Sincerely and Thank you,

Khanh


On Mon, Apr 18, 2011 at 8:56 AM, Khanh Nguyen  wrote:

> Hi,
>
>
>
> My name is Khanh Nguyen and currently using SQLite3.DLL 3.7.6 in my
> application (DLL built with VS2008 C++ with this flag: Multi-threaded Debug
> DLL (/MDd). This DLL is called by other DLL via GetProcAddress to access a
> blob database. The access and blob database is in very good operation.
> However, whenever I exited the application, the VS2008 debugger reported
> this memory leak dectection:
>
>
>
> The DLL has some memory leaks that I have captured here:
>
>
>
> The thread 'Win32 Thread' (0x368) has exited with code 0 (0x0).
>
> Detected memory leaks!
>
> Dumping objects ->
>
> {8390} normal block at 0x01364C70, 64 bytes long.
>
>  Data:  63 3A 2F 44 45 56 2F 50 6C 61 74 66 6F 72 6D 2F
>
> {8382} normal block at 0x0138C9C0, 32 bytes long.
>
>  Data: <7Zl7ji/F9x+bOgbG> 37 5A 6C 37 6A 69 2F 46 39 78 2B 62 4F 67 62 47
>
> {8380} normal block at 0x0138B938, 32 bytes long.
>
>  Data:  50 6F 6C 69 63 79 44 61 74 61 50 61 63 6B 2E 69
>
> {8377} normal block at 0x01391F48, 448 bytes long.
>
>  Data: <> 10 1F F3 02 00 00 00 00 00 00 00 00 CD CD CD CD
>
> {7174} normal block at 0x01391DC8, 64 bytes long.
>
>  Data:  63 3A 2F 44 45 56 2F 50 6C 61 74 66 6F 72 6D 2F
>
> {7166} normal block at 0x013621D8, 32 bytes long.
>
>  Data: <7Zl7ji/F9x+bOgbG> 37 5A 6C 37 6A 69 2F 46 39 78 2B 62 4F 67 62 47
>
> {7164} normal block at 0x01386690, 32 bytes long.
>
>  Data:  50 6F 6C 69 63 79 44 61 74 61 50 61 63 6B 2E 69
>
> {7161} normal block at 0x01390430, 448 bytes long.
>
>  Data: <> 10 1F F3 02 00 00 00 00 00 00 00 00 CD CD CD CD
>
> {7108} normal block at 0x0138CDC8, 64 bytes long.
>
>  Data:  63 3A 2F 44 45 56 2F 50 6C 61 74 66 6F 72 6D 2F
>
> {7100} normal block at 0x01386320, 32 bytes long.
>
>  Data:  45 4E 74 35 4B 6B 59 48 52 71 65 55 2F 69 4C 52
>
> {7098} normal block at 0x0138BCD8, 32 bytes long.
>
>  Data:  50 6F 6C 69 63 79 44 61 74 61 50 61 63 6B 2E 62
>
> {7095} normal block at 0x0138D530, 448 bytes long.
>
>  Data: <> 10 1F F3 02 00 00 00 00 00 00 00 00 CD CD CD CD
>
> {7033} normal block at 0x013796D8, 64 bytes long.
>
>  Data:  63 3A 2F 44 45 56 2F 50 6C 61 74 66 6F 72 6D 2F
>
> {7025} normal block at 0x0136DED0, 32 bytes long.
>
>  Data: <5U/jyx2txHeUQUe/> 35 55 2F 6A 79 78 32 74 78 48 65 55 51 55 65 2F
>
> {7023} normal block at 0x013658D0, 32 bytes long.
>
>  Data:  4E 65 74 77 6F 72 6B 53 65 74 74 69 6E 67 33 2E
>
> {7020} normal block at 0x01389BF0, 448 bytes long.
>
>  Data: <> 10 1F F3 02 00 00 00 00 00 00 00 00 CD CD CD CD
>
> Object dump complete.
>
> The program '[5432] DebugConsole.exe: Native' has exited with code 0 (0x0).
>
>
> Please help me resolve this memory leak issue.
>
> Sincerely,
>
> Khanh
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] SQLite 3.7.6 and 3.7.6.1 -- Performance issue with Triggers

2011-04-20 Thread Richard Hipp
On Sat, Apr 16, 2011 at 5:35 PM, Kenneth Ballard <
kball...@kennethballard.com> wrote:

> Good afternoon,
>
> Here is an issue I started to experience after upgrading from SQLite
> 3.7.5 to 3.7.6 involving a trigger I have on a database table.
>

Using the database you sent me by private email, I found that SQLite was
uniformly slow for all versions of SQLite back through 3.6.23.  (I didn't
test anything further back than that.)  There was no speed difference going
from 3.7.5 to 3.7.6.

However, I did find that I could make the query fast as follows:

   CREATE INDEX newidx1 ON shoppes(island);
   CREATE INDEX newidx2 ON offers(shoppe_id);

As a rule of thumb, you should always have in index on foreign keys.  SQLite
does *not* create such indices for you automatically.


>
> The table with the trigger is a 2-column table with the following
> trigger installed to it:
>
> CREATE TABLE [table_a] (
>   [col_a] INTEGER NOT NULL PRIMARY KEY,
>   [col_b] INT64 NOT NULL);
>
> CREATE TRIGGER [RemoveOffers]
> BEFORE DELETE
> ON [table_a]
> BEGIN
> DELETE FROM table_b
> WHERE col_a IN
> (SELECT col_a FROM table_c WHERE col_b = old.col_a);
> END;
>
> On 3.7.5, a single delete statement from this table executed almost
> instantaneously even on the largest sets of data it would be clearing
> out. However, after upgrading to 3.7.6 and 3.7.6.1, this isn't the case.
> To have the same performance as I did on 3.7.5, I have to use the
> trigger query separately -- a delete statement on table_a and the delete
> statement on table_b separately.
>
> Again, as a trigger this statement takes seconds to run -- one run took
> as much as 15 seconds to execute. As separate delete statements, it
> takes a fraction of a second, similar to how it ran as a trigger in 3.7.5.
>
> I've also noticed issues where queries with an IN clause (like the
> trigger above) took significantly longer to execute than before, but
> that was cleared up by adding some more indexes to the table
> definitions. But even adding additional indexes didn't help the
> performance of this trigger running as a trigger.
>
> So this begs the question: what changed?
>
> ___
> 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] Is Lock Table statement spported?

2011-04-20 Thread asheu
I have read those links but there is a reason I want to keep everyone out of 
the file completely. 

I did came across "PRAGMA locking_mode=EXCLUSIVE;" and this is what I am doing 
to achieve what I want. 
Is there a reason why I should not use this? 


On 4/20/2011 10:40 AM, asheu at comcast.net wrote: 
> Is LOCK TABLE statement supported by by SQLite? 

No. Read more about how SQLite peforms locking here: 

http://sqlite.org/lockingv3.html 
http://sqlite.org/atomiccommit.html 

-- 
Igor Tandetnik 

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


Re: [sqlite] Is Lock Table statement spported?

2011-04-20 Thread Pavel Ivanov
Whenever you have doubt like that just go to
http://www.sqlite.org/lang.html and see if the statement you are
trying to execute exists there and what its correct syntax is.


Pavel


On Wed, Apr 20, 2011 at 10:40 AM,   wrote:
> Is LOCK TABLE statement supported by by SQLite? I am getting syntax error 
> when I execute this "LOCK TABLE tablename IN EXCLUSIVE MODE NOWAIT". Just 
> want to make sure it's not supported rather than my syntax is incorrect.
>
>
> ___
> 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] Is Lock Table statement spported?

2011-04-20 Thread Igor Tandetnik
On 4/20/2011 10:40 AM, as...@comcast.net wrote:
> Is LOCK TABLE statement supported by by SQLite?

No. Read more about how SQLite peforms locking here:

http://sqlite.org/lockingv3.html
http://sqlite.org/atomiccommit.html

-- 
Igor Tandetnik

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


[sqlite] Is Lock Table statement spported?

2011-04-20 Thread asheu
Is LOCK TABLE statement supported by by SQLite? I am getting syntax error when 
I execute this "LOCK TABLE tablename IN EXCLUSIVE MODE NOWAIT". Just want to 
make sure it's not supported rather than my syntax is incorrect. 


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


Re: [sqlite] Security issues with SQLite3.6.23.1

2011-04-20 Thread thilo
On 4/13/2011 4:04 PM, Roger Binns wrote:
> On 04/12/2011 08:25 AM, Stephen Blessing wrote:
> > It appears that your SQLite3.6.23.1 software may have some security
> issues
> > that need to be addressed:
>
> The tool you used is pathetic.  It is about as helpful as saying your
> house
> has "High" security risks because it found scissors.  What is important is
> context - how are they used, by whom and can unintended people get access.
> The tool is "rough" because it doesn't bother with that context.
>
> Far better tools are Coverity and one included with Clang.  You can see
> Coverity's opinion here:
>
>   http://scan.coverity.com/rung1.html
As coverity corp runs their tool on sqlite, doesn't this mean the
developers have access to the results?

And yes those source code checkers do test if a room has no doors or
that there are no bricks stacked straight.
Nothing a good programmer w(c)ouldn't see himself - if he spent the
hours of digging n-levels deep into the call chain
They are a great tool ensuring programs have fewer memory leaks, thread
issues and the like and if one has access to their results, please USE
it and judge the false positives with human eyes - strcpy & fprintf are
not security risks by themselves but only in an application context. 
Reviews (human & automated) are always a good step towards a stable
codebase!

- my 5 cent

thilo

>
> And because Clang is open source the SQLite authors were able to run it
> themselves and fix anything it showed up.
>
> Note that in the vast majority of cases these tools come up with false
> positives.  The styling of the SQLite code is changed to keep them happy.
> See also:
>
>   http://www.sqlite.org/faq.html#q17
>
> Roger
___
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] How to handle SQLITE_MISUSE in Android ?

2011-04-20 Thread sajnank
sqlite3_prepare_v2() is giving SQLITE_MISUSE error(error code 21) after 
running the application for several times. Once SQLITE_MISUSE is 
returned all sqlite queries are failing and they return the same error 
code. In our application, native layer opens the DB for writing(which 
include: sqlite3_prepare_v2, sqlite3_step, sqlite3_exec, sqlite3_reset, 
sqlite3_finalize ) and the above java layer open the DB for reading.

The SQLITE_MISUSE error is thrown from the native layer when we do 
sqlite3_prepare_v2 after exiting from the application and then 
re-entering... Actually, the same scenario was working for more than 
15-20 times, but after that SQLITE_MISUSE comes and thereafter system 
crashes with a signal11


-- 
Regards,
Sajna Nazeer.K


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


Re: [sqlite] Documentation clarification

2011-04-20 Thread Richard Hipp
On Tue, Apr 19, 2011 at 6:46 PM, Dennis Cote  wrote:

> Hi,
>
> On the page http://www.sqlite.org/lang_createtable.html
>
> The following text appears:
>
>* If the default value of a column is CURRENT_TIME, CURRENT_DATE or
> CURRENT_DATETIME, then the value used in the new row is a text
> representation of the current UTC date and/or time. For CURRENT_TIME,
> the format of the value is "HH:MM:SS". For CURRENT_DATE, "-MM-DD".
> The format for CURRENT_TIMESTAMP is "-MM-DD HH:MM:SS".
>
> The first sentence uses the name CURRENT_DATETIME (hooray), the fourth
> uses the name CURRENT_TIMESTAMP (booo) for what I believe are supposed
> to be the same thing.
>
> Which of these is the correct name, or are they equivalent?
>

CURRENT_TIMESTAMP is correct.  The documentation has been updated.


>
> --
> Dennis Cote
>
> ___
> 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] SQLITE_ENABLE_COLUMN_METADATA

2011-04-20 Thread Richard Hipp
On Wed, Apr 20, 2011 at 1:40 AM, Prasanna Parthasarathy <
pvenk...@hotmail.com> wrote:

> Can you please update the website with the dll compiled using the
> preprocessor symbol in the subject?


The build procedures have been updated to include
SQLITE_ENABLE_COLUMN_METADATA for the windows DLL and a new build of the
website has been uploaded.


-- 
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] SQLite 3.7.6 and 3.7.6.1 -- Performance issue with Triggers

2011-04-20 Thread Richard Hipp
On Wed, Apr 20, 2011 at 12:37 AM, Kenneth Ballard <
kball...@kennethballard.com> wrote:

> Okay I'm going to just give up on creating a specific test case for this
> one and I'm just attaching the original database file. Every time I tried to
> isolate out just the tables applicable to the trigger code, the issue is not
> reproducible. So attached to this message is the database in question with
> data.
>

This mailing list strips attachments.  Why don't you email the database
directly to me at d...@sqlite.org?


>
> To reproduce the issue, merely execute this query:
>
> DELETE FROM age WHERE island = ?;
>
> where ? is one of the values in the table -- 140 will likely provide the
> largest wait time. However, if you execute the trigger's code as a
> stand-alone query, it executes almost instantly.
>
> DELETE FROM offers
> WHERE shoppe_id IN
> (SELECT id FROM shoppes WHERE island = ?);
>
> where ? is the same island id you use in the previous query.
>
> So until this is figured out, I guess my application code is going to have
> to execute the queries separately -- not a huge deal, but the trigger
> simplifies the application code a little. Let me know if you have any luck
> reproducing the issue.
>
> Kenneth
>
>
> On 4/16/2011 8:09 PM, Richard Hipp wrote:
>
>> On Sat, Apr 16, 2011 at 6:29 PM, Kenneth Ballard<
>> kball...@kennethballard.com>  wrote:
>>
>>  The schema for these two tables is unchanged between the 3.7.5 and 3.7.6
>>> version with the exception of the sort modifiers on table_b's unique
>>> index.
>>>
>>>  Using the schema and sqlite_stat1 data you provide, I get identical
>> query
>> plans for 3.7.5 and 3.7.6.1.  So I do not know what might have changed.
>>  Can
>> you put together a reasonably sized test case that demonstrates the
>> performance regression?
>>
>>
>>
>>  Table table_b:
>>>
>>> CREATE TABLE [table_b] (
>>>   [col_a] INTEGER NOT NULL CONSTRAINT [fk_tableb_tablec] REFERENCES
>>> [tablec]([col_a]) ON DELETE CASCADE,
>>>   [col_b] INTEGER NOT NULL CONSTRAINT [fk_tableb_tabled] REFERENCES
>>> [tabled]([col_a]) ON DELETE CASCADE,
>>>   [col_c] INTEGER,
>>>   [col_d] INTEGER,
>>>   [col_e] INTEGER,
>>>   [col_f] INTEGER,
>>>   CONSTRAINT [VALID_OFFER] CHECK(((col_c IS NOT NULL AND col_c>  0) AND
>>> (col_d IS NOT NULL AND col_d>= 0))
>>> OR
>>> ((col_e IS NOT NULL AND col_e>  0) AND (col_f IS NOT NULL AND col_f>=
>>> 0;
>>>
>>> CREATE UNIQUE INDEX [idx_tableb_tablec_tabled] ON [table_b] ([col_b]
>>> ASC, [col_a] ASC);
>>>
>>> Table table_c:
>>>
>>> CREATE TABLE [table_c] (
>>>[col_a] INTEGER NOT NULL PRIMARY KEY,
>>>[col_b] INTEGER NOT NULL CONSTRAINT [fk_tablec_tablee] REFERENCES
>>> [table_e]([col_a]),
>>>   [col_c] TEXT NOT NULL);
>>>
>>> And the sqlite_stat1 table data:
>>>
>>> table_a,,1
>>> table_b,idx_tableb_tablec_tabled,6745 42 1
>>> table_c,974
>>>
>>>
>>> On 4/16/2011 4:35 PM, Kenneth Ballard wrote:
>>>
 Good afternoon,

 Here is an issue I started to experience after upgrading from SQLite
 3.7.5 to 3.7.6 involving a trigger I have on a database table.

 The table with the trigger is a 2-column table with the following
 trigger installed to it:

 CREATE TABLE [table_a] (
 [col_a] INTEGER NOT NULL PRIMARY KEY,
 [col_b] INT64 NOT NULL);

 CREATE TRIGGER [RemoveOffers]
 BEFORE DELETE
 ON [table_a]
 BEGIN
 DELETE FROM table_b
 WHERE col_a IN
 (SELECT col_a FROM table_c WHERE col_b = old.col_a);
 END;

 On 3.7.5, a single delete statement from this table executed almost
 instantaneously even on the largest sets of data it would be clearing
 out. However, after upgrading to 3.7.6 and 3.7.6.1, this isn't the case.
 To have the same performance as I did on 3.7.5, I have to use the
 trigger query separately -- a delete statement on table_a and the delete
 statement on table_b separately.

 Again, as a trigger this statement takes seconds to run -- one run took
 as much as 15 seconds to execute. As separate delete statements, it
 takes a fraction of a second, similar to how it ran as a trigger in

>>> 3.7.5.
>>>
 I've also noticed issues where queries with an IN clause (like the
 trigger above) took significantly longer to execute than before, but
 that was cleared up by adding some more indexes to the table
 definitions. But even adding additional indexes didn't help the
 performance of this trigger running as a trigger.

 So this begs the question: what changed?

 ___
 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 

[sqlite] SQLITE_ENABLE_COLUMN_METADATA

2011-04-20 Thread Prasanna Parthasarathy
Hello, after 3 hours of struggle, I have come to determine that the current 
windows dll available for download from the website has been compiled *without* 
the preprocessor symbol SQLITE_ENABLE_COLUMN_METADATA and therefore I am unable 
to run my rails project.  I have Ruby 1.9.2, Rails 3.0.7, and sqlite3-ruby 
version 1.3.3 installed and when I start the rails server, it aborts with the 
message “The procedure entry point sqlite3_column_database_name could not be 
located in the dynamic link library sqlite3.dll”.  Looking at the .def file 
that comes along with the .dll file in the .zip file on the sqlite.org website, 
this seems to be in fact correct (def file is missing this function).  Can you 
please update the website with the dll compiled using the preprocessor symbol 
in the subject?  I am downloading cygwin to try and compile this myself but 
would like it if you uploaded your version so I can be sure that I did not 
screw something up.

Thanks much for your help – I look forward to a quick response.

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


Re: [sqlite] SQLite 3.7.6 and 3.7.6.1 -- Performance issue with Triggers

2011-04-20 Thread Kenneth Ballard
Okay I'm going to just give up on creating a specific test case for this 
one and I'm just attaching the original database file. Every time I 
tried to isolate out just the tables applicable to the trigger code, the 
issue is not reproducible. So attached to this message is the database 
in question with data.


To reproduce the issue, merely execute this query:

DELETE FROM age WHERE island = ?;

where ? is one of the values in the table -- 140 will likely provide the 
largest wait time. However, if you execute the trigger's code as a 
stand-alone query, it executes almost instantly.


DELETE FROM offers
WHERE shoppe_id IN
(SELECT id FROM shoppes WHERE island = ?);

where ? is the same island id you use in the previous query.

So until this is figured out, I guess my application code is going to 
have to execute the queries separately -- not a huge deal, but the 
trigger simplifies the application code a little. Let me know if you 
have any luck reproducing the issue.


Kenneth

On 4/16/2011 8:09 PM, Richard Hipp wrote:

On Sat, Apr 16, 2011 at 6:29 PM, Kenneth Ballard<
kball...@kennethballard.com>  wrote:


The schema for these two tables is unchanged between the 3.7.5 and 3.7.6
version with the exception of the sort modifiers on table_b's unique index.


Using the schema and sqlite_stat1 data you provide, I get identical query
plans for 3.7.5 and 3.7.6.1.  So I do not know what might have changed.  Can
you put together a reasonably sized test case that demonstrates the
performance regression?




Table table_b:

CREATE TABLE [table_b] (
   [col_a] INTEGER NOT NULL CONSTRAINT [fk_tableb_tablec] REFERENCES
[tablec]([col_a]) ON DELETE CASCADE,
   [col_b] INTEGER NOT NULL CONSTRAINT [fk_tableb_tabled] REFERENCES
[tabled]([col_a]) ON DELETE CASCADE,
   [col_c] INTEGER,
   [col_d] INTEGER,
   [col_e] INTEGER,
   [col_f] INTEGER,
   CONSTRAINT [VALID_OFFER] CHECK(((col_c IS NOT NULL AND col_c>  0) AND
(col_d IS NOT NULL AND col_d>= 0))
OR
((col_e IS NOT NULL AND col_e>  0) AND (col_f IS NOT NULL AND col_f>=
0;

CREATE UNIQUE INDEX [idx_tableb_tablec_tabled] ON [table_b] ([col_b]
ASC, [col_a] ASC);

Table table_c:

CREATE TABLE [table_c] (
[col_a] INTEGER NOT NULL PRIMARY KEY,
[col_b] INTEGER NOT NULL CONSTRAINT [fk_tablec_tablee] REFERENCES
[table_e]([col_a]),
   [col_c] TEXT NOT NULL);

And the sqlite_stat1 table data:

table_a,,1
table_b,idx_tableb_tablec_tabled,6745 42 1
table_c,974


On 4/16/2011 4:35 PM, Kenneth Ballard wrote:

Good afternoon,

Here is an issue I started to experience after upgrading from SQLite
3.7.5 to 3.7.6 involving a trigger I have on a database table.

The table with the trigger is a 2-column table with the following
trigger installed to it:

CREATE TABLE [table_a] (
 [col_a] INTEGER NOT NULL PRIMARY KEY,
 [col_b] INT64 NOT NULL);

CREATE TRIGGER [RemoveOffers]
BEFORE DELETE
ON [table_a]
BEGIN
DELETE FROM table_b
WHERE col_a IN
(SELECT col_a FROM table_c WHERE col_b = old.col_a);
END;

On 3.7.5, a single delete statement from this table executed almost
instantaneously even on the largest sets of data it would be clearing
out. However, after upgrading to 3.7.6 and 3.7.6.1, this isn't the case.
To have the same performance as I did on 3.7.5, I have to use the
trigger query separately -- a delete statement on table_a and the delete
statement on table_b separately.

Again, as a trigger this statement takes seconds to run -- one run took
as much as 15 seconds to execute. As separate delete statements, it
takes a fraction of a second, similar to how it ran as a trigger in

3.7.5.

I've also noticed issues where queries with an IN clause (like the
trigger above) took significantly longer to execute than before, but
that was cleared up by adding some more indexes to the table
definitions. But even adding additional indexes didn't help the
performance of this trigger running as a trigger.

So this begs the question: what changed?

___
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


[sqlite] Documentation clarification

2011-04-20 Thread Dennis Cote
Hi,

On the page http://www.sqlite.org/lang_createtable.html

The following text appears:

* If the default value of a column is CURRENT_TIME, CURRENT_DATE or
CURRENT_DATETIME, then the value used in the new row is a text
representation of the current UTC date and/or time. For CURRENT_TIME,
the format of the value is "HH:MM:SS". For CURRENT_DATE, "-MM-DD".
The format for CURRENT_TIMESTAMP is "-MM-DD HH:MM:SS". 

The first sentence uses the name CURRENT_DATETIME (hooray), the fourth
uses the name CURRENT_TIMESTAMP (booo) for what I believe are supposed
to be the same thing.

Which of these is the correct name, or are they equivalent? 

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