aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbrep/build-extra.sql17
-rw-r--r--libbrep/build-package.hxx28
-rw-r--r--libbrep/build.hxx2
-rw-r--r--libbrep/build.xml2
-rw-r--r--libbrep/common.hxx19
-rw-r--r--libbrep/package.hxx25
-rw-r--r--libbrep/package.xml46
-rw-r--r--migrate/migrate.cxx37
-rw-r--r--mod/mod-package-version-details.cxx4
-rw-r--r--mod/page.cxx4
-rw-r--r--tests/load/driver.cxx18
11 files changed, 187 insertions, 15 deletions
diff --git a/libbrep/build-extra.sql b/libbrep/build-extra.sql
index bd3df2b..a8464cf 100644
--- a/libbrep/build-extra.sql
+++ b/libbrep/build-extra.sql
@@ -12,6 +12,8 @@ DROP FOREIGN TABLE IF EXISTS build_package_builds;
DROP FOREIGN TABLE IF EXISTS build_package_tests;
+DROP FOREIGN TABLE IF EXISTS build_package_requirement_alternative_requirements;
+
DROP FOREIGN TABLE IF EXISTS build_package_requirement_alternatives;
DROP FOREIGN TABLE IF EXISTS build_package_requirements;
@@ -82,9 +84,22 @@ CREATE FOREIGN TABLE build_package_requirement_alternatives (
version_revision INTEGER NOT NULL,
requirement_index BIGINT NOT NULL,
index BIGINT NOT NULL,
- id TEXT NOT NULL)
+ enable TEXT NULL)
SERVER package_server OPTIONS (table_name 'package_requirement_alternatives');
+CREATE FOREIGN TABLE build_package_requirement_alternative_requirements (
+ tenant TEXT NOT NULL,
+ name CITEXT NOT NULL,
+ version_epoch INTEGER NOT NULL,
+ version_canonical_upstream TEXT NOT NULL,
+ version_canonical_release TEXT NOT NULL COLLATE "C",
+ version_revision INTEGER NOT NULL,
+ requirement_index BIGINT NOT NULL,
+ alternative_index BIGINT NOT NULL,
+ index BIGINT NOT NULL,
+ id TEXT NOT NULL)
+SERVER package_server OPTIONS (table_name 'package_requirement_alternative_requirements');
+
-- The foreign table for the build_package object tests member (that is of a
-- container type).
--
diff --git a/libbrep/build-package.hxx b/libbrep/build-package.hxx
index 77520d1..c46119d 100644
--- a/libbrep/build-package.hxx
+++ b/libbrep/build-package.hxx
@@ -135,17 +135,41 @@ namespace brep
// requirements
//
- #pragma db member(requirement_key::outer) column("requirement_index")
- #pragma db member(requirement_key::inner) column("index")
+ // Note that this is a 2-level nested container (see package.hxx for
+ // details).
+ //
+ // Container of the requirement_alternatives values.
+ //
#pragma db member(requirements) id_column("") value_column("")
+
+ // Container of the requirement_alternative values.
+ //
+ #pragma db member(requirement_alternative_key::outer) column("requirement_index")
+ #pragma db member(requirement_alternative_key::inner) column("index")
+
#pragma db member(requirement_alternatives) \
virtual(requirement_alternatives_map) \
after(requirements) \
get(odb::nested_get (this.requirements)) \
set(odb::nested_set (this.requirements, std::move (?))) \
+ id_column("") key_column("") value_column("")
+
+ // Container of the requirement (string) values.
+ //
+ #pragma db member(requirement_key::outer) column("requirement_index")
+ #pragma db member(requirement_key::middle) column("alternative_index")
+ #pragma db member(requirement_key::inner) column("index")
+
+ #pragma db member(requirement_alternative_requirements) \
+ virtual(requirement_alternative_requirements_map) \
+ after(requirement_alternatives) \
+ get(odb::nested2_get (this.requirements)) \
+ set(odb::nested2_set (this.requirements, std::move (?))) \
id_column("") key_column("") value_column("id")
+ // tests, builds, and constraints
+ //
#pragma db member(tests) id_column("") value_column("test_")
#pragma db member(builds) id_column("") value_column("")
#pragma db member(constraints) id_column("") value_column("")
diff --git a/libbrep/build.hxx b/libbrep/build.hxx
index 29d9890..de12a70 100644
--- a/libbrep/build.hxx
+++ b/libbrep/build.hxx
@@ -30,7 +30,7 @@
//
#define LIBBREP_BUILD_SCHEMA_VERSION_BASE 15
-#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 15, closed)
+#pragma db model version(LIBBREP_BUILD_SCHEMA_VERSION_BASE, 16, closed)
// We have to keep these mappings at the global scope instead of inside
// the brep namespace because they need to be also effective in the
diff --git a/libbrep/build.xml b/libbrep/build.xml
index 42de81a..d90f871 100644
--- a/libbrep/build.xml
+++ b/libbrep/build.xml
@@ -1,4 +1,6 @@
<changelog xmlns="http://www.codesynthesis.com/xmlns/odb/changelog" database="pgsql" schema-name="build" version="1">
+ <changeset version="16"/>
+
<model version="15">
<table name="build" kind="object">
<column name="package_tenant" type="TEXT" null="false"/>
diff --git a/libbrep/common.hxx b/libbrep/common.hxx
index 98fc4e7..b9b6928 100644
--- a/libbrep/common.hxx
+++ b/libbrep/common.hxx
@@ -373,13 +373,28 @@ namespace brep
// requirements
//
+ // Note that this is a 2-level nested container (see package.hxx for
+ // details).
+ //
+ using bpkg::requirement_alternative;
using bpkg::requirement_alternatives;
using requirements = vector<requirement_alternatives>;
+ #pragma db value(requirement_alternative) definition
#pragma db value(requirement_alternatives) definition
- using requirement_key = odb::nested_key<requirement_alternatives>;
- using requirement_alternatives_map = std::map<requirement_key, string>;
+ using requirement_alternative_key =
+ odb::nested_key<requirement_alternatives>;
+
+ using requirement_alternatives_map =
+ std::map<requirement_alternative_key, requirement_alternative>;
+
+ #pragma db value(requirement_alternative_key)
+
+ using requirement_key = odb::nested2_key<requirement_alternatives>;
+
+ using requirement_alternative_requirements_map =
+ std::map<requirement_key, string>;
#pragma db value(requirement_key)
diff --git a/libbrep/package.hxx b/libbrep/package.hxx
index 1927298..38ca0ec 100644
--- a/libbrep/package.hxx
+++ b/libbrep/package.hxx
@@ -607,15 +607,36 @@ namespace brep
// requirements
//
- #pragma db member(requirement_key::outer) column("requirement_index")
- #pragma db member(requirement_key::inner) column("index")
+ // Note that this is a 2-level nested container which is mapped to three
+ // container tables each containing data of each dimension.
+ // Container of the requirement_alternatives values.
+ //
#pragma db member(requirements) id_column("") value_column("")
+
+ // Container of the requirement_alternative values.
+ //
+ #pragma db member(requirement_alternative_key::outer) column("requirement_index")
+ #pragma db member(requirement_alternative_key::inner) column("index")
+
#pragma db member(requirement_alternatives) \
virtual(requirement_alternatives_map) \
after(requirements) \
get(odb::nested_get (this.requirements)) \
set(odb::nested_set (this.requirements, std::move (?))) \
+ id_column("") key_column("") value_column("")
+
+ // Container of the requirement (string) values.
+ //
+ #pragma db member(requirement_key::outer) column("requirement_index")
+ #pragma db member(requirement_key::middle) column("alternative_index")
+ #pragma db member(requirement_key::inner) column("index")
+
+ #pragma db member(requirement_alternative_requirements) \
+ virtual(requirement_alternative_requirements_map) \
+ after(requirement_alternatives) \
+ get(odb::nested2_get (this.requirements)) \
+ set(odb::nested2_set (this.requirements, std::move (?))) \
id_column("") key_column("") value_column("id")
// tests
diff --git a/libbrep/package.xml b/libbrep/package.xml
index 9e162ed..956e5d2 100644
--- a/libbrep/package.xml
+++ b/libbrep/package.xml
@@ -110,6 +110,52 @@
</references>
</foreign-key>
</add-table>
+ <alter-table name="package_requirement_alternatives">
+ <add-column name="enable" type="TEXT" null="true"/>
+ <drop-column name="id"/>
+ </alter-table>
+ <add-table name="package_requirement_alternative_requirements" kind="container">
+ <column name="tenant" type="TEXT" null="false"/>
+ <column name="name" type="CITEXT" null="false"/>
+ <column name="version_epoch" type="INTEGER" null="false"/>
+ <column name="version_canonical_upstream" type="TEXT" null="false"/>
+ <column name="version_canonical_release" type="TEXT" null="false" options="COLLATE &quot;C&quot;"/>
+ <column name="version_revision" type="INTEGER" null="false"/>
+ <column name="requirement_index" type="BIGINT" null="false"/>
+ <column name="alternative_index" type="BIGINT" null="false"/>
+ <column name="index" type="BIGINT" null="false"/>
+ <column name="id" type="TEXT" null="false"/>
+ <foreign-key name="tenant_fk" deferrable="DEFERRED">
+ <column name="tenant"/>
+ <references table="tenant">
+ <column name="id"/>
+ </references>
+ </foreign-key>
+ <foreign-key name="object_id_fk" on-delete="CASCADE">
+ <column name="tenant"/>
+ <column name="name"/>
+ <column name="version_epoch"/>
+ <column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
+ <column name="version_revision"/>
+ <references table="package">
+ <column name="tenant"/>
+ <column name="name"/>
+ <column name="version_epoch"/>
+ <column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
+ <column name="version_revision"/>
+ </references>
+ </foreign-key>
+ <index name="package_requirement_alternative_requirements_object_id_i">
+ <column name="tenant"/>
+ <column name="name"/>
+ <column name="version_epoch"/>
+ <column name="version_canonical_upstream"/>
+ <column name="version_canonical_release"/>
+ <column name="version_revision"/>
+ </index>
+ </add-table>
</changeset>
<model version="21">
diff --git a/migrate/migrate.cxx b/migrate/migrate.cxx
index 627ee4f..7e009e0 100644
--- a/migrate/migrate.cxx
+++ b/migrate/migrate.cxx
@@ -222,9 +222,13 @@ struct package_migration_entry: package_migration_entry_base<v>
static const package_migration_entry<22>
package_migrate_v22 ([] (database& db)
{
- // Note that package_dependency_alternative_dependencies.alternative_index
- // is copied from package_dependency_alternatives.index and
- // package_dependency_alternative_dependencies.index is set to 0.
+ // Note that for both dependency and requirement
+ // package_*_alternative_*s.alternative_index is copied from
+ // package_*_alternatives.index and package_*_alternative_*s.index is set to
+ // 0.
+ //
+
+ // Migrate dependencies.
//
db.execute (
"INSERT INTO \"package_dependency_alternative_dependencies\" "
@@ -290,6 +294,33 @@ package_migrate_v22 ([] (database& db)
"\"dep_package_version_canonical_release\", "
"\"dep_package_version_revision\" "
"FROM \"package_dependency_alternatives\"");
+
+ // Migrate requirements.
+ //
+ db.execute (
+ "INSERT INTO \"package_requirement_alternative_requirements\" "
+ "(\"tenant\", "
+ "\"name\", "
+ "\"version_epoch\", "
+ "\"version_canonical_upstream\", "
+ "\"version_canonical_release\", "
+ "\"version_revision\", "
+ "\"requirement_index\", "
+ "\"alternative_index\", "
+ "\"index\", "
+ "\"id\") "
+ "SELECT "
+ "\"tenant\", "
+ "\"name\", "
+ "\"version_epoch\", "
+ "\"version_canonical_upstream\", "
+ "\"version_canonical_release\", "
+ "\"version_revision\", "
+ "\"requirement_index\", "
+ "\"index\", "
+ "0, "
+ "\"id\" "
+ "FROM \"package_requirement_alternatives\"");
});
// Register the data migration functions for the build database schema.
diff --git a/mod/mod-package-version-details.cxx b/mod/mod-package-version-details.cxx
index 68d43de..e271c45 100644
--- a/mod/mod-package-version-details.cxx
+++ b/mod/mod-package-version-details.cxx
@@ -385,7 +385,9 @@ handle (request& rq, response& rs)
if (&ra != &ras[0])
s << " | ";
- s << ra;
+ assert (ra.size () == 1); // @@ DEP
+
+ s << ra[0];
}
s << ~SPAN
diff --git a/mod/page.cxx b/mod/page.cxx
index af9c795..fb6ba90 100644
--- a/mod/page.cxx
+++ b/mod/page.cxx
@@ -553,7 +553,9 @@ namespace brep
if (&ra != &ras[0])
s << " | ";
- s << ra;
+ assert (ra.size () == 1); // @@ DEP
+
+ s << ra[0];
}
if (mult)
diff --git a/tests/load/driver.cxx b/tests/load/driver.cxx
index 25403c7..bc51c8d 100644
--- a/tests/load/driver.cxx
+++ b/tests/load/driver.cxx
@@ -30,11 +30,25 @@ using namespace butl;
using namespace brep;
using labels = small_vector<string, 5>;
-using req_alts = small_vector<string, 1>;
static const path packages ("packages.manifest");
static const path repositories ("repositories.manifest");
+static requirement_alternatives
+req_alts (const strings& ras)
+{
+ requirement_alternatives r;
+ for (const string& s: ras)
+ {
+ requirement_alternative ra;
+ ra.push_back (s);
+
+ r.push_back (move (ra));
+ }
+
+ return r;
+}
+
static bool
check_location (shared_ptr<package>& p)
{
@@ -827,7 +841,7 @@ test_pkg_repos (const cstrings& loader_args,
assert (fpvr5[3].conditional);
assert (fpvr5[3].comment == "Only if using VC++ on Windows.");
- assert (fpvr5[4][0] == "host");
+ assert (fpvr5[4][0][0] == "host");
assert (check_location (fpv5));