[sqlite] Limiting the result set size at each recursive step in a CTE

2019-05-07 Thread Thomas Zimmermann

Hi!

Sometimes it is desirable to limit the size of the queue¹ in a recursive 
CTE when the
domain allows for it. That puts an upper bound on processing time, even 
when the given table is huge.
This can be achieved by adding a LIMIT clause at every step (setup and 
recursive).
But there is my problem: The setup step allows subqueries, but the 
recursive step doesn't.

Is there a general solution available?

As a concrete example, consider the following table for a commenting system:

CREATE TABLE comment (
    comment_id INTEGER PRIMARY KEY,
    parent_comment_id INTEGER REFERENCES comment (comment_id),
    created_at INTEGER NOT NULL -- timestamp, bigger means newer
);
CREATE INDEX comment_hierarchy ON comment (parent_comment_id, created_at 
DESC);


The comments should be arranged by hierarchy and creation date, newest 
first.

Only up to 100 comments should be shown. Example:

Comment 2 (2019-05-03)
- Comment 3 (2019-05-04)
- Comment 4 (2019-05-05)
-- Comment 5 (2019-05-05)
Comment 1 (2019-05-02)

The following query should accomplish this, but the optimization isn't 
allowed (see comments inline):


WITH RECURSIVE
    sorted_comment(comment_id, parent_comment_id, created_at, depth) AS (
        -- Start with all comments at the root level.
        -- Optimization: Only consider the latest 100 comments, since 
that's the maximum amount we could pick from this level.
        -- This guarantees good performance even when there are 
millions of comments at the root level.

    SELECT *
    FROM (
        SELECT comment_id, parent_comment_id, created_at, 0 AS depth
        FROM comment
        WHERE parent_comment_id IS NULL
        ORDER BY created_at DESC
        LIMIT 100
    )

    UNION ALL

    -- Find all direct descendants of the current comment from the 
queue.
    -- Same optimization: There might be many comments at this 
level, but we could oly ever consider up to the latest 100.
    -- (Actually, we only need to consider (100 - 
COUNT(sorted_comment)), but let's ignore that for now.)
    -- NOTE: This doesn't actually work, Error: recursive reference 
in a subquery: sorted_comment

    SELECT *
    FROM (
    SELECT c.comment_id, c.parent_comment_id, c.created_at, 
sc.depth + 1 AS depth

    FROM comment AS c
    JOIN sorted_comment AS sc
    ON c.parent_comment_id = sc.comment_id
    ORDER BY created_at DESC
    LIMIT 100
    )
    -- Do a depth-first search, picking the latest comment from the 
queue.

    ORDER BY depth DESC, created_at DESC
    LIMIT 100
    )
SELECT comment_id, parent_comment_id, created_at, depth
FROM sorted_comment;

I would be very interested in a general solution that still allows for 
the adjacency list design,

but I'm open to denormalization. :)

Kind regards,
Thomas

¹ As defined in the documentation here: https://sqlite.org/lang_with.html
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] INSERT OR FAIL inserts row although it violates a table constraint

2019-05-07 Thread Richard Hipp
On 5/7/19, Manuel Rigger  wrote:
> Great, thanks! In which commits were they addressed? I saw two commits that
> address https://www.sqlite.org/src/info/e63cbcfd3378afe6980d6. Was this
> issue derived from the test case?

Issue 1:  Foreign key constraints are not checked until the end of a statement,
so the INSERT OR IGNORE needs to act like INSERT OR ABORT when dealing
with FK constraints.  This will involve a (pending) change to the
documentation as well.
Check-in https://www.sqlite.org/src/info/659c551dcc374a0d

Issue 2: Foreign key constraint checking might cause some elements of
an inserted or updated row to change datatypes, which causes the row
to be constructed incorrectly.  Fixed by check-in
https://www.sqlite.org/src/info/3f1c8051648a341d
-- 
D. Richard Hipp
d...@sqlite.org
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] INSERT OR FAIL inserts row although it violates a table constraint

2019-05-07 Thread Manuel Rigger
Great, thanks! In which commits were they addressed? I saw two commits that
address https://www.sqlite.org/src/info/e63cbcfd3378afe6980d6. Was this
issue derived from the test case?

