Re: [sqlite] Bitten by lack of isolation between SELECT and UPDATE on the same connection

2017-01-30 Thread Hick Gunter
Maybe adding "order by rowid" to your select statement can help avoid "sawing off the branch you are sitting on". Unless you need to update rowids... -Ursprüngliche Nachricht- Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Jens Alfke Gesendet: Dien

Re: [sqlite] BUG: Illegal initialization in icu.c : sqlite3IcuInit

2017-01-30 Thread Hick Gunter
alization in icu.c : sqlite3IcuInit > >On Thu, 26 Jan 2017 08:19:02 + >Hick Gunter wrote: > >> On LP_64 architactures, the integer 0 is 32 bits while (void *)0 is >> 64 bits, which makes more than a bit of a difference. A 64 bit integer >> 0 would be denoted by 0L. > &

Re: [sqlite] text/numeric comparison confusion

2017-01-26 Thread Hick Gunter
The constant '1' (of storage class TEXT) has no affinity, neither has the constant 1 (of storage class INTEGER), nor the result of an expression - with documented exceptions, notably CAST( AS ). Consider: 1 = '1' --- 0 (1=1) = '1' --- 0 cast((1=1) as integer) = '1' ---

Re: [sqlite] BUG: Illegal initialization in icu.c : sqlite3IcuInit

2017-01-26 Thread Hick Gunter
reff: Re: [sqlite] BUG: Illegal initialization in icu.c : sqlite3IcuInit Hick Gunter wrote: > On ILP_32 architectures, the integer 0 What integer 0? The message is about initializing scalars[11].pContent (a "void*") with "(void*)db", which is "sqlite3*". > Oh? What ex

Re: [sqlite] BUG: Illegal initialization in icu.c : sqlite3IcuInit

2017-01-26 Thread Hick Gunter
On ILP_32 architectures, the integer 0 is not discernible from the (void *)0 (aka NULL) and so most compilers don't bother to issue a warning. This comes from an age where programmers were expected to know how computers work on an assembly language level and would "know what they are doing" when

Re: [sqlite] Feature request

2017-01-16 Thread Hick Gunter
-- Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Simon Slavin Gesendet: Montag, 16. Jänner 2017 13:30 An: SQLite mailing list Betreff: Re: [sqlite] Feature request On 16 Jan 2017, at 12:17pm, Hick Gunter wrote: > Please be aware that %V implies %G/%g

Re: [sqlite] Feature request

2017-01-16 Thread Hick Gunter
Please be aware that %V implies %G/%g (four and two digit ISO Year number), which differs from %Y/%y on the "spillover days" that belong to the first/last week of the "other" year. -Ursprüngliche Nachricht- Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftr

Re: [sqlite] tclsqlite 64-bit bug [Was: extension to run bash]

2017-01-12 Thread Hick Gunter
There are a couple more cases of Tcl_AppendResults( ..., 0) in tclsqlite.c Unfortunately, Tcl_AppendResults() is defined as having varargs and thus lacking type checking. I would prefer NULL over (char*)0 anyway, which BTW is also present at least once in tclsqlite.c -Ursprüngliche Nachric

Re: [sqlite] Why this query plan?

2017-01-12 Thread Hick Gunter
I must disagree. SQL is based on sets. Sets do not have any order, even if the elements of the set (e.g. cardinal numbers) suggest a "natural" order (which may not be the same for all jurisdictions). An ordered set is called a permutation. Operations on sets (should) yield identical results, reg

Re: [sqlite] Why this query plan?

2017-01-11 Thread Hick Gunter
Since you did not specify an ORDER BY clause, SQLite is free to return rows in *any* order. The order may even change if the underlying schema changes and SQLite finds a better way to compute the results. A "covering index" is one that contains all the fields required from a certain table to fu

Re: [sqlite] Need help with System.Data.SQLite

2017-01-11 Thread Hick Gunter
What is the result if you exchange your currently executed statement to "SELECT 1,0;" ? Or to "SELECT 1, cast(0 as real)"? The effect of declaring a NUMERIC(5,5) field in SQLite is that it's affinity becomes NUMERIC. The value .0 thus becomes the integer 0. The other legal values (.1 to

Re: [sqlite] Possible bug with union and join.

2016-12-27 Thread Hick Gunter
Incorrect. All data is stored as NULL, integer, float, text or blob. The "declared type" is taken as a hint from the designer in respect to the kind of values he intends to store there. The result of the hint is called an "affinity", i.e. the kind of data the field "likes to" store. If the type

Re: [sqlite] How do I see a full query?

