]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
The name of a result column is now the name of column it originated from, by
authordrh <drh@noemail.net>
Fri, 20 Feb 2004 14:50:58 +0000 (14:50 +0000)
committerdrh <drh@noemail.net>
Fri, 20 Feb 2004 14:50:58 +0000 (14:50 +0000)
default.  This can be turned off with PRAGMA short_column_names=OFF.  This
is to be more like PostgreSQL.  More testing needed. (CVS 1250)

FossilOrigin-Name: 574dd444e7ff00e0fccc3436fe617ad832daae40

manifest
manifest.uuid
src/main.c
src/pragma.c
src/select.c
src/sqliteInt.h

index 1a427a899b92c6a70381131c5b7cb6b525bbfee3..16e3cb805537369fa8d7ef915bb694bc259c12f6 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\sbug\sin\sthe\sparser\stable\scompression\salgorithm\sof\slemon.\s(CVS\s1249)
-D 2004-02-19T18:41:53
+C The\sname\sof\sa\sresult\scolumn\sis\snow\sthe\sname\sof\scolumn\sit\soriginated\sfrom,\sby\ndefault.\s\sThis\scan\sbe\sturned\soff\swith\sPRAGMA\sshort_column_names=OFF.\s\sThis\nis\sto\sbe\smore\slike\sPostgreSQL.\s\sMore\stesting\sneeded.\s(CVS\s1250)
+D 2004-02-20T14:50:58
 F Makefile.in cfd75c46b335881999333a9e4b982fa8491f200b
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -36,20 +36,20 @@ F src/func.c cbc5edd10c82a5193b9ca0726873328be445e6c1
 F src/hash.c 9b56ef3b291e25168f630d5643a4264ec011c70e
 F src/hash.h 3247573ab95b9dd90bcca0307a75d9a16da1ccc7
 F src/insert.c f0a95cb6e6b0aacc916c76a89649196e4f10adca
-F src/main.c 992114429fa45f0015cab0648caeeb9d9a12294a
+F src/main.c 8d348b97fa48353eee0c5ab0081fc498129954fc
 F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565
 F src/os.c f5fc4954725b2fcd852979f2746085fe8ca27710
 F src/os.h 250a3789be609adfee5c5aa20137ce8683276f24
 F src/pager.c 29ddad4dd454f0aaa98e2bcd327710ab9f02f833
 F src/pager.h 82332878799280145639a48d88cdb4058925e3f6
 F src/parse.y 226bbdba2dee362d4b1cacc424bd82f7740071ee
-F src/pragma.c 23dac1d20cc278e1fbbae5181eba0508ca7f2d7a
+F src/pragma.c fe677be978d8cae19f73272d52f91ba4b95af2da
 F src/printf.c 84e4ea4ba49cbbf930e95e82295127ad5843ae1f
 F src/random.c 775913e0b7fbd6295d21f12a7bd35b46387c44b2
-F src/select.c 3b8eaf1a9585cbcf7a90bc9915b9b2f75ffe3921
+F src/select.c 9a41dace754f0dab5e991e402c05fa3c24d04f19
 F src/shell.c c3d3404fa82bb0808444fda9884d1bb572fd18b9
 F src/sqlite.h.in 64f016cd5ce190643a0f47760188fdf4e0b2227e
-F src/sqliteInt.h 2b5e327ba20a864a95ff12e0d243dabfbc37d613
+F src/sqliteInt.h 2e30f2bf445d3b797149cdf8b246f40f117e16b4
 F src/table.c d845cb101b5afc1f7fea083c99e3d2fa7998d895
 F src/tclsqlite.c b84dafe3a8532ff534c36e96bd38880e4b9cedf3
 F src/test1.c 56e9a156df3ad5e4e98df776776e963effc727f7
@@ -186,7 +186,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
 F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
 F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P 2c1e74e58a702fd2be954467a12e69a33b252831
-R 5f3caba9f5c70827c1b24157eff71fd5
+P 8d3e924975681a871e0eeac3b6a62cffdb947ac7
+R 25fc9e67ed64c9634c3063950c1dbf75
 U drh