Best,
Manuel

On Tue, May 7, 2019 at 10:08 PM Richard Hipp  wrote:

> Two separate problems, both now fixed on trunk.
>
> On 5/6/19, Manuel Rigger  wrote:
> > Hi everyone,
> >
> > consider the following example:
> >
> > PRAGMA foreign_keys=true;
> > CREATE TABLE t0 (c0 UNIQUE, c1 UNIQUE, FOREIGN KEY(c0) REFERENCES
> t0(c1));
> > INSERT OR FAIL INTO t0(c0, c1) VALUES
> > (0, 1),
> > (0, 2);
> > SELECT * FROM t0; -- returns 0|1
> >
> > I expect the INSERT to fail, since both the UNIQUE and the FOREIGN KEY
> > constraints are violated. However, the (0, 1) row is inserted, as the
> > result of the SELECT query above demonstrates. When splitting up the
> INSERT
> > into two INSERTS, no row is inserted, as expected:
> >
> > PRAGMA foreign_keys=true;
> > CREATE TABLE t0 (c0 UNIQUE, c1 UNIQUE, FOREIGN KEY(c0) REFERENCES
> t0(c1));
> > INSERT OR FAIL INTO t0(c0, c1) VALUES (0, 1);
> > INSERT OR FAIL INTO t0(c0, c1) VALUES (0, 2);
> > SELECT * FROM t0; -- returns no row
> >
> > I found this bug because a WHERE clause did not fetch the row after a
> > REINDEX:
> >
> > PRAGMA foreign_keys=true;
> > CREATE TABLE t0 (c0 INT UNIQUE, c1 TEXT UNIQUE, FOREIGN KEY(c0)
> REFERENCES
> > t0(c1));
> > INSERT OR FAIL INTO t0(c0, c1) VALUES
> > (0, 1),
> > (0, 2);
> > REINDEX;;
> > SELECT * FROM t0; -- returns 0|1
> > SELECT * FROM t0 WHERE c1=1; -- returns nothing
> >
> > Best,
> > Manuel
> > ___
> > sqlite-users mailing list
> > sqlite-users@mailinglists.sqlite.org
> > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
> >
>
>
> --
> D. Richard Hipp
> d...@sqlite.org
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] PRAGMA reverse_unordered_selects=true results into row not being fetched

2019-05-07 Thread Manuel Rigger
Hi everyone,

I discovered what I think is a bug, as demonstrated below:

CREATE TABLE t0(c0);
CREATE TABLE t1(c0 INTEGER PRIMARY KEY);
PRAGMA reverse_unordered_selects=true;
INSERT INTO t1(c0) VALUES (0);
INSERT INTO t0(c0) VALUES ('a');
SELECT * FROM t1, t0 WHERE t1.c0 < t0.c0;

I would expect (0, 'a') to be fetched, which is not the case. The
comparison should be true, as demonstrated by this query:

SELECT t1.c0 < t0.c0 FROM t1, t0; -- 1

The bug is only triggered when setting the PRAGMA and when c0 is an INTEGER
PRIMARY KEY.

Best,
Manuel
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] INSERT OR FAIL inserts row although it violates a table constraint

2019-05-07 Thread Richard Hipp
Two separate problems, both now fixed on trunk.

