inner join, a condition has the same effect either way,
whether it appears in ON or WHERE clause.
--
Igor Tandetnik
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
On 2/15/2017 10:42 PM, Igor Korot wrote:
Now I presume that calling sqlite3_finalize() on the NULL handle is safe?
Yes; the documentation explicitly states that.
--
Igor Tandetnik
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
tory, it
may return an error code from the most recent failed sqlite3_step() call
(see Goofy Interface Alert section at https://sqlite.org/c3ref/step.html
). Since you are using sqlite3_prepare_v2, you may ignore the return
value of sqlite3_finalize
plan, it ends up in the innermost loop. SQLite then goes
through the full cross join of all the other tables, only to get to the
inner loop and discover that there isn't going to be a row after all.
"LIMIT 1" doesn't help any as the query is never going to produce a row
ed if that takes an enormous amount of time.
You have a cross-join of 19 tables. Even if each one contains just 2
rows, that's 2^19 ~ 500K rows to work through. And it grows
exponentially from there.
--
Igor Tandetnik
___
sqlite-users mailing li
andom
garbage it contains just accidentally happens to match a valid statement
handle. That kind of heisenbug would be a doozy to debug.
--
Igor Tandetnik
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cg
finalize the first statement before reusing the variable for the
second one.
--
Igor Tandetnik
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
e you
get around to sqlite3_errmsg(). Which is why sqlite3_exec() makes the
effort to preserve the message and forward it to you, should you choose
to accept it.
--
Igor Tandetnik
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlit
phonebook, with
people's names listed in alphabetic order. This makes it easy to find an
entry for a particular name, but doesn't help at all with finding an
entry number N; for that, you still have to start from the first entry,
and count them one by one.
--
Igor
? sqlite3_bind_int numbers parameters
starting from 1. What is this btLBAdd that you have in one place but not
the other?
Also, as a sanity check, print CType() of that element and, if it's a
string, the length of that string.
--
Igor Tandetnik
___
s
,
and perhaps CLng() returns -1 to indicate failure. Another possibility
is that the variant contains boolean True value; VB6 represents it
numerically as -1
--
Igor Tandetnik
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http
vant here:
sqlite3_exec still expects a UTF-8 encoded string. There are SQLite API
functions that accept UTF-16 strings (e.g. sqlite3_bind_text16), but
sqlite3_exec is not one of them.
--
Igor Tandetnik
___
sqlite-users mailing list
sqlite-users@mailinglists.s
On 12/17/2016 8:38 PM, Ariel M. Martin wrote:
Note: szSQL is the wchar-string my app uses
char szAux[2048];
ZeroMemory(szAux, 2048);
WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, szSQL, wcslen(szSQL),
szAux, 2048, NULL, 0);
Replace CP_ACP with CP_UTF8.
--
Igor
this?
limit 1 only applies to data producing statements. Adding a where clause,
say where
rowid = 1 is a bit tricky (all this has to be done in code) and there may
not be a rowid of 1
where rowid = (select min(rowid) from table1);
--
Igor Tandetnik
While SQLite only folds ASCII
letters by default, it could be compiled with full ICU collation support.
--
Igor Tandetnik
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
On 12/5/2016 10:19 AM, Igor Tandetnik wrote:
On 12/5/2016 7:30 AM, ravi.shan...@cellworksgroup.com wrote:
select name from employee table where name like '%Araya%' or name like
'%Amul%' or name like '%Aj%';
Table - Employee
Id | Name | age |
1 | Araya
Ajay Kumar | 45 |
I dont like to use may or conditions for pattern matching using like
operator.
Is there any other way I can workaround without using or condition in
like operator in sqlite.
WHERE length(replace(replace(replace(name, 'Araya', ''), 'Amul
On 12/2/2016 8:39 PM, Igor Tandetnik wrote:
On 12/2/2016 6:56 PM, Igor Korot wrote:
res = sqlite3_bind_text( stmt, 1,
sqlite_pimpl->m_myconv.to_bytes( tableName.c_str() ).c_str(), -1,
SQLITE_STATIC );
SQLITE_STATIC tells SQLite that the string will outlive the statement
handle. But
fer, deallocated at
the end of the statement. Your program exhibits undefined behavior.
--
Igor Tandetnik
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
n other OS processes? (I'm looking
for a way to detect this.)
There's nothing in SQLite that would help with that, to my knowledge.
--
Igor Tandetnik
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite
the Count's.)
SELECT totalUsed, COUNT(*) AS Count FROM tips GROUP BY totalUsed
union all
SELECT null, COUNT(*) FROM tips;
--
Igor Tandetnik
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/ma
On 11/30/2016 9:42 AM, Werner Kleiner wrote:
It would be nice if there is a way to store in the same way as in
MySQL with filling zeros.
Is this not possible with sqlite?
Store it as an integer, in $.0001 units. So $1.500 would be represented
simply as an integer 1500.
--
Igor Tandetnik
On 11/29/2016 4:00 AM, Max Vlasov wrote:
I wonder why OP and other authors of the discussion
https://www.mail-archive.com/sqlite-users@mailinglists.sqlite.org/msg49355.html
was so sure about backslash escaping support, even Igor Tandetnik :)
I said, and I quote:
"""
If yo
hrough the resultset.
For example, imagine that, in the limit, all rows have the same value in
Value2. If you only do "order by Value2", then the resulting order will
be completely indeterminate; there's no telling where a row with a given
ID would
o "order by Value2, ID" in your temporary table approach.
--
Igor Tandetnik
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
elect ID from Test order by Value2;
select rowid from TempIDs where ID = 1;
drop Table TempIDs;
select count(*) from Test
where Value2 <= (select t2.Value2 from Test t2 where t2.ID=1);
--
Igor Tandetnik
___
sqlite-users mailing list
sqli
CAST(expr AS name)
determines affinity from `name`, then coerces the value of `expr`
according to that affinity. The default affinity, when no specific rules
apply, is NUMERIC.
--
Igor Tandetnik
___
sqlite-users mailing list
sqlite-users@mailinglists.s
words
(id INTEGER PRIMARY KEY AUTOINCREMENT
,cnt INTEGER DEFAULT 1
,rvw INTEGER DEFAULT 0
,txt TEXT UNIQUE);
sqlite> select txt, cnt, rvw from words where txt!="" and rvw!=0 order by
cnt desc;
Just do " order by cnt desc, txt &
On 10/17/2016 10:32 AM, Daniel Polski wrote:
Den 2016-10-17 kl. 16:03, skrev Igor Tandetnik:
select unit, sum(1 << bit_position) from table1 where val group by unit;
Wow!!
Thanks alot!
Alot accepts expressions of gratitude but wonders why they are being
addressed to it:
in the above table).
How can I get the byte data in a single select instead of parsing
through the individual bits one by one?
select unit, sum(1 << bit_position) from table1 where val group by unit;
--
Igor Tandetnik
___
sqlite-
mode: https://www.sqlite.org/wal.html . It allows a
writing transaction to co-exist with multiple readers. See if this helps.
--
Igor Tandetnik
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/ma
r you haven't told us about that suggests the
new record should go between 2 and 3? If so, make that indicator part of
the row data, and use it in your ordering to break ties between
timestamps. It makes no sense to use RowId for that.
--
Igor
it's possible to also display the average score of a film.
Have you tried the obvious?
SELECT films.*, AVG(films_genres.score) ...
--
Igor Tandetnik
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.o
e or the most recent sqlite3_reset; and ends with
sqlite3_reset or sqlite3_finalize.
--
Igor Tandetnik
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
time T+10 and
ends it at T+30. Both reads are part of the same unbroken transaction
lasting (at least) from T to T+30. If there's an update committed at T+5
on a different connection, neither read would see it, even though thread
B started after it.
--
o interleave SELECT and updates on the same connection.
This is the current situation that I need to correct. My SQLite is old enough
that it doesn't prevent committing in this case
Check for errors. I predict your COMMIT statement fails.
--
Igor Tandetnik
ed under SELECT's feet, phantom rows are just one
problem; it's also possible for the statement to skip rows it would have
otherwise returned, and to return rows containing stale data. Basically,
undefined behavior is undefined.
--
Igor Tandetnik
___
on Y
alone (it doesn't matter which of the two is X and which is Y in this
case). The (X, Y) index also works for searching on X, but not for
searching on Y.
--
Igor Tandetnik
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
htt
On 7/20/2016 6:40 AM, Leonardo Massei wrote:
I've a simple question: I need to get the precision (or scale) of a
table's field
SQLite doesn't have a concept of field precision or scale, so there's
nothing to get. See also: http://www.sqlite.org/datatype3.htm
On 7/13/2016 8:12 PM, Igor Korot wrote:
char *z = sqlite3_mprintf( query2.c_str(), tableName );
There is a bunch of calls to sqlite3_mprintf, but nary a call to
sqlite3_free.
--
Igor Tandetnik
___
sqlite-users mailing list
?
Yes in journal mode, no in WAL mode.
I'm using PRAGMA read_uncommitted = true
This is only meaningful when using shared cache mode (
https://www.sqlite.org/sharedcache.html ). It does nothing otherwise.
--
Igor Tandetnik
___
sqlite-users mailing
precludes NULLs and is sure to
pick the
-- | - --- correct max when joined to b too.
-- 1 | ORD005
-- 2 | ORD009
And if you do need NULLs, then just change it to "LEFT JOIN b".
--
Igor Tandetnik
, get max(b.orderno) across the whole group, only
across some random item in it.
If you want max(orderno) across the group, just join with b:
SELECT a.id, max(b.orderno) as maxorderno
FROM a INNER JOIN c on c.a_id=a.id JOIN b ON b.c_id=c.id
GROUP BY a.id
--
Igor Tand
assume a one-to-one correspondence between columns and
placeholders. This assumption doesn't generally hold.
--
Igor Tandetnik
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
ples.Weight may store 79 or 81 for an apple belonging to such a group.
--
Igor Tandetnik
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
http://www.joelonsoftware.com/articles/Unicode.html .
--
Igor Tandetnik
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
in
fact a valid byte sequence in any Unicode encoding - neither UTF-8 nor
UTF-16 nor any other. If you want Unicode data in your database, then
store Unicode data, and not ANSI, in your database.
--
Igor Tandetnik
___
sqlite-users mailing list
sqlite
one query.
Something along these lines, perhaps:
select ProjectName, KeyDate
from Projects p, KeyDates using (ProjectID)
where KeyDate in (
select d2.KeyDate from KeyDates d2
where d2.ProjectId = p.ProjectId
order by d2.KeyDate limit 5);
--
Igor Tandetnik
them, and their support fixed
it. Like you, I'm not an admin or anything, just a regular lurker.
--
Igor Tandetnik
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
On 5/24/2016 1:34 PM, Scott Doctor wrote:
SELECT field FROM table FOR UPDATE;
My question is, looking through the sqlite documentation, it is not
clear how sqlite will handle that statement.
SQLite will report a syntax error. That's pretty easy to confirm
experimentally.
--
Igor Tand
On 5/13/2016 11:51 AM, Dominique Devienne wrote:
> But it still returns both rows. Any idea on that part?
Change "u1.user <> u2.user" to "u1.user < u2.user"
--
Igor Tandetnik
high from Brackets where high > low + 1;
--
Igor Tandetnik
way?
It should not make any difference.
--
Igor Tandetnik
insensitive index
cannot be used to satisfy it.
If you expect SQLite to inspect the string literal character by
character and prove that case sensitivity won't make a difference, then
I'm afraid you expect too much.
--
Igor Tandetnik
de heap manager further sub-allocating those
pages. The garbage you see in uninitialized heap allocations came from
your own process; you don't get to observe random data from other
processes this way.
--
Igor Tandetnik
tps://en.wikipedia.org/wiki/Race_condition . In any case, "undefined
behavior" is not at all the same thing as "non-deterministic behavior".
A conforming C (or C++) program does not (by definition of "conforming")
exhibit undefined behavior, but may very well be non-deterministic.
--
Igor Tandetnik
> operators or functions in a where clause.
Things that appear in the list after SELECT are also expressions, no
different from those that appear in WHERE clause or elsewhere.
--
Igor Tandetnik
On 3/9/2016 9:58 AM, R Smith wrote:
> On 2016/03/09 4:35 PM, Igor Tandetnik wrote:
>> Yes, but why is that a problem? It is perfectly legal, and often
>> useful, for a subquery to refer to columns from enclosing query.
>> That's what makes it a *correlated* subquery.
>
and often useful,
for a subquery to refer to columns from enclosing query. That's what
makes it a *correlated* subquery.
--
Igor Tandetnik
l and DateViewed is null) Unwatched,
count(VideoID) Videos
from Projects left join vViewedVideos using (ProjectID)
group by ProjectID;
--
Igor Tandetnik
row.
If you want to count the number of rows but stop at, say, 100, then you
can transform your original statement like this:
select count(*) from (
select original ...
LIMIT 100
);
So, you append the LIMIT clause to the original query, then wrap the
whole thing in another query that does the counting.
--
Igor Tandetnik
ve it one:
SELECT * FROM test WHERE A = CAST(1.0 as REAL); -- returns 1.
See also: https://www.sqlite.org/datatype3.html#compaff
--
Igor Tandetnik
number of rows that the inner query would have returned. Is
this not what you want? Of course, it would take approximately as much
time to run this new query as it would the original query.
--
Igor Tandetnik
On 3/4/2016 9:29 AM, Paul van Helden wrote:
> On Fri, Mar 4, 2016 at 4:23 PM, Igor Tandetnik wrote:
>
>> On 3/4/2016 9:15 AM, Paul van Helden wrote:
>>
>>> So I have to detect integers in order to avoid the .0
>>>
>>
>> WHERE CAST(A as integer) = 1
On 3/4/2016 9:15 AM, Paul van Helden wrote:
> So I have to detect integers in order to avoid the .0
WHERE CAST(A as integer) = 1
--
Igor Tandetnik
On 2/28/2016 9:19 PM, Rowan Worth wrote:
> On 27 February 2016 at 00:02, Igor Tandetnik wrote:
>
>> On 2/26/2016 4:01 AM, Rowan Worth wrote:
>>
>>> In principle this is correct, but actually the database *file* is not
>>> immediately modified in rollback mode.
uble. There is a very narrow band of build configuration
parameters in which this would work.
--
Igor Tandetnik
On 2/26/2016 4:01 AM, Rowan Worth wrote:
> On 24 February 2016 at 23:46, Igor Tandetnik wrote:
>
>> On 2/24/2016 10:08 AM, Stephen Chrzanowski wrote:
>>
>>> IMO, all that, plus the fact that you have an easy roll back mechanism.
>>> Anything that needs to be pu
On 2/25/2016 7:28 PM, Stephen Chrzanowski wrote:
> What does ABI stand for?
https://en.wikipedia.org/wiki/Application_binary_interface
--
Igor Tandetnik
s "deadlock".
--
Igor Tandetnik
goes out in the middle of this?
Note also that a typical application commits much more often than it
rolls back, so the system should be designed to make the former fast;
the latter can be slow.
--
Igor Tandetnik
On 2/24/2016 12:56 AM, Sairam Gaddam wrote:
> Before checkpointing the data from WAL, if the DB is queried, will the
> result include updated data from WAL or not?
It will. A transaction reads both from WAL and the original database
file - whichever contains the fresher data.
--
Igor Tandetnik
andle; the time_t variable was also part of
that class).
--
Igor Tandetnik
ges() API function. It tells
you how many rows where touched by the most recent data modification
statement. So you can call it right after performing the UPDATE.
--
Igor Tandetnik
to 9. Keep all other
> records intact.
update MyTable set F2=9 where F1 in
(select t.F1 from MyTable t group by t.F1 having count(*) > 1);
> Can task 2 and 3 be implemented in one SQL query
No. One is a "get", the other is a "set". A single SQL query can't do
both. Did you mean tasks 1 and 2, perhaps?
--
Igor Tandetnik
t scan
the table with "select * from MyTable order by I, L" and compute the
runs in one pass, in linear time. The query above runs in O(N^3) time
(though an index on (I, L) might improve things) - only really suitable
as a toy example.
--
Igor Tandetnik
On 2/18/2016 12:42 AM, admin at shuling.net wrote:
> Then I want to obtain the total count of unique values for F1 field.
select count(distinct F1) from MyTable;
--
Igor Tandetnik
On 2/12/2016 10:44 PM, J Decker wrote:
> On Fri, Feb 12, 2016 at 7:37 PM, Igor Tandetnik wrote:
>> It performs the conversion it is documented to perform. It indeed doesn't
>> perform the conversion that you, for reasons unclear, expect it to perform.
>> In other wo
y :)
It performs the conversion it is documented to perform. It indeed
doesn't perform the conversion that you, for reasons unclear, expect it
to perform. In other words, you engage in wishful thinking, and then
blame the messenger for failure of your wishes to materialize.
--
Igor Tandetnik
.
In any case, MultiByteToWideChar and WideCharToMultiByte are perfectly
capable of converting between UTF-8 and UTF-16.
--
Igor Tandetnik
n your example, it would help with
grouping (or sorting, or filtering) on (a), or (a, b), or (a, b, c).
--
Igor Tandetnik
similar, but MMDD representation needs to be
parsed and converted first; simply subtracting two integers like this
produces meaningless result.
--
Igor Tandetnik
On 1/30/2016 8:22 AM, E.Pasma wrote:
> With respect to Igor's suggestion, mmdd (as integer), why not leave out
> the century? I prefer the oldfashoned yymmdd.
I too like to live dangerously.
--
Igor Tandetnik
'now') as int) - in other
words, storing calendar dates as integers like 20160129.
--
Igor Tandetnik
;m reasonably, but not 100%, sure this is standard-conforming.
--
Igor Tandetnik
On 1/11/2016 11:52 PM, Scott Doctor wrote:
> TOCTTOU? What is that?
A friendly local search engine suggests it means "time of check to time
of use" ( https://en.wikipedia.org/wiki/Time_of_check_to_time_of_use )
--
Igor Tandetnik
r code.
--
Igor Tandetnik
gether.
If you look at the implementation of sqlite3_get_table, it works by
calling _prepare and _step and so on. It's not some kind of alternative
interface to SQLite, merely a wrapper.
--
Igor Tandetnik
tion, so that SQLite knows that
the string is in fact Unicode.
--
Igor Tandetnik
ection (SQLite to VB), but not in the other, as far as I can tell. I
suspect you need sqlite3_result_text16 instead.
Also lPos-2 looks wrong. Can't the substring be found at lPos == 1 ?
--
Igor Tandetnik
the last parameter - the pointer returned by
sqlite3_value_text is only guaranteed to be valid until the custom
function returns.
> or it could be a pointer to a locally declared variable
In this case, you would also use SQLITE_TRANSIENT.
--
Igor Tandetnik
On 12/14/2015 2:21 PM, Bart Smissaert wrote:
> Not sure if I need to call sqlite3_free after running sqlite3_result_text or
> if sqlite3_free should be an argument (last one) in sqlite3_result_text.
That depends on how the memory was obtained that the second argument
points to.
--
(Total - Used) AS Free
select count(*) Total,
sum(used is not null) Used,
sum(used is null) Free,
sum(any_boolean_condition) CountSatisfyingCondition
from proverbs;
--
Igor Tandetnik
nverted to a
string). 0x0A is an integer, I suspect it gets converted to the string '10'
--
Igor Tandetnik
quent no-op inserts.
--
Igor Tandetnik
f REGEXP, not in SELECT clause.
The reason it doesn't work is that, with most regular expression
engines, unless certain flags are used, "." (period) doesn't match
newline characters.
--
Igor Tandetnik
te it started
from. So you may as well do nothing at all and achieve the same result.
--
Igor Tandetnik
the corrupted data
structures when it tries to allocate memory. Heap corruption is nasty
this way.
--
Igor Tandetnik
git:]]+$');
>>
>> However, this generates the error:
>>
>> Error: no such function: regexp
>
> Maybe this instead:
>
> SELECT * FROM zip_codes WHERE zip_code NOT GLOB '[^0-9]';
Another variation: WHERE ltrim(zip_code, '0123456789')=''
--
Igor Tandetnik
On 11/24/2015 2:58 PM, Domingo Alvarez Duarte wrote:
> Actually we can not use "select" on constraints !
And that's a problem because... ? Your triggers don't refer to any other
table either.
Color me dense, but I utterly fail to grasp the nature of the difficulty.
--
Igor Tandetnik
101 - 200 of 3828 matches
Mail list logo