/ Check-in [e80afe75]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Minor follow-on changes to the recent ATTACH patch. (CVS 892)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e80afe75b33d4eacb40ef6128cf688f7c3253984
User & Date: drh 2003-03-31 13:36:08
Original User & Date: drh 2003-03-31 13:36:09
Context
2003-03-31
13:36
Minor follow-on changes to the recent ATTACH patch. (CVS 893) check-in: 11378c5b user: drh tags: trunk
13:36
Minor follow-on changes to the recent ATTACH patch. (CVS 892) check-in: e80afe75 user: drh tags: trunk
02:12
Add the sqliteErrorMsg() function and use it to generate error message text during parsing and code generation. This simplifies the code somewhat and makes it easier to handle names with a database prefix. (CVS 891) check-in: 1d3fc977 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/build.c.

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
....
2666
2667
2668
2669
2670
2671
2672





2673
2674
2675
2676
2677
2678
2679
**     COPY
**     VACUUM
**     BEGIN TRANSACTION
**     COMMIT
**     ROLLBACK
**     PRAGMA
**
** $Id: build.c,v 1.138 2003/03/31 02:12:47 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** This routine is called when a new SQL statement is beginning to
** be parsed.  Check to see if the schema for the database needs
................................................................................
  Db *aNew;
  int rc, i;
  char *zFile, *zName;
  sqlite *db;

  if( pParse->explain ) return;
  db = pParse->db;





  if( db->aDb==db->aDbStatic ){
    aNew = sqliteMalloc( sizeof(db->aDb[0])*3 );
    if( aNew==0 ) return;
    memcpy(aNew, db->aDb, sizeof(db->aDb[0])*2);
  }else{
    aNew = sqliteRealloc(db->aDb, sizeof(db->aDb[0])*(db->nDb+1) );
    if( aNew==0 ) return;







|







 







>
>
>
>
>







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
....
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
**     COPY
**     VACUUM
**     BEGIN TRANSACTION
**     COMMIT
**     ROLLBACK
**     PRAGMA
**
** $Id: build.c,v 1.139 2003/03/31 13:36:09 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>

/*
** This routine is called when a new SQL statement is beginning to
** be parsed.  Check to see if the schema for the database needs
................................................................................
  Db *aNew;
  int rc, i;
  char *zFile, *zName;
  sqlite *db;

  if( pParse->explain ) return;
  db = pParse->db;
  if( db->nDb>=MAX_ATTACHED ){
    sqliteErrorMsg(pParse, "too many attached databases - max %d", 
       MAX_ATTACHED);
    return;
  }
  if( db->aDb==db->aDbStatic ){
    aNew = sqliteMalloc( sizeof(db->aDb[0])*3 );
    if( aNew==0 ) return;
    memcpy(aNew, db->aDb, sizeof(db->aDb[0])*2);
  }else{
    aNew = sqliteRealloc(db->aDb, sizeof(db->aDb[0])*(db->nDb+1) );
    if( aNew==0 ) return;

Changes to src/select.c.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
**    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 are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.129 2003/03/31 02:12:47 drh Exp $
*/
#include "sqliteInt.h"


/*
** Allocate a new Select structure and return a pointer to that
** structure.
................................................................................
**
**  (11)  The subquery and the outer query do not both have ORDER BY clauses.
**
** In this routine, the "p" parameter is a pointer to the outer query.
** The subquery is p->pSrc->a[iFrom].  isAgg is true if the outer query
** uses aggregates and subqueryIsAgg is true if the subquery uses aggregates.
**
** If flattening is not attempted, this routine is a no-op and return 0.
** If flattening is attempted this routine returns 1.
**
** All of the expression analysis must occur on both the outer query and
** the subquery before this routine runs.
*/
static int flattenSubquery(
  Parse *pParse,       /* The parsing context */







|







 







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
....
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
**    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 are called by the parser
** to handle SELECT statements in SQLite.
**
** $Id: select.c,v 1.130 2003/03/31 13:36:09 drh Exp $
*/
#include "sqliteInt.h"


/*
** Allocate a new Select structure and return a pointer to that
** structure.
................................................................................
**
**  (11)  The subquery and the outer query do not both have ORDER BY clauses.
**
** In this routine, the "p" parameter is a pointer to the outer query.
** The subquery is p->pSrc->a[iFrom].  isAgg is true if the outer query
** uses aggregates and subqueryIsAgg is true if the subquery uses aggregates.
**
** If flattening is not attempted, this routine is a no-op and returns 0.
** If flattening is attempted this routine returns 1.
**
** All of the expression analysis must occur on both the outer query and
** the subquery before this routine runs.
*/
static int flattenSubquery(
  Parse *pParse,       /* The parsing context */

Changes to src/sqliteInt.h.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
53
54
55
56
57
58
59








60
61
62
63
64
65
66
**    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.
**
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.168 2003/03/31 02:12:48 drh Exp $
*/
#include "config.h"
#include "sqlite.h"
#include "hash.h"
#include "vdbe.h"
#include "parse.h"
#include "btree.h"
................................................................................
** If the following macro is set to 0, the NULLs are indistinct for
** a UNIQUE index.  In this mode, you can only have a single NULL entry
** for a column declared UNIQUE.  This is the way Informix and SQL Server
** work.
*/
#define NULL_DISTINCT_FOR_UNIQUE 1









/*
** Integers of known sizes.  These typedefs might change for architectures
** where the sizes very.  Preprocessor macros are available so that the
** types can be conveniently redefined at compile-type.  Like this:
**
**         cc '-DUINTPTR_TYPE=long long int' ...
*/







|







 







>
>
>
>
>
>
>
>







7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
..
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
**    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.
**
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.169 2003/03/31 13:36:09 drh Exp $
*/
#include "config.h"
#include "sqlite.h"
#include "hash.h"
#include "vdbe.h"
#include "parse.h"
#include "btree.h"
................................................................................
** If the following macro is set to 0, the NULLs are indistinct for
** a UNIQUE index.  In this mode, you can only have a single NULL entry
** for a column declared UNIQUE.  This is the way Informix and SQL Server
** work.
*/
#define NULL_DISTINCT_FOR_UNIQUE 1

/*
** The maximum number of attached databases.  This must be at least 2
** in order to support the main database file (0) and the file used to
** hold temporary tables (1).  And it must be less than 256 because the
** an unsigned character is used to stored the database index.
*/
#define MAX_ATTACHED 10

/*
** Integers of known sizes.  These typedefs might change for architectures
** where the sizes very.  Preprocessor macros are available so that the
** types can be conveniently redefined at compile-type.  Like this:
**
**         cc '-DUINTPTR_TYPE=long long int' ...
*/

Changes to src/util.c.

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
...
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
**
*************************************************************************
** Utility functions used throughout sqlite.
**
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.59 2003/03/31 02:12:48 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
#include <ctype.h>

/*
** If malloc() ever fails, this global variable gets set to 1.
................................................................................
  char *z;
  static char zNull[] = "NULL";

  pParse->nErr++;
  nByte = 1 + strlen(zFormat);
  va_start(ap, zFormat);
  for(i=0; zFormat[i]; i++){
    if( zFormat[i]!='%' && zFormat[i+1] ) continue;
    i++;
    switch( zFormat[i] ){
      case 'd': {
        (void)va_arg(ap, int);
        nByte += 20;
        break;
      }
................................................................................
  va_end(ap);
  z = sqliteMalloc( nByte );
  if( z==0 ) return;
  sqliteFree(pParse->zErrMsg);
  pParse->zErrMsg = z;
  va_start(ap, zFormat);
  for(i=j=0; zFormat[i]; i++){
    if( zFormat[i]!='%' ) continue;
    if( i>j ){
      memcpy(z, &zFormat[j], i-j);
      z += i-j;
    }
    j = i+2;
    i++;
    switch( zFormat[i] ){







|







 







|







 







|







10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
...
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
...
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
**
*************************************************************************
** Utility functions used throughout sqlite.
**
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.60 2003/03/31 13:36:09 drh Exp $
*/
#include "sqliteInt.h"
#include <stdarg.h>
#include <ctype.h>

/*
** If malloc() ever fails, this global variable gets set to 1.
................................................................................
  char *z;
  static char zNull[] = "NULL";

  pParse->nErr++;
  nByte = 1 + strlen(zFormat);
  va_start(ap, zFormat);
  for(i=0; zFormat[i]; i++){
    if( zFormat[i]!='%' || zFormat[i+1]==0 ) continue;
    i++;
    switch( zFormat[i] ){
      case 'd': {
        (void)va_arg(ap, int);
        nByte += 20;
        break;
      }
................................................................................
  va_end(ap);
  z = sqliteMalloc( nByte );
  if( z==0 ) return;
  sqliteFree(pParse->zErrMsg);
  pParse->zErrMsg = z;
  va_start(ap, zFormat);
  for(i=j=0; zFormat[i]; i++){
    if( zFormat[i]!='%' || zFormat[i+1]==0 ) continue;
    if( i>j ){
      memcpy(z, &zFormat[j], i-j);
      z += i-j;
    }
    j = i+2;
    i++;
    switch( zFormat[i] ){