@@ -77,9 +77,6 @@ Private Type TSQLiteCExecSQL
77
77
PageSize As Long
78
78
FilledPagesCount As Long
79
79
RowCount As Long
80
- '''' Meta API's fenced with the .UseTableMetadataAPI flag will fail if executed
81
- '''' against the PRAGMA-Table-functions SELECTs. Set it to false in such a case.
82
- UseTableMetaAPI As Boolean
83
80
End Type
84
81
Private this As TSQLiteCExecSQL
85
82
@@ -106,7 +103,6 @@ Friend Sub Init(ByVal DbStmt As SQLiteCStatement)
106
103
.MetaLoaded = False
107
104
.AffinityMap = Array(SQLITE_BLOB, SQLITE_TEXT, SQLITE_TEXT, _
108
105
SQLITE_INTEGER, SQLITE_FLOAT)
109
- .UseTableMetaAPI = True
110
106
End With
111
107
End Sub
112
108
@@ -154,17 +150,6 @@ Public Property Get RowCount() As Long
154
150
End Property
155
151
156
152
157
- '@Ignore ProcedureNotUsed
158
- Public Property Get UseTableMetaAPI() As Boolean
159
- UseTableMetaAPI = this.UseTableMetaAPI
160
- End Property
161
-
162
-
163
- Public Property Let UseTableMetaAPI(ByVal Value As Boolean )
164
- this.UseTableMetaAPI = Value
165
- End Property
166
-
167
-
168
153
'@Ignore ProcedureNotUsed
169
154
Public Property Get PageCount() As Long
170
155
PageCount = this.PageCount
@@ -246,6 +231,7 @@ Attribute ColumnMetaAPI.VB_Description = "Retrieves columns metadata."
246
231
hStmt = dbs.StmtHandle
247
232
248
233
Dim ResultCode As SQLiteResultCodes
234
+ ResultCode = SQLITE_OK
249
235
With ColumnInfo
250
236
If .Initialized <> -1 Then Err.Raise ErrNo.InvalidParameterErr, _
251
237
"SQLiteCExecSQL" , "Set .ColumnIndex and .Initialized=-1 before the call!"
@@ -278,48 +264,45 @@ Attribute ColumnMetaAPI.VB_Description = "Retrieves columns metadata."
278
264
ColumnNamePtr = sqlite3_column_origin_name(hStmt, ColumnIndex)
279
265
If ColumnNamePtr <> 0 Then .OriginName = UTFlib.StrFromUTF8Ptr(ColumnNamePtr)
280
266
281
- '''' Meta API's fenced with the .UseTableMetadataAPI flag will fail if executed
282
- '''' against the PRAGMA-Table-functions SELECTs. Set it to false in such a case.
283
- If this.UseTableMetaAPI Then
284
- Dim DataTypePtr As Variant
285
- DataTypePtr = sqlite3_column_decltype(hStmt, ColumnIndex)
286
- If DataTypePtr <> 0 Then
287
- .DeclaredTypeC = UTFlib.StrFromUTF8Ptr(DataTypePtr)
288
- .Affinity = TypeAffinityFromDeclaredType(.DeclaredTypeC)
289
- .AffinityType = this.AffinityMap(.Affinity - SQLITE_AFF_NONE - 1 )
290
- Else
291
- '''' SQLITE_RANGE is expected for a calculated column, such as "count(*)"
292
- '''' Only return an error, if this is not the case; otherwise, continue.
293
- If dbc.ErrInfoRetrieve <> SQLITE_RANGE Then GoTo META_ERROR:
294
- End If
267
+ Dim DataTypePtr As Variant
268
+ DataTypePtr = sqlite3_column_decltype(hStmt, ColumnIndex)
269
+ If DataTypePtr <> 0 Then
270
+ .DeclaredTypeC = UTFlib.StrFromUTF8Ptr(DataTypePtr)
271
+ .Affinity = TypeAffinityFromDeclaredType(.DeclaredTypeC)
272
+ .AffinityType = this.AffinityMap(.Affinity - SQLITE_AFF_NONE - 1 )
273
+ .TableMeta = True
274
+ Else
275
+ '''' SQLITE_RANGE is expected for a calculated column, such as "count(*)"
276
+ '''' Only return an error, if this is not the case; otherwise, continue.
277
+ If dbc.ErrInfoRetrieve <> SQLITE_RANGE Then GoTo META_ERROR:
278
+ .TableMeta = False
279
+ End If
295
280
296
- '''' For queries against PRAGMA functions, table_column_metadata
297
- '''' should return SQLITE_ERROR (no such table column...).
298
- ''''
299
- '''' Make sure that relevant previous APIs did not return null pointers.
300
- '''' This issue occurs for calculated columns, but basic armor would cut
301
- '''' off this information for all columns.
302
- ''''
303
- If DatabaseNamePtr <> 0 And TableNamePtr <> 0 And ColumnNamePtr <> 0 Then
304
- Dim NotNull As Long
305
- NotNull = False
306
- Dim PrimaryKey As Long
307
- PrimaryKey = False
308
- Dim AutoIncrement As Long
309
- AutoIncrement = False
310
- Dim CollationPtr As Variant : CollationPtr = 0 '''' RD workaround
311
- ResultCode = sqlite3_table_column_metadata(dbc.DbHandle, _
312
- DatabaseNamePtr, TableNamePtr, ColumnNamePtr, _
313
- DataTypePtr, CollationPtr, NotNull, PrimaryKey, AutoIncrement)
314
- If ResultCode = SQLITE_OK And DataTypePtr <> 0 And CollationPtr <> 0 Then
315
- .DeclaredTypeT = UTFlib.StrFromUTF8Ptr(DataTypePtr)
316
- .Collation = UTFlib.StrFromUTF8Ptr(CollationPtr)
317
- .NotNull = CBool(NotNull)
318
- .PrimaryKey = CBool(PrimaryKey)
319
- .AutoIncrement = CBool(AutoIncrement)
320
- Else
321
- ResultCode = dbc.ErrInfoRetrieve
322
- End If
281
+ '''' For queries against PRAGMA functions, table_column_metadata
282
+ '''' should return SQLITE_ERROR (no such table column...).
283
+ ''''
284
+ '''' Make sure that relevant previous APIs did not return null pointers.
285
+ ''''
286
+ If DatabaseNamePtr <> 0 And TableNamePtr <> 0 And _
287
+ ColumnNamePtr <> 0 And DataTypePtr <> 0 Then
288
+ Dim NotNull As Long
289
+ NotNull = False
290
+ Dim PrimaryKey As Long
291
+ PrimaryKey = False
292
+ Dim AutoIncrement As Long
293
+ AutoIncrement = False
294
+ Dim CollationPtr As Variant : CollationPtr = 0 '''' RD workaround
295
+ ResultCode = sqlite3_table_column_metadata(dbc.DbHandle, _
296
+ DatabaseNamePtr, TableNamePtr, ColumnNamePtr, _
297
+ DataTypePtr, CollationPtr, NotNull, PrimaryKey, AutoIncrement)
298
+ If ResultCode = SQLITE_OK And DataTypePtr <> 0 And CollationPtr <> 0 Then
299
+ .DeclaredTypeT = UTFlib.StrFromUTF8Ptr(DataTypePtr)
300
+ .Collation = UTFlib.StrFromUTF8Ptr(CollationPtr)
301
+ .NotNull = CBool(NotNull)
302
+ .PrimaryKey = CBool(PrimaryKey)
303
+ .AutoIncrement = CBool(AutoIncrement)
304
+ Else
305
+ ResultCode = dbc.ErrInfoRetrieve
323
306
End If
324
307
End If
325
308
End With
0 commit comments