From: | Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com> |
---|---|
To: | Korbin Hoffman <k1(at)k1(dot)io> |
Cc: | Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: hstore: add hstore_length function |
Date: | 2016-06-06 18:23:57 |
Message-ID: | CAFcNs+o4s3EYqzNU+oDhOairwby2qi1K2SKxmGbfnsNqaQtEhw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Jun 3, 2016 at 7:58 AM, Korbin Hoffman <k1(at)k1(dot)io> wrote:
>
> Hi there-
>
> I've attached a small patch exposing HS_COUNT to the user as
> "hstore_length(hstore)". Documentation, upgrade sql files, and a few
> tests are also included.
>
> Almost every hstore function calls HS_COUNT, but I couldn't determine
> if there was a reason this exposure didn't already exist.
>
> Without this function, I've been converting an hstore into an array
> and then counting it - a more expensive operation (~30-40% slower than
> SELECTing the hstore itself in a few of my tests).
>
> I will add this thread and patch to the next Commitfest.
>
Something goes wrong when applying against master:
$ git apply ~/Downloads/hstore_length-v1.patch
error: contrib/hstore/Makefile: already exists in working directory
error: contrib/hstore/expected/hstore.out: already exists in working
directory
error: contrib/hstore/hstore--1.3.sql: already exists in working directory
error: contrib/hstore/hstore.control: already exists in working directory
error: contrib/hstore/hstore_op.c: already exists in working directory
error: contrib/hstore/sql/hstore.sql: already exists in working directory
error: doc/src/sgml/hstore.sgml: already exists in working directory
Anyway I have some comments:
1) I don't see any reason to add this sort of thing if you're adding a new
function
+ HSTORE_POLLUTE(hstore_length, length);
2) Shouldn't this declaration use 'uint32' instead of 'int' ??
+ int count = HS_COUNT(hs);
+
+ PG_RETURN_INT32(count);
maybe
+ uint32 count = HS_COUNT(hs);
+
+ PG_RETURN_UINT32(count);
Regards,
--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL
>> Timbira: http://www.timbira.com.br
>> Blog: http://fabriziomello.github.io
>> Linkedin: http://br.linkedin.com/in/fabriziomello
>> Twitter: http://twitter.com/fabriziomello
>> Github: http://github.com/fabriziomello
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Frost | 2016-06-06 18:24:14 | Re: Reviewing freeze map code |
Previous Message | Tomas Vondra | 2016-06-06 18:20:05 | Re: pg9.6 segfault using simple query (related to use fk for join estimates) |