On 5/6/19, Manuel Rigger  wrote:
> Hi everyone,
>
> consider the following example:
>
> PRAGMA foreign_keys=true;
> CREATE TABLE t0 (c0 UNIQUE, c1 UNIQUE, FOREIGN KEY(c0) REFERENCES t0(c1));
> INSERT OR FAIL INTO t0(c0, c1) VALUES
> (0, 1),
> (0, 2);
> SELECT * FROM t0; -- returns 0|1
>
> I expect the INSERT to fail, since both the UNIQUE and the FOREIGN KEY
> constraints are violated. However, the (0, 1) row is inserted, as the
> result of the SELECT query above demonstrates. When splitting up the INSERT
> into two INSERTS, no row is inserted, as expected:
>
> PRAGMA foreign_keys=true;
> CREATE TABLE t0 (c0 UNIQUE, c1 UNIQUE, FOREIGN KEY(c0) REFERENCES t0(c1));
> INSERT OR FAIL INTO t0(c0, c1) VALUES (0, 1);
> INSERT OR FAIL INTO t0(c0, c1) VALUES (0, 2);
> SELECT * FROM t0; -- returns no row
>
> I found this bug because a WHERE clause did not fetch the row after a
> REINDEX:
>
> PRAGMA foreign_keys=true;
> CREATE TABLE t0 (c0 INT UNIQUE, c1 TEXT UNIQUE, FOREIGN KEY(c0) REFERENCES
> t0(c1));
> INSERT OR FAIL INTO t0(c0, c1) VALUES
> (0, 1),
> (0, 2);
> REINDEX;;
> SELECT * FROM t0; -- returns 0|1
> SELECT * FROM t0 WHERE c1=1; -- returns nothing
>
> Best,
> Manuel
> ___
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>


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


[sqlite] .import into databases other than main doesn't work

2019-05-07 Thread Shawn Wagner
The .import command doesn't play well with attempts to use tables in
schemas other than main:

sqlite> .mode csv
sqlite> .import test.csv temp.test
Error: no such table: temp.test

It creates the table if needed, but fails on the insert part because it
tries to execute `INSERT INTO "temp.test" ` instead of `INSERT INTO
"temp"."test" ...`.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Improving CSV import

2019-05-07 Thread Shawn Wagner
Late follow up:

> .import "tail -n +2 foo.csv |" mytable

Found out today that this works (Though the pipe character has to be the
first character, not the last) and apparently has for years, though I can't
find it documented anywhere.

On Thu, Mar 21, 2019 at 4:06 PM Shawn Wagner 
wrote:

> Importing a CSV file in the command line shell has two different
> behaviors: if the table to import to doesn't exist, treat the first row of
> the file as a header with column names to use when creating the table. If
> the table does exist, treat all rows as data.
>
> A way to skip a header row when the table exists would be useful.
> Sometimes it's awkward to make a copy of a file minus the first line before
> doing the import.
>
> Alternatively, allow .import to pipe from the output of a command, not
> just a file:
>
> .import "tail -n +2 foo.csv |" mytable
>
> More work to implement, but a lot more flexible, and it would match the
> behavior of .output and .once. If the devs are willing to accept user
> contributed patches to the shell, I'd happy to look into implementing that.
>
> Also something I've run into that would be useful: a way to strip leading
> and trailing whitespace from unquoted fields before inserting them.
>
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Getting the week of the month from strftime or date functions

2019-05-07 Thread Petite Abeille


> On May 7, 2019, at 05:35, Jens Alfke  wrote:
> 
> [https://en.wikipedia.org/wiki/French_Republican_calendar]

Along the same lines: International Fixed Calendar

https://en.m.wikipedia.org/wiki/International_Fixed_Calendar

> You Advocate An Approach To Calendar Reform; Your Idea Will Not Work; Here Is 
> Why  (brutal takedown)

While at it:  So You Want To Abolish Time Zones

https://qntm.org/abolish



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


Re: [sqlite] Getting the week of the month from strftime or date functions

2019-05-07 Thread Jose Isaias Cabrera

I apologize to the group for the non-sqlite emails caused by my post. It was 
just having a little fun. :-)

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


[sqlite] GCC 4.8.5 compiler warnings with sqlite3 3.28.0: -Warray-bounds and -Wempty-body

2019-05-07 Thread LfSt
Hi!

when including SQLite3 in our build, I noticed the following warnings:

sqlite3.c: In function 'sqlite3WhereCodeOneLoopStart':
sqlite3.c:138260:56: warning: suggest braces around empty body in an 
'if' statement [-Wempty-body]
 if( pWInfo->nLevel>1 ) sqlite3StackFree(db, pOrTab);
^
sqlite3.c: In function 'balance_nonroot':
sqlite3.c:71175:47: warning: array subscript is above array bounds 
[-Warray-bounds]
 pOld = iOldhttp://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Getting the week of the month from strftime or date functions

2019-05-07 Thread R Smith

On 2019/05/07 3:07 PM, Jose Isaias Cabrera wrote:

