-C More\sbugs\sfixed\sfor\sviews.\s(CVS\s416)
-D 2002-03-03T23:06:01
+C Updates\sto\sthe\sdocumentation.\s\sChanged\sversion\snumber\sto\s2.4.0-beta1\s(CVS\s417)
+D 2002-03-04T02:26:16
F Makefile.in 50f1b3351df109b5774771350d8c1b8d3640130d
F Makefile.template 89e373b2dad0321df00400fa968dc14b61a03296
F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
-F VERSION 80c0f75cf7de338f1c6c31c07f5576d21f764431
+F VERSION bb1eea85a80e8034130db85d6c0857abe42c9460
F aclocal.m4 11faa843caa38fd451bc6aeb43e248d1723a269d
F config.guess f38b1e93d1e0fa6f5a6913e9e7b12774b9232588
F config.log 6a73d03433669b10a3f0c221198c3f26b9413914
F src/TODO af7f3cab0228e34149cf98e073aa83d45878e7e6
F src/btree.c d25ea795a0f7017bc2099c437e6cc01d4c31b22d
F src/btree.h 8abeabfe6e0b1a990b64fa457592a6482f6674f3
-F src/build.c 5b91d41cbeed1da348a43a8af3eb5a7ce5812673
+F src/build.c e11b0daa79ba894c7476c33372b1dc42b13471e6
F src/delete.c 577da499162291c1855f0b304b211bffcf9da945
F src/expr.c e12ca550536c0bae7a3acef49dfa3068fe5f0900
-F src/func.c 5b4d9707b0c8f463824c1f04547b524cba24bf7b
+F src/func.c 87516e7dc37190c24af77593931a5d09d797520a
F src/hash.c cc259475e358baaf299b00a2c7370f2b03dda892
F src/hash.h dca065dda89d4575f3176e75e9a3dc0f4b4fb8b9
F src/insert.c 42bfd145efd428d7e5f200dd49ea0b816fc30d79
F www/arch.fig d5f9752a4dbf242e9cfffffd3f5762b6c63b3bcf
F www/arch.png 82ef36db1143828a7abc88b1e308a5f55d4336f4
F www/arch.tcl 72a0c80e9054cc7025a50928d28d9c75c02c2b8b
-F www/c_interface.tcl 63efc40f09e2f0d8fea43d174103248b160fdf0e
-F www/changes.tcl 18df8bc8dbcefbfd9538ce476d4fcbc193ac3352
+F www/c_interface.tcl 567cda531aac9d68a61ef02e26c6b202bd856db2
+F www/changes.tcl cdd351b0f358bc23ca6243f3ca52c35ca1bede26
F www/conflict.tcl 81dd21f9a679e60aae049e9dd8ab53d59570cda2
F www/crosscompile.tcl 3622ebbe518927a3854a12de51344673eb2dd060
F www/download.tcl a6d75b8b117cd33dcb090bef7e80d7556d28ebe0
F www/dynload.tcl 02eb8273aa78cfa9070dd4501dca937fb22b466c
F www/faq.tcl c6d1d6d69a9083734ee73d1b5ee4253ae8f10074
-F www/formatchng.tcl 2d9a35c787823b48d72a5c64bb5414a43e26d5ad
+F www/formatchng.tcl 5cffc0ebd00b3085c976a527eeeef70db4ccc7a7
F www/index.tcl eacd99bcc3132d6e6b74a51422d415cc0bf7bfdf
-F www/lang.tcl 01e47b43cb81cd24bd2918a2e1bd31a959097279
+F www/lang.tcl db13f9a9c5ce7a400fa7ae021cd99dc6b05fd74a
F www/mingw.tcl f1c7c0a7f53387dd9bb4f8c7e8571b7561510ebc
F www/opcode.tcl bdec8ef9f100dbd87bbef8976c54b88e43fd8ccc
F www/speed.tcl 83457b2bf6bb430900bd48ca3dd98264d9a916a5
F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279
F www/tclsqlite.tcl 829b393d1ab187fd7a5e978631b3429318885c49
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P 6121e5ab9328c90c64d40ade3de73ad11d4aaf4e
-R 83a8a52daf3c29d4bf2f935e98a598c9
+P 813077623087ffc6cd506f57cf6d1e3d9239f806
+R fe676fb38cbe5a2068c89e56308a155d
U drh
-Z 8a99e2c5584a6641ebfdb027f72777c2
+Z 9a81a81e1e363e5bb6c841e14ddef308
-813077623087ffc6cd506f57cf6d1e3d9239f806
\ No newline at end of file
+36a8fe0ad0ee2a67afafc04125dcc085ec1b5a13
\ No newline at end of file
** ROLLBACK
** PRAGMA
**
-** $Id: build.c,v 1.83 2002/03/03 23:06:01 drh Exp $
+** $Id: build.c,v 1.84 2002/03/04 02:26:16 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
zTab = sqliteTableNameFromToken(pTableName);
if( sqlite_malloc_failed || zTab==0 ) goto copy_cleanup;
- pTab = sqliteFindTable(db, zTab);
+ pTab = sqliteTableNameToTable(pParse, zTab);
sqliteFree(zTab);
- if( pTab==0 ){
- sqliteSetNString(&pParse->zErrMsg, "no such table: ", 0,
- pTableName->z, pTableName->n, 0);
- pParse->nErr++;
- goto copy_cleanup;
- }
- if( pTab->readOnly ){
- sqliteSetString(&pParse->zErrMsg, "table ", pTab->zName,
- " may not be modified", 0);
- pParse->nErr++;
- goto copy_cleanup;
- }
+ if( pTab==0 ) goto copy_cleanup;
v = sqliteGetVdbe(pParse);
if( v ){
int openOp;
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
** All other code has file scope.
**
-** $Id: func.c,v 1.13 2002/03/02 19:00:31 drh Exp $
+** $Id: func.c,v 1.14 2002/03/04 02:26:16 drh Exp $
*/
#include <ctype.h>
#include <math.h>
double sum2; /* Sum of the squares of terms */
};
+#if 0 /* Omit because math library is required */
/*
** Routines used to compute the standard deviation as an aggregate.
*/
sqrt((p->sum2 - p->sum*p->sum/rN)/(rN-1.0)));
}
}
+#endif
/*
** The following structure keeps track of state information for the
{ "avg", 1, sumStep, avgFinalize },
{ "count", 0, countStep, countFinalize },
{ "count", 1, countStep, countFinalize },
+#if 0
{ "stddev", 1, stdDevStep, stdDevFinalize },
+#endif
};
int i;
#
# Run this Tcl script to generate the sqlite.html file.
#
-set rcsid {$Id: c_interface.tcl,v 1.24 2002/02/19 22:42:06 drh Exp $}
+set rcsid {$Id: c_interface.tcl,v 1.25 2002/03/04 02:26:17 drh Exp $}
puts {<html>
<head>
SQLite printf routines and the %q formatting option instead of <b>sprintf</b>.
</p>
+<h2>Adding New SQL Functions</h2>
+
+<p>Beginning with version 2.4.0, SQLite allows the SQL language to be
+extended with new functions implemented as C code. The following interface
+is used:
+</p>
+
+<blockquote><pre>
+typedef struct sqlite_func sqlite_func;
+
+int sqlite_create_function(
+ sqlite *db,
+ const char *zName,
+ int nArg,
+ void (*xFunc)(sqlite_func*,int,const char**),
+ void *pUserData
+);
+int sqlite_create_aggregate(
+ sqlite *db,
+ const char *zName,
+ int nArg,
+ void (*xStep)(sqlite_func*,int,const char**),
+ void (*xFinalize)(sqlite_func*),
+ void *pUserData
+);
+
+char *sqlite_set_result_string(sqlite_func*,const char*,int);
+void sqlite_set_result_int(sqlite_func*,int);
+void sqlite_set_result_double(sqlite_func*,double);
+void sqlite_set_result_error(sqlite_func*,const char*,int);
+
+void *sqlite_user_data(sqlite_func*);
+void *sqlite_aggregate_context(sqlite_func*, int nBytes);
+int sqlite_aggregate_count(sqlite_func*);
+</pre></blockquote>
+
+<p>
+The <b>sqlite_create_function()</b> interface is used to create
+regular functions and <b>sqlite_create_aggregate()</b> is used to
+create new aggregate functions. In both cases, the <b>db</b>
+parameter is an open SQLite database on which the functions should
+be registered, <b>zName</b> is the name of the new function,
+<b>nArg</b> is the number of arguments, and <b>pUserData</b> is
+a pointer which is passed through unchanged to the C implementation
+of the function.
+</p>
+
+<p>
+For regular functions, the <b>xFunc</b> callback is invoked once
+for each function call. The implementation of xFunc should call
+one of the <b>sqlite_set_result_...</b> interfaces to return its
+result. The <b>sqlite_user_data()</b> routine can be used to
+retrieve the <b>pUserData</b> pointer that was passed in when the
+function was registered.
+</p>
+
+<p>
+For aggregate functions, the <b>xStep</b> callback is invoked once
+for each row in the result and then <b>xFinalize</b> is invoked at the
+end to compute a final answer. The xStep routine can use the
+<b>sqlite_aggregate_context()</b> interface to allocate memory that
+will be unique to that particular instance of the SQL function.
+This memory will be automatically deleted after xFinalize is called.
+The <b>sqlite_aggregate_count()</b> routine can be used to find out
+how many rows of data were passed to the aggregate. The xFinalize
+callback should invoke one of the <b>sqlite_set_result_...</b>
+interfaces to set the final result of the aggregate.
+</p>
+
+<p>
+SQLite now implements all of its built-in functions using this
+interface. For additional information and examples on how to create
+new SQL functions, review the SQLite source code in the file
+<b>func.c</b>.
+</p>
+
<h2>Usage Examples</h2>
<p>For examples of how the SQLite C/C++ interface can be used,
puts "<DD><P><UL>$desc</UL></P></DD>"
}
-chng {2002 Feb * (2.3.4)} {
+chng {2002 Mar * (2.4.0)} {
<li>Change the name of the sanity_check PRAGMA to <b>integrity_check</b>
and make it available in all compiles.</li>
<li>SELECT min() or max() of an indexed column with no WHERE or GROUP BY
<li>Modifications to the "lemon" parser generator so that the parser tables
are 4 times smaller.</li>
<li>Added support for user-defined functions implemented in C.</li>
+<li>Added support for new functions: <b>coalesce()</b>, <b>lower()</b>,
+ <b>upper()</b>, and <b>random()</b>
<li>Added support for VIEWs.</li>
<li>Added the subquery flattening optimizer.</li>
+<li>Modified the B-Tree and Pager modules so that disk pages that do not
+ contain real data (free pages) are not journalled and are not
+ written from memory back to the disk when they change. This does not
+ impact database integrity, since the
+ pages contain no real data, but it does make large INSERT operations
+ about 2.5 times faster and large DELETEs about 5 times faster.</li>
}
chng {2002 Feb 18 (2.3.3)} {
#
# Run this Tcl script to generate the formatchng.html file.
#
-set rcsid {$Id: formatchng.tcl,v 1.2 2002/01/30 16:17:25 drh Exp $ }
+set rcsid {$Id: formatchng.tcl,v 1.3 2002/03/04 02:26:17 drh Exp $ }
puts {<html>
<head>
that are stored in the SQLITE_MASTER table. If you create a database that
contains this new syntax, then try to read that database using version 2.2.5
or earlier, the parser will not understand the new syntax and you will get
- an error. Otherwise, databases for 2.2.x and 2.3.x are interchangeable.</p>
+ an error. Otherwise, databases for 2.2.x and 2.3.x are interchangeable.</td>
+</tr>
+<tr>
+ <td valign="top">2.3.3 to 2.4.0</td>
+ <td valign="top">2002-Mar-?</td>
+ <td>Beginning with version 2.4.0, SQLite added support for views.
+ Information about views is stored in the SQLITE_MASTER table. If an older
+ version of SQLite attempts to read a database that contains VIEW information
+ in the SQLITE_MASTER table, the parser will not understand the new syntax
+ and you will get an error. Also, the
+ way SQLite keeps track of unused disk blocks in the database file
+ changed slightly.
+ If an older version of SQLite attempts to write a database that
+ was previously written by version 2.4.0 or later, then it may leak disk
+ blocks.</td>
</tr>
</table>
</blockquote>
#
# Run this Tcl script to generate the sqlite.html file.
#
-set rcsid {$Id: lang.tcl,v 1.26 2002/02/19 22:42:06 drh Exp $}
+set rcsid {$Id: lang.tcl,v 1.27 2002/03/04 02:26:17 drh Exp $}
puts {<html>
<head>
{{BEGIN TRANSACTION} transaction}
{PRAGMA pragma}
{{ON CONFLICT clause} conflict}
+ {{CREATE VIEW} createview}
+ {{DROP VIEW} dropview}
}] {
puts "<li><a href=\"#[lindex $section 1]\">[lindex $section 0]</a></li>"
}
</p>
}
+Section {CREATE VIEW} {createview}
+
+Syntax {sql-command} {
+CREATE VIEW <view-name> AS <select-statement>
+}
+
+puts {
+<p>The CREATE VIEW command assigns a name to a pre-packaged SELECT
+statement. Once the view is created, it can be used in the FROM clause
+of another SELECT in place of a table name.
+</p>
+
+<p>You cannot COPY, INSERT or UPDATE a view. Views are read-only.</p>
+}
+
Section DELETE delete
Syntax {sql-statement} {
the disk. The table can not be recovered. All indices associated with
the table are also deleted.</p>}
+Section {DROP VIEW} dropview
+
+Syntax {sql-command} {
+DROP VIEW <view-name>
+}
+
+puts {
+<p>The DROP VIEW statement consists of the keywords "DROP TABLE" followed
+by the name of the view. The view named is removed from the database.
+But no actual data is modified.</p>}
+
Section EXPLAIN explain
Syntax {sql-statement} {
<expression> NOTNULL |
<expression> [NOT] BETWEEN <expression> AND <expression> |
<expression> [NOT] IN ( <value-list> ) |
-<expression> [NOT] IN ( <select> ) |
-( <select> )
+<expression> [NOT] IN ( <select-statement> ) |
+( <select-statement> )
} {like-op} {
LIKE | GLOB | NOT LIKE | NOT GLOB
}
more than one result row, all rows after the first are ignored. If
the SELECT yeilds no rows, then the value of the SELECT is NULL.</p>
-<p>The expression syntax currently supports the following
-functions:</p>
-
-<blockquote><pre>
-<font color="#2c2cf0"><big>count min max sum
-avg length substr abs round</big></font>
-</pre></blockquote>
+<p>Both simple and aggregate functions are supported. A simple
+function can be used in any expression. Simple functions return
+a result immediately based on their inputs. Aggregate functions
+may only be used in a SELECT statement. Aggregate functions compute
+their result across all rows of the result set.</p>
+
+<p>The following simple functions are currently supported:</p>
+
+<table border=0 cellpadding=10>
+<tr>
+<td valign="top" align="right" width=120>abs(<i>X</i>)</td>
+<td valign="top">Return the absolute value of argument <i>X</i>.</td>
+</tr>
+
+<tr>
+<td valign="top" align="right">coelasce(<i>X</i>,<i>Y</i>,...)</td>
+<td valign="top">Return a copy of the first non-NULL argument. If
+all arguments are NULL then NULL is returned.</td>
+</tr>
+
+<tr>
+<td valign="top" align="right">length(<i>X</i>)</td>
+<td valign="top">Return the string length of <i>X</i> in characters.
+If SQLite is configured to support UTF-8, then the number of UTF-8
+characters is returned, not the number of bytes.</td>
+</tr>
+
+<tr>
+<td valign="top" align="right">lower(<i>X</i>)</td>
+<td valign="top">Return a copy of string <i>X</i> will all characters
+converted to lower case. The C library <b>tolower()</b> routine is used
+for the conversion, which means that this function might not
+work correctly on UTF-8 characters.</td>
+</tr>
+
+<tr>
+<td valign="top" align="right">max(<i>X</i>,<i>Y</i>,...)</td>
+<td valign="top">Return the argument with the maximum value. Arguments
+may be strings in addition to numbers. The maximum value is determined
+by the usual sort order. Note that <b>max()</b> is a simple function when
+it has 2 or more arguments but converts to an aggregate function if given
+only a single argument.</td>
+</tr>
+
+<tr>
+<td valign="top" align="right">min(<i>X</i>,<i>Y</i>,...)</td>
+<td valign="top">Return the argument with the minimum value. Arguments
+may be strings in addition to numbers. The mminimum value is determined
+by the usual sort order. Note that <b>min()</b> is a simple function when
+it has 2 or more arguments but converts to an aggregate function if given
+only a single argument.</td>
+</tr>
+
+<tr>
+<td valign="top" align="right">random(*)</td>
+<td valign="top">Return a random integer between -2147483648 and
++2147483647.</td>
+</tr>
+
+<tr>
+<td valign="top" align="right">round(<i>X</i>)<br>round(<i>X</i>,<i>Y</i>)</td>
+<td valign="top">Round off the number <i>X</i> to <i>Y</i> digits to the
+right of the decimal point. If the <i>Y</i> argument is omitted, 0 is
+assumed.</td>
+</tr>
+
+<tr>
+<td valign="top" align="right">subst(<i>X</i>,<i>Y</i>,<i>Z</i>)</td>
+<td valign="top">Return a substring of input string <i>X</i> that begins
+with the <i>Y</i>-th character and which is <i>Z</i> characters long.
+The left-most character of <i>X</i> is number 1. If <i>Y</i> is negative
+the the first character of the substring is found by counting from the
+right rather than the left. If SQLite is configured to support UTF-8,
+then characters indices refer to actual UTF-8 characters, not bytes.</td>
+</tr>
+
+<tr>
+<td valign="top" align="right">upper(<i>X</i>)</td>
+<td valign="top">Return a copy of input string <i>X</i> converted to all
+upper-case letters. The implementation of this function uses the C library
+routine <b>toupper()</b> which means it may not work correctly on
+UTF-8 strings.</td>
+</tr>
+</table>
<p>
-The functions <b>count</b>, <b>sum</b>, and <b>avg</b> and the functions
-<b>min</b> and <b>max</b> used with only one argument are all aggregate
-functions. This means that they are computed across all rows of the result.
-The functions <b>min</b> and <b>max</b>
-with two or more arguments and all other functions
-are non-aggregates. Non-aggregate functions
-are computed separately for each row of the result.
+The following aggregate functions are supported:
</p>
-<p>
-The <b>round</b> function can take either 1 or 2 arguments. The
-first argument is the floating point value that is rounded. The
-second argument is the number of digits to the right of the
-decimal point to preserve. If the second argument is omitted,
-zero is assumed. So round(1.23456,2) is 1.23 and
-round(12.34,0) and round(12.34) both evaluate to 12.
-</p>
-
-<p>
-The "<b>count(*)</b>" syntax is supported but
-"<b>count(distinct</b> <i>COLUMN-NAME</i><b>)</b>" is not.
-</p>
+<table border=0 cellpadding=10>
+<tr>
+<td valign="top" align="right" width=120>avg(<i>X</i>)</td>
+<td valign="top">Return the average value of all <i>X</i> within a group.</td>
+</tr>
+
+<tr>
+<td valign="top" align="right">count(<i>X</i>)<br>count(*)</td>
+<td valign="top">The first form return a count of the number of times
+that <i>X</i> is not NULL in a group. The second form (with no argument)
+returns the total number of rows in the group.</td>
+</tr>
+
+<tr>
+<td valign="top" align="right">max(<i>X</i>)</td>
+<td valign="top">Return the maximum value of all values in the group.
+The usual sort order is used to determine the maximum.</td>
+</tr>
+
+<tr>
+<td valign="top" align="right">min(<i>X</i>)</td>
+<td valign="top">Return the minimum value of all values in the group.
+The usual sort order is used to determine the minimum.</td>
+</tr>
+
+<tr>
+<td valign="top" align="right">sum(<i>X</i>)</td>
+<td valign="top">Return the numeric sum of all values in the group.</td>
+</tr>
+</table>
}
Section INSERT insert