Skip to content

Commit 9ddc31d

Browse files
authored
Merge pull request #14492 from OSGeo/backport-14487-to-release/3.13
[Backport release/3.13] Parquet: declare empty GDAL_DMD_CREATIONOPTIONLIST
2 parents ec2ab05 + 5250673 commit 9ddc31d

8 files changed

Lines changed: 92 additions & 18 deletions

File tree

alg/gdaltransformer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,8 +2237,8 @@ void *GDALCreateGenImgProjTransformer2(GDALDatasetH hSrcDS, GDALDatasetH hDstDS,
22372237
CSLConstList papszOptions)
22382238

22392239
{
2240-
GDALValidateOptions(GDALGetGenImgProjTranformerOptionList(), papszOptions,
2241-
"option", "transformer options");
2240+
GDALValidateOptions(nullptr, GDALGetGenImgProjTranformerOptionList(),
2241+
papszOptions, "option", "transformer options");
22422242

22432243
double dfWestLongitudeDeg = 0.0;
22442244
double dfSouthLatitudeDeg = 0.0;

alg/gdalwarpoperation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,8 @@ int GDALWarpOperation::ValidateOptions()
378378
aosWO.SetNameValue("ERROR_OUT_IF_EMPTY_SOURCE_WINDOW", nullptr);
379379
aosWO.SetNameValue("MULT_FACTOR_VERTICAL_SHIFT_PIPELINE", nullptr);
380380
aosWO.SetNameValue("SRC_FILL_RATIO_HEURISTICS", nullptr);
381-
GDALValidateOptions(GDALWarpGetOptionList(), aosWO.List(), "option",
382-
"warp options");
381+
GDALValidateOptions(nullptr, GDALWarpGetOptionList(), aosWO.List(),
382+
"option", "warp options");
383383
}
384384

385385
const char *pszSampleSteps =

autotest/ogr/ogr_csv.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3631,6 +3631,20 @@ def test_ogr_csv_creation_illegal_layer_name(tmp_vsimem):
36313631
###############################################################################
36323632

36333633

3634+
@gdaltest.enable_exceptions()
3635+
def test_ogr_csv_used_creation_option_instead_of_layer_creation_option(tmp_vsimem):
3636+
3637+
with gdaltest.error_raised(
3638+
gdal.CE_Warning, match="but a layer creation option of that name exists"
3639+
):
3640+
gdal.GetDriverByName("CSV").CreateVector(
3641+
tmp_vsimem / "out", options=["SEPARATOR=COMMA"]
3642+
)
3643+
3644+
3645+
###############################################################################
3646+
3647+
36343648
if __name__ == "__main__":
36353649
gdal.UseExceptions()
36363650
if len(sys.argv) != 2:

autotest/ogr/ogr_mitab.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3118,3 +3118,19 @@ def test_ogr_mitab_mif_multilinestring_one_point(tmp_vsimem):
31183118
lyr = ds.GetLayer(0)
31193119
f = lyr.GetNextFeature()
31203120
assert f.GetGeometryRef().ExportToWkt() == "MULTILINESTRING ((1 2))"
3121+
3122+
3123+
###############################################################################
3124+
3125+
3126+
@gdaltest.enable_exceptions()
3127+
def test_ogr_mitab_used_layer_creation_option_instead_of_creation_option(tmp_vsimem):
3128+
3129+
with gdal.GetDriverByName("MapInfo File").CreateVector(
3130+
tmp_vsimem / "out.mif"
3131+
) as ds:
3132+
with gdaltest.error_raised(
3133+
gdal.CE_Warning, match="but a creation option of that name exists"
3134+
):
3135+
lyr = ds.CreateLayer("out", options=["FORMAT=TAB"])
3136+
lyr.CreateField(ogr.FieldDefn("x"))

gcore/gdal_cpp_functions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ CPLErr CPL_DLL EXIFExtractMetadata(char **&papszMetadata, void *fpL,
245245

246246
int GDALValidateOpenOptions(GDALDriverH hDriver,
247247
const char *const *papszOptionOptions);
248-
int GDALValidateOptions(const char *pszOptionList,
248+
int GDALValidateOptions(GDALDriverH hDriver, const char *pszOptionList,
249249
const char *const *papszOptionsToValidate,
250250
const char *pszErrorMessageOptionType,
251251
const char *pszErrorMessageContainerName);

gcore/gdaldataset.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2516,8 +2516,9 @@ CPLErr GDALDataset::BuildOverviews(const char *pszResampling, int nOverviews,
25162516

25172517
CPLString osDriver;
25182518
osDriver.Printf("driver %s", poDriver->GetDescription());
2519-
GDALValidateOptions(pszOptionList, aosOptions.List(),
2520-
"overview creation option", osDriver);
2519+
GDALValidateOptions(GDALDriver::ToHandle(poDriver), pszOptionList,
2520+
aosOptions.List(), "overview creation option",
2521+
osDriver);
25212522
}
25222523
}
25232524

@@ -6141,8 +6142,8 @@ int GDALDataset::ValidateLayerCreationOptions(const char *const *papszLCO)
61416142
}
61426143
CPLString osDataset;
61436144
osDataset.Printf("dataset %s", GetDescription());
6144-
return GDALValidateOptions(pszOptionList, papszLCO, "layer creation option",
6145-
osDataset);
6145+
return GDALValidateOptions(GDALDriver::ToHandle(poDriver), pszOptionList,
6146+
papszLCO, "layer creation option", osDataset);
61466147
}
61476148

