Yes, pragma table_info on a non-existent table is good example. I think we
can only return NULL and don't create the table in this case:
sqlite> .load ./libsqlitepragmacols.so
sqlite> select pragma_cols('pragma table_info(sqlite_master2)')='';
sqlite> select pragma_cols('pragma table_info(sqlite_master2)') IS NULL;
1
sqlite> select pragma_cols('pragma table_info(sqlite_master)');
cid, name, type, notnull, dflt_value, pk, readonly, enforced
Note: my SQLite build has additional fields "readonly" and "enforced".
Updated pragmacols.c include this lines:
rc = sqlite3_prepare_v2(db, (char*)sqlite3_value_text(argv[0]), -1,
&stmt, NULL);
if (rc != SQLITE_OK) {
sqlite3_result_error_code(context, rc);
return;
}
str = sqlite3_mprintf("%s", sqlite3_column_name(stmt,0));
for (i=1;i<sqlite3_column_count(stmt);i++) {
str = sqlite3_mprintf("%s, %s", str, sqlite3_column_name(stmt,i));
}
sqlite3_finalize(stmt);
if (strlen(str)) {
sqlite3_result_text( context, str, strlen(str), sqlite3_free);
} else {
sqlite3_result_null( context );
sqlite3_free(str);
}
--
Best regards, Alexey Pechnikov.
http://pechnikov.tel/
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users