We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parent96e218a commit3df4fa6Copy full SHA for 3df4fa6
contrib/hstore/hstore_io.c
@@ -1,5 +1,5 @@
1
/*
2
- * $PostgreSQL: pgsql/contrib/hstore/hstore_io.c,v 1.9 2009/03/15 22:05:17 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/hstore/hstore_io.c,v 1.10 2009/04/02 17:57:05 teodor Exp $
3
*/
4
#include"postgres.h"
5
@@ -446,7 +446,8 @@ hstore_out(PG_FUNCTION_ARGS)
446
{
447
HStore*in=PG_GETARG_HS(0);
448
intbuflen,
449
-i;
+i,
450
+nnulls=0;
451
char*out,
452
*ptr;
453
char*base=STRPTR(in);
@@ -460,8 +461,15 @@ hstore_out(PG_FUNCTION_ARGS)
460
461
PG_RETURN_CSTRING(out);
462
}
463
-buflen= (4/* " */+2/* => */+2/* , */ )*in->size+
464
-2/* esc */* (VARSIZE(in)-CALCDATASIZE(in->size,0));
+for (i=0;i<in->size;i++)
465
+if (entries[i].valisnull)
466
+nnulls++;
467
+
468
+buflen= (4/* " */+2/* => */ )* (in->size-nnulls )+
469
+(2/* " */+2/* => */+4/* NULL */ )*nnulls+
470
+2/* , */* (in->size-1 )+
471
+2/* esc */* (VARSIZE(in)-CALCDATASIZE(in->size,0))+
472
+1/* \0 */;
473
474
out=ptr=palloc(buflen);
475
for (i=0;i<in->size;i++)