@@ -79,8 +79,7 @@ static void report_invalid_token(JsonLexContext *lex);
7979static int report_json_context (JsonLexContext * lex );
8080static char * extract_mb_char (char * s );
8181static void composite_to_json (Datum composite ,StringInfo result ,
82- bool use_line_feeds ,
83- bool ignore_nulls );
82+ bool use_line_feeds );
8483static void array_dim_to_json (StringInfo result ,int dim ,int ndims ,int * dims ,
8584Datum * vals ,bool * nulls ,int * valcount ,
8685JsonTypeCategory tcategory ,Oid outfuncoid ,
@@ -1366,7 +1365,7 @@ datum_to_json(Datum val, bool is_null, StringInfo result,
13661365array_to_json_internal (val ,result , false);
13671366break ;
13681367case JSONTYPE_COMPOSITE :
1369- composite_to_json (val ,result , false, false );
1368+ composite_to_json (val ,result , false);
13701369break ;
13711370case JSONTYPE_BOOL :
13721371outputstr = DatumGetBool (val ) ?"true" :"false" ;
@@ -1591,8 +1590,7 @@ array_to_json_internal(Datum array, StringInfo result, bool use_line_feeds)
15911590 * Turn a composite / record into JSON.
15921591 */
15931592static void
1594- composite_to_json (Datum composite ,StringInfo result ,bool use_line_feeds ,
1595- bool ignore_nulls )
1593+ composite_to_json (Datum composite ,StringInfo result ,bool use_line_feeds )
15961594{
15971595HeapTupleHeader td ;
15981596Oid tupType ;
@@ -1631,12 +1629,6 @@ composite_to_json(Datum composite, StringInfo result, bool use_line_feeds,
16311629if (tupdesc -> attrs [i ]-> attisdropped )
16321630continue ;
16331631
1634- val = heap_getattr (tuple ,i + 1 ,tupdesc ,& isnull );
1635-
1636- /* Don't serialize NULL field when we don't want it */
1637- if (isnull && ignore_nulls )
1638- continue ;
1639-
16401632if (needsep )
16411633appendStringInfoString (result ,sep );
16421634needsep = true;
@@ -1645,6 +1637,8 @@ composite_to_json(Datum composite, StringInfo result, bool use_line_feeds,
16451637escape_json (result ,attname );
16461638appendStringInfoChar (result ,':' );
16471639
1640+ val = heap_getattr (tuple ,i + 1 ,tupdesc ,& isnull );
1641+
16481642if (isnull )
16491643{
16501644tcategory = JSONTYPE_NULL ;
@@ -1693,10 +1687,26 @@ add_json(Datum val, bool is_null, StringInfo result,
16931687}
16941688
16951689/*
1696- * SQL function array_to_json(row, prettybool )
1690+ * SQL function array_to_json(row)
16971691 */
16981692extern Datum
16991693array_to_json (PG_FUNCTION_ARGS )
1694+ {
1695+ Datum array = PG_GETARG_DATUM (0 );
1696+ StringInfo result ;
1697+
1698+ result = makeStringInfo ();
1699+
1700+ array_to_json_internal (array ,result , false);
1701+
1702+ PG_RETURN_TEXT_P (cstring_to_text_with_len (result -> data ,result -> len ));
1703+ }
1704+
1705+ /*
1706+ * SQL function array_to_json(row, prettybool)
1707+ */
1708+ extern Datum
1709+ array_to_json_pretty (PG_FUNCTION_ARGS )
17001710{
17011711Datum array = PG_GETARG_DATUM (0 );
17021712bool use_line_feeds = PG_GETARG_BOOL (1 );
@@ -1710,19 +1720,34 @@ array_to_json(PG_FUNCTION_ARGS)
17101720}
17111721
17121722/*
1713- * SQL function row_to_json(rowval record, pretty bool, ignore_nulls bool )
1723+ * SQL function row_to_json(row )
17141724 */
17151725extern Datum
17161726row_to_json (PG_FUNCTION_ARGS )
1727+ {
1728+ Datum array = PG_GETARG_DATUM (0 );
1729+ StringInfo result ;
1730+
1731+ result = makeStringInfo ();
1732+
1733+ composite_to_json (array ,result , false);
1734+
1735+ PG_RETURN_TEXT_P (cstring_to_text_with_len (result -> data ,result -> len ));
1736+ }
1737+
1738+ /*
1739+ * SQL function row_to_json(row, prettybool)
1740+ */
1741+ extern Datum
1742+ row_to_json_pretty (PG_FUNCTION_ARGS )
17171743{
17181744Datum array = PG_GETARG_DATUM (0 );
17191745bool use_line_feeds = PG_GETARG_BOOL (1 );
1720- bool ignore_nulls = PG_GETARG_BOOL (2 );
17211746StringInfo result ;
17221747
17231748result = makeStringInfo ();
17241749
1725- composite_to_json (array ,result ,use_line_feeds , ignore_nulls );
1750+ composite_to_json (array ,result ,use_line_feeds );
17261751
17271752PG_RETURN_TEXT_P (cstring_to_text_with_len (result -> data ,result -> len ));
17281753}