2016-12-27 Thread Hick Gunter
The functions sqlite3_sql() and sqlite3_expanded_sql() will return the original and expanded (i.e. with the bound values insted of parameter names) SQL strings for a statement created with the sqlite3_prepare_V2() interface. -Ursprüngliche Nachricht- Von: sqlite-users [mailto:sqlite-user

Re: [sqlite] Opcodes missing from documentation

2016-12-23 Thread Hick Gunter
According to sqlite 3.7.14 code the equivalences are SorterInsert == IdxInsert, SorterSort == Sort and SorterNext == Next case OP_SorterInsert: /* in2 */ #ifdef SQLITE_OMIT_MERGE_SORT pOp->opcode = OP_IdxInsert; #endif case OP_IdxInsert: {/* in2 */ case OP_SorterNext:/* jump

Re: [sqlite] What's the lifespan of a text/blob value returned from a virtual table?

2016-12-21 Thread Hick Gunter
The value obtained from sqlite3_column_blob() is valid only after sqlite3_step() returned SQLITE_ROW and will - at the very latest - go out of scope the moment the queries' idea of "current row" changes, i.e. one of sqlite3_step(), sqlite3_reset() or sqlite3_finalize() is called. It may also ch

Re: [sqlite] How do I check if the DB is open?

2016-12-14 Thread Hick Gunter
Perhaps you should change your calling sequence so that you call sqlite3_next_stmt() BEFORE sqlite3_close()? If you exclusively use sqlte3_prepare_v2() you can retrieve the text of the unfinalized statement(s), print/log that, and maybe even call sqlite3_finalize() if you like. -Ursprünglic

Re: [sqlite] Error code for VT xColumn()/xRowid() if row does not exist?

2016-12-13 Thread Hick Gunter
xRowid() is only called if the (hidden field) rowid is explicitly mentioned in the select list, join condition or where clause(s) of a SELECT statement; or if your VTAB supports write operations (see xUpdate documentation http://www.sqlite.org/vtab.html#the_xupdate_method ). -Ursprüngliche

Re: [sqlite] Error code for VT xColumn()/xRowid() if row does not exist?

2016-12-13 Thread Hick Gunter
>On 12/13/2016 01:47 AM, Bob Friesenhahn wrote: >> I am reworking code for a virtual table module and need to provide >> proper error codes from the xColumn() and xRowid() callbacks for the >> case where the row id does not exist, or the current row goes away. >> This problem occurs because the cur

Re: [sqlite] Error code for VT xColumn()/xRowid() if row does not exist?

2016-12-13 Thread Hick Gunter
Current documentation http://www.sqlite.org/rescode.html suggests you return (267) SQLITE_CORRUPT_VTAB in this case. Other candidates would be SQLITE_IOERR or SQLITE_NOTFOUND. You may also call one or more of the sqlite_result_error() functions to set an error string and/or an error code; curre

Re: [sqlite] Run non-data producing statement just once to test UDF

2016-12-12 Thread Hick Gunter
Select AddOne( ); -Ursprüngliche Nachricht- Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Bart Smissaert Gesendet: Sonntag, 11. Dezember 2016 22:39 An: General Discussion of SQLite Database Betreff: [sqlite] Run non-data producing statement just

Re: [sqlite] Problem with CASE in WHERE clause

2016-12-07 Thread Hick Gunter
>1) SELECT * FROM TEST WHERE posted = 1; >[(‘inv’, 100, 1)] > >2) SELECT * FROM TEST WHERE posted = ‘1’; >[(‘inv’, 100, 1)] > >3) SELECT * FROM TEST WHERE CASE WHEN tran_type = ‘inv’ THEN posted END = 1; >[(‘inv’, 100, 1)] > >4) SELECT * FROM TEST WHERE CASE WHEN tran_type = ‘inv’ THE

Re: [sqlite] *** suspected spam or bulk *** Re: Datatype for prices (1, 500)

2016-12-02 Thread Hick Gunter
Assuming the OPs native language is German: Lieber Freund, Du hast kein Problem mit der Speicherung sondern mit der Darstellung der Werte. MySQL übernimmt aufgrund der Typangabe "decimal(7,4)" die Darstellung/Formatierung der Werte. Vor dem Speichern wird der Wert so skaliert, dass immer ganzz

Re: [sqlite] CREATE TABLE fails

2016-11-22 Thread Hick Gunter
Perhaps you mean ...,"a bc_tag" char(254), PRIMARY KEY ("abc_tnam", "abc_ownr", "abc_cnam") ); -Ursprüngliche Nachricht- Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Igor Korot Gesendet: Dienstag, 22. November 2016 14:46 An: Discussion of SQLite

Re: [sqlite] Query Planner fails to recognise efficient strategy when '=' condition gives a strong hint