-Z 79840b805b40a8de29ae5e58e39914fc
+Z a53a93fc0bf92133df676d6edc4a0f50
index 5e658d06bba6b267ee288a04927d97a901d74013..4ad02109120dcbc87c32af0464b2be60abfc2fab 100644 (file)
@@ -1 +1 @@
-8d3e924975681a871e0eeac3b6a62cffdb947ac7
\ No newline at end of file
+574dd444e7ff00e0fccc3436fe617ad832daae40
\ No newline at end of file
index fb6a8e145dc2bc35a8beac233601e52302c36af3..659ebfb259407f4d22f6dfff9facfaf2555e37c3 100644 (file)
@@ -14,7 +14,7 @@
 ** other files are for internal use by SQLite and should not be
 ** accessed by users of the library.
 **
-** $Id: main.c,v 1.156 2004/02/16 03:44:02 drh Exp $
+** $Id: main.c,v 1.157 2004/02/20 14:50:58 drh Exp $
 */
 #include "sqliteInt.h"
 #include "os.h"
@@ -478,6 +478,7 @@ sqlite *sqlite_open(const char *zFilename, int mode, char **pzErrMsg){
   db->magic = SQLITE_MAGIC_BUSY;
   db->nDb = 2;
   db->aDb = db->aDbStatic;
+  db->flags |= SQLITE_ShortColNames;
   sqliteHashInit(&db->aFunc, SQLITE_HASH_STRING, 1);
   for(i=0; i<db->nDb; i++){
     sqliteHashInit(&db->aDb[i].tblHash, SQLITE_HASH_STRING, 0);
index 337f601166fd6eed3142553a534dbf20b0ee195f..18c8846277e02fe826f77a1703c387ec7537aed3 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** This file contains code used to implement the PRAGMA command.
 **
-** $Id: pragma.c,v 1.14 2004/02/16 03:44:02 drh Exp $
+** $Id: pragma.c,v 1.15 2004/02/20 14:50:58 drh Exp $
 */
 #include "sqliteInt.h"
 #include <ctype.h>
@@ -310,6 +310,14 @@ void sqlitePragma(Parse *pParse, Token *pLeft, Token *pRight, int minusFlag){
     }
   }else
 
+  if( sqliteStrICmp(zLeft, "short_column_names")==0 ){
+    if( getBoolean(zRight) ){
+      db->flags |= SQLITE_ShortColNames;
+    }else{
+      db->flags &= ~SQLITE_ShortColNames;
+    }
+  }else
+
   if( sqliteStrICmp(zLeft, "show_datatypes")==0 ){
     if( getBoolean(zRight) ){
       db->flags |= SQLITE_ReportTypes;
index 95b5841d54db7d2ef1267dc5e955a3660603daad..149eecae12a86a7287b3f4f4d2ccf84241a0cc48 100644 (file)
@@ -12,7 +12,7 @@
 ** This file contains C code routines that are called by the parser
 ** to handle SELECT statements in SQLite.
 **
-** $Id: select.c,v 1.156 2004/02/16 03:44:02 drh Exp $
+** $Id: select.c,v 1.157 2004/02/20 14:50:58 drh Exp $
 */
 #include "sqliteInt.h"
 
@@ -680,7 +680,7 @@ static void generateColumnTypes(
 /*
 ** Generate code that will tell the VDBE the names of columns
 ** in the result set.  This information is used to provide the
-** azCol[] vaolues in the callback.
+** azCol[] values in the callback.
 */
 static void generateColumnNames(
   Parse *pParse,      /* Parser context */
@@ -689,13 +689,16 @@ static void generateColumnNames(
 ){
   Vdbe *v = pParse->pVdbe;
   int i, j;
+  sqlite *db = pParse->db;
+  int fullNames, shortNames;
+
   assert( v!=0 );
   if( pParse->colNamesSet || v==0 || sqlite_malloc_failed ) return;
   pParse->colNamesSet = 1;
+  fullNames = (db->flags & SQLITE_FullColNames)!=0;
+  shortNames = (db->flags & SQLITE_ShortColNames)!=0;
   for(i=0; i<pEList->nExpr; i++){
     Expr *p;
-    char *zType = 0;
-    int showFullNames;
     int p2 = i==pEList->nExpr-1;
     p = pEList->a[i].pExpr;
     if( p==0 ) continue;
@@ -705,7 +708,6 @@ static void generateColumnNames(
       sqliteVdbeChangeP3(v, -1, zName, strlen(zName));
       continue;
     }
-    showFullNames = (pParse->db->flags & SQLITE_FullColNames)!=0;
     if( p->op==TK_COLUMN && pTabList ){
       Table *pTab;
       char *zCol;
@@ -717,21 +719,19 @@ static void generateColumnNames(
       assert( iCol==-1 || (iCol>=0 && iCol<pTab->nCol) );
       if( iCol<0 ){
         zCol = "_ROWID_";
-        zType = "INTEGER";
       }else{
         zCol = pTab->aCol[iCol].zName;
-        zType = pTab->aCol[iCol].zType;
       }
-      if( p->span.z && p->span.z[0] && !showFullNames ){
+      if( !shortNames && !fullNames && p->span.z && p->span.z[0] ){
         int addr = sqliteVdbeAddOp(v,OP_ColumnName, i, p2);
         sqliteVdbeChangeP3(v, -1, p->span.z, p->span.n);
         sqliteVdbeCompressSpace(v, addr);
-      }else if( pTabList->nSrc>1 || showFullNames ){
+      }else if( fullNames || (!shortNames && pTabList->nSrc>1) ){
         char *zName = 0;
         char *zTab;
  
         zTab = pTabList->a[j].zAlias;
-        if( showFullNames || zTab==0 ) zTab = pTab->zName;
+        if( fullNames || zTab==0 ) zTab = pTab->zName;
         sqliteSetString(&zName, zTab, ".", zCol, 0);
         sqliteVdbeAddOp(v, OP_ColumnName, i, p2);
         sqliteVdbeChangeP3(v, -1, zName, strlen(zName));
index dfdfef37bef5532143de618750f3f4dd12c1afdb..4fb8953d73cbbaba82250e50c270e52252a7db8a 100644 (file)
@@ -11,7 +11,7 @@
 *************************************************************************
 ** Internal interface definitions for SQLite.
 **
-** @(#) $Id: sqliteInt.h,v 1.213 2004/02/14 23:59:58 drh Exp $
+** @(#) $Id: sqliteInt.h,v 1.214 2004/02/20 14:50:58 drh Exp $
 */
 #include "config.h"
 #include "sqlite.h"
@@ -365,10 +365,11 @@ struct sqlite {
 #define SQLITE_InTrans        0x00000008  /* True if in a transaction */
 #define SQLITE_InternChanges  0x00000010  /* Uncommitted Hash table changes */
 #define SQLITE_FullColNames   0x00000020  /* Show full column names on SELECT */
-#define SQLITE_CountRows      0x00000040  /* Count rows changed by INSERT, */
+#define SQLITE_ShortColNames  0x00000040  /* Show short columns names */
+#define SQLITE_CountRows      0x00000080  /* Count rows changed by INSERT, */
                                           /*   DELETE, or UPDATE and return */
                                           /*   the count using a callback. */
-#define SQLITE_NullCallback   0x00000080  /* Invoke the callback once if the */
+#define SQLITE_NullCallback   0x00000100  /* Invoke the callback once if the */
                                           /*   result set is empty */
 #define SQLITE_ReportTypes    0x00000200  /* Include information on datatypes */
                                           /*   in 4th argument of callback */
@@ -410,6 +411,7 @@ struct Column {
   u8 notNull;      /* True if there is a NOT NULL constraint */
   u8 isPrimKey;    /* True if this column is part of the PRIMARY KEY */
   u8 sortOrder;    /* Some combination of SQLITE_SO_... values */
+  u8 dottedName;   /* True if zName contains a "." character */
 };
 
 /*