Line data Source code
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 : * Permission is hereby granted, free of charge, to any person obtaining a 11 : * copy of this software and associated documentation files (the "Software"), 12 : * to deal in the Software without restriction, including without limitation 13 : * the rights to use, copy, modify, merge, publish, distribute, sublicense, 14 : * and/or sell copies of the Software, and to permit persons to whom the 15 : * Software is furnished to do so, subject to the following conditions: 16 : * 17 : * The above copyright notice and this permission notice shall be included 18 : * in all copies or substantial portions of the Software. 19 : * 20 : * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 21 : * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 : * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 23 : * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 : * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 25 : * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 26 : * DEALINGS IN THE SOFTWARE. 27 : ****************************************************************************/ 28 : 29 : #include "ogrsf_frmts.h" 30 : 31 : #include "ogrhanadrivercore.h" 32 : 33 : // clang-format off 34 1230 : const char* OGRHanaLayerCreationOptionsConstants::GetList() 35 : { 36 : return 37 : "<LayerCreationOptionList>" 38 : " <Option name='OVERWRITE' type='boolean' description='Specifies whether to overwrite an existing table with the layer name to be created' default='NO'/>" 39 : " <Option name='LAUNDER' type='boolean' description='Specifies whether layer and field names will be laundered' default='YES'/>" 40 : " <Option name='PRECISION' type='boolean' description='Specifies whether fields created should keep the width and precision' default='YES'/>" 41 : " <Option name='DEFAULT_STRING_SIZE' type='int' description='Specifies default string column size' default='256'/>" 42 : " <Option name='GEOMETRY_NAME' type='string' description='Specifies name of geometry column.' default='OGR_GEOMETRY'/>" 43 : " <Option name='GEOMETRY_NULLABLE' type='boolean' description='Specifies whether the values of the geometry column can be NULL' default='YES'/>" 44 : " <Option name='GEOMETRY_INDEX' type='string' description='Specifies which spatial index to use for the geometry column' default='DEFAULT'/>" 45 : " <Option name='SRID' type='int' description='Forced SRID of the layer'/>" 46 : " <Option name='FID' type='string' description='Specifies the name of the FID column to create' default='OGR_FID'/>" 47 : " <Option name='FID64' type='boolean' description='Specifies whether to create the FID column with BIGINT type to handle 64bit wide ids' default='NO'/>" 48 : " <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.'/>" 49 : " <Option name='BATCH_SIZE' type='int' description='Specifies the number of bytes to be written per one batch' default='4194304'/>" 50 1230 : "</LayerCreationOptionList>"; 51 : } 52 : 53 : // clang-format on 54 : 55 : // clang-format off 56 1230 : const char* OGRHanaOpenOptionsConstants::GetList() 57 : { 58 : return 59 : "<OpenOptionList>" 60 : " <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'/>" 61 : " <Option name='HOST' type='string' description='Server hostname' required='true'/>" 62 : " <Option name='PORT' type='int' description='Port number' required='true'/>" 63 : " <Option name='DATABASE' type='string' description='Specifies the name of the database to connect to' required='true'/>" 64 : " <Option name='USER' type='string' description='Specifies the user name' required='true'/>" 65 : " <Option name='PASSWORD' type='string' description='Specifies the user password' required='true'/>" 66 : " <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'/>" 67 : " <Option name='SCHEMA' type='string' description='Specifies the schema used for tables listed in TABLES option' required='true'/>" 68 : " <Option name='TABLES' type='string' description='Restricted set of tables to list (comma separated)'/>" 69 : " <Option name='ENCRYPT' type='boolean' description='Enables or disables TLS/SSL encryption' default='NO'/>" 70 : " <Option name='SSL_CRYPTO_PROVIDER' type='string' description='Cryptographic library provider used for SSL communication (commoncrypto| sapcrypto | openssl)'/>" 71 : " <Option name='SSL_KEY_STORE' type='string' description='Path to the keystore file that contains the server's private key'/>" 72 : " <Option name='SSL_TRUST_STORE' type='string' description='Path to trust store file that contains the server's public certificate(s) (OpenSSL only)'/>" 73 : " <Option name='SSL_VALIDATE_CERTIFICATE' type='boolean' description='If set to true, the server's certificate is validated' default='YES'/>" 74 : " <Option name='SSL_HOST_NAME_IN_CERTIFICATE' type='string' description='Host name used to verify server's identity'/>" 75 : " <Option name='CONNECTION_TIMEOUT' type='int' description='Connection timeout measured in milliseconds. Setting this option to 0 disables the timeout'/>" 76 : " <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.'/>" 77 : " <Option name='SPLIT_BATCH_COMMANDS' type='boolean' description='Allows split and parallel execution of batch commands on partitioned tables' default='YES'/>" 78 : " <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'/>" 79 1230 : "</OpenOptionList>"; 80 : } 81 : 82 : // clang-format on 83 : 84 : /************************************************************************/ 85 : /* OGRHanaDriverIdentify() */ 86 : /************************************************************************/ 87 : 88 41701 : int OGRHanaDriverIdentify(GDALOpenInfo *poOpenInfo) 89 : 90 : { 91 41701 : return STARTS_WITH_CI(poOpenInfo->pszFilename, HANA_PREFIX); 92 : } 93 : 94 : /************************************************************************/ 95 : /* OGRHANADriverSetCommonMetadata() */ 96 : /************************************************************************/ 97 : 98 1230 : void OGRHANADriverSetCommonMetadata(GDALDriver *poDriver) 99 : { 100 1230 : poDriver->SetDescription(DRIVER_NAME); 101 1230 : poDriver->SetMetadataItem(GDAL_DMD_LONGNAME, "SAP HANA"); 102 1230 : poDriver->SetMetadataItem(GDAL_DCAP_VECTOR, "YES"); 103 1230 : poDriver->SetMetadataItem(GDAL_DCAP_CREATE_LAYER, "YES"); 104 1230 : poDriver->SetMetadataItem(GDAL_DCAP_DELETE_LAYER, "YES"); 105 1230 : poDriver->SetMetadataItem(GDAL_DCAP_CREATE_FIELD, "YES"); 106 1230 : poDriver->SetMetadataItem(GDAL_DCAP_DELETE_FIELD, "YES"); 107 1230 : poDriver->SetMetadataItem(GDAL_DCAP_MEASURED_GEOMETRIES, "YES"); 108 1230 : poDriver->SetMetadataItem(GDAL_DMD_HELPTOPIC, "drivers/vector/hana.html"); 109 1230 : poDriver->SetMetadataItem(GDAL_DMD_CONNECTION_PREFIX, HANA_PREFIX); 110 1230 : poDriver->SetMetadataItem(GDAL_DMD_OPENOPTIONLIST, 111 1230 : OGRHanaOpenOptionsConstants::GetList()); 112 1230 : poDriver->SetMetadataItem(GDAL_DMD_CREATIONOPTIONLIST, 113 1230 : "<CreationOptionList/>"); 114 1230 : poDriver->SetMetadataItem(GDAL_DS_LAYER_CREATIONOPTIONLIST, 115 1230 : OGRHanaLayerCreationOptionsConstants::GetList()); 116 1230 : poDriver->SetMetadataItem(GDAL_DMD_CREATIONFIELDDATATYPES, 117 : "Integer Integer64 Real String Date DateTime " 118 : "Time IntegerList " 119 1230 : "Integer64List RealList StringList Binary"); 120 : 121 1230 : poDriver->SetMetadataItem(GDAL_DMD_CREATION_FIELD_DEFN_FLAGS, 122 1230 : "WidthPrecision Nullable Default"); 123 1230 : poDriver->SetMetadataItem(GDAL_DMD_ALTER_FIELD_DEFN_FLAGS, 124 1230 : "Name Type WidthPrecision Nullable Default"); 125 : 126 1230 : poDriver->SetMetadataItem(GDAL_DCAP_NOTNULL_FIELDS, "YES"); 127 1230 : poDriver->SetMetadataItem(GDAL_DCAP_DEFAULT_FIELDS, "YES"); 128 1230 : poDriver->SetMetadataItem(GDAL_DMD_SUPPORTED_SQL_DIALECTS, 129 1230 : "NATIVE OGRSQL SQLITE"); 130 : 131 1230 : poDriver->pfnIdentify = OGRHanaDriverIdentify; 132 1230 : poDriver->SetMetadataItem(GDAL_DCAP_OPEN, "YES"); 133 1230 : poDriver->SetMetadataItem(GDAL_DCAP_CREATE, "YES"); 134 1230 : } 135 : 136 : /************************************************************************/ 137 : /* DeclareDeferredOGRHANAPlugin() */ 138 : /************************************************************************/ 139 : 140 : #ifdef PLUGIN_FILENAME 141 1522 : void DeclareDeferredOGRHANAPlugin() 142 : { 143 1522 : if (GDALGetDriverByName(DRIVER_NAME) != nullptr) 144 : { 145 301 : return; 146 : } 147 1221 : auto poDriver = new GDALPluginDriverProxy(PLUGIN_FILENAME); 148 : #ifdef PLUGIN_INSTALLATION_MESSAGE 149 : poDriver->SetMetadataItem(GDAL_DMD_PLUGIN_INSTALLATION_MESSAGE, 150 : PLUGIN_INSTALLATION_MESSAGE); 151 : #endif 152 1221 : OGRHANADriverSetCommonMetadata(poDriver); 153 1221 : GetGDALDriverManager()->DeclareDeferredPluginDriver(poDriver); 154 : } 155 : #endif