2016-11-17 Thread Hick Gunter
Maybe you are looking for SELECT id,baz from foo where exists( select 1 from bar where foo = id) ... which has the effect of easily extending to an arbitrary number of bar tables via additional exists subqueries that may be connected by logical operators -Ursprüngliche Nachricht- Von: s

Re: [sqlite] Changing ID's to UUID

2016-11-15 Thread Hick Gunter
On Tuesday, 15 November, 2016 15:30, R Smith wrote: > >> On 2016/11/15 10:38 PM, Jens Alfke wrote: > >> >> On Nov 15, 2016, at 11:35 AM, Quan Yong Zhai wrote: > >> >> Create a custom function MD5 , >> > If you’re going to go to this trouble, at least use SHA256! >> > >> > MD5 is broken. These days

Re: [sqlite] Is it possible to connect to an in-memory sqlite

2016-11-14 Thread Hick Gunter
The virtual table approach works very well for us here. Unfortunately it is all proprietary code, so I can share only a basic description. Bottom layer is an abstraction layer that provides an interface to some form of shared memory (BSD, SysV or Posix or even a memory-mapped file); This provide

Re: [sqlite] Virtual table acting as wrapper of a regular table

2016-10-24 Thread Hick Gunter
_ From: sqlite-users on behalf of Hick Gunter Sent: Monday, October 24, 2016 10:39 AM To: 'SQLite mailing list' Subject: Re: [sqlite] Virtual table acting as wrapper of a regular table Your xFilter method is blindly assuming that there is always an argv[0] without ch

Re: [sqlite] Virtual table acting as wrapper of a regular table

2016-10-24 Thread Hick Gunter
Your xFilter method is blindly assuming that there is always an argv[0] without checking argc first. You are incurring an extra "prepare" in your xConnect method, an extra "step" and "column" in your xFilter/xNext methods and an extra "result" in your xColumn function. Doing twice as much work

Re: [sqlite] 2 consecutive rises in value

2016-10-19 Thread Hick Gunter
Write a procedural program... ;) In SQL it requires a triple self join similar to: Select t1.id from table1 t1, table1 t2, table1 t3 where t2.id=t1.d and t1.value < t2.value and t2.date = (select min(date) from table1 where id =t.id and date > t1.date) and t3.id=t2.id and t2.value < t3.value an

Re: [sqlite] Possible Bug in VTable handling in SQLite 3.14.2

2016-10-17 Thread Hick Gunter
16 20:33 An: sqlite-users@mailinglists.sqlite.org Betreff: Re: [sqlite] Possible Bug in VTable handling in SQLite 3.14.2 On 10/14/2016 04:59 PM, Hick Gunter wrote: > In the vdbeaux.c source, the function > > resolveP2Values(...) > > is not resetting p->readOnly when it encounter

Re: [sqlite] Any performance penalty for SELECTing more columns? (C API)

2016-10-17 Thread Hick Gunter
Try using the sqlite shell program and the explain feature. You will see that each column fetched requires an additional opcode to do the fetching and an additional register to hold the result, all of this on top of requiring SQLite to decode all of these fields without you ever intending to use

[sqlite] Possible Bug in VTable handling in SQLite 3.14.2

2016-10-14 Thread Hick Gunter
In the vdbeaux.c source, the function resolveP2Values(...) is not resetting p->readOnly when it encounters an OP_VUpdate opcode is not setting p->bIsReader when it encounters an OP_VFilter opcode Additionally, the frunction sqlite3VdbeHalt(...) is only checking p->bIsReader and omitting to c

Re: [sqlite] .mode column .width .separator

2016-10-14 Thread Hick Gunter
You can eliminate separators by using .mode list .sepa "" But then you need to format your values to the correct widths for the record description. Text processing is not the primary domain of SQLite and is best left to the presentation layer. Alternatively you may consider writing a virtual ta

Re: [sqlite] Trigger WHEN condition, comparing with null

2016-10-13 Thread Hick Gunter
(new.value != old.value) or (new.value IS NULL) or (old.value IS NULL) -Ursprüngliche Nachricht- Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Daniel Polski Gesendet: Donnerstag, 13. Oktober 2016 12:03 An: SQLite mailing list Betreff: Re: [sqlite]

Re: [sqlite] Backward cursor support?

2016-10-12 Thread Hick Gunter
SQLite supports only "forward cursors". You do realize that the example given is a "stored procedure"... -Ursprüngliche Nachricht- Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Igor Korot Gesendet: Mittwoch, 12. Oktober 2016 18:49 An: SQLite maili

Re: [sqlite] *** suspected spam or bulk *** Re: Order of fields for insert

