Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Bug fix in date/time computations. Ticket #1964. Some unrelated comment typos are also fixed and got accidently checked in at the same time. (CVS 3396) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
c81eaa0dc9a327d222e066076c4a2da5 |
User & Date: | drh 2006-09-08 12:27:37.000 |
Context
2006-09-08
| ||
12:49 | Add HAVE_GMTIME_R and HAVE_LOCALTIME_R flags and use them if defined. Unable to modify the configure script to test for gmtime_r and localtime_r, however, because on my SuSE 10.2 system, autoconf generates a configure script that does not work. Bummer. Ticket #1906 (CVS 3397) (check-in: 862302eaae user: drh tags: trunk) | |
12:27 | Bug fix in date/time computations. Ticket #1964. Some unrelated comment typos are also fixed and got accidently checked in at the same time. (CVS 3396) (check-in: c81eaa0dc9 user: drh tags: trunk) | |
11:56 | Improvements to the documentation of the return codes for sqlite3_step(). Tickets #1633, #1366, #1178, #906, and probably others too. (CVS 3395) (check-in: 508248e783 user: drh tags: trunk) | |
Changes
Changes to src/alter.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that used to generate VDBE code ** that implements the ALTER TABLE command. ** | | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This file contains C code routines that used to generate VDBE code ** that implements the ALTER TABLE command. ** ** $Id: alter.c,v 1.22 2006/09/08 12:27:37 drh Exp $ */ #include "sqliteInt.h" #include <ctype.h> /* ** The code in this file only exists if we are not omitting the ** ALTER TABLE logic from the build. */ #ifndef SQLITE_OMIT_ALTERTABLE /* ** This function is used by SQL generated to implement the ** ALTER TABLE command. The first argument is the text of a CREATE TABLE or ** CREATE INDEX command. The second is a table name. The table name in ** the CREATE TABLE or CREATE INDEX statement is replaced with the third ** argument and the result returned. Examples: ** ** sqlite_rename_table('CREATE TABLE abc(a, b, c)', 'def') ** -> 'CREATE TABLE def(a, b, c)' ** ** sqlite_rename_table('CREATE INDEX i ON abc(a)', 'def') ** -> 'CREATE INDEX i ON def(a, b, c)' |
︙ | ︙ | |||
74 75 76 77 78 79 80 | zRet = sqlite3MPrintf("%.*s%Q%s", tname.z - zSql, zSql, zTableName, tname.z+tname.n); sqlite3_result_text(context, zRet, -1, sqlite3FreeX); } } #ifndef SQLITE_OMIT_TRIGGER | | | | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | zRet = sqlite3MPrintf("%.*s%Q%s", tname.z - zSql, zSql, zTableName, tname.z+tname.n); sqlite3_result_text(context, zRet, -1, sqlite3FreeX); } } #ifndef SQLITE_OMIT_TRIGGER /* This function is used by SQL generated to implement the ** ALTER TABLE command. The first argument is the text of a CREATE TRIGGER ** statement. The second is a table name. The table name in the CREATE ** TRIGGER statement is replaced with the third argument and the result ** returned. This is analagous to renameTableFunc() above, except for CREATE ** TRIGGER, not CREATE INDEX and CREATE TABLE. */ static void renameTriggerFunc( sqlite3_context *context, int argc, sqlite3_value **argv |
︙ | ︙ |
Changes to src/date.c.
︙ | ︙ | |||
12 13 14 15 16 17 18 | ** This file contains the C functions that implement date and time ** functions for SQLite. ** ** There is only one exported symbol in this file - the function ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file. ** All other code has file scope. ** | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ** This file contains the C functions that implement date and time ** functions for SQLite. ** ** There is only one exported symbol in this file - the function ** sqlite3RegisterDateTimeFunctions() found at the bottom of the file. ** All other code has file scope. ** ** $Id: date.c,v 1.55 2006/09/08 12:27:37 drh Exp $ ** ** NOTES: ** ** SQLite processes all times and dates as Julian Day numbers. The ** dates and times are stored as the number of days since noon ** in Greenwich on November 24, 4714 B.C. according to the Gregorian ** calendar system. |
︙ | ︙ | |||
230 231 232 233 234 235 236 | } A = Y/100; B = 2 - A + (A/4); X1 = 365.25*(Y+4716); X2 = 30.6001*(M+1); p->rJD = X1 + X2 + D + B - 1524.5; p->validJD = 1; | < > | 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | } A = Y/100; B = 2 - A + (A/4); X1 = 365.25*(Y+4716); X2 = 30.6001*(M+1); p->rJD = X1 + X2 + D + B - 1524.5; p->validJD = 1; if( p->validHMS ){ p->rJD += (p->h*3600.0 + p->m*60.0 + p->s)/86400.0; if( p->validTZ ){ p->rJD -= p->tz*60/86400.0; p->validYMD = 0; p->validHMS = 0; p->validTZ = 0; } } } /* |
︙ | ︙ | |||
353 354 355 356 357 358 359 360 361 362 363 364 365 366 | /* ** Compute the Hour, Minute, and Seconds from the julian day number. */ static void computeHMS(DateTime *p){ int Z, s; if( p->validHMS ) return; Z = p->rJD + 0.5; s = (p->rJD + 0.5 - Z)*86400000.0 + 0.5; p->s = 0.001*s; s = p->s; p->s -= s; p->h = s/3600; s -= p->h*3600; | > | 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | /* ** Compute the Hour, Minute, and Seconds from the julian day number. */ static void computeHMS(DateTime *p){ int Z, s; if( p->validHMS ) return; computeJD(p); Z = p->rJD + 0.5; s = (p->rJD + 0.5 - Z)*86400000.0 + 0.5; p->s = 0.001*s; s = p->s; p->s -= s; p->h = s/3600; s -= p->h*3600; |
︙ | ︙ | |||
577 578 579 580 581 582 583 | computeJD(&tx); tx.rJD -= 0.5; day = (int)tx.rJD; tx.rJD -= day; if( z[0]=='-' ) tx.rJD = -tx.rJD; computeJD(p); clearYMD_HMS_TZ(p); | | | 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 | computeJD(&tx); tx.rJD -= 0.5; day = (int)tx.rJD; tx.rJD -= day; if( z[0]=='-' ) tx.rJD = -tx.rJD; computeJD(p); clearYMD_HMS_TZ(p); p->rJD += tx.rJD; rc = 0; break; } z += n; while( isspace(*(u8*)z) ) z++; n = strlen(z); if( n>10 || n<3 ) break; |
︙ | ︙ |
Changes to test/date.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # 2003 October 31 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing date and time functions. # | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # 2003 October 31 # # The author disclaims copyright to this source code. In place of # a legal notice, here is a blessing: # # May you do good and not evil. # May you find forgiveness for yourself and forgive others. # May you share freely, never taking more than you give. # #*********************************************************************** # This file implements regression tests for SQLite library. The # focus of this file is testing date and time functions. # # $Id: date.test,v 1.16 2006/09/08 12:27:37 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl # Skip this whole file if date and time functions are omitted # at compile-time # |
︙ | ︙ | |||
269 270 271 272 273 274 275 | {2004-02-28 08:01:00} datetest 11.8 {datetime('2004-02-28 20:00:00', '11:59')} \ {2004-02-29 07:59:00} datetest 11.9 {datetime('2004-02-28 20:00:00', '12:01')} \ {2004-02-29 08:01:00} datetest 11.10 {datetime('2004-02-28 20:00:00', '12:60')} NULL | | | > | 269 270 271 272 273 274 275 276 277 278 279 280 | {2004-02-28 08:01:00} datetest 11.8 {datetime('2004-02-28 20:00:00', '11:59')} \ {2004-02-29 07:59:00} datetest 11.9 {datetime('2004-02-28 20:00:00', '12:01')} \ {2004-02-29 08:01:00} datetest 11.10 {datetime('2004-02-28 20:00:00', '12:60')} NULL # Ticket #1964 datetest 12.1 {datetime('2005-09-01')} {2005-09-01 00:00:00} datetest 12.2 {datetime('2005-09-01','+0 hours')} {2005-09-01 00:00:00} finish_test |