61486149
//! @endcond

gcore/gdaldriver.cpp

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,8 @@ GDALDriver::CreateMultiDimensional(const char *pszFilename,
393393
GetMetadataItem(GDAL_DMD_MULTIDIM_DATASET_CREATIONOPTIONLIST);
394394
CPLString osDriver;
395395
osDriver.Printf("driver %s", GetDescription());
396-
GDALValidateOptions(pszOptionList, papszOptions, "creation option",
397-
osDriver);
396+
GDALValidateOptions(GDALDriver::ToHandle(this), pszOptionList,
397+
papszOptions, "creation option", osDriver);
398398
}
399399

400400
auto poDstDS = pfnCreateMultiDimensional(pszFilename, papszRootGroupOptions,
@@ -2318,8 +2318,9 @@ int CPL_STDCALL GDALValidateCreationOptions(GDALDriverH hDriver,
23182318
papszOptionsToValidate = papszOptionsToFree;
23192319
}
23202320

2321-
const bool bRet = CPL_TO_BOOL(GDALValidateOptions(
2322-
pszOptionList, papszOptionsToValidate, "creation option", osDriver));
2321+
const bool bRet = CPL_TO_BOOL(
2322+
GDALValidateOptions(hDriver, pszOptionList, papszOptionsToValidate,
2323+
"creation option", osDriver));
23232324
CSLDestroy(papszOptionsToFree);
23242325
return bRet;
23252326
}
@@ -2338,15 +2339,15 @@ int GDALValidateOpenOptions(GDALDriverH hDriver,
23382339
CPLString osDriver;
23392340
osDriver.Printf("driver %s",
23402341
GDALDriver::FromHandle(hDriver)->GetDescription());
2341-
return GDALValidateOptions(pszOptionList, papszOpenOptions, "open option",
2342-
osDriver);
2342+
return GDALValidateOptions(hDriver, pszOptionList, papszOpenOptions,
2343+
"open option", osDriver);
23432344
}
23442345

23452346
/************************************************************************/
23462347
/* GDALValidateOptions() */
23472348
/************************************************************************/
23482349

2349-
int GDALValidateOptions(const char *pszOptionList,
2350+
int GDALValidateOptions(GDALDriverH hDriver, const char *pszOptionList,
23502351
const char *const *papszOptionsToValidate,
23512352
const char *pszErrorMessageOptionType,
23522353
const char *pszErrorMessageContainerName)
@@ -2475,10 +2476,48 @@ int GDALValidateOptions(const char *pszOptionList,
24752476
CPLFetchBool(papszOptionsToValidate, "VALIDATE_OPEN_OPTIONS",
24762477
true)))
24772478
{
2479+
const char *pszAdditionalMsg = "";
2480+
if (hDriver &&
2481+
EQUAL(pszErrorMessageOptionType, "creation option"))
2482+
{
2483+
const char *pszLCOList =
2484+
GDALDriver::FromHandle(hDriver)->GetMetadataItem(
2485+
GDAL_DS_LAYER_CREATIONOPTIONLIST);
2486+
if (pszLCOList &&
2487+
(CPLString(pszLCOList)
2488+
.ifind(CPLSPrintf("\"%s\"", pszKey)) !=
2489+
std::string::npos ||
2490+
CPLString(pszLCOList)
2491+
.ifind(CPLSPrintf("'%s'", pszKey)) !=
2492+
std::string::npos))
2493+
{
2494+
pszAdditionalMsg = ", but a layer creation option of "
2495+
"that name exists.";
2496+
}
2497+
}
2498+
else if (hDriver && EQUAL(pszErrorMessageOptionType,
2499+
"layer creation option"))
2500+
{
2501+
const char *pszLCOList =
2502+
GDALDriver::FromHandle(hDriver)->GetMetadataItem(
2503+
GDAL_DMD_CREATIONOPTIONLIST);
2504+
if (pszLCOList &&
2505+
(CPLString(pszLCOList)
2506+
.ifind(CPLSPrintf("\"%s\"", pszKey)) !=
2507+
std::string::npos ||
2508+
CPLString(pszLCOList)
2509+
.ifind(CPLSPrintf("'%s'", pszKey)) !=
2510+
std::string::npos))
2511+
{
2512+
pszAdditionalMsg = ", but a creation option of "
2513+
"that name exists.";
2514+
}
2515+
}
2516+
24782517
CPLError(CE_Warning, CPLE_NotSupported,
2479-
"%s does not support %s %s",
2518+
"%s does not support %s %s%s",
24802519
pszErrorMessageContainerName,
2481-
pszErrorMessageOptionType, pszKey);
2520+
pszErrorMessageOptionType, pszKey, pszAdditionalMsg);
24822521
bRet = false;
24832522
}
24842523

ogr/ogrsf_frmts/parquet/ogrparquetdrivercore.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ void OGRParquetDriverSetCommonMetadata(GDALDriver *poDriver)
102102
"AlternativeName Domain");
103103
poDriver->SetMetadataItem(GDAL_DMD_SUPPORTED_SQL_DIALECTS, "OGRSQL SQLITE");
104104

105+
poDriver->SetMetadataItem(GDAL_DMD_CREATIONOPTIONLIST,
106+
"<CreationOptionList>"
107+
"</CreationOptionList>");
108+
105109
poDriver->SetMetadataItem(
106110
GDAL_DMD_OPENOPTIONLIST,
107111
"<OpenOptionList>"

0 commit comments

Comments
 (0)