2016-10-06 Thread Hick Gunter
Betreff: *** suspected spam or bulk *** Re: [sqlite] Order of fields for insert On Thu, Oct 6, 2016 at 9:25 AM, Hick Gunter wrote: > SQLite compresses rows before storing and decompresses rows before > returning fields. BLOB fields are the most time consuming to process > and so should

Re: [sqlite] Order of fields for insert

2016-10-06 Thread Hick Gunter
SQLite compresses rows before storing and decompresses rows before returning fields. BLOB fields are the most time consuming to process and so should be placed at the end of the row. Often used fields - i.e. (foreign) key fields - should be placed at the front of the row. This will help most if

Re: [sqlite] Regarding the effects of the COMMIT keyword

2016-09-29 Thread Hick Gunter
>I am using multiple threads, but in this instance just 2 inside of one >process. I do not change any PRAGMA settings other than user_version and >journal_mode. The two >connections differ only by the fact that one is read >only and one is read-write. It’s possible that I’ve forgotten a fina

Re: [sqlite] Strange problem (pehaps bug) with sqlite + json

2016-09-23 Thread Hick Gunter
SQLite evaluates the WHERE clause from left to right, which means it needs to evaluate xyz and thereby call json_extract first, even before it can determine that no rows match the second condition. Maybe the transformation algorithm can be changed to check the "subselect constraints" first? --

Re: [sqlite] When is data committed on one connection seen on another?

2016-09-14 Thread Hick Gunter
>> As already stated, and per my own experience, each thread should have it's >> own connection and do whatever it needs to do there, without interference >> from other threads. > >I appreciate this point. Early prototyping indicated that this might not be >possible for our system, which makes me

Re: [sqlite] When is data committed on one connection seen on another?

2016-09-14 Thread Hick Gunter
AFAIK there is no "write mark" in the WAL journal. Instead, each read transaction (either implicit or explicit) has an associated "read mark" that determines which data the transaction will see (i.e. the data from the main file plus any pages in the WAL journal file before the read mark). This i

Re: [sqlite] page_size: bug with PRAGMA or documentation?

2016-09-12 Thread Hick Gunter
I guess that selecting from sqlite_master issues an implicit create, and querying/updateing something from the file header (i.e. several PRAGMAs) would also imply writing the first page of the file (with the current setting of page_size) too. -Ursprüngliche Nachricht- Von: sqlite-users

Re: [sqlite] Question about Memsys5 Internals

2016-09-05 Thread Hick Gunter
This should be computable from the base addresses returned when allocating successive objects. -Ursprüngliche Nachricht- Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Philip Bennefall Gesendet: Montag, 05. September 2016 08:22 An: General Discuss

[sqlite] Incompatibility in virtual table mechanism when upgrading from 3.7.14.1 to 3.13.0

2016-08-19 Thread Hick Gunter
It seems that SQLite is no longer honoring the aConstaintUsage[].omit flag for constraints that do not have an aContraint[].argvIndex set. This breaks a feature of our virtual table implementation that allows special hidden columns named in the WHERE clause to be interpreted as hints (i.e. which

Re: [sqlite] SQL Syntax fault on UPDATE statement

2016-08-17 Thread Hick Gunter
Your UPDATE statement does not mean what you think it means. UPDATE test SET id=0 AND name='new_name' AND age=30 WHERE id=1; Is parsed as: UPDATE test SET id = (0 AND name='new_name' AND age=30) WHERE id=1; The expression (0 AND ...) will always evaluate to 0. -Ursprüngliche Nachricht

Re: [sqlite] [System.Data.SQLite.DLL] Retrieving table names with column names

2016-07-21 Thread Hick Gunter
Short answer: YES. This question crops up regulary. The SQL Standard mandates only that column names set with AS be reliably returned. Otherwise each implementation is free to choose whatever name it deems appropriate, because - by omitting the AS clause - you state that you "don't care". The

Re: [sqlite] SQL to SQLite

2016-07-19 Thread Hick Gunter
Converting from one SQLite database to another may also be accomplished by using the ".mode insert " output format of the SQLite shell and then SELECTING the rows according to the full target schema. This creates SQL of the form "insert into values (); NOTE: No field list Or you can SELECT 'i

Re: [sqlite] Question on Join in Virtual Tables

2016-07-18 Thread Hick Gunter
Joins against virtual tables are handled in two steps: 1) your xBestIndex function is called (maybe more than once) with an array on valid constraints the give the "shape" of the requested operation Each "constraint" consists of a field number and and operation code; no value is passed.

Re: [sqlite] insert or replace on PK and UNIQUE INDEX

