MCPcopy Create free account
hub / github.com/OSGeo/gdal / TestLayerSQL

Function TestLayerSQL

apps/test_ogrsf.cpp:3792–4049  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3790/************************************************************************/
3791
3792static int TestLayerSQL(GDALDataset *poDS, OGRLayer *poLayer)
3793
3794{
3795 int bRet = TRUE;
3796 bool bGotFeature = false;
3797
3798 /* Test consistency between result layer and traditional layer */
3799 LOG_ACTION(poLayer->ResetReading());
3800 OGRFeature *poLayerFeat = LOG_ACTION(poLayer->GetNextFeature());
3801
3802 /* Reset to avoid potentially a statement to be active which cause */
3803 /* issue in the transaction test of the second layer, when testing */
3804 /* multi-tables sqlite and gpkg databases */
3805 LOG_ACTION(poLayer->ResetReading());
3806
3807 CPLString osSQL;
3808 osSQL.Printf("SELECT * FROM %s",
3809 GetLayerNameForSQL(poDS, poLayer->GetName()));
3810 OGRLayer *poSQLLyr =
3811 LOG_ACTION(poDS->ExecuteSQL(osSQL.c_str(), nullptr, nullptr));
3812 OGRFeature *poSQLFeat = nullptr;
3813 if (poSQLLyr == nullptr)
3814 {
3815 printf("ERROR: ExecuteSQL(%s) failed.\n", osSQL.c_str());
3816 bRet = FALSE;
3817 return bRet;
3818 }
3819 else
3820 {
3821 poSQLFeat = LOG_ACTION(poSQLLyr->GetNextFeature());
3822 if (poSQLFeat != nullptr)
3823 bGotFeature = TRUE;
3824 if (poLayerFeat == nullptr && poSQLFeat != nullptr)
3825 {
3826 printf("ERROR: poLayerFeat == NULL && poSQLFeat != NULL.\n");
3827 bRet = FALSE;
3828 }
3829 else if (poLayerFeat != nullptr && poSQLFeat == nullptr)
3830 {
3831 printf("ERROR: poLayerFeat != NULL && poSQLFeat == NULL.\n");
3832 bRet = FALSE;
3833 }
3834 else if (poLayerFeat != nullptr && poSQLFeat != nullptr)
3835 {
3836 if (poLayer->GetLayerDefn()->GetGeomFieldCount() !=
3837 poSQLLyr->GetLayerDefn()->GetGeomFieldCount())
3838 {
3839 printf("ERROR: poLayer->GetLayerDefn()->GetGeomFieldCount() != "
3840 "poSQLLyr->GetLayerDefn()->GetGeomFieldCount().\n");
3841 bRet = FALSE;
3842 }
3843 else
3844 {
3845 int nGeomFieldCount =
3846 poLayer->GetLayerDefn()->GetGeomFieldCount();
3847 for (int i = 0; i < nGeomFieldCount; i++)
3848 {
3849 int iOtherI;

Callers 1

TestOGRLayerFunction · 0.85

Calls 15

GetLayerNameForSQLFunction · 0.85
DestroyFeatureAndNullifyFunction · 0.85
PrintfMethod · 0.80
GetGeomFieldRefMethod · 0.80
addRingMethod · 0.80
ResetReadingMethod · 0.45
GetNextFeatureMethod · 0.45
GetNameMethod · 0.45
ExecuteSQLMethod · 0.45
c_strMethod · 0.45
GetGeomFieldCountMethod · 0.45
GetLayerDefnMethod · 0.45

Tested by

no test coverage detected