Warren Young, on Monday, May 6, 2019 09:15 PM, wrote...
On May 6, 2019, at 11:58 AM, Jose Isaias Cabrera wrote:

someday, as John Lennon sang, "...the world will live as one." ;-)

Okay, but one *what*?  Serious question.

Yeah, if I have to explain it to you, then you miss the idea. :-) But here is 
something: you, one Warren Young, are composed of billions of living small 
living cells, all working to your well being. You are one. :-)

By the way, there will be a time when time will no longer be, but instead, 
we'll have eternity. :-) My personal believe, of course.


The spectacular width by which Warren's point was missed aside, I did 
chuckle at the irony of quoting a John Lennon song that advocates for no 
Religion with the very next post claiming adherence. :)


If time doesn't exist then, how will you know it is eternity?
(It's rhetorical, no answer required).


PS: It's Trillions of small cells, not Billions - around 38 Trillion in 
a reference 70Kg male, with almost equal numbers (around 30 Trillion 
more) non-human cells.

https://www.smithsonianmag.com/smart-news/there-are-372-trillion-cells-in-your-body-4941473/
https://journals.plos.org/plosbiology/article?id=10.1371/journal.pbio.1002533

PPS: Time is nothing but a measurement of the rate of progression, the 
progression of an irreversible sequence of events or states along a 
continuum. Progression rate is also relative to a frame of reference, 
and thus, so is time. This we can agree on: One day, time/progression 
will cease to be; in your frame of reference; for eternity. :)

https://en.wikipedia.org/wiki/Time


Cheers!
Ryan


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


Re: [sqlite] [EXTERNAL] If two orders are both the same order?

2019-05-07 Thread sqlite
sqlite-users@mailinglists.sqlite.org wrote:

> Your schema implies that there can be more than one TIME for any GNAME and AN 
> combination (otherwise the primary key would not need to include alle three 
> fields). This contradicts your statement that AN and TIME are "the same 
> order". 
> (consider the tuples ("T1",1,1) and ("T2",1,2); the AN field compares equal, 
> so 
> ORDER BY AN is free to return the T2 row before the T1 row).
>
> Which query specifically would you have in mind that relies on your assertion?
>
> Also, if your application requires that rows be returned in a specifc order, 
> your MUST specify this with en ORDER BY clause and not rely on the visitation 
> order. The visitation order may change due to a number of factors including 
> the 
> SQLite version, the "shape" of your data, running ANALYZE and maybe more.

About the PRIMARY KEY you are correct; that is my mistake.

The specific query is this one:
  SELECT `ART`.`MID` FROM `XPOST`, `ART` USING(`AN`) WHERE `XPOST`.`TIME` >= ?1 
AND `XPOST`.`GNAME` = ?2;

(The (GNAME,AN) combinations are actually unique, for any value of AN there is 
exactly one value of TIME. Probably TIME doesn't really belong in XPOST at all; 
I originally put it there due to this confusion I had and then forgot to remove 
it; that is also why it is part of the primary key even though it shouldn't be. 
The next version of my software would probably fix that.)

The above query implements the NEWNEWS command of NNTP. RFC 3977 says "the 
order of the response has no specific significance and may vary from response 
to response in the same session"; so, in order that SQLite can choose the most 
efficient query plan without requiring a specific order, there is no ORDER BY 
clause.

(There is another variant of that query without the second part of the WHERE 
clause, used if "NEWNEWS *" is specified. NEWNEWS followed by anything other 
than * or a single newsgroup currently results in a 503 error in this 
implementation.)
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Location of error in SQL statements ?

2019-05-07 Thread x
I think pzTail just points to the trailing ‘/0’ of zSql if an error occurs.




From: sqlite-users  on behalf of 
Rowan Worth 
Sent: Tuesday, May 7, 2019 9:07:34 AM
To: SQLite mailing list
Subject: Re: [sqlite] Location of error in SQL statements ?

On Tue, 7 May 2019 at 16:00, Eric Grange  wrote:

> Is there are way to get more information about an SQL syntax error message
> ?
> For example on a largish SQL query I got the following error message
>
> near "on": syntax error
>
> but as the query is basically a long list of joins, this is not too helpful
> ;)
>

