Index: src/pragma.c
==================================================================
--- src/pragma.c
+++ src/pragma.c
@@ -1081,28 +1081,34 @@
   ** the returned data set are:
   **
   ** cid:        Column id (numbered from left to right, starting at 0)
   ** name:       Column name
   ** type:       Column declaration type.
+  ** aff:        Column affinity
+  ** coll:       Column collation
   ** notnull:    True if 'NOT NULL' is part of column declaration
   ** dflt_value: The default value for the column, if any.
   ** pk:         Non-zero for PK fields.
+  ** rowid       Column is RowID
   */
   case PragTyp_TABLE_INFO: if( zRight ){
     Table *pTab;
+    int iPKey;
+    char *affinity[] = {"NONE", "BLOB", "TEXT", "NUMERIC", "INTEGER", "REAL"};
     pTab = sqlite3LocateTable(pParse, LOCATE_NOERR, zRight, zDb);
     if( pTab ){
       int iTabDb = sqlite3SchemaToIndex(db, pTab->pSchema);
       int i, k;
       int nHidden = 0;
       Column *pCol;
       Index *pPk = sqlite3PrimaryKeyIndex(pTab);
-      pParse->nMem = 7;
+      pParse->nMem = 10;
       sqlite3CodeVerifySchema(pParse, iTabDb);
       sqlite3ViewGetColumnNames(pParse, pTab);
+      iPKey = pTab->iPKey;
       for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
         int isHidden = IsHiddenColumn(pCol);
+        int affcode = (int)(pCol->affinity - SQLITE_AFF_NONE);
+        if ((affcode < 0) || (affcode > 5))
+            affcode = 0;
         if( isHidden && pPragma->iArg==0 ){
           nHidden++;
           continue;
         }
         if( (pCol->colFlags & COLFLAG_PRIMKEY)==0 ){
@@ -1111,14 +1117,16 @@
           k = 1;
         }else{
           for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){}
         }
         assert( pCol->pDflt==0 || pCol->pDflt->op==TK_SPAN );
-        sqlite3VdbeMultiLoad(v, 1, pPragma->iArg ? "issisii" : "issisi",
+        sqlite3VdbeMultiLoad(v, 1, pPragma->iArg ? "issssisiii" : "issssisii",
                i-nHidden,
                pCol->zName,
                sqlite3ColumnType(pCol,""),
+               affinity[affcode],
+               pCol->zColl ? pCol->zColl : "",
                pCol->notNull ? 1 : 0,
                pCol->pDflt ? pCol->pDflt->u.zToken : 0,
                k,
+               iPKey == i,
                isHidden);
       }


Index: tool/mkpragmatab.tcl
==================================================================
--- tool/mkpragmatab.tcl
+++ tool/mkpragmatab.tcl
@@ -219,11 +219,11 @@
   IF:   !defined(SQLITE_OMIT_PAGER_PRAGMAS)

   NAME: table_info
   FLAG: NeedSchema Result1 SchemaOpt
   ARG:  0
-  COLS: cid name type notnull dflt_value pk
+  COLS: cid name type aff coll notnull dflt_value pk rowid
   IF:   !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)

   NAME: trigger_list
   FLAG: NeedSchema Result1 SchemaOpt
   COLS: seq name tm_tr op
@@ -231,11 +231,11 @@

   NAME: table_xinfo
   TYPE: TABLE_INFO
   FLAG: NeedSchema Result1 SchemaOpt
   ARG:  1
-  COLS: cid name type notnull dflt_value pk hidden
+  COLS: cid name type aff coll notnull dflt_value pk rowid hidden
   IF:   !defined(SQLITE_OMIT_SCHEMA_PRAGMAS)

   NAME: stats
   FLAG: NeedSchema Result0 SchemaReq
   COLS: tbl idx wdth hght flgs


Released to the Public Domain ...

-- 
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.



_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to