On 10/17/2013 10:23 AM, Alvaro Herrera wrote:
Oskari Saarenmaa wrote:
@@ -1241,8 +1241,8 @@ hstore_to_json_loose(PG_FUNCTION_ARGS)
if (count == 0)
{
- out = palloc(1);
- *out = '\0';
+ out = palloc(3);
+ memcpy(out, "{}", 3
On 17/10/13 17:23, Alvaro Herrera wrote:
Oskari Saarenmaa wrote:
@@ -1241,8 +1241,8 @@ hstore_to_json_loose(PG_FUNCTION_ARGS)
if (count == 0)
{
- out = palloc(1);
- *out = '\0';
+ out = palloc(3);
+ memcpy(out, "{}", 3);
Oskari Saarenmaa wrote:
> @@ -1241,8 +1241,8 @@ hstore_to_json_loose(PG_FUNCTION_ARGS)
>
> if (count == 0)
> {
> - out = palloc(1);
> - *out = '\0';
> + out = palloc(3);
> + memcpy(out, "{}", 3);
> PG_RETURN_TEXT_P(cstring
On 10/17/2013 08:20 AM, Robert Haas wrote:
On Wed, Oct 16, 2013 at 12:02 PM, Oskari Saarenmaa wrote:
hstore_to_json used to return an empty string for empty hstores, but
that is not correct as an empty string is not valid json and calling
row_to_json() on rows which have empty hstores will gen
On Thu, Oct 17, 2013 at 7:20 AM, Robert Haas wrote:
> On Wed, Oct 16, 2013 at 12:02 PM, Oskari Saarenmaa wrote:
>> hstore_to_json used to return an empty string for empty hstores, but
>> that is not correct as an empty string is not valid json and calling
>> row_to_json() on rows which have empty
On Wed, Oct 16, 2013 at 12:02 PM, Oskari Saarenmaa wrote:
> hstore_to_json used to return an empty string for empty hstores, but
> that is not correct as an empty string is not valid json and calling
> row_to_json() on rows which have empty hstores will generate invalid
> json for the entire row.