In the course of porting some software to use SQLite, I found I have needed some information that I could not figure out how to get from SQLite without undo effort, but that SQLite actually "knows". The first is whether a database currently attached to the database connection was open read-only or read/write. The second is whether a column within an index is sorted ascending or descending.
The first could be obtained by trying to create then delete an object in each attached database (as returned by pragma database_list) in turn. This is not particularly elegant, and would be kind of problematic if there are multiple simultaneous writers. But I don't have to support multiple simultaneous writers at the moment, so it should work. It seems like it could be a bit expensive, though. The second could be obtained by parsing the index creation statement in stored in sqlite_master. I do not particularly want to parse SQL if I can possibly avoid it! What I have done at the moment is added a fourth column named "readonly" to pragma database_list (it gets the value for this column from a function I added called sqlite3BtreeIsreadonly(), which in turn is a wrapper around sqlite3PagerIsreadonly()), and a fourth column named "desc" to pragma index_info (it gets the value for this column from pIdx->aSortOrder[i]). Now the above changes are fairly clean and simple (and surrounded by ifdefs) and only apply to information returned by the pragma statements. However, I don't really want to get involved in porting them each time I decide to switch to a new release of SQLite (the code that uses these is in a library that links in sqlite3.o/sqlite3.obj directly, so I don't have to worry about running against an unmodified version of SQLite by accident). On the other hand, I don't especially like any of the alternate approaches I have come up with. And while I suppose I could ask for these changes to be made as enhancements to SQLite, I assume from the lack of them at this time that they are not exactly common requirements. Any suggestions? Thanks! Peter _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

