SQLite

Check-in [ef0d5ebe96]
Login

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

Overview
Comment:Correct handling of views on tables with quoted column names. Ticket #756. (CVS 1827)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | version_2
Files: files | file ages | folders
SHA1: ef0d5ebe96b9babe275d62ed6abe95652838de5f
User & Date: drh 2004-07-20 00:20:47.000
Context
2004-07-20
00:40
Comment out all of date/time functions with SQLITE_OMIT_DATETIME_FUNCS. Ticket #784. (CVS 1829) (check-in: 28c01d2ac7 user: drh tags: version_2)
00:20
Correct handling of views on tables with quoted column names. Ticket #756. (CVS 1827) (check-in: ef0d5ebe96 user: drh tags: version_2)
2004-07-19
23:33
Limit occurs after DISTINCT. Ticket #749. (CVS 1824) (check-in: db5ae13db3 user: drh tags: version_2)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/select.c.
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
**    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.161.2.2 2004/07/19 23:33:03 drh Exp $
*/
#include "sqliteInt.h"


/*
** Allocate a new Select structure and return a pointer to that
** structure.







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
**    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.161.2.3 2004/07/20 00:20:47 drh Exp $
*/
#include "sqliteInt.h"


/*
** Allocate a new Select structure and return a pointer to that
** structure.
821
822
823
824
825
826
827
828
829

830
831
832
833
834
835
836
        }
      }
    }else if( p->span.z && p->span.z[0] ){
      sqliteSetNString(&pTab->aCol[i].zName, p->span.z, p->span.n, 0);
    }else{
      char zBuf[30];
      sprintf(zBuf, "column%d", i+1);
      pTab->aCol[i].zName = sqliteStrDup(zBuf);
    }

  }
  pTab->iPKey = -1;
  return pTab;
}

/*
** For the given SELECT statement, do three things.







|

>







821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
        }
      }
    }else if( p->span.z && p->span.z[0] ){
      sqliteSetNString(&pTab->aCol[i].zName, p->span.z, p->span.n, 0);
    }else{
      char zBuf[30];
      sprintf(zBuf, "column%d", i+1);
      aCol[i].zName = sqliteStrDup(zBuf);
    }
    sqliteDequote(aCol[i].zName);
  }
  pTab->iPKey = -1;
  return pTab;
}

/*
** For the given SELECT statement, do three things.
Changes to test/view.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2002 February 26
#
# 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 VIEW statements.
#
# $Id: view.test,v 1.16 2003/05/31 16:21:13 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl

do_test view-1.0 {
  execsql {
    CREATE TABLE t1(a,b,c);
    INSERT INTO t1 VALUES(1,2,3);













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2002 February 26
#
# 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 VIEW statements.
#
# $Id: view.test,v 1.16.2.1 2004/07/20 00:20:47 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl

do_test view-1.0 {
  execsql {
    CREATE TABLE t1(a,b,c);
    INSERT INTO t1 VALUES(1,2,3);
380
381
382
383
384
385
386


















387
388
389
  }
} {5 1 4 2 3 4}
do_test view-9.6 {
  execsql {
    SELECT * FROM v10 ORDER BY 1;
  }
} {3 4 4 2 5 1}




















finish_test







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
  }
} {5 1 4 2 3 4}
do_test view-9.6 {
  execsql {
    SELECT * FROM v10 ORDER BY 1;
  }
} {3 4 4 2 5 1}

# Tables with columns having peculiar quoted names used in views
# Ticket #756.
#
do_test view-10.1 {
  execsql {
    CREATE TABLE t3("9" integer, [4] text);
    INSERT INTO t3 VALUES(1,2);
    CREATE VIEW v_t3_a AS SELECT a.[9] FROM t3 AS a;
    CREATE VIEW v_t3_b AS SELECT "4" FROM t3;
    SELECT * FROM v_t3_a;
  }
} {1}
do_test view-10.2 {
  execsql {
    SELECT * FROM v_t3_b;
  }
} {2}


finish_test