/ Check-in [80ee166e]
Login

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

Overview
Comment::-) (CVS 65)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 80ee166ed1bb3694530a73c57544cb4d16964884
User & Date: drh 2000-06-07 00:12:25
Context
2000-06-07
01:27
:-) (CVS 66) check-in: 5d2e72e4 user: drh tags: trunk
00:12
:-) (CVS 65) check-in: 80ee166e user: drh tags: trunk
2000-06-06
22:19
:-) (CVS 64) check-in: 3a2f4dca user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

    20     20   **   drh@hwaci.com
    21     21   **   http://www.hwaci.com/drh/
    22     22   **
    23     23   *************************************************************************
    24     24   ** This file contains code to implement the "sqlite" command line
    25     25   ** utility for accessing SQLite databases.
    26     26   **
    27         -** $Id: shell.c,v 1.8 2000/06/05 02:07:04 drh Exp $
           27  +** $Id: shell.c,v 1.9 2000/06/07 00:12:25 drh Exp $
    28     28   */
    29     29   #include <stdlib.h>
    30     30   #include <string.h>
    31     31   #include <stdio.h>
    32     32   #include "sqlite.h"
    33     33   #include <unistd.h>
    34     34   #include <ctype.h>
................................................................................
   361    361       struct callback_data data;
   362    362       char *zErrMsg = 0;
   363    363       char zSql[1000];
   364    364       memcpy(&data, p, sizeof(data));
   365    365       data.showHeader = 0;
   366    366       data.mode = MODE_List;
   367    367       if( nArg>1 ){
   368         -      sprintf(zSql, "SELECT sql FROM sqlite_master WHERE name LIKE '%.900s'",
          368  +      sprintf(zSql, "SELECT sql FROM sqlite_master "
          369  +                    "WHERE tbl_name LIKE '%.800s'"
          370  +                    "ORDER BY type DESC, name",
   369    371            azArg[1]);
   370    372       }else{
   371    373         sprintf(zSql, "SELECT sql FROM sqlite_master "
   372    374            "ORDER BY tbl_name, type DESC, name");
   373    375       }
   374    376       sqlite_exec(db, zSql, callback, &data, &zErrMsg);
   375    377       if( zErrMsg ){

Changes to src/vdbe.c.

    37     37   ** inplicit conversion from one type to the other occurs as necessary.
    38     38   ** 
    39     39   ** Most of the code in this file is taken up by the sqliteVdbeExec()
    40     40   ** function which does the work of interpreting a VDBE program.
    41     41   ** But other routines are also provided to help in building up
    42     42   ** a program instruction by instruction.
    43     43   **
    44         -** $Id: vdbe.c,v 1.24 2000/06/06 22:13:55 drh Exp $
           44  +** $Id: vdbe.c,v 1.25 2000/06/07 00:12:25 drh Exp $
    45     45   */
    46     46   #include "sqliteInt.h"
    47     47   #include <unistd.h>
    48     48   
    49     49   /*
    50     50   ** SQL is translated into a sequence of instructions to be
    51     51   ** executed by a virtual machine.  Each instruction is an instance
................................................................................
  2371   2371           for(i=p->tos-nField+1; i<=p->tos; i++){
  2372   2372             if( Stringify(p, i) ) goto no_mem;
  2373   2373             nByte += p->aStack[i].n+2;
  2374   2374           }
  2375   2375           zNewKey = sqliteMalloc( nByte );
  2376   2376           if( zNewKey==0 ) goto no_mem;
  2377   2377           j = 0;
  2378         -        k = nField-1;
         2378  +        k = 0;
  2379   2379           for(i=p->tos-nField+1; i<=p->tos; i++){
  2380         -          zNewKey[j++] = pOp->p3[k--];
         2380  +          zNewKey[j++] = pOp->p3[k++];
  2381   2381             memcpy(&zNewKey[j], p->zStack[i], p->aStack[i].n-1);
  2382   2382             j += p->aStack[i].n-1;
  2383   2383             zNewKey[j++] = 0;
  2384   2384           }
  2385   2385           zNewKey[j] = 0;
  2386   2386           PopStack(p, nField);
  2387   2387           NeedStack(p, p->tos+1);

Added test/sort.test.

            1  +# Copyright (c) 1999, 2000 D. Richard Hipp
            2  +#
            3  +# This program is free software; you can redistribute it and/or
            4  +# modify it under the terms of the GNU General Public
            5  +# License as published by the Free Software Foundation; either
            6  +# version 2 of the License, or (at your option) any later version.
            7  +#
            8  +# This program is distributed in the hope that it will be useful,
            9  +# but WITHOUT ANY WARRANTY; without even the implied warranty of
           10  +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
           11  +# General Public License for more details.
           12  +# 
           13  +# You should have received a copy of the GNU General Public
           14  +# License along with this library; if not, write to the
           15  +# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
           16  +# Boston, MA  02111-1307, USA.
           17  +#
           18  +# Author contact information:
           19  +#   drh@hwaci.com
           20  +#   http://www.hwaci.com/drh/
           21  +#
           22  +#***********************************************************************
           23  +# This file implements regression tests for SQLite library.  The
           24  +# focus of this file is testing the CREATE TABLE statement.
           25  +#
           26  +# $Id: sort.test,v 1.1 2000/06/07 00:12:25 drh Exp $
           27  +
           28  +set testdir [file dirname $argv0]
           29  +source $testdir/tester.tcl
           30  +
           31  +# Create a bunch of data to sort against
           32  +#
           33  +do_test sort-1.0 {
           34  +  set fd [open data.txt w]
           35  +  puts $fd "1\tone\t0\tI\t3.141592653"
           36  +  puts $fd "2\ttwo\t1\tII\t2.15"
           37  +  puts $fd "3\tthree\t1\tIII\t4221.0"
           38  +  puts $fd "4\tfour\t2\tIV\t-0.0013442"
           39  +  puts $fd "5\tfive\t2\tV\t-11"
           40  +  puts $fd "6\tsix\t2\tVI\t0.123"
           41  +  puts $fd "7\tseven\t2\tVII\t123.0"
           42  +  puts $fd "8\teight\t3\tVIII\t-1.6"
           43  +  close $fd
           44  +  execsql {
           45  +    CREATE TABLE t1(
           46  +       n int,
           47  +       v varchar(10),
           48  +       log int,
           49  +       roman varchar(10),
           50  +       flt real
           51  +    );
           52  +    COPY t1 FROM 'data.txt'
           53  +  }
           54  +  file delete data.txt
           55  +  execsql {SELECT count(*) FROM t1}
           56  +} {8}
           57  +
           58  +do_test sort-1.1 {
           59  +  execsql {SELECT n FROM t1 ORDER BY n}
           60  +} {1 2 3 4 5 6 7 8}
           61  +do_test sort-1.2 {
           62  +  execsql {SELECT n FROM t1 ORDER BY n DESC}
           63  +} {8 7 6 5 4 3 2 1}
           64  +do_test sort-1.3a {
           65  +  execsql {SELECT v FROM t1 ORDER BY v}
           66  +} {eight five four one seven six three two}
           67  +do_test sort-1.3b {
           68  +  execsql {SELECT n FROM t1 ORDER BY v}
           69  +} {8 5 4 1 7 6 3 2}
           70  +do_test sort-1.4 {
           71  +  execsql {SELECT n FROM t1 ORDER BY v DESC}
           72  +} {2 3 6 7 1 4 5 8}
           73  +do_test sort-1.5 {
           74  +  execsql {SELECT flt FROM t1 ORDER BY flt}
           75  +} {-11 -1.6 -0.0013442 0.123 2.15 3.141592653 123.0 4221.0}
           76  +do_test sort-1.6 {
           77  +  execsql {SELECT flt FROM t1 ORDER BY flt DESC}
           78  +} {4221.0 123.0 3.141592653 2.15 0.123 -0.0013442 -1.6 -11}
           79  +do_test sort-1.7 {
           80  +  execsql {SELECT roman FROM t1 ORDER BY roman}
           81  +} {I II III IV V VI VII VIII}
           82  +do_test sort-1.8 {
           83  +  execsql {SELECT n FROM t1 ORDER BY log, flt}
           84  +} {1 2 3 5 4 6 7 8}
           85  +do_test sort-1.9 {
           86  +  execsql {SELECT n FROM t1 ORDER BY log, flt DESC}
           87  +} {1 3 2 7 6 4 5 8}
           88  +do_test sort-1.10 {
           89  +  execsql {SELECT n FROM t1 ORDER BY log DESC, flt}
           90  +} {8 5 4 6 7 2 3 1}
           91  +do_test sort-1.11 {
           92  +  execsql {SELECT n FROM t1 ORDER BY log DESC, flt DESC}
           93  +} {8 7 6 4 5 3 2 1}
           94  +
           95  +finish_test