[PostgreSQL] Subnet entity with ServiceType grouped by both tables
The SQL clause "GROUP BY" in PostgreSQL requires the presence of all
fields provided in the "SELECT" clause; this is not happening in
MariaDB not MySQL.
Since [1] (and the related patch [2] that are part of the same bug
fix), when a resource with RBAC registers is selected, the "GROUP BY"
clause is added to reduce the number of returned registers. The
filed used is "id", present in all the RBAC controlled resources
('network', 'qospolicy', 'securitygroup', 'addressscope',
'subnetpool', 'addressgroup'). That is in opposition to what was
stated in the first paragraph "requires the presence of all
fields provided in the "SELECT" clause". However it is possible
to group only by a primary key [3].
In [4] a prior change was introduced that modifies the "Subnet" entity
to include a child table "SubnetServiceType". That introduces two new
fields ("SubnetServiceType" fields) that are not present in the
"GROUP BY" clause, causing the reported error in the LP bug.
This patch is adding these two fields (that form the composite primary
key of "SubnetServiceType" table) to the "GROUP BY" clause, when
needed; if the query is executed by an administrator, the RBAC query
won't be performed (an administrator has always permissions) and the
"GROUP BY" clause won't be issued.
Reviewed: https:/ /review. opendev. org/c/openstack /neutron/ +/896522 /opendev. org/openstack/ neutron/ commit/ a4efc2dd80f1628 e794e761d2d3e9e 6c27e992b5
Committed: https:/
Submitter: "Zuul (22348)"
Branch: stable/yoga
commit a4efc2dd80f1628 e794e761d2d3e9e 6c27e992b5
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Tue Jul 18 02:38:47 2023 +0000
[PostgreSQL] Subnet entity with ServiceType grouped by both tables
The SQL clause "GROUP BY" in PostgreSQL requires the presence of all
fields provided in the "SELECT" clause; this is not happening in
MariaDB not MySQL.
Since [1] (and the related patch [2] that are part of the same bug
fix), when a resource with RBAC registers is selected, the "GROUP BY"
clause is added to reduce the number of returned registers. The
filed used is "id", present in all the RBAC controlled resources
('network', 'qospolicy', 'securitygroup', 'addressscope',
'subnetpool', 'addressgroup'). That is in opposition to what was
stated in the first paragraph "requires the presence of all
fields provided in the "SELECT" clause". However it is possible
to group only by a primary key [3].
In [4] a prior change was introduced that modifies the "Subnet" entity ype". That introduces two new Type" fields) that are not present in the
to include a child table "SubnetServiceT
fields ("SubnetService
"GROUP BY" clause, causing the reported error in the LP bug.
This patch is adding these two fields (that form the composite primary
key of "SubnetServiceType" table) to the "GROUP BY" clause, when
needed; if the query is executed by an administrator, the RBAC query
won't be performed (an administrator has always permissions) and the
"GROUP BY" clause won't be issued.
[1]https:/ /review. opendev. org/c/openstack /neutron- lib/+/884878 /review. opendev. org/c/openstack /neutron/ +/884877 /learnsql. com/blog/ must-appear- in-group- by-clause/ /review. opendev. org/c/openstack /neutron/ +/744512
[2]https:/
[3]https:/
[4]https:/
Closes-Bug: #2028003 995076eb9166da2 3fc14c92fc5 1f7e6e3a1799720 1f695925ec) 2117bbc364012da 7d1de8bf0a)
neutron/ objects/ subnet. py
Change-Id: I18e65d79e56fe5
(cherry picked from commit c831771053c2952
(cherry picked from commit 96267a25821f1fa
Conflicts: