浏览代码

fcl-db: sqlite: check if sqlite library is compiled with SQLITE_ENABLE_COLUMN_METADATA IOW there is API function sqlite3_column_origin_name() and co. Bug #30935

git-svn-id: trunk@34962 -
lacak 8 年之前
父节点
当前提交
b78ff18bfa
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      packages/fcl-db/src/sqldb/sqlite/sqlite3conn.pp

+ 6 - 2
packages/fcl-db/src/sqldb/sqlite/sqlite3conn.pp

@@ -501,9 +501,13 @@ begin
                end;
       ftUnknown : DatabaseErrorFmt('Unknown or unsupported data type %s of column %s', [FD, FN]);
     end; // Case
-    // is column declared as NOT NULL ? (table name parameter (3rd) must be not nil)
+    // check if SQLite is compiled with SQLITE_ENABLE_COLUMN_METADATA
+    if Assigned(sqlite3_column_origin_name) then
+      CN := sqlite3_column_origin_name(st,i)
+    else
+      CN := nil;
     // check only for physical table columns (not computed)
-    CN := sqlite3_column_origin_name(st,i);
+    // is column declared as NOT NULL ? (table name parameter (3rd) must be not nil)
     if not (Assigned(CN) and (sqlite3_table_column_metadata(fhandle, sqlite3_column_database_name(st,i), sqlite3_column_table_name(st,i), CN, nil, nil, @NotNull, nil, nil) = SQLITE_OK)) then
       NotNull := 0;
     FieldDefs.Add(FN, FT, size1, size2, NotNull=1, false, i+1, CP_UTF8);