aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2021-04-04 22:44:07 +0200
committerEven Rouault <even.rouault@spatialys.com>2021-04-06 23:30:19 +0200
commit950ce787b26b3b3afd0ff76151fdf72d1381b7a1 (patch)
treeb2d70e6c7151361c6cf9e99592ada7386c4a1d95
parentf85b0723136eed9891569b988607f07ef185d504 (diff)
downloadPROJ-950ce787b26b3b3afd0ff76151fdf72d1381b7a1.tar.gz
PROJ-950ce787b26b3b3afd0ff76151fdf72d1381b7a1.zip
Database: nullify auth_name, code of usage table
We never select by those columns, so don't set them. Reduce from 8.4 to 7.9 MB. Upgrade the minor version of the database layout. (that database can still be read by PROJ 8.0)
-rw-r--r--data/sql/commit.sql3
-rw-r--r--data/sql/metadata.sql2
-rw-r--r--data/sql/proj_db_table_defs.sql6
-rw-r--r--src/iso19111/factory.cpp14
-rw-r--r--test/cli/testprojinfo_out.dist2
5 files changed, 20 insertions, 7 deletions
diff --git a/data/sql/commit.sql b/data/sql/commit.sql
index 7a4b74ad..3cdb0861 100644
--- a/data/sql/commit.sql
+++ b/data/sql/commit.sql
@@ -9,6 +9,9 @@ CREATE INDEX grid_transformation_idx ON grid_transformation(source_crs_auth_name
CREATE INDEX other_transformation_idx ON other_transformation(source_crs_auth_name, source_crs_code, target_crs_auth_name, target_crs_code);
CREATE INDEX concatenated_operation_idx ON concatenated_operation(source_crs_auth_name, source_crs_code, target_crs_auth_name, target_crs_code);
+-- We don't need to select by auth_name, code so nullify them to save space
+UPDATE usage SET auth_name = NULL, code = NULL;
+
-- Final consistency checks
CREATE TABLE dummy(foo);
CREATE TRIGGER final_checks
diff --git a/data/sql/metadata.sql b/data/sql/metadata.sql
index bb8e3095..93b4c62e 100644
--- a/data/sql/metadata.sql
+++ b/data/sql/metadata.sql
@@ -7,7 +7,7 @@
-- DATABASE_LAYOUT_VERSION_MINOR constants in src/iso19111/factory.cpp must be
-- updated as well.
INSERT INTO "metadata" VALUES('DATABASE.LAYOUT.VERSION.MAJOR', 1);
-INSERT INTO "metadata" VALUES('DATABASE.LAYOUT.VERSION.MINOR', 0);
+INSERT INTO "metadata" VALUES('DATABASE.LAYOUT.VERSION.MINOR', 1);
INSERT INTO "metadata" VALUES('EPSG.VERSION', 'v10.018');
INSERT INTO "metadata" VALUES('EPSG.DATE', '2021-04-02');
diff --git a/data/sql/proj_db_table_defs.sql b/data/sql/proj_db_table_defs.sql
index 08f74c34..9b1d3dce 100644
--- a/data/sql/proj_db_table_defs.sql
+++ b/data/sql/proj_db_table_defs.sql
@@ -86,8 +86,8 @@ CREATE TABLE scope(
);
CREATE TABLE usage(
- auth_name TEXT NOT NULL CHECK (length(auth_name) >= 1),
- code INTEGER_OR_TEXT NOT NULL CHECK (length(code) >= 1),
+ auth_name TEXT CHECK (auth_name IS NULL OR length(auth_name) >= 1),
+ code INTEGER_OR_TEXT CHECK (code IS NULL OR length(code) >= 1),
object_table_name TEXT NOT NULL CHECK (object_table_name IN (
'geodetic_datum', 'vertical_datum',
'geodetic_crs', 'projected_crs', 'vertical_crs', 'compound_crs',
@@ -1490,7 +1490,7 @@ CREATE VIEW authority_list AS
UNION
SELECT DISTINCT auth_name FROM scope
UNION
- SELECT DISTINCT auth_name FROM usage
+ SELECT DISTINCT auth_name FROM usage WHERE auth_name IS NOT NULL
UNION
SELECT DISTINCT auth_name FROM prime_meridian
UNION
diff --git a/src/iso19111/factory.cpp b/src/iso19111/factory.cpp
index 2da09d27..b59cc1ab 100644
--- a/src/iso19111/factory.cpp
+++ b/src/iso19111/factory.cpp
@@ -101,7 +101,7 @@ namespace io {
constexpr int DATABASE_LAYOUT_VERSION_MAJOR = 1;
// If the code depends on the new additions, then DATABASE_LAYOUT_VERSION_MINOR
// must be incremented.
-constexpr int DATABASE_LAYOUT_VERSION_MINOR = 0;
+constexpr int DATABASE_LAYOUT_VERSION_MINOR = 1;
constexpr size_t N_MAX_PARAMS = 7;
@@ -735,7 +735,7 @@ void DatabaseContext::Private::checkDatabaseLayout(
// cppcheck-suppress knownConditionTrueFalse
DATABASE_LAYOUT_VERSION_MAJOR == 1 &&
// cppcheck-suppress knownConditionTrueFalse
- DATABASE_LAYOUT_VERSION_MINOR == 0,
+ DATABASE_LAYOUT_VERSION_MINOR == 1,
"remove that assertion and below lines next time we upgrade "
"database structure");
res = run("SELECT 1 FROM metadata WHERE key = 'EPSG.VERSION' AND "
@@ -766,6 +766,15 @@ void DatabaseContext::Private::checkDatabaseLayout(
" is expected. "
"It comes from another PROJ installation.");
}
+ // Database layout v1.0 of PROJ 8.0 is forward compatible with v1.1
+ static_assert(
+ // cppcheck-suppress knownConditionTrueFalse
+ DATABASE_LAYOUT_VERSION_MAJOR == 1 &&
+ // cppcheck-suppress knownConditionTrueFalse
+ DATABASE_LAYOUT_VERSION_MINOR == 1,
+ "re-enable the check below if database layout v1.0 and v1.1 is no "
+ "longer compatible");
+#if 0
if (minor < DATABASE_LAYOUT_VERSION_MINOR) {
throw FactoryException(
path +
@@ -774,6 +783,7 @@ void DatabaseContext::Private::checkDatabaseLayout(
" is expected. "
"It comes from another PROJ installation.");
}
+#endif
if (dbNamePrefix.empty()) {
nLayoutVersionMajor_ = major;
nLayoutVersionMinor_ = minor;
diff --git a/test/cli/testprojinfo_out.dist b/test/cli/testprojinfo_out.dist
index ed6a431a..ccb9e070 100644
--- a/test/cli/testprojinfo_out.dist
+++ b/test/cli/testprojinfo_out.dist
@@ -1559,7 +1559,7 @@ CREATE TABLE unit_of_measure(
Testing projinfo --dump-db-structure --output-id HOBU:XXXX EPSG:4326 | tail -n 4
INSERT INTO metadata VALUES('DATABASE.LAYOUT.VERSION.MAJOR',1);
-INSERT INTO metadata VALUES('DATABASE.LAYOUT.VERSION.MINOR',0);
+INSERT INTO metadata VALUES('DATABASE.LAYOUT.VERSION.MINOR',1);
INSERT INTO geodetic_crs VALUES('HOBU','XXXX','WGS 84','','geographic 2D','EPSG','6422','EPSG','6326',NULL,0);
INSERT INTO usage VALUES('HOBU','USAGE_GEODETIC_CRS_XXXX','geodetic_crs','HOBU','XXXX','EPSG','1262','EPSG','1183');