2016-07-12 Thread Hick Gunter
The conflict action "replace" looks at ALL the PRIMARY KEY and UNIQUE constraints (express or implied) and deletes ALL the existing rows that prevent the candidate row from being inserted. As in "I don't care what it takes, I want THIS row to be in the table." The other conflict actions just re

Re: [sqlite] Query Flattener vs. result-set column names

2016-07-07 Thread Hick Gunter
The returned column names depend on the exact path taken in the query optimizer. This may change if the shape of your data changes (analyze is run). The SQL standard only requires that column references be either unique or qualified by table. -Ursprüngliche Nachricht- Von: sqlite-users-

Re: [sqlite] Trigger slowness even when it's not fired

2016-07-04 Thread Hick Gunter
Creating a trigger causes SQLite to insert a row into the sqlite_master table which contains the text you supply for the trigger. No code is generated at this time. You can verify this by creating a trigger that references undefined fields. It willl succeed. But entering a statement that referen

Re: [sqlite] Trigger slowness even when it's not fired

2016-07-04 Thread Hick Gunter
How many times are you preparing the update statement? Maybe you are just measuring the effort required to prepare 55000 UPDATE statements. What is the purpose of counting all the rows of several tables before firing the trigger? If you are attempting to avoid running UPDATE on an empty table,

Re: [sqlite] Readers Sharing Connection

2016-06-30 Thread Hick Gunter
I would like to add: If you have multiple readers sharing a connection and they share the same prepared statement, none of them can be expected to receive the full result set, nor can it be guaranteed that the fields values retrieved will belong to the same row of the result set. A prepared sta

Re: [sqlite] How to use "cursors" in c#

2016-06-27 Thread Hick Gunter
Do not use SQLite for concurrent access over a network connection. Locking semantics are broken for most network filesystems, so you will have corruption issues that are no fault of SQLite. If your application requires concurrent network access, you should be using either a network client/server

Re: [sqlite] Regarding redirecting SQL results and errors to a single output file.

2016-06-27 Thread Hick Gunter
SQLite is already telling you that whatever statement contains line 13 of your input file test44.sql is attempting to evaluate a function named log_file_check which is unknown to SQLite. Additionally, the correct command for exiting a SQLite shell is ".exit" and not "exit" alone. Interfacing wi

Re: [sqlite] Regarding redirecting SQL results and errors to a single output file.

