Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit728ac26

Browse files
committed
Make object address handling more robust
pg_identify_object_as_address crashes when passed certain tuples frominconsistent system catalogs. Make it more defensive.Author: Álvaro HerreraReviewed-by: Michaël PaquierDiscussion:https://postgr.es/m/20190218202743.GA12392@alvherre.pgsql
1 parentfbec6fa commit728ac26

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

‎src/backend/catalog/objectaddress.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3887,7 +3887,10 @@ pg_identify_object_as_address(PG_FUNCTION_ARGS)
38873887
pfree(identity);
38883888

38893889
/* object_names */
3890-
values[1]=PointerGetDatum(strlist_to_textarray(names));
3890+
if (names!=NIL)
3891+
values[1]=PointerGetDatum(strlist_to_textarray(names));
3892+
else
3893+
values[1]=PointerGetDatum(construct_empty_array(TEXTOID));
38913894
nulls[1]= false;
38923895

38933896
/* object_args */
@@ -5209,10 +5212,12 @@ strlist_to_textarray(List *list)
52095212
{
52105213
ArrayType*arr;
52115214
Datum*datums;
5215+
bool*nulls;
52125216
intj=0;
52135217
ListCell*cell;
52145218
MemoryContextmemcxt;
52155219
MemoryContextoldcxt;
5220+
intlb[1];
52165221

52175222
/* Work in a temp context; easier than individually pfree'ing the Datums */
52185223
memcxt=AllocSetContextCreate(CurrentMemoryContext,
@@ -5221,18 +5226,26 @@ strlist_to_textarray(List *list)
52215226
oldcxt=MemoryContextSwitchTo(memcxt);
52225227

52235228
datums= (Datum*)palloc(sizeof(Datum)*list_length(list));
5229+
nulls=palloc(sizeof(bool)*list_length(list));
52245230

52255231
foreach(cell,list)
52265232
{
52275233
char*name=lfirst(cell);
52285234

5229-
datums[j++]=CStringGetTextDatum(name);
5235+
if (name)
5236+
{
5237+
nulls[j]= false;
5238+
datums[j++]=CStringGetTextDatum(name);
5239+
}
5240+
else
5241+
nulls[j]= true;
52305242
}
52315243

52325244
MemoryContextSwitchTo(oldcxt);
52335245

5234-
arr=construct_array(datums,list_length(list),
5235-
TEXTOID,-1, false,'i');
5246+
lb[0]=1;
5247+
arr=construct_md_array(datums,nulls,1,&j,
5248+
lb,TEXTOID,-1, false,'i');
52365249

52375250
MemoryContextDelete(memcxt);
52385251

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp