MCPcopy Create free account
hub / github.com/Kitware/VTK / UpdateDataTypeMap

Method UpdateDataTypeMap

IO/PostgreSQL/vtkPostgreSQLDatabase.cxx:680–751  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

678//------------------------------------------------------------------------------
679
680void vtkPostgreSQLDatabase::UpdateDataTypeMap()
681{
682 if (!this->IsOpen())
683 {
684 return;
685 }
686
687 this->Connection->DataTypeMap.clear();
688
689 vtkSQLQuery* typeQuery = this->GetQueryInstance();
690 typeQuery->SetQuery("SELECT oid, typname, typlen FROM pg_type");
691 bool status = typeQuery->Execute();
692 if (!status)
693 {
694 vtkErrorMacro(<< "I was totally surprised to see the data type query fail. Error message: "
695 << typeQuery->GetLastErrorText());
696 typeQuery->Delete();
697 }
698 else
699 {
700 while (typeQuery->NextRow())
701 {
702 Oid oid;
703 std::string name;
704 int len;
705
706 // Caution: this assumes that the Postgres OID type is a 32-bit
707 // unsigned int.
708 oid = typeQuery->DataValue(0).ToUnsignedInt();
709 name = typeQuery->DataValue(1).ToString();
710 len = typeQuery->DataValue(2).ToInt();
711
712 if (name == "int8" || (name == "oid" && len == 8))
713 {
714 this->Connection->DataTypeMap[oid] = VTK_TYPE_INT64;
715 }
716 else if (name == "int4" || (name == "oid" && len == 4))
717 {
718 this->Connection->DataTypeMap[oid] = VTK_TYPE_INT32;
719 }
720 else if (name == "int2")
721 {
722 this->Connection->DataTypeMap[oid] = VTK_TYPE_INT16;
723 }
724 else if (name == "char")
725 {
726 this->Connection->DataTypeMap[oid] = VTK_TYPE_INT8;
727 }
728 else if (name == "time_stamp")
729 {
730 this->Connection->DataTypeMap[oid] = VTK_TYPE_INT64;
731 }
732 else if (name == "float4")
733 {
734 this->Connection->DataTypeMap[oid] = VTK_FLOAT;
735 }
736 else if (name == "float8")
737 {

Callers 1

OpenInternalMethod · 0.95

Calls 12

IsOpenMethod · 0.95
GetQueryInstanceMethod · 0.95
ToUnsignedIntMethod · 0.80
DeleteMethod · 0.65
clearMethod · 0.45
SetQueryMethod · 0.45
ExecuteMethod · 0.45
GetLastErrorTextMethod · 0.45
NextRowMethod · 0.45
DataValueMethod · 0.45
ToStringMethod · 0.45
ToIntMethod · 0.45

Tested by

no test coverage detected