2016-06-27 Thread Hick Gunter
You need to redirect "standard error" to "standard output". In linux/bash this is achieved by adding "2>&1" to your command line. -Ursprüngliche Nachricht- Von: sqlite-users-boun...@mailinglists.sqlite.org [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Kaja Varunku

Re: [sqlite] Conversion failure

2016-06-24 Thread Hick Gunter
The hex dump shows the sz-ligature encoded as (hex) e1. That is NOT a valid UTF sequence. Sqlite ASSUMES and EXPECTS all input to be UTF encoded. Passing ISO/ANSI encoded special characters in strings is ok as long as the presentation layer on both sides EXPECTS that same encoding. Using ISO/AN

Re: [sqlite] Conversion failure

2016-06-23 Thread Hick Gunter
, Gunter, On Thu, Jun 23, 2016 at 10:59 AM, Hick Gunter wrote: > Open the editor application, type in your command, save to file and the view > with a hex editor. I suspect it will be in ISO encoding. According to https://sqlite.org/src4/doc/trunk/www/data_encoding.wiki, all this data should

Re: [sqlite] Conversion failure

2016-06-23 Thread Hick Gunter
Open the editor application, type in your command, save to file and the view with a hex editor. I suspect it will be in ISO encoding. -Ursprüngliche Nachricht- Von: sqlite-users-boun...@mailinglists.sqlite.org [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Igor Koro

Re: [sqlite] sqlite3_column_origin_name for INSERT and UPDATE

2016-06-17 Thread Hick Gunter
Does .pragma table_info(); not solve your problem? -Ursprüngliche Nachricht- Von: sqlite-users-boun...@mailinglists.sqlite.org [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Rapin Patrick Gesendet: Freitag, 17. Juni 2016 10:57 An: sqlite-users@mailinglists.sqlite.

Re: [sqlite] Latin-1 characters cannot be supported for Unicode

2016-06-15 Thread Hick Gunter
supported for Unicode There are some unintelligible text in my database. Is there any methods to see their byte sequence? Best Regards, Wang Wei -Original Message- From: sqlite-users-boun...@mailinglists.sqlite.org [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On Behalf Of Hick

Re: [sqlite] Latin-1 characters cannot be supported for Unicode

2016-06-15 Thread Hick Gunter
The answer is very simple: Do not use ANSI/ISO encoding with SQLite. SQLite expects Unicode. -Ursprüngliche Nachricht- Von: sqlite-users-boun...@mailinglists.sqlite.org [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Wang, Wei Gesendet: Mittwoch, 15. Juni 2016 04:44

Re: [sqlite] Latin-1 characters cannot be supported for Unicode

2016-06-08 Thread Hick Gunter
Yes, I missed the trailing 00 -Ursprüngliche Nachricht- Von: sqlite-users-boun...@mailinglists.sqlite.org [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im Auftrag von Jean-Christophe Deschamps Gesendet: Mittwoch, 08. Juni 2016 09:37 An: SQLite mailing list Betreff: Re: [sqlite]

Re: [sqlite] Latin-1 characters cannot be supported for Unicode

2016-06-08 Thread Hick Gunter
That the same character is found in both encodings is no surprise. You need to look at the actual sequence of bytes. Comparing a file containing just the "capital A with diaresis" yields A 1 Byte sequence 0xC4 in ANSI A 2 Byte sequence 0xC384 in en_US.UTF8 on a RH5 linux system A 3 Byte Sequence

Re: [sqlite] Latin-1 characters cannot be supported for Unicode

2016-06-07 Thread Hick Gunter
As already stated, this is not a problem of SQLite. SQLite assumes all input to be correctly encoded in UTF (unicode), the precise flavor of which may be set (once, between creating a db file and the first insert) by a pragma. If you insert ISO (latin) encoded strings, SQLite will faithfully re

Re: [sqlite] UPDATE statement without FROM clause

2016-06-06 Thread Hick Gunter
Would not Replace into A () select ,, from A [cross] join B on( ); do the trick? If a.rowid has an alias (i.e. integer primary key) then the modified rows would be deleted, but reinserted with their respective previous rowids. This may required switching foreign keys off fort he duration of t

Re: [sqlite] Some Latin characters cannot be handled correctly

2016-06-02 Thread Hick Gunter
SQLite will faithfully return whatever sequence of bytes you passed in when inserting the data. If you insert ISO-ANSI encoded data then please do not expect the returned data to be magically converted to UTF. BTW, this mailing list does not support attachments. -Ursprüngliche Nachricht---

Re: [sqlite] a question about data synchronization

2016-06-01 Thread Hick Gunter
Process B can see only data that is committed before it's read transaction is started. I suspect you are creating a transaction in process B right after connecting to the database that remains open for the lifetime of the connection. This will force Process B to see the state as it was before i

Re: [sqlite] SELECT ... FOR UPDATE

2016-05-24 Thread Hick Gunter
SQLite does not use row level locking, only file level locking. You can use BEGIN IMMEDIATE to exclude writers or BEGIN EXCLUSIVE to exclude readers and writers. If you do not explicitly start a transaction, each statement constitutes it's own transaction. -Ursprüngliche Nachricht- Von:

[sqlite] 2 different SQLite versions inside the same process space

2016-05-11 Thread Hick Gunter
To get this effect you need to have 2 (shareable) images, each with their own and very private copy of sqlite, loaded into the same process. With the mentioned #defines that make all sqlite3 symbols become static, it is quite easy to compile sometool.c and sqlite3.c into a single sometool.so (or

[sqlite] SELECT DISTINCT question

2016-05-09 Thread Hick Gunter
This is documented behaviour for SQLite: SELECT a, MAX(b) table; Will return (one of) the a value(s) that comes from the same row as the MAX(b). If there are not exactly on of MIN or MAX aggregate functions, SQLite is free to pick any row (within a group) to return non-aggregated columns from.

[sqlite] Incremental backup/sync facility?

2016-05-06 Thread Hick Gunter
No,you just have to log the bound parameters and a reference to the prepared statement (so the other side will know which statement to prepare). Or just log the statement & the parameters each time. -Original Message- From: sqlite-users-bounces at mailinglists.sqlite.org [mailto:sqlite-u

[sqlite] Incremental backup/sync facility?

2016-05-06 Thread Hick Gunter
May I suggest using a statement log of the "primary" database to update the secondary sites? If you have a sequence counter (separate or embedded) then the state of the database could be recovered from a backup (sequence counter x) plus the log files for all statements from x+1 to "current". --

[sqlite] strftime accepts an illegal time string

2016-05-06 Thread Hick Gunter
> >For instance, do you care if someone enters a time which is skipped by the >clocks going forward ? If at 1am your clocks skip straight to 2am, do you >care if someone enters a time of 1:30am on that >day ? > > >Simon. > Our local time skips from 2am to 3am and from 3am back to 2am for DST. T

[sqlite] Illegal SQL not rejected

2016-05-02 Thread Hick Gunter
This is the much discussed and misunderstood feature that enables SQLite to process statements like SELECT A, B, MAX(C) FROM TABLE GROUP BY B; and return the (or one of the) value(s) of A associated with the maximum value of C within each group of B in just one full table scan. By extension, t

[sqlite] Processing arguments in a user-defined function

2016-05-02 Thread Hick Gunter
The Pointer you received calling sqlite3_value_test16() on the FIRST argument is not invalidated by calling the same function on the SECOND argument. Value conversions may (and do for specific calling sequences) happen only when calling a different sqlite3_value_x() function on the SAME argument

[sqlite] SELECT 0 gives TEXT instead of INTEGER

2016-04-21 Thread Hick Gunter
Try "limit 20". The hex function interprets the argument as a blob. This causes your integer value to be converted to text, and the hex representation of that text is your result. -Urspr?ngliche Nachricht- Von: sqlite-users-bounces at mailinglists.sqlite.org [mailto:sqlite-users-bounces

[sqlite] storing coordinate pairs efficiently?

2016-04-20 Thread Hick Gunter
The "Usability" of an index for a certain set of constraints ends with the first (in the order mentioned in the index) field with an inequality constraint. However, and index on (gx,gy) is still be faster for the query shown than just on (gx), because the value of the second field is read from t

[sqlite] Expecting syntax error on delete

2016-04-11 Thread Hick Gunter
The expression "a in ('abc','def')" will return either TRUE or FALSE so your condition devolves to "a in (TRUE, FALSE)" which is FALSE for all text values. -Urspr?ngliche Nachricht- Von: sqlite-users-bounces at mailinglists.sqlite.org [mailto:sqlite-users-bounces at mailinglists.sqlite.o

[sqlite] regression in 3.12.0 vs. 3.11.0, column type information in PRAGMA missing

2016-04-06 Thread Hick Gunter
You are hopefully aware of the fact that SQLite associates type with the actual values and not the containers(columns) used to hold these values? This means that a data object of any type may be held/returned in a column, irrespective of the declared type (which, for expressions, is NULL). What

[sqlite] Calling some predefined SQL function from another custom SQL function?

2016-03-31 Thread Hick Gunter
While it is technically possible to convincingly fake an SQLite context to call strftimeFunc() with, it also means that you are ignoring SQLite function overloading. And making yourself dependant on internal changes to SQLite structures that are opaque for a reason. -Urspr?ngliche Nachricht

[sqlite] Error msg help

2016-03-17 Thread Hick Gunter
It seems your 14 digit API well number is being converted to a real before being output with only 2 digits of precision, giving the string "3.11E+13". This is nearly guaranteed to NOT be unique. You need to request a CSV File with the API well number in string format. -Urspr?ngliche Nachric

[sqlite] jude a record is exist or not

2016-03-10 Thread Hick Gunter
Assuming the "id" is the primary key of your table "table_name", your statement will list the id of all the records present (full scan, reading every entry of the implicit primary key index). To find out if a specific record exists, use "select count() from table_name where id = " to return a s

[sqlite] Insert or Replace Trouble

2016-03-09 Thread Hick Gunter
There is no unique constraint (express or implied) in your schema, therefore no conflict occurs and it is possible to insert as many identical rows as your diskspace will hold. -Urspr?ngliche Nachricht- Von: sqlite-users-bounces at mailinglists.sqlite.org [mailto:sqlite-users-bounces at

[sqlite] How to modify page_size

2016-02-25 Thread Hick Gunter
Works as advertised. A database in WAL mode does not allow the page size to be changed. -Urspr?ngliche Nachricht- Von: sqlite-users-bounces at mailinglists.sqlite.org [mailto:sqlite-users-bounces at mailinglists.sqlite.org] Im Auftrag von Yongil Jang Gesendet: Donnerstag, 25. Februar 20

[sqlite] How to modify page_size

2016-02-25 Thread Hick Gunter
Short answer: you can't. It would require rebuilding every single page of the database. Exception 1: If the database is empty, the pragma will set the page size. Exception 2: If your database is not empty and you run VACUUM (which rebuilds every page of the database anyway) immediately after is

[sqlite] SQLite as calculator

2016-02-19 Thread Hick Gunter
Yes it is expected. Strings always compare greater than numbers. Arithmetic operators will apply numeric affinity to their operands, allowing e.g. the addition of a string and an integer to produce the expected result. -Urspr?ngliche Nachricht- Von: sqlite-users-bounces at mailinglists.s

[sqlite] EXPLAIN QUERY PLAN for non-SELECT statements?

2016-02-19 Thread Hick Gunter
-Urspr?ngliche Nachricht- Von: sqlite-users-bounces at mailinglists.sqlite.org [mailto:sqlite-users-bounces at mailinglists.sqlite.org] Im Auftrag von nomad at null.net Gesendet: Freitag, 19. Februar 2016 11:01 An: SQLite mailing list Betreff: [sqlite] EXPLAIN QUERY PLAN for non-SELECT st

[sqlite] Multiple Column index

2016-02-19 Thread Hick Gunter
The order of fields in the multicolumn index matters. Taken in the order of fields in the index, the first inequality relation terminates the part of the index that is usable. For a constraint "plate EQUALS and date BETWEEN" you need an index on (plate,date). Your index is only usable for "date

[sqlite] Process duplicate field values

2016-02-19 Thread Hick Gunter
Basic idea, no testing The core query is Select F1 as key,count() as count from MyTable group by F1 having count>1; The number of distinct F1 values is select count() from () The number of conflict records is Select sum(count) from () And the update would be Update MyTable set F2=9 where F1

[sqlite] Can't understand why I need this cast

2016-02-18 Thread Hick Gunter
Consider asql> select '1' >= 1, '1' <= 1; '1' >= 1 '1' <= 1 1 0 This is because of the implicit ordering of TEXT and INTEGER values. Strftime() returns a text; in the expression "strftime() + 1" the arithmetic operator "casts" its left hand operand to integer (actual

[sqlite] json_group_array

2016-02-05 Thread Hick Gunter
mailinglists.sqlite.org] Im Auftrag von Yannick Duch?ne Gesendet: Freitag, 05. Februar 2016 12:38 An: sqlite-users at mailinglists.sqlite.org Betreff: Re: [sqlite] json_group_array On Fri, 5 Feb 2016 07:51:06 + Hick Gunter wrote: > That is because count(a) and count(*) means two differ

[sqlite] json_group_array

2016-02-05 Thread Hick Gunter
That is because count(a) and count(*) means two different things. The first counts values, the second counts rows. -Urspr?ngliche Nachricht- Von: sqlite-users-bounces at mailinglists.sqlite.org [mailto:sqlite-users-bounces at mailinglists.sqlite.org] Im Auftrag von TJ O'Donnell Gesendet

[sqlite] Table entries disappearing for unknown reason.

2016-02-02 Thread Hick Gunter
Does the error still occur if you run with only one thread? Does each thread have ist own connection or are you sharing a single connection across multiple threads? -Urspr?ngliche Nachricht- Von: sqlite-users-bounces at mailinglists.sqlite.org [mailto:sqlite-users-bounces at mailinglist

[sqlite] Suggesting an Index to Use Can Improve Performance Even When Planner was Already Going to Use It

2016-01-25 Thread Hick Gunter
Adding the INDEXED BY changed the nesting order of the loops. Also, note the word AUTOMATIC in the query plan: This means that the QP has decided it is worthwhile to build an Index just for this one query. The first plan in English: Build an Index on T2.E = 2 that also contains the field

[sqlite] Store the value from a variable into a field in database table

2016-01-22 Thread Hick Gunter
You can either printf() the statement to insert the value into the text, or use SQL variables to prepare the generic statement and sqlite3_bind_xxx() the desired value. -Urspr?ngliche Nachricht- Von: sqlite-users-bounces at mailinglists.sqlite.org [mailto:sqlite-users-bounces at mailing

[sqlite] SQLite scans the largest table in the query where a very small table is available

2016-01-20 Thread Hick Gunter
Have you tried running ANALYZE on a representative dataset? This will determine the "shape" of your tables and allow the query planner to make better guesses of the costs associated with each join. If, after ANALYZE, you still feel the need to improve over the query planners' ordering, you can

[sqlite] UPSERT

2016-01-20 Thread Hick Gunter
REPLACE will delete the offending row in the referenced table and insert a new one with a newly generated rowid. If the foreign key references the rowid, the DELETE CASCADE will be invoked because there is no longer a record with the referenced rowid. -Urspr?ngliche Nachricht- Von: sqli

[sqlite] Wish list: allow developers use the power of sqliteparser

2016-01-19 Thread Hick Gunter
Use the documented and supported sqlite3_set_authorizer() function to achieve security vetting of SQL Statements. This calls a user-supplied function with the details of which tables and fields the user is attempting to access and if this is a read or write access. -Urspr?ngliche Nachricht-

[sqlite] Retrieved Blob Data has 16 Byte Header or ?

2016-01-19 Thread Hick Gunter
Just a wild guess: The NSData object has an overhead of 16 bytes and the (overloaded/member?) sizeof() function returns the NET contents, not the total size which should be 16 bytes (the overhead) longer. -Urspr?ngliche Nachricht- Von: sqlite-users-bounces at mailinglists.sqlite.org [ma

<    1   2   3   4   5   6   7   8   9   10   >