Here are some alternate API naming suggestions, that I have thought through at length and believe will work.

Since the proposed new functions are all related and talk about the source table or view columns for the query, they should all have the word 'source' in their names. Here are my suggestions for new functions (and we keep the old ones as they are):

  sqlite3_column_source() or sqlite3_column_source_column()
  sqlite3_column_source_table()
  sqlite3_column_source_database()

All 3 of the above functions return null values for a calculated field, and non-null values for a non-calculated field. The first function gives the source table or view field/column name, and is the same as many databases return when you say "select *". The second function gives the name of the table or view; since another name for a "view" is a "viewed table" (see SQL:2003), that name isn't inappropriate when the source is a view. And the third function is the database containing the source table. If desired, pair each one with a second version for UTF16.

At 5:33 PM -0700 2/28/05, Dennis Cote wrote:
D. Richard Hipp wrote:
Wouldn't it be better to provide this information with a new API
rather than depend on a column naming convention?  That would avoid
ambiguity in cases where users create dodgy column names that contain
characters like space and '.'
Yes, it sure would be better to use an API.

The second would naturally become sqlite3_column_table(), and the fourth sqlite3_column_database().

Unfortunately, the natural name for the third item, sqlite3_column_name(), is already used. However, rather than the column name, it returns the usual column heading. This is sometime the column name alone, and sometimes the table name and the column name separated by a period, depending upon the type of query, joined or not, and the column name pragma settings. It's too bad this wasn't called sqlite3_column_heading().

I disagree with your assessment about the existing use of sqlite3_column_name(), and think that function should stay the way it is. My reason is that the common thing between all the "sqlite3_column" functions is that they refer to a RESULT column for a select query.


Since the QUERY is the primary subject under discussion, it makes sense that sqlite3_column_name() refers to the name of the result column, which is determined either by the AS clause or other default rules.

Calling this sqlite3_column_heading() is inappropriate when you consider that most of the time this value is used as a primary identifier for a query result column, for example being used as a hash key.

Anyone agree or disagree with my suggestions?

-- Darren Duncan

Reply via email to