diff options
Diffstat (limited to 'meta-openstack/recipes-devtools/python/python-ceilometer')
| -rw-r--r-- | meta-openstack/recipes-devtools/python/python-ceilometer/0001-sqlalchemy-fix-grouping-for-postgresql-databases.patch | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/meta-openstack/recipes-devtools/python/python-ceilometer/0001-sqlalchemy-fix-grouping-for-postgresql-databases.patch b/meta-openstack/recipes-devtools/python/python-ceilometer/0001-sqlalchemy-fix-grouping-for-postgresql-databases.patch new file mode 100644 index 0000000..b2417d7 --- /dev/null +++ b/meta-openstack/recipes-devtools/python/python-ceilometer/0001-sqlalchemy-fix-grouping-for-postgresql-databases.patch | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | From d64999f1eba3db1444f36214bf4be7b8eaffdcb1 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Bruce Ashfield <bruce.ashfield@windriver.com> | ||
| 3 | Date: Mon, 7 Apr 2014 16:24:18 -0400 | ||
| 4 | Subject: [PATCH] sqlalchemy: fix grouping for postgresql databases | ||
| 5 | |||
| 6 | To avoid horizon errors, and avoid the following query issue: | ||
| 7 | |||
| 8 | ProgrammingError: (ProgrammingError) column "meter.unit" must appear in the GROUP BY clause or be used in an aggregate function | ||
| 9 | |||
| 10 | We need to add meter.unit as an explicit group_by attribute | ||
| 11 | |||
| 12 | Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com> | ||
| 13 | --- | ||
| 14 | ceilometer/storage/impl_sqlalchemy.py | 10 ++++++++-- | ||
| 15 | 1 file changed, 8 insertions(+), 2 deletions(-) | ||
| 16 | |||
| 17 | diff --git a/ceilometer/storage/impl_sqlalchemy.py b/ceilometer/storage/impl_sqlalchemy.py | ||
| 18 | index 0e5df7008c5e..697f51136c37 100644 | ||
| 19 | --- a/ceilometer/storage/impl_sqlalchemy.py | ||
| 20 | +++ b/ceilometer/storage/impl_sqlalchemy.py | ||
| 21 | @@ -674,8 +674,14 @@ class Connection(base.Connection): | ||
| 22 | group_attributes = [getattr(models.Sample, g) for g in groupby] | ||
| 23 | select.extend(group_attributes) | ||
| 24 | |||
| 25 | - query = session.query(*select).filter( | ||
| 26 | - models.Meter.id == models.Sample.meter_id) | ||
| 27 | + # Group by Meter.unit for postgresql queries | ||
| 28 | + # In mysql this doesn't change anything because one meter has one unit | ||
| 29 | + | ||
| 30 | + # mysql: | ||
| 31 | + # query = session.query(*select).filter( | ||
| 32 | + # models.Meter.id == models.Sample.meter_id) | ||
| 33 | + # postgres: | ||
| 34 | + query = session.query(*select).group_by(models.Meter.unit) | ||
| 35 | |||
| 36 | if groupby: | ||
| 37 | query = query.group_by(*group_attributes) | ||
| 38 | -- | ||
| 39 | 1.7.10.4 | ||
| 40 | |||
