@@ -3939,7 +3939,10 @@ pg_identify_object_as_address(PG_FUNCTION_ARGS)
3939
3939
pfree (identity );
3940
3940
3941
3941
/* object_names */
3942
- values [1 ] = PointerGetDatum (strlist_to_textarray (names ));
3942
+ if (names != NIL )
3943
+ values [1 ] = PointerGetDatum (strlist_to_textarray (names ));
3944
+ else
3945
+ values [1 ] = PointerGetDatum (construct_empty_array (TEXTOID ));
3943
3946
nulls [1 ] = false;
3944
3947
3945
3948
/* object_args */
@@ -5268,10 +5271,12 @@ strlist_to_textarray(List *list)
5268
5271
{
5269
5272
ArrayType * arr ;
5270
5273
Datum * datums ;
5274
+ bool * nulls ;
5271
5275
int j = 0 ;
5272
5276
ListCell * cell ;
5273
5277
MemoryContext memcxt ;
5274
5278
MemoryContext oldcxt ;
5279
+ int lb [1 ];
5275
5280
5276
5281
/* Work in a temp context; easier than individually pfree'ing the Datums */
5277
5282
memcxt = AllocSetContextCreate (CurrentMemoryContext ,
@@ -5280,18 +5285,26 @@ strlist_to_textarray(List *list)
5280
5285
oldcxt = MemoryContextSwitchTo (memcxt );
5281
5286
5282
5287
datums = (Datum * ) palloc (sizeof (Datum ) * list_length (list ));
5288
+ nulls = palloc (sizeof (bool ) * list_length (list ));
5283
5289
5284
5290
foreach (cell , list )
5285
5291
{
5286
5292
char * name = lfirst (cell );
5287
5293
5288
- datums [j ++ ] = CStringGetTextDatum (name );
5294
+ if (name )
5295
+ {
5296
+ nulls [j ] = false;
5297
+ datums [j ++ ] = CStringGetTextDatum (name );
5298
+ }
5299
+ else
5300
+ nulls [j ] = true;
5289
5301
}
5290
5302
5291
5303
MemoryContextSwitchTo (oldcxt );
5292
5304
5293
- arr = construct_array (datums , list_length (list ),
5294
- TEXTOID , -1 , false, 'i' );
5305
+ lb [0 ] = 1 ;
5306
+ arr = construct_md_array (datums , nulls , 1 , & j ,
5307
+ lb , TEXTOID , -1 , false, 'i' );
5295
5308
5296
5309
MemoryContextDelete (memcxt );
5297
5310
0 commit comments