| 3790 | /************************************************************************/ |
| 3791 | |
| 3792 | static 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; |
no test coverage detected