forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvtkSQLiteQuery.cxx
821 lines (696 loc) · 22.4 KB
/
vtkSQLiteQuery.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
/*=========================================================================
Program: Visualization Toolkit
Module: vtkSQLiteQuery.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/*-------------------------------------------------------------------------
Copyright 2008 Sandia Corporation.
Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
the U.S. Government retains certain rights in this software.
-------------------------------------------------------------------------*/
#include "vtkSQLiteQuery.h"
#include "vtkObjectFactory.h"
#include "vtkSQLiteDatabase.h"
#include "vtkStringArray.h"
#include "vtkVariant.h"
#include "vtkVariantArray.h"
#include <vtksqlite/vtk_sqlite3.h>
#include <assert.h>
#include <vtksys/ios/sstream>
#include <vtksys/stl/vector>
#define BEGIN_TRANSACTION "BEGIN TRANSACTION"
#define COMMIT_TRANSACTION "COMMIT"
#define ROLLBACK_TRANSACTION "ROLLBACK"
vtkStandardNewMacro(vtkSQLiteQuery);
// ----------------------------------------------------------------------
vtkSQLiteQuery::vtkSQLiteQuery()
{
this->Statement = NULL;
this->InitialFetch = true;
this->InitialFetchResult=VTK_SQLITE_DONE;
this->LastErrorText = NULL;
this->TransactionInProgress = false;
}
// ----------------------------------------------------------------------
vtkSQLiteQuery::~vtkSQLiteQuery()
{
this->SetLastErrorText(NULL);
if (this->TransactionInProgress)
{
this->RollbackTransaction();
}
if (this->Statement != NULL)
{
if (this->Database != NULL)
{
vtk_sqlite3_finalize(this->Statement);
this->Statement = NULL;
}
}
}
// ----------------------------------------------------------------------
void vtkSQLiteQuery::PrintSelf(ostream &os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
os << indent << "Statement: ";
if (this->Statement)
{
os << this->Statement << "\n";
}
else
{
os << "(null)" << "\n";
}
os << indent << "InitialFetch: " << this->InitialFetch << "\n";
os << indent << "InitialFetchResult: " << this->InitialFetchResult << "\n";
os << indent << "TransactionInProgress: " << this->TransactionInProgress
<< "\n";
os << indent << "LastErrorText: "
<< (this->LastErrorText ? this->LastErrorText : "(null)") << endl;
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::SetQuery(const char *newQuery)
{
vtkDebugMacro(<< this->GetClassName()
<< " (" << this << "): setting Query to "
<< (newQuery?newQuery:"(null)") );
if (this->Query == NULL && newQuery == NULL)
{
return true;
}
if (this->Query && newQuery && (!strcmp(this->Query, newQuery)))
{
return true; // we've already got that query
}
if (this->Query)
{
delete [] this->Query;
}
if (newQuery)
{
// Keep a local copy of the query - this is from vtkSetGet.h
size_t n = strlen(newQuery) + 1;
char *cp1 = new char[n];
const char *cp2 = (newQuery);
this->Query = cp1;
do { *cp1++ = *cp2++; } while ( --n );
}
else
{
this->Query = NULL;
}
// If we get to this point the query has changed. We need to
// finalize the already-prepared statement if one exists and then
// prepare a new statement.
if (this->Statement)
{
vtkDebugMacro(<<"Finalizing old statement");
int finalizeStatus = vtk_sqlite3_finalize(this->Statement);
if (finalizeStatus != VTK_SQLITE_OK)
{
vtkWarningMacro(<<"SetQuery(): Finalize returned unexpected code "
<< finalizeStatus);
}
this->Statement = NULL;
}
if (this->Query)
{
vtkSQLiteDatabase *dbContainer =
vtkSQLiteDatabase::SafeDownCast(this->Database);
if (dbContainer == NULL)
{
vtkErrorMacro(<<"This should never happen: SetQuery() called when there is no underlying database. You probably instantiated vtkSQLiteQuery directly instead of calling vtkSQLDatabase::GetInstance(). This also happens during TestSetGet in the CDash testing.");
return false;
}
vtk_sqlite3 *db = dbContainer->SQLiteInstance;
const char *unused_statement;
int prepareStatus = vtk_sqlite3_prepare_v2(db,
this->Query,
static_cast<int>(strlen(this->Query)),
&this->Statement,
&unused_statement);
if (prepareStatus != VTK_SQLITE_OK)
{
this->SetLastErrorText(vtk_sqlite3_errmsg(db));
vtkWarningMacro(<<"SetQuery(): vtk_sqlite3_prepare_v2() failed with error message "
<< this->GetLastErrorText()
<< " on statement: '"
<< this->Query << "'");
this->Active = false;
return false;
}
} // Done preparing new statement
this->Modified();
return true;
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::Execute()
{
if (this->Query == NULL)
{
vtkErrorMacro(<<"Cannot execute before a query has been set.");
return false;
}
if (this->Statement == NULL)
{
vtkErrorMacro(<<"Execute(): Query is not null but prepared statement is. There may have been an error during SetQuery().");
this->Active = false;
return false;
}
else
{
vtk_sqlite3_reset(this->Statement);
}
vtkDebugMacro(<<"Execute(): Query ready to execute.");
this->InitialFetch = true;
int result = vtk_sqlite3_step(this->Statement);
this->InitialFetchResult = result;
if (result == VTK_SQLITE_DONE)
{
this->SetLastErrorText(NULL);
this->Active = true;
return true;
}
else if (result != VTK_SQLITE_ROW)
{
vtkSQLiteDatabase *dbContainer =
vtkSQLiteDatabase::SafeDownCast(this->Database);
assert(dbContainer != NULL);
vtk_sqlite3 *db = dbContainer->SQLiteInstance;
this->SetLastErrorText(vtk_sqlite3_errmsg(db));
vtkDebugMacro(<< "Execute(): vtk_sqlite3_step() returned error message "
<< this->GetLastErrorText());
this->Active = false;
return false;
}
this->SetLastErrorText(NULL);
this->Active = true;
return true;
}
// ----------------------------------------------------------------------
int vtkSQLiteQuery::GetNumberOfFields()
{
if (! this->Active)
{
vtkErrorMacro(<<"GetNumberOfFields(): Query is not active!");
return 0;
}
else
{
return vtk_sqlite3_column_count(this->Statement);
}
}
// ----------------------------------------------------------------------
const char * vtkSQLiteQuery::GetFieldName(int column)
{
if (! this->Active)
{
vtkErrorMacro(<<"GetFieldName(): Query is not active!");
return NULL;
}
else if (column < 0 || column >= this->GetNumberOfFields())
{
vtkErrorMacro(<<"GetFieldName(): Illegal field index "
<< column);
return NULL;
}
else
{
return vtk_sqlite3_column_name(this->Statement, column);
}
}
// ----------------------------------------------------------------------
int vtkSQLiteQuery::GetFieldType(int column)
{
if (! this->Active)
{
vtkErrorMacro(<<"GetFieldType(): Query is not active!");
return -1;
}
else if (column < 0 || column >= this->GetNumberOfFields())
{
vtkErrorMacro(<<"GetFieldType(): Illegal field index "
<< column);
return -1;
}
else
{
switch (vtk_sqlite3_column_type(this->Statement, column))
{
case VTK_SQLITE_INTEGER:
return VTK_INT;
case VTK_SQLITE_FLOAT:
return VTK_FLOAT;
case VTK_SQLITE_TEXT:
return VTK_STRING;
case VTK_SQLITE_BLOB:
return VTK_STRING; // until we have a BLOB type of our own
case VTK_SQLITE_NULL:
return VTK_VOID; // ??? what makes sense here?
default:
{
vtkErrorMacro(<<"GetFieldType(): Unknown data type "
<< vtk_sqlite3_column_type(this->Statement, column)
<<" from SQLite.");
return VTK_VOID;
}
}
}
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::NextRow()
{
if (! this->IsActive())
{
vtkErrorMacro(<<"NextRow(): Query is not active!");
return false;
}
if (this->InitialFetch)
{
vtkDebugMacro(<<"NextRow(): Initial fetch being handled.");
this->InitialFetch = false;
if (this->InitialFetchResult == VTK_SQLITE_DONE)
{
return false;
}
else
{
return true;
}
}
else
{
int result = vtk_sqlite3_step(this->Statement);
if (result == VTK_SQLITE_DONE)
{
return false;
}
else if (result == VTK_SQLITE_ROW)
{
return true;
}
else
{
vtkSQLiteDatabase *dbContainer = vtkSQLiteDatabase::SafeDownCast( this->Database );
assert(dbContainer != NULL);
vtk_sqlite3 *db = dbContainer->SQLiteInstance;
this->SetLastErrorText(vtk_sqlite3_errmsg(db));
vtkErrorMacro(<<"NextRow(): Database returned error code "
<< result << " with the following message: "
<< this->GetLastErrorText());
this->Active = false;
return false;
}
}
}
// ----------------------------------------------------------------------
vtkVariant vtkSQLiteQuery::DataValue(vtkIdType column)
{
if (this->IsActive() == false)
{
vtkWarningMacro(<<"DataValue() called on inactive query");
return vtkVariant();
}
else if (column < 0 || column >= this->GetNumberOfFields())
{
vtkWarningMacro(<<"DataValue() called with out-of-range column index "
<< column);
return vtkVariant();
}
else
{
switch (vtk_sqlite3_column_type(this->Statement, column))
{
case VTK_SQLITE_INTEGER:
return vtkVariant(vtk_sqlite3_column_int(this->Statement, column));
case VTK_SQLITE_FLOAT:
return vtkVariant(vtk_sqlite3_column_double(this->Statement, column));
case VTK_SQLITE_TEXT:
{
vtksys_ios::ostringstream str;
str << vtk_sqlite3_column_text(this->Statement, column);
return vtkVariant(vtkStdString(str.str()));
}
case VTK_SQLITE_BLOB:
{
// This is a hack ... by passing the BLOB to vtkStdString with an explicit
// byte count, we ensure that the string will store all of the BLOB's bytes,
// even if there are NULL values.
return vtkVariant(vtkStdString(
static_cast<const char*>(vtk_sqlite3_column_blob(this->Statement, column)),
vtk_sqlite3_column_bytes(this->Statement, column)));
}
case VTK_SQLITE_NULL:
default:
return vtkVariant();
}
}
}
// ----------------------------------------------------------------------
const char * vtkSQLiteQuery::GetLastErrorText()
{
return this->LastErrorText;
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::HasError()
{
return (this->GetLastErrorText() != NULL);
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BeginTransaction()
{
if (this->TransactionInProgress)
{
vtkErrorMacro(<<"Cannot start a transaction. One is already in progress.");
return false;
}
vtkSQLiteDatabase *dbContainer = vtkSQLiteDatabase::SafeDownCast( this->Database );
assert(dbContainer != NULL);
vtk_sqlite3 *db = dbContainer->SQLiteInstance;
char *errorMessage = NULL;
int result = vtk_sqlite3_exec(db, BEGIN_TRANSACTION, NULL, NULL, &errorMessage);
if (result == VTK_SQLITE_OK)
{
this->TransactionInProgress = true;
this->SetLastErrorText(NULL);
vtkDebugMacro(<<"BeginTransaction() succeeded.");
return true;
}
else
{
vtkErrorMacro(<<"BeginTransaction(): sqlite3_exec returned unexpected result code " << result);
if (errorMessage)
{
vtkErrorMacro(<< " and error message " << errorMessage);
}
this->TransactionInProgress = false;
return false;
}
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::CommitTransaction()
{
if (this->Statement)
{
vtk_sqlite3_finalize(this->Statement);
this->Statement = NULL;
}
if (!this->TransactionInProgress)
{
vtkErrorMacro(<<"Cannot commit. There is no transaction in progress.");
return false;
}
vtkSQLiteDatabase *dbContainer = vtkSQLiteDatabase::SafeDownCast( this->Database );
assert(dbContainer != NULL);
vtk_sqlite3 *db = dbContainer->SQLiteInstance;
char *errorMessage = NULL;
int result = vtk_sqlite3_exec(db, COMMIT_TRANSACTION, NULL, NULL, &errorMessage);
if (result == VTK_SQLITE_OK)
{
this->TransactionInProgress = false;
this->SetLastErrorText(NULL);
vtkDebugMacro(<<"CommitTransaction() succeeded.");
return true;
}
else
{
vtkErrorMacro(<<"CommitTransaction(): sqlite3_exec returned unexpected result code " << result);
if (errorMessage)
{
this->SetLastErrorText(errorMessage);
vtkErrorMacro(<< " and error message " << errorMessage);
}
assert(1==0);
return false;
}
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::RollbackTransaction()
{
if (!this->TransactionInProgress)
{
vtkErrorMacro(<<"Cannot rollback. There is no transaction in progress.");
return false;
}
vtkSQLiteDatabase *dbContainer = vtkSQLiteDatabase::SafeDownCast( this->Database );
assert(dbContainer != NULL);
vtk_sqlite3 *db = dbContainer->SQLiteInstance;
char *errorMessage = NULL;
int result = vtk_sqlite3_exec(db, ROLLBACK_TRANSACTION, NULL, NULL, &errorMessage);
if (result == VTK_SQLITE_OK)
{
this->TransactionInProgress = false;
this->SetLastErrorText(NULL);
vtkDebugMacro(<<"RollbackTransaction() succeeded.");
return true;
}
else
{
vtkErrorMacro(<<"RollbackTransaction(): sqlite3_exec returned unexpected result code " << result);
if (errorMessage)
{
this->SetLastErrorText(errorMessage);
vtkErrorMacro(<< " and error message " << errorMessage);
}
return false;
}
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BindParameter(int index, unsigned char value)
{
return this->BindIntegerParameter(index, value);
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BindParameter(int index, signed char value)
{
return this->BindIntegerParameter(index, value);
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BindParameter(int index, unsigned short value)
{
return this->BindIntegerParameter(index, value);
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BindParameter(int index, short value)
{
return this->BindIntegerParameter(index, value);
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BindParameter(int index, unsigned int value)
{
return this->BindIntegerParameter(index, value);
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BindParameter(int index, int value)
{
return this->BindIntegerParameter(index, value);
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BindParameter(int index, unsigned long value)
{
return this->BindIntegerParameter(index, value);
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BindParameter(int index, long value)
{
return this->BindIntegerParameter(index, value);
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BindParameter(int index, vtkTypeUInt64 value)
{
return this->BindInt64Parameter(index, static_cast<vtkTypeInt64>(value));
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BindParameter(int index, vtkTypeInt64 value)
{
return this->BindInt64Parameter(index, value);
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BindParameter(int index, float value)
{
return this->BindDoubleParameter(index, value);
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BindParameter(int index, double value)
{
return this->BindDoubleParameter(index, value);
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BindParameter(int index, const char *value)
{
return this->BindParameter(index, value, strlen(value));
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BindParameter(int index, const char *data, size_t length)
{
return this->BindStringParameter(index, data, static_cast<int>(length));
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BindParameter(int index, const vtkStdString &value)
{
return this->BindParameter(index, value.c_str());
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BindParameter(int index, const void *data, size_t length)
{
return this->BindBlobParameter(index, data, static_cast<int>(length));
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BindIntegerParameter(int index, int value)
{
if (!this->Statement)
{
vtkErrorMacro(<<"No statement available. Did you forget to call SetQuery?");
return false;
}
if (this->Active)
{
this->Active = false;
vtk_sqlite3_reset(this->Statement);
}
int status = vtk_sqlite3_bind_int(this->Statement, index+1, value);
if (status != VTK_SQLITE_OK)
{
vtksys_ios::ostringstream errormessage;
errormessage << "sqlite_bind_int returned error: " << status;
this->SetLastErrorText(errormessage.str().c_str());
vtkErrorMacro(<<errormessage.str().c_str());
return false;
}
return true;
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BindInt64Parameter(int index, vtkTypeInt64 value)
{
if (!this->Statement)
{
vtkErrorMacro(<<"No statement available. Did you forget to call SetQuery?");
return false;
}
if (this->Active)
{
this->Active = false;
vtk_sqlite3_reset(this->Statement);
}
int status = vtk_sqlite3_bind_int(this->Statement, index+1, static_cast<vtk_sqlite_int64>(value));
if (status != VTK_SQLITE_OK)
{
vtksys_ios::ostringstream errormessage;
errormessage << "sqlite_bind_int64 returned error: " << status;
this->SetLastErrorText(errormessage.str().c_str());
vtkErrorMacro(<<this->GetLastErrorText());
return false;
}
return true;
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BindDoubleParameter(int index, double value)
{
if (!this->Statement)
{
vtkErrorMacro(<<"No statement available. Did you forget to call SetQuery?");
return false;
}
if (this->Active)
{
this->Active = false;
vtk_sqlite3_reset(this->Statement);
}
int status = vtk_sqlite3_bind_double(this->Statement, index+1, value);
if (status != VTK_SQLITE_OK)
{
vtksys_ios::ostringstream errormessage;
errormessage << "sqlite_bind_double returned error: " << status;
this->SetLastErrorText(errormessage.str().c_str());
vtkErrorMacro(<<this->GetLastErrorText());
return false;
}
return true;
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BindStringParameter(int index, const char *value, int length)
{
if (!this->Statement)
{
vtkErrorMacro(<<"No statement available. Did you forget to call SetQuery?");
return false;
}
if (this->Active)
{
this->Active = false;
vtk_sqlite3_reset(this->Statement);
}
int status = vtk_sqlite3_bind_text(this->Statement, index+1, value, length, VTK_SQLITE_TRANSIENT);
if (status != VTK_SQLITE_OK)
{
vtksys_ios::ostringstream errormessage;
errormessage << "sqlite_bind_text returned error: " << status;
this->SetLastErrorText(errormessage.str().c_str());
vtkErrorMacro(<<this->GetLastErrorText());
return false;
}
return true;
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BindBlobParameter(int index, const void *data, int length)
{
if (!this->Statement)
{
vtkErrorMacro(<<"No statement available. Did you forget to call SetQuery?");
return false;
}
if (this->Active)
{
this->Active = false;
vtk_sqlite3_reset(this->Statement);
}
int status =
vtk_sqlite3_bind_blob(this->Statement,
index+1,
data,
length,
VTK_SQLITE_TRANSIENT);
if (status != VTK_SQLITE_OK)
{
vtksys_ios::ostringstream errormessage;
errormessage << "sqlite_bind_blob returned error: " << status;
this->SetLastErrorText(errormessage.str().c_str());
vtkErrorMacro(<<this->GetLastErrorText());
return false;
}
return true;
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::ClearParameterBindings()
{
if (!this->Statement)
{
vtkErrorMacro(<<"No statement available. Did you forget to call SetQuery?");
return false;
}
if (this->Active)
{
this->Active = false;
vtk_sqlite3_reset(this->Statement);
}
int status = vtk_sqlite3_clear_bindings(this->Statement);
if (status != VTK_SQLITE_OK)
{
vtksys_ios::ostringstream errormessage;
errormessage << "sqlite_clear_bindings returned error: " << status;
this->SetLastErrorText(errormessage.str().c_str());
vtkErrorMacro(<<this->GetLastErrorText());
return false;
}
return true;
}
// ----------------------------------------------------------------------
bool vtkSQLiteQuery::BindParameter(int index, vtkVariant value)
{
return this->Superclass::BindParameter(index, value);
}