LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/hana - ogrhanadrivercore.cpp (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 43 43 100.0 %
Date: 2024-11-21 22:18:42 Functions: 9 9 100.0 %

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

Generated by: LCOV version 1.14