| 1 |
/****************************************************************************** |
| 2 |
* |
| 3 |
* Project: SAP HANA Spatial Driver |
| 4 |
* Purpose: OGRHanaDriver functions implementation |
| 5 |
* Author: Maxim Rylov |
| 6 |
* |
| 7 |
****************************************************************************** |
| 8 |
* Copyright (c) 2020, SAP SE |
| 9 |
* |
| 10 |
* SPDX-License-Identifier: MIT |
| 11 |
****************************************************************************/ |
| 12 |
|
| 13 |
#include "gdal_frmts.h" |
| 14 |
|
| 15 |
#ifdef PLUGIN_FILENAME |
| 16 |
#include "gdalplugindriverproxy.h" |
| 17 |
#endif |
| 18 |
|
| 19 |
#include "ogrsf_frmts.h" |
| 20 |
|
| 21 |
#include "ogrhanadrivercore.h" |
| 22 |
|
| 23 |
// clang-format off |
| 24 |
const char* OGRHanaLayerCreationOptionsConstants::GetList() |
| 25 |
{ |
| 26 |
return |
| 27 |
"<LayerCreationOptionList>" |
| 28 |
" <Option name='OVERWRITE' type='boolean' description='Specifies whether to overwrite an existing table with the layer name to be created' default='NO'/>" |
| 29 |
" <Option name='LAUNDER' type='boolean' description='Specifies whether layer and field names will be laundered' default='YES'/>" |
| 30 |
" <Option name='PRECISION' type='boolean' description='Specifies whether fields created should keep the width and precision' default='YES'/>" |
| 31 |
" <Option name='DEFAULT_STRING_SIZE' type='int' description='Specifies default string column size' default='256'/>" |
| 32 |
" <Option name='GEOMETRY_NAME' type='string' description='Specifies name of geometry column.' default='OGR_GEOMETRY'/>" |
| 33 |
" <Option name='GEOMETRY_NULLABLE' type='boolean' description='Specifies whether the values of the geometry column can be NULL' default='YES'/>" |
| 34 |
" <Option name='GEOMETRY_INDEX' type='string' description='Specifies which spatial index to use for the geometry column' default='DEFAULT'/>" |
| 35 |
" <Option name='SRID' type='int' description='Forced SRID of the layer'/>" |
| 36 |
" <Option name='FID' type='string' description='Specifies the name of the FID column to create' default='OGR_FID'/>" |
| 37 |
" <Option name='FID64' type='boolean' description='Specifies whether to create the FID column with BIGINT type to handle 64bit wide ids' default='NO'/>" |
| 38 |
" <Option name='COLUMN_TYPES' type='string' description='Specifies a comma-separated list of strings in the format field_name=hana_field_type that define column types.'/>" |
| 39 |
" <Option name='BATCH_SIZE' type='int' description='Specifies the number of bytes to be written per one batch' default='4194304'/>" |
| 40 |
"</LayerCreationOptionList>"; |
| 41 |
} |
| 42 |
|
| 43 |
// clang-format on |
| 44 |
|
| 45 |
// clang-format off |
| 46 |
const char* OGRHanaOpenOptionsConstants::GetList() |
| 47 |
{ |
| 48 |
return |
| 49 |
"<OpenOptionList>" |
| 50 |
" <Option name='DRIVER' type='string' description='Name or a path to a driver.For example, DRIVER={HDBODBC} or DRIVER=/usr/sap/hdbclient/libodbcHDB.so' required='true'/>" |
| 51 |
" <Option name='HOST' type='string' description='Server hostname' required='true'/>" |
| 52 |
" <Option name='PORT' type='int' description='Port number' required='true'/>" |
| 53 |
" <Option name='DATABASE' type='string' description='Specifies the name of the database to connect to' required='true'/>" |
| 54 |
" <Option name='USER' type='string' description='Specifies the user name' required='true'/>" |
| 55 |
" <Option name='PASSWORD' type='string' description='Specifies the user password' required='true'/>" |
| 56 |
" <Option name='USER_STORE_KEY' type='string' description='Specifies whether a connection is made using a key defined in the SAP HANA user store (hdbuserstore)' required='false'/>" |
| 57 |
" <Option name='SCHEMA' type='string' description='Specifies the schema used for tables listed in TABLES option' required='true'/>" |
| 58 |
" <Option name='TABLES' type='string' description='Restricted set of tables to list (comma separated)'/>" |
| 59 |
" <Option name='ENCRYPT' type='boolean' description='Enables or disables TLS/SSL encryption' default='NO'/>" |
| 60 |
" <Option name='SSL_CRYPTO_PROVIDER' type='string' description='Cryptographic library provider used for SSL communication (commoncrypto| sapcrypto | openssl)'/>" |
| 61 |
" <Option name='SSL_KEY_STORE' type='string' description='Path to the keystore file that contains the server's private key'/>" |
| 62 |
" <Option name='SSL_TRUST_STORE' type='string' description='Path to trust store file that contains the server's public certificate(s) (OpenSSL only)'/>" |
| 63 |
" <Option name='SSL_VALIDATE_CERTIFICATE' type='boolean' description='If set to true, the server's certificate is validated' default='YES'/>" |
| 64 |
" <Option name='SSL_HOST_NAME_IN_CERTIFICATE' type='string' description='Host name used to verify server's identity'/>" |
| 65 |
" <Option name='CONNECTION_TIMEOUT' type='int' description='Connection timeout measured in milliseconds. Setting this option to 0 disables the timeout'/>" |
| 66 |
" <Option name='PACKET_SIZE' type='int' description='Sets the maximum size of a request packet sent from the client to the server, in bytes. The minimum is 1 MB.'/>" |
| 67 |
" <Option name='SPLIT_BATCH_COMMANDS' type='boolean' description='Allows split and parallel execution of batch commands on partitioned tables' default='YES'/>" |
| 68 |
" <Option name='DETECT_GEOMETRY_TYPE' type='boolean' description='Specifies whether to detect the type of geometry columns. Note, the detection may take a significant amount of time for large tables' default='YES'/>" |
| 69 |
"</OpenOptionList>"; |
| 70 |
} |
| 71 |
|
| 72 |
// clang-format on |
| 73 |
|
| 74 |
/************************************************************************/ |
| 75 |
/* OGRHanaDriverIdentify() */ |
| 76 |
/************************************************************************/ |
| 77 |
|
| 78 |
int OGRHanaDriverIdentify(GDALOpenInfo *poOpenInfo) |
| 79 |
|
| 80 |
{ |
| 81 |
return STARTS_WITH_CI(poOpenInfo->pszFilename, HANA_PREFIX); |
| 82 |
} |
| 83 |
|
| 84 |
/************************************************************************/ |
| 85 |
/* OGRHANADriverSetCommonMetadata() */ |
| 86 |
/************************************************************************/ |
| 87 |
|
| 88 |
void OGRHANADriverSetCommonMetadata(GDALDriver *poDriver) |
| 89 |
{ |
| 90 |
poDriver->SetDescription(DRIVER_NAME); |
| 91 |
poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "SAP HANA"); |
| 92 |
poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES"); |
| 93 |
poDriver->SetMetadataItem(GDAL_DCAP_CREATE_LAYER, "YES"); |
| 94 |
poDriver->SetMetadataItem(GDAL_DCAP_DELETE_LAYER, "YES"); |
| 95 |
poDriver->SetMetadataItem(GDAL_DCAP_CREATE_FIELD, "YES"); |
| 96 |
poDriver->SetMetadataItem(GDAL_DCAP_DELETE_FIELD, "YES"); |
| 97 |
poDriver->SetMetadataItem(GDAL_DCAP_MEASURED_GEOMETRIES, "YES"); |
| 98 |
poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/vector/hana.html"); |
| 99 |
poDriver->SetMetadataItem(GDAL_DMD_CONNECTION_PREFIX, HANA_PREFIX); |
| 100 |
poDriver->SetMetadataItem(GDAL_DMD_OPENOPTIONLIST, |
| 101 |
OGRHanaOpenOptionsConstants::GetList()); |
| 102 |
poDriver->SetMetadataItem(GDAL_DMD_CREATIONOPTIONLIST, |
| 103 |
"<CreationOptionList/>"); |
| 104 |
poDriver->SetMetadataItem(GDAL_DS_LAYER_CREATIONOPTIONLIST, |
| 105 |
OGRHanaLayerCreationOptionsConstants::GetList()); |
| 106 |
poDriver->SetMetadataItem(GDAL_DMD_CREATIONFIELDDATATYPES, |
| 107 |
"Integer Integer64 Real String Date DateTime " |
| 108 |
"Time IntegerList " |
| 109 |
"Integer64List RealList StringList Binary"); |
| 110 |
|
| 111 |
poDriver->SetMetadataItem(GDAL_DMD_CREATION_FIELD_DEFN_FLAGS, |
| 112 |
"WidthPrecision Nullable Default"); |
| 113 |
poDriver->SetMetadataItem(GDAL_DMD_ALTER_FIELD_DEFN_FLAGS, |
| 114 |
"Name Type WidthPrecision Nullable Default"); |
| 115 |
|
| 116 |
poDriver->SetMetadataItem(GDAL_DCAP_NOTNULL_FIELDS, "YES"); |
| 117 |
poDriver->SetMetadataItem(GDAL_DCAP_DEFAULT_FIELDS, "YES"); |
| 118 |
poDriver->SetMetadataItem(GDAL_DMD_SUPPORTED_SQL_DIALECTS, |
| 119 |
"NATIVE OGRSQL SQLITE"); |
| 120 |
|
| 121 |
poDriver->pfnIdentify = OGRHanaDriverIdentify; |
| 122 |
poDriver->SetMetadataItem(GDAL_DCAP_OPEN, "YES"); |
| 123 |
poDriver->SetMetadataItem(GDAL_DCAP_CREATE, "YES"); |
| 124 |
|
| 125 |
poDriver->SetMetadataItem(GDAL_DCAP_UPDATE, "YES"); |
| 126 |
poDriver->SetMetadataItem(GDAL_DMD_UPDATE_ITEMS, "Features"); |
| 127 |
} |
| 128 |
|
| 129 |
/************************************************************************/ |
| 130 |
/* DeclareDeferredOGRHANAPlugin() */ |
| 131 |
/************************************************************************/ |
| 132 |
|
| 133 |
#ifdef PLUGIN_FILENAME |
| 134 |
void DeclareDeferredOGRHANAPlugin() |
| 135 |
{ |
| 136 |
if (GDALGetDriverByName(DRIVER_NAME) != nullptr) |
| 137 |
{ |
| 138 |
return; |
| 139 |
} |
| 140 |
auto poDriver = new GDALPluginDriverProxy(PLUGIN_FILENAME); |
| 141 |
#ifdef PLUGIN_INSTALLATION_MESSAGE |
| 142 |
poDriver->SetMetadataItem(GDAL_DMD_PLUGIN_INSTALLATION_MESSAGE, |
| 143 |
PLUGIN_INSTALLATION_MESSAGE); |
| 144 |
#endif |
| 145 |
OGRHANADriverSetCommonMetadata(poDriver); |
| 146 |
GetGDALDriverManager()->DeclareDeferredPluginDriver(poDriver); |
| 147 |
} |
| 148 |
#endif |