LCOV - code coverage report
Current view: top level - ogr/ogrsf_frmts/sqlite - ogrsqliteutility.h (source / functions) Hit Total Coverage
Test: gdal_filtered.info Lines: 4 4 100.0 %
Date: 2026-03-25 17:52:11 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /******************************************************************************
       2             :  *
       3             :  * Project:  GeoPackage Translator
       4             :  * Purpose:  Utility header for OGR GeoPackage driver.
       5             :  * Author:   Paul Ramsey, pramsey@boundlessgeo.com
       6             :  *
       7             :  ******************************************************************************
       8             :  * Copyright (c) 2013, Paul Ramsey <pramsey@boundlessgeo.com>
       9             :  *
      10             :  * SPDX-License-Identifier: MIT
      11             :  ****************************************************************************/
      12             : 
      13             : #ifndef OGR_SQLITEUTILITY_H_INCLUDED
      14             : #define OGR_SQLITEUTILITY_H_INCLUDED
      15             : 
      16             : #include "ogr_core.h"
      17             : #include "cpl_string.h"
      18             : #include "sqlite3.h"
      19             : 
      20             : #include <set>
      21             : #include <string>
      22             : #include <memory>
      23             : #include <vector>
      24             : 
      25             : class SQLResult
      26             : {
      27             :   public:
      28             :     SQLResult(char **result, int nRow, int nCol);
      29             :     ~SQLResult();
      30             : 
      31       68699 :     int RowCount() const
      32             :     {
      33       68699 :         return nRowCount;
      34             :     }
      35             : 
      36         670 :     int ColCount() const
      37             :     {
      38         670 :         return nColCount;
      39             :     }
      40             : 
      41             :     void LimitRowCount(int nLimit);
      42             : 
      43             :     const char *GetValue(int iColumnNum, int iRowNum) const;
      44             :     int GetValueAsInteger(int iColNum, int iRowNum) const;
      45             :     double GetValueAsDouble(int iColNum, int iRowNum) const;
      46             : 
      47             :   private:
      48             :     char **papszResult = nullptr;
      49             :     int nRowCount = 0;
      50             :     int nColCount = 0;
      51             : 
      52             :     CPL_DISALLOW_COPY_ASSIGN(SQLResult)
      53             : };
      54             : 
      55             : OGRErr SQLCommand(sqlite3 *poDb, const char *pszSQL);
      56             : int SQLGetInteger(sqlite3 *poDb, const char *pszSQL, OGRErr *err);
      57             : GIntBig SQLGetInteger64(sqlite3 *poDb, const char *pszSQL, OGRErr *err);
      58             : 
      59             : std::unique_ptr<SQLResult> SQLQuery(sqlite3 *poDb, const char *pszSQL);
      60             : 
      61             : const char *SQLGetSQLite3DataType(int nSQLite3DataType);
      62             : 
      63             : /* To escape literals. The returned string doesn't contain the surrounding
      64             :  * single quotes */
      65             : CPLString SQLEscapeLiteral(const char *pszLiteral);
      66             : 
      67             : /* To escape table or field names. The returned string doesn't contain the
      68             :  * surrounding double quotes */
      69             : CPLString SQLEscapeName(const char *pszName);
      70             : 
      71             : /* Remove leading ' or " and unescape in that case. Or return string unmodified
      72             :  */
      73             : CPLString SQLUnescape(const char *pszVal);
      74             : 
      75             : char **SQLTokenize(const char *pszSQL);
      76             : 
      77             : struct SQLSqliteMasterContent
      78             : {
      79             :     std::string osSQL{};
      80             :     std::string osType{};
      81             :     std::string osTableName{};
      82             : };
      83             : 
      84             : std::set<std::string> SQLGetUniqueFieldUCConstraints(
      85             :     sqlite3 *poDb, const char *pszTableName,
      86             :     const std::vector<SQLSqliteMasterContent> &sqliteMasterContent =
      87             :         std::vector<SQLSqliteMasterContent>());
      88             : 
      89             : bool OGRSQLiteRTreeRequiresTrustedSchemaOn();
      90             : 
      91             : bool OGRSQLiteIsSpatialFunctionReturningGeometry(const char *pszName);
      92             : 
      93             : /* Wrapper of sqlite3_prepare_v2() that emits a CPLError() if failure */
      94             : int SQLPrepareWithError(sqlite3 *db, const char *sql, int nByte,
      95             :                         sqlite3_stmt **ppStmt, const char **pzTail);
      96             : 
      97             : class GDALDataset;
      98             : 
      99             : void OGRSQLite_gdal_get_pixel_value_common(const char *pszFunctionName,
     100             :                                            sqlite3_context *pContext, int argc,
     101             :                                            sqlite3_value **argv,
     102             :                                            GDALDataset *poDS);
     103             : 
     104             : #if defined(DEBUG) || defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION) ||     \
     105             :     defined(ALLOW_FORMAT_DUMPS)
     106             : bool SQLCheckLineIsSafe(const char *pszLine);
     107             : #endif
     108             : 
     109             : bool SQLHasRemainingContent(const char *pszTail);
     110             : 
     111             : std::string SQLFormatErrorMsgFailedPrepare(sqlite3 *hDB,
     112             :                                            const char *pszErrMsgIntro,
     113             :                                            const char *pszSQL);
     114             : 
     115             : #endif  // OGR_SQLITEUTILITY_H_INCLUDED

Generated by: LCOV version 1.14