forked from Kitware/VTK
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathvtkPostgreSQLDatabase.cxx
770 lines (699 loc) · 21.7 KB
/
vtkPostgreSQLDatabase.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
/*=========================================================================
Program: Visualization Toolkit
Module: vtkPostgreSQLDatabase.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 "vtkPostgreSQLDatabase.h"
#include "vtkPostgreSQLDatabasePrivate.h"
#include "vtkPostgreSQLQuery.h"
#include "vtkSQLDatabaseSchema.h"
#include "vtkObjectFactory.h"
#include "vtkStringArray.h"
#include <vtksys/SystemTools.hxx>
#include <vtksys/ios/sstream>
#include <vtkSmartPointer.h>
#define VTK_CREATE(classname, varname) vtkSmartPointer<classname> varname = vtkSmartPointer<classname>::New()
#include <libpq-fe.h>
#include <assert.h>
vtkStandardNewMacro(vtkPostgreSQLDatabase);
// ----------------------------------------------------------------------
vtkPostgreSQLDatabase::vtkPostgreSQLDatabase()
{
this->Connection = 0;
this->ConnectionMTime = this->MTime;
this->DatabaseType = 0;
this->SetDatabaseType("psql");
this->HostName = 0;
this->User = 0;
this->Password = 0;
this->DatabaseName = 0;
this->ServerPort = -1;
this->ConnectOptions = 0;
this->LastErrorText = 0;
this->Tables = vtkStringArray::New();
this->Tables->Register(this);
this->Tables->Delete();
}
// ----------------------------------------------------------------------
vtkPostgreSQLDatabase::~vtkPostgreSQLDatabase()
{
if ( this->IsOpen() )
{
this->Close();
}
this->SetHostName( 0 );
this->SetUser( 0 );
this->SetDatabaseName( 0 );
this->SetConnectOptions( 0 );
this->SetDatabaseType( 0 );
this->SetLastErrorText( 0 );
this->Tables->UnRegister(this);
}
// ----------------------------------------------------------------------
void vtkPostgreSQLDatabase::PrintSelf(ostream &os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
os << indent << "Connection: ";
if ( this->Connection )
{
os << this->Connection << endl;
}
else
{
os << "(null)" << endl;
}
os << indent << "DatabaseType: " << (this->DatabaseType ? this->DatabaseType : "NULL") << endl;
os << indent << "HostName: " << (this->HostName ? this->HostName : "NULL") << endl;
os << indent << "User: " << (this->User ? this->User : "NULL") << endl;
os << indent << "Password: " << (this->Password? "(hidden)":"(none)") << endl;
os << indent << "DatabaseName: " << (this->DatabaseName ? this->DatabaseName : "NULL") << endl;
os << indent << "ServerPort: " << this->ServerPort << endl;
os << indent << "ConnectOptions: " << (this->ConnectOptions ? this->ConnectOptions : "NULL") << endl;
os << indent << "LastErrorText: " << this->LastErrorText << endl;
}
// ----------------------------------------------------------------------
vtkStdString vtkPostgreSQLDatabase::GetColumnSpecification(
vtkSQLDatabaseSchema* schema, int tblHandle, int colHandle )
{
vtksys_ios::ostringstream queryStr;
queryStr << schema->GetColumnNameFromHandle( tblHandle, colHandle );
// Figure out column type
int colType = schema->GetColumnTypeFromHandle( tblHandle, colHandle );
vtkStdString colTypeStr;
switch ( static_cast<vtkSQLDatabaseSchema::DatabaseColumnType>( colType ) )
{
case vtkSQLDatabaseSchema::SERIAL:
colTypeStr = "SERIAL";
break;
case vtkSQLDatabaseSchema::SMALLINT:
colTypeStr = "SMALLINT";
break;
case vtkSQLDatabaseSchema::INTEGER:
colTypeStr = "INTEGER";
break;
case vtkSQLDatabaseSchema::BIGINT:
colTypeStr = "BIGINT";
break;
case vtkSQLDatabaseSchema::VARCHAR:
colTypeStr = "VARCHAR";
break;
case vtkSQLDatabaseSchema::TEXT:
colTypeStr = "TEXT";
break;
case vtkSQLDatabaseSchema::REAL:
colTypeStr = "REAL";
break;
case vtkSQLDatabaseSchema::DOUBLE:
colTypeStr = "DOUBLE PRECISION";
break;
case vtkSQLDatabaseSchema::BLOB:
colTypeStr = "BYTEA";
break;
case vtkSQLDatabaseSchema::TIME:
colTypeStr = "TIME";
break;
case vtkSQLDatabaseSchema::DATE:
colTypeStr = "DATE";
break;
case vtkSQLDatabaseSchema::TIMESTAMP:
colTypeStr = "TIMESTAMP WITH TIME ZONE";
break;
}
if ( colTypeStr.size() )
{
queryStr << " " << colTypeStr;
}
else // if ( colTypeStr.size() )
{
vtkGenericWarningMacro( "Unable to get column specification: unsupported data type " << colType );
return vtkStdString();
}
// Decide whether size is allowed, required, or unused
int colSizeType = 0;
switch ( static_cast<vtkSQLDatabaseSchema::DatabaseColumnType>( colType ) )
{
case vtkSQLDatabaseSchema::SERIAL:
colSizeType = 0;
break;
case vtkSQLDatabaseSchema::SMALLINT:
colSizeType = 0;
break;
case vtkSQLDatabaseSchema::INTEGER:
colSizeType = 0;
break;
case vtkSQLDatabaseSchema::BIGINT:
colSizeType = 0;
break;
case vtkSQLDatabaseSchema::VARCHAR:
colSizeType = -1;
break;
case vtkSQLDatabaseSchema::TEXT:
colSizeType = 0;
break;
case vtkSQLDatabaseSchema::REAL:
colSizeType = 0;
break;
case vtkSQLDatabaseSchema::DOUBLE:
colSizeType = 0;
break;
case vtkSQLDatabaseSchema::BLOB:
colSizeType = 0;
break;
case vtkSQLDatabaseSchema::TIME:
colSizeType = 1;
break;
case vtkSQLDatabaseSchema::DATE:
colSizeType = 0;
break;
case vtkSQLDatabaseSchema::TIMESTAMP:
colSizeType = 0;
break;
}
// Specify size if allowed or required
if ( colSizeType )
{
int colSize = schema->GetColumnSizeFromHandle( tblHandle, colHandle );
// IF size is provided but absurd,
// OR, if size is required but not provided OR absurd,
// THEN assign the default size.
if ( ( colSize < 0 ) || ( colSizeType == -1 && colSize < 1 ) )
{
colSize = VTK_SQL_DEFAULT_COLUMN_SIZE;
}
// At this point, we have either a valid size if required, or a possibly null valid size
// if not required. Thus, skip sizing in the latter case.
if ( colSize > 0 )
{
queryStr << "(" << colSize << ")";
}
}
vtkStdString attStr = schema->GetColumnAttributesFromHandle( tblHandle, colHandle );
if ( attStr.size() )
{
queryStr << " " << attStr;
}
return queryStr.str();
}
// ----------------------------------------------------------------------
bool vtkPostgreSQLDatabase::Open( const char* password )
{
if ( ! this->HostName || ! this->DatabaseName )
{
this->SetLastErrorText( "Cannot open database because HostName and/or DatabaseName are null." );
vtkErrorMacro( << this->GetLastErrorText() );
return false;
}
if ( this->Connection )
{
if ( this->ConnectionMTime > this->URLMTime )
{
return true; // we already had that database open.
}
this->Close(); // close the old connection before opening a new one
}
vtkstd::string options;
options = "dbname=";
options += this->DatabaseName;
if ( this->ServerPort > 0 )
{
options += " port=";
vtksys_ios::ostringstream stream;
stream << this->ServerPort;
options += stream.str();
}
if ( this->User && strlen( this->User ) > 0 )
{
options += " user=";
options += this->User;
}
if ( password && this->Password != password )
{
if ( this->Password )
{
delete [] this->Password;
}
this->Password = password ? vtksys::SystemTools::DuplicateString( password ) : 0;
}
if ( this->Password && strlen( this->Password ) > 0 )
{
options += " password=";
options += this->Password;
}
if ( this->ConnectOptions && strlen( this->ConnectOptions ) > 0 )
{
options += this->ConnectOptions;
}
// If localhost is specified, try the local socket connection
// first. Only if that doesn't work will we try the loopback
// device.
if ( ! strcmp( this->HostName, "localhost" ) )
{
if ( this->OpenInternal( options.c_str() ) )
{
this->SetLastErrorText( 0 );
return true;
}
}
vtkstd::string hspec( "host=" );
hspec += this->HostName;
options = hspec + " " + options;
if ( this->OpenInternal( options.c_str() ) )
{
this->SetLastErrorText( 0 );
return true;
}
return false;
}
// ----------------------------------------------------------------------
void vtkPostgreSQLDatabase::Close()
{
if ( this->Connection )
{
delete this->Connection;
this->Connection = 0;
this->SetLastErrorText( 0 );
this->URLMTime.Modified(); // Force a re-open to occur when Open() is called.
}
}
// ----------------------------------------------------------------------
bool vtkPostgreSQLDatabase::IsOpen()
{
return (this->Connection != 0 &&
this->Connection->Connection != 0 &&
PQstatus(this->Connection->Connection) == CONNECTION_OK);
}
// ----------------------------------------------------------------------
vtkSQLQuery* vtkPostgreSQLDatabase::GetQueryInstance()
{
vtkPostgreSQLQuery* query = vtkPostgreSQLQuery::New();
query->SetDatabase( this );
return query;
}
// ----------------------------------------------------------------------
bool vtkPostgreSQLDatabase::HasError()
{
// Assume that an unopened connection is not a symptom of failure.
if ( this->Connection )
{
return this->LastErrorText ? true : false;
}
else
{
return false;
}
}
// ----------------------------------------------------------------------
const char* vtkPostgreSQLDatabase::GetLastErrorText()
{
return this->LastErrorText;
}
// ----------------------------------------------------------------------
vtkStdString vtkPostgreSQLDatabase::GetURL()
{
vtkStdString url = this->GetDatabaseType();
url += "://";
if ( this->HostName && this->DatabaseName )
{
if ( this->User && strlen( this->User ) > 0 )
{
url += this->User;
url += "@";
}
url += this->HostName;
url += "/";
url += this->DatabaseName;
}
return url;
}
// ----------------------------------------------------------------------
bool vtkPostgreSQLDatabase::ParseURL( const char* URL )
{
vtkstd::string urlstr( URL ? URL : "" );
vtkstd::string protocol;
vtkstd::string username;
vtkstd::string password;
vtkstd::string hostname;
vtkstd::string dataport;
vtkstd::string database;
// Okay now for all the other database types get more detailed info
if ( ! vtksys::SystemTools::ParseURL(
urlstr, protocol, username, password, hostname, dataport, database) )
{
vtkErrorMacro( "Invalid URL: \"" << urlstr.c_str() << "\"" );
return false;
}
if ( protocol == "psql" )
{
this->SetUser( username.empty() ? 0 : username.c_str() );
this->SetPassword( password.empty() ? 0 : password.c_str() );
this->SetHostName( hostname.empty() ? 0 : hostname.c_str() );
this->SetServerPort( atoi( dataport.c_str() ) );
this->SetDatabaseName( database.empty() ? 0 : database.c_str() );
return true;
}
return false;
}
// ----------------------------------------------------------------------
vtkStringArray* vtkPostgreSQLDatabase::GetTables()
{
this->Tables->Resize(0);
if ( ! this->Connection )
{
vtkErrorMacro(<< this->GetLastErrorText());
return this->Tables;
}
// NB: Other columns of interest include table_catalog, table_schema, table_type,
// self_referencing_column_name, reference_generation, user_defined_type_catalog,
// user_defined_type_schema, user_defined_type_name, is_insertable_into, is_typed,
// commit_action
vtkSQLQuery* query = this->GetQueryInstance();
query->SetQuery(
"SELECT table_name FROM information_schema.tables"
" WHERE table_schema='public' and table_type='BASE TABLE'" );
bool status = query->Execute();
if ( ! status )
{
vtkErrorMacro(<< "Database returned error: " << query->GetLastErrorText());
this->SetLastErrorText(query->GetLastErrorText());
query->Delete();
return this->Tables;
}
vtkDebugMacro(<< "GetTables(): SQL query succeeded.");
while ( query->NextRow() )
{
this->Tables->InsertNextValue( query->DataValue( 0 ).ToString() );
}
query->Delete();
this->SetLastErrorText(NULL);
return this->Tables;
}
// ----------------------------------------------------------------------
vtkStringArray* vtkPostgreSQLDatabase::GetRecord( const char* table )
{
// NB: There are *too many* other column names to list. Even the ones
// currently in the query below are probably over the top. But there's
// just so much peanut-buttery goodness in the table, I couldn't resist.
vtkSQLQuery* query = this->GetQueryInstance();
vtkStdString text(
"SELECT column_name,column_default,data_type,is_nullable,character_maximum_length,numeric_precision,datetime_precision"
" FROM information_schema.columns"
" WHERE table_name='" );
text += table;
text += "' ORDER BY ordinal_position";
query->SetQuery( text.c_str() );
bool status = query->Execute();
if ( ! status )
{
vtkErrorMacro(<< "GetRecord(" << table << "): Database returned error: "
<< query->GetLastErrorText());
this->SetLastErrorText(query->GetLastErrorText());
query->Delete();
return 0;
}
// Each row in the results that come back from this query
// describes a single column in the table.
vtkStringArray* results = vtkStringArray::New();
while ( query->NextRow() )
{
results->InsertNextValue( query->DataValue( 0 ).ToString() );
}
query->Delete();
this->SetLastErrorText(0);
return results;
}
// ----------------------------------------------------------------------
bool vtkPostgreSQLDatabase::IsSupported( int feature )
{
switch (feature)
{
case VTK_SQL_FEATURE_BLOB:
case VTK_SQL_FEATURE_LAST_INSERT_ID:
case VTK_SQL_FEATURE_NAMED_PLACEHOLDERS:
case VTK_SQL_FEATURE_POSITIONAL_PLACEHOLDERS:
case VTK_SQL_FEATURE_PREPARED_QUERIES:
case VTK_SQL_FEATURE_TRANSACTIONS:
case VTK_SQL_FEATURE_UNICODE:
case VTK_SQL_FEATURE_BATCH_OPERATIONS:
case VTK_SQL_FEATURE_QUERY_SIZE:
case VTK_SQL_FEATURE_TRIGGERS:
return true;
default:
{
vtkErrorMacro(
<< "Unknown SQL feature code " << feature << "! See "
<< "vtkSQLDatabase.h for a list of possible features.");
return false;
};
}
}
// ----------------------------------------------------------------------
vtkStringArray* vtkPostgreSQLDatabase::GetDatabases()
{
if ( ! this->Connection )
{
vtkErrorMacro( "Must be connected to a server to get a list of databases." );
return 0;
}
vtkSQLQuery* query = this->GetQueryInstance();
if ( ! query )
{
vtkErrorMacro( "Could not create a query." );
return 0;
}
query->SetQuery( "SELECT datname FROM pg_database" );
if ( ! query->Execute() )
{
query->Delete();
return 0;
}
vtkStringArray* dbNames = vtkStringArray::New();
while ( query->NextRow() )
{
dbNames->InsertNextValue( query->DataValue( 0 ).ToString() );
}
query->Delete();
return dbNames;
}
// ----------------------------------------------------------------------
bool vtkPostgreSQLDatabase::CreateDatabase( const char* dbName, bool dropExisting )
{
if ( ! dbName )
{
vtkErrorMacro( "Databases must have a non-NULL name" );
return false;
}
bool dropCurrentlyConnected = false;
if ( this->DatabaseName && ! strcmp( this->DatabaseName, dbName ) )
{
dropCurrentlyConnected = true;
if ( dropExisting )
{
// we can't drop a database we're connected to...
this->SetDatabaseName( "template1" );
this->Open();
}
else
{
// this will fail... let it. then report the error via LastErrorText
}
}
if ( ! this->Connection )
{
if ( this->DatabaseName && ! strcmp( this->DatabaseName, dbName ) )
{
// we can't connect to a database we haven't created yet and aren't connected to...
this->SetDatabaseName( "template1" );
dropCurrentlyConnected = true;
}
bool err = true;
if ( this->DatabaseName && this->HostName )
{
err = this->Open() ? false : true;
}
if ( err )
{
vtkErrorMacro( "Must be connected to a server to create a database." );
return false;
}
}
if ( dropExisting )
{
this->DropDatabase( dbName );
}
vtkstd::string qstr( "CREATE DATABASE \"" );
qstr += dbName;
qstr += "\"";
vtkSQLQuery *query = this->GetQueryInstance();
query->SetQuery(qstr.c_str());
if (query->Execute() == false)
{
this->SetLastErrorText(query->GetLastErrorText());
vtkErrorMacro(
"Could not create database \"" << dbName << "\". "
<< this->GetLastErrorText() << "\n");
query->Delete();
return false;
}
query->Delete();
this->SetLastErrorText(0);
if ( dropCurrentlyConnected )
{
this->SetDatabaseName( dbName );
this->Open();
}
return true;
}
// ----------------------------------------------------------------------
bool vtkPostgreSQLDatabase::DropDatabase( const char* dbName )
{
if ( ! dbName || strlen( dbName ) <= 0 )
{
vtkErrorMacro( "DropDatabase called with an empty database name" );
return false;
}
if ( ! strcmp( dbName, this->DatabaseName ) )
{
// Can't drop database we're connected to... connect to the default db.
this->SetDatabaseName( "template1" );
}
if ( ! this->Connection )
{
bool err = true;
if ( this->DatabaseName && this->HostName )
{
err = this->Open() ? false : true;
}
if ( err )
{
vtkErrorMacro( "Must be connected to a server to create a database." );
return false;
}
}
vtkstd::string qstr( "DROP DATABASE IF EXISTS \"" );
qstr += dbName;
qstr += "\"";
vtkSQLQuery *query = this->GetQueryInstance();
query->SetQuery(qstr.c_str());
if (query->Execute() == false)
{
this->SetLastErrorText(query->GetLastErrorText());
vtkErrorMacro(<<"Could not drop database \""
<< dbName << "\". "
<< query->GetLastErrorText());
query->Delete();
return false;
}
this->SetLastErrorText(0);
query->Delete();
return true;
}
void vtkPostgreSQLDatabase::NullTrailingWhitespace( char* msg )
{
// overwrite any blank space at the end of a message with NULL.
// PostgreSQL error messages are terminated with a newline, which
// does not work well with VTK's already lengthy error output.
int msglen = strlen( msg );
char* tail = msg + msglen - 1;
while ( tail > msg && isspace( *tail ) )
*(tail--) = 0;
}
bool vtkPostgreSQLDatabase::OpenInternal( const char* connectionOptions )
{
assert(this->Connection == NULL);
this->Connection = new vtkPostgreSQLDatabasePrivate;
this->Connection->Connection = PQconnectdb(connectionOptions);
if (PQstatus(this->Connection->Connection) == CONNECTION_OK)
{
this->SetLastErrorText(0);
this->UpdateDataTypeMap();
return true;
}
else
{
this->SetLastErrorText(PQerrorMessage(this->Connection->Connection));
vtkErrorMacro(<<"Unable to open database connection. "
<< this->GetLastErrorText());
delete this->Connection;
this->Connection = 0;
return false;
}
}
// ----------------------------------------------------------------------
void vtkPostgreSQLDatabase::UpdateDataTypeMap()
{
if (!this->IsOpen())
{
return;
}
this->Connection->DataTypeMap.clear();
vtkSQLQuery *typeQuery = this->GetQueryInstance();
typeQuery->SetQuery("SELECT oid, typname, typlen FROM pg_type");
bool status = typeQuery->Execute();
if (!status)
{
vtkErrorMacro(<<"I was totally surprised to see the data type query fail. Error message: "
<< typeQuery->GetLastErrorText());
typeQuery->Delete();
}
else
{
while (typeQuery->NextRow())
{
Oid oid;
vtkStdString name;
int len;
// Caution: this assumes that the Postgres OID type is a 32-bit
// unsigned int.
oid = typeQuery->DataValue(0).ToUnsignedInt();
name = typeQuery->DataValue(1).ToString();
len = typeQuery->DataValue(2).ToInt();
if ( name == "int8" || ( name == "oid" && len == 8 ) )
{
this->Connection->DataTypeMap[ oid ] = VTK_TYPE_INT64;
}
else if ( name == "int4" || ( name == "oid" && len == 4 ) )
{
this->Connection->DataTypeMap[ oid ] = VTK_TYPE_INT32;
}
else if ( name == "int2" )
{
this->Connection->DataTypeMap[ oid ] = VTK_TYPE_INT16;
}
else if ( name == "char" )
{
this->Connection->DataTypeMap[ oid ] = VTK_TYPE_INT8;
}
else if ( name == "time_stamp" )
{
this->Connection->DataTypeMap[ oid ] = VTK_TYPE_INT64;
}
else if ( name == "float4" )
{
this->Connection->DataTypeMap[ oid ] = VTK_FLOAT;
}
else if ( name == "float8" )
{
this->Connection->DataTypeMap[ oid ] = VTK_DOUBLE;
}
else if ( name == "abstime" || name == "reltime" )
{
this->Connection->DataTypeMap[ oid ] = ( len == 4 ? VTK_TYPE_INT32 : VTK_TYPE_INT64 );
}
else if ( name == "text" )
{
this->Connection->DataTypeMap[ oid ] = VTK_STRING;
}
} // done looping over rows
} // done with "query is successful"
typeQuery->Delete();
}