It's not clear from the docs whether this is guaranteed, but a quick look
at the code suggests that the pzTail argument (if provided to
sqlite3_prepare_v2) is also updated when there's a parse error. You might
be able to rely on that to infer how far through the statement the problem
lies.

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


Re: [sqlite] Error when renaming a table when an invalid view exists in the schema

2019-05-07 Thread Tom Bassel
Thanks Keith. LEGACY_ALTER_TABLE=ON lets me change the table name without 
error. But the docs say "New applications should leave this flag turned off."

Is there any other way of checking if the schema is invalid besides attempting 
to change the name of a table?

I went through the pragmas and commands below and they did not report that the 
schema was invalid.

SQLite version 3.29.0 2019-04-27 20:30:19
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> create table t1(f1);
sqlite> create view v1 as select * from t1;
sqlite> drop table t1;
sqlite> create table t2(f1);
sqlite> .schema
CREATE VIEW v1 as select * from t1;
CREATE TABLE t2(f1);
sqlite> pragma integrity_check;
ok
sqlite> pragma quick_check;
ok
sqlite> pragma optimize;
sqlite> vacuum;
sqlite> pragma foreign_key_check;
sqlite> pragma database_list;
0|main|
1|temp|
sqlite> .lint
Usage lint sub-command ?switches...?
Where sub-commands are:
fkey-indexes
sqlite> .lint fkey-indexes
sqlite> alter table t2 rename to t20;
Error: error in view v1: no such table: main.t1


---
Date: Fri, 03 May 2019 13:27:18 -0600
From: "Keith Medcalf" 
To: "SQLite mailing list" 
Subject: Re: [sqlite] Error when renaming a table when an invalid view
exists in the schema
Message-ID: <802bb8bcf08af448bd5d9a4b9bf2f...@mail.dessus.com>
Content-Type: text/plain; charset="utf-8"


Use PRAGMA LEGACY_ALTER_TABLE=ON;

The "Legacy alter table" does not require the database to be "valid/consistent" 
after executing the "alter table" command.  The non-legacy (default) mode 
requires that the database be "transformed" in
to a "valid/consistent" state in order for the alter table command to be 
processed.

A side effect of this is that if the database was invalid BEFORE you issue the 
alter table command, and it is still invalid after, that in the "validity" 
checking mode (the default), the alter table c
ommand will not be processed (since it will throw an error that the 
transformation did not result in a "valid" schema).

Correctly, you should either (a) drop view v1, or (b) create table t1 so that 
the database schema is consistent before you attempt to use ALTER TABLE. (Or, 
if you know that your schema is invalid, you
 can turn off validity checking with pragma LEGACY_ALTER_TABLE).  Since 
creating a view is nothing more than storing a statement in the database, it is 
not checked when you create a view or drop a tab
le that the schema is still valid (otherwise you would get a message of the 
form "Cannot drop table t1 because it is referenced in a view" or mayhaps view 
v1 would be dropped automatically).

Perhaps a setting "ALLOW_INVALID_SCHEMA" needs to be added such that after each 
DDL statement the schema is checked for validity and if it is not valid then 
the DDL is tossed with an error (such as oc
curs in SQLFat databases)?

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


Re: [sqlite] Getting the week of the month from strftime or date functions

2019-05-07 Thread Jose Isaias Cabrera

Warren Young, on Monday, May 6, 2019 09:15 PM, wrote...
On May 6, 2019, at 11:58 AM, Jose Isaias Cabrera wrote:
>> someday, as John Lennon sang, "...the world will live as one." ;-)
>
> Okay, but one *what*?  Serious question.

Yeah, if I have to explain it to you, then you miss the idea. :-) But here is 
something: you, one Warren Young, are composed of billions of living small 
living cells, all working to your well being. You are one. :-)

By the way, there will be a time when time will no longer be, but instead, 
we'll have eternity. :-) My personal believe, of course.

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


Re: [sqlite] Location of error in SQL statements ?

2019-05-07 Thread Rowan Worth
On Tue, 7 May 2019 at 16:00, Eric Grange  wrote:

