hstore each() function - returned order??

From: Brent Wood <Brent(dot)Wood(at)niwa(dot)co(dot)nz>
To: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: hstore each() function - returned order??
Date: 2021-03-12 03:46:58
Message-ID: SY3PR01MB0810FF20F164CE2536930B2CA16F9@SY3PR01MB0810.ausprd01.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I'm using the following in an SQL :

select (EACH(value)).key as measurement_key,
(EACH(value)).value as value
from t_reading_hstore;

I'm assuming this will give two columns containing the key/value pairs in the hstore record.

The docs suggest the order of the keys/values returned is undetermined. That is a bit ambiguous to me.

The order is not a problem in this case: as long as the keys and values are returned in the SAME order, what that order is I don't care.
Just that the key is always returned in the same row as its value.

It does seem to work, at least in my test cases, but I need to know if that is just luck, or if it is a safe assumption to make.

Can anyone confirm this is a robust assumption for me?

Thanks

Brent Wood

Principal Technician, Fisheries
NIWA
DDI: +64 (4) 3860529
[https://www.niwa.co.nz/static/niwa-2018-horizontal-180.png][https://niwa.co.nz/sites/niwa.co.nz/files/ETNZ_Official-supplier-logo-75h.png]<https://www.niwa.co.nz>
Brent Wood
Principal Technician - GIS and Spatial Data Management
Programme Leader - Environmental Information Delivery
+64-4-386-0529
National Institute of Water & Atmospheric Research Ltd (NIWA)
301 Evans Bay Parade Hataitai Wellington New Zealand
Connect with NIWA: niwa.co.nz<https://www.niwa.co.nz> Facebook<https://www.facebook.com/nzniwa> LinkedIn<https://www.linkedin.com/company/niwa> Twitter<https://twitter.com/niwa_nz> Instagram<https://www.instagram.com/niwa_science>
To ensure compliance with legal requirements and to maintain cyber security standards, NIWA's IT systems are subject to ongoing monitoring, activity logging and auditing. This monitoring and auditing service may be provided by third parties. Such third parties can access information transmitted to, processed by and stored on NIWA's IT systems

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2021-03-12 08:19:08 Re: hstore each() function - returned order??
Previous Message Thomas Munro 2021-03-12 01:27:14 Re: SV: Log files polluted with permission denied error messages after every 10 seconds