Enhance the "PRAGMA index_info" and "PRAGMA index_xinfo" statements so that
they work on WITHOUT ROWID tables and provide information about the underlying
index btree that implements the WITHOUT ROWID table.

FossilOrigin-Name: fe49fb03133fec8bed51c2e2c1b6848ab9fc563e
diff --git a/manifest b/manifest
index d4950ff..c7ce587 100644
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\stest\scase\sto\sdemonstrate\sa\s"BEGIN\sEXCLUSIVE"\scommand\sreturning\nSQLITE_BUSY_SNAPSHOT.
-D 2016-10-25T15:06:11.142
+C Enhance\sthe\s"PRAGMA\sindex_info"\sand\s"PRAGMA\sindex_xinfo"\sstatements\sso\sthat\nthey\swork\son\sWITHOUT\sROWID\stables\sand\sprovide\sinformation\sabout\sthe\sunderlying\nindex\sbtree\sthat\simplements\sthe\sWITHOUT\sROWID\stable.
+D 2016-10-25T15:39:58.696
 F Makefile.in 6fd48ffcf7c2deea7499062d1f3747f986c19678
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc 5151cc64c4c05f3455f4f692ad11410a810d937f
@@ -380,7 +380,7 @@
 F src/pcache.c 5ff2a08f76a9c1b22f43eb063b7068fb085465ac
 F src/pcache.h 2cedcd8407eb23017d92790b112186886e179490
 F src/pcache1.c e3967219b2a92b9edcb9324a4ba75009090d3953
-F src/pragma.c d932ba278654617cdd281f88a790a3185fca7c44
+F src/pragma.c 18a2b0aa050396725e8ebb74b055d5afa802b54f
 F src/pragma.h 64c78a648751b9f4f297276c4eb7507b14b4628c
 F src/prepare.c b1140c3d0cf59bc85ace00ce363153041b424b7a
 F src/printf.c a5f0ca08ddede803c241266abb46356ec748ded1
@@ -1429,7 +1429,7 @@
 F test/with2.test 2b40da883658eb74ad8ad06afabe11a408e7fb87
 F test/with3.test 511bacdbe41c49cf34f9fd1bd3245fe1575bca98
 F test/withM.test 693b61765f2b387b5e3e24a4536e2e82de15ff64
-F test/without_rowid1.test 1a7b9bd51b899928d327052df9741d2fe8dbe701
+F test/without_rowid1.test eaac24556ed2dfaf84d8a32fac46229bd61b1015
 F test/without_rowid2.test af260339f79d13cb220288b67cd287fbcf81ad99
 F test/without_rowid3.test aad4f9d383e199349b6c7e508a778f7dff5dff79
 F test/without_rowid4.test 4e08bcbaee0399f35d58b5581881e7a6243d458a
@@ -1527,7 +1527,10 @@
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 98795c2dd9a6d8fa8d49a9f5c36cdf824cae7246
-R e30d5f9c1b1789e2c9a0ef25079fdb1b
-U dan
-Z 8c4ba873f6fa2463459d3dd02e3529e2
+P b115856408b6aa5538be67beb619d7aff0630bea
+R 169c1df42ad3211c7cffa140b51fc0ef
+T *branch * index-info-on-table
+T *sym-index-info-on-table *
+T -sym-trunk *
+U drh
+Z c67713b53054dcc5980cf7c3020b1123
diff --git a/manifest.uuid b/manifest.uuid
index 9cf0539..bee5cdd 100644
--- a/manifest.uuid
+++ b/manifest.uuid
@@ -1 +1 @@
-b115856408b6aa5538be67beb619d7aff0630bea
\ No newline at end of file
+fe49fb03133fec8bed51c2e2c1b6848ab9fc563e
\ No newline at end of file
diff --git a/src/pragma.c b/src/pragma.c
index e774de3..cc31ed0 100644
--- a/src/pragma.c
+++ b/src/pragma.c
@@ -1122,6 +1122,10 @@
     Index *pIdx;
     Table *pTab;
     pIdx = sqlite3FindIndex(db, zRight, zDb);
+    if( pIdx==0 ){
+      pTab = sqlite3FindTable(db, zRight, zDb);
+      if( pTab && !HasRowid(pTab) ) pIdx = sqlite3PrimaryKeyIndex(pTab);
+    }
     if( pIdx ){
       static const char *azCol[] = {
          "seqno", "cid", "name", "desc", "coll", "key"
diff --git a/test/without_rowid1.test b/test/without_rowid1.test
index 0c77773..23fac40 100644
--- a/test/without_rowid1.test
+++ b/test/without_rowid1.test
@@ -328,5 +328,24 @@
   ) WITHOUT ROWID;
 } {1 {no such column: rowid}}
 
+# The PRAGMA index_info and index_xinfo pragmas work on 
+# WITHOUT ROWID tables too, but not on rowid tables.
+#
+do_execsql_test 8.1 {
+  CREATE TABLE t80a(a TEXT, b INT, c BLOB, PRIMARY KEY(c,b));
+  PRAGMA index_info(t80a);
+} {}
+do_execsql_test 8.2 {
+  PRAGMA index_xinfo(t80a);
+} {}
+do_execsql_test 8.3 {
+  CREATE TABLE t80b(a TEXT, b INT, c BLOB, PRIMARY KEY(c,b)) WITHOUT ROWID;
+  PRAGMA index_info(t80b);
+} {0 2 c 1 1 b}
+do_execsql_test 8.4 {
+  PRAGMA index_xinfo(t80b);
+} {0 2 c 0 BINARY 1 1 1 b 0 BINARY 1 2 0 a 0 BINARY 0}
+
+
   
 finish_test