> Is there are way to get more information about an SQL syntax error message
> ?
> For example on a largish SQL query I got the following error message
>
> near "on": syntax error
>
> but as the query is basically a long list of joins, this is not too helpful
> ;)
>

It's not clear from the docs whether this is guaranteed, but a quick look
at the code suggests that the pzTail argument (if provided to
sqlite3_prepare_v2) is also updated when there's a parse error. You might
be able to rely on that to infer how far through the statement the problem
lies.

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


[sqlite] Location of error in SQL statements ?

2019-05-07 Thread Eric Grange
Hi,

Is there are way to get more information about an SQL syntax error message ?
For example on a largish SQL query I got the following error message

near "on": syntax error

but as the query is basically a long list of joins, this is not too helpful
;)

Having a character offset, a line number or a larger code snippet would be
enough.

Best regards,
Eric
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] [EXTERNAL] Re: Getting the week of the month from strftime or date functions

2019-05-07 Thread Gary R. Schmidt

On 07/05/2019 16:46, Hick Gunter wrote:

Even the concept of "year" is subject to differing religious and cultural viewpoints, with some 
traditions still insisting on a lunar calendar with the corresponding shift of seasons by 11 days each year. 
And in one case, the length of a month depending on the weather conditions and the eyesight of the guy who 
happens to call the months. Pity the maya calendar didn't catch on. One "day number" wraparound 
every 4000 years sounds great (until you are the one who has to fix the coding that assumed it would 
"never happen")

Little known fact about the Mayan religion and calendar - you had to 
treat the "end" as really, really, being the end.


Their belief system was that the world would end at the end of a cycle, 
but they didn't know which one!  And if you got it wrong, the ghods 
would be very unhappy  :-(


So yes, it would "never happen"!!!

Cheers,
GaryB-)
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] [EXTERNAL] Re: Getting the week of the month from strftime or date functions

2019-05-07 Thread Hick Gunter
Even the concept of "year" is subject to differing religious and cultural 
viewpoints, with some traditions still insisting on a lunar calendar with the 
corresponding shift of seasons by 11 days each year. And in one case, the 
length of a month depending on the weather conditions and the eyesight of the 
guy who happens to call the months. Pity the maya calendar didn't catch on. One 
"day number" wraparound every 4000 years sounds great (until you are the one 
who has to fix the coding that assumed it would "never happen")

-Ursprüngliche Nachricht-
Von: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] Im 
Auftrag von Jens Alfke
Gesendet: Dienstag, 07. Mai 2019 05:36
An: SQLite mailing list 
Betreff: [EXTERNAL] Re: [sqlite] Getting the week of the month from strftime or 
date functions



> On May 6, 2019, at 6:15 PM, Warren Young  wrote:
>
> Ideas for fixing this aren’t new.

The French had a supremely utopian "Republican Calendar" that lasted from 1793 
to 1805 ("and for 18 days by the Paris Commune 
 in 1871" … such pathos in that 
little aside.)

> There were twelve months, each divided into three ten-day weeks called 
> décades. The tenth day, décadi, replaced Sunday as the day of rest and 
> festivity. The five or six extra days needed to approximate the solar or 
> tropical year were placed after the months at the end of each year and called 
> complementary days. … Each day in the Republican Calendar was divided into 
> ten hours, each hour into 100 decimal minutes, and each decimal minute into 
> 100 decimal seconds."

[https://en.wikipedia.org/wiki/French_Republican_calendar]

Face it, if they couldn't ram through a pointy-headed decimalized regularized 
calendar during the effin' *French Enlightenment*, it's certainly not going to 
work in the current dark ages.

Also relevant to this entire thread, since apparently a lot of people aren't 
aware of this stuff:

Falsehoods Programmers Believe About Time 

 (really a must-read for anyone dealing with dates and times) You Advocate An 
Approach To Calendar Reform; Your Idea Will Not Work; Here Is Why 
 (brutal takedown)

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


___
 Gunter Hick | Software Engineer | Scientific Games International GmbH | 
Klitschgasse 2-4, A-1130 Vienna | FN 157284 a, HG Wien, DVR: 0430013 | (O) +43 
1 80100 - 0

May be privileged. May be confidential. Please delete if not the addressee.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users