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

Commit5721b9b

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 parent29d108c commit5721b9b

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
@@ -3939,7 +3939,10 @@ pg_identify_object_as_address(PG_FUNCTION_ARGS)
39393939
pfree(identity);
39403940

39413941
/* 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));
39433946
nulls[1]= false;
39443947

39453948
/* object_args */
@@ -5268,10 +5271,12 @@ strlist_to_textarray(List *list)
52685271
{
52695272
ArrayType*arr;
52705273
Datum*datums;
5274+
bool*nulls;
52715275
intj=0;
52725276
ListCell*cell;
52735277
MemoryContextmemcxt;
52745278
MemoryContextoldcxt;
5279+
intlb[1];
52755280

52765281
/* Work in a temp context; easier than individually pfree'ing the Datums */
52775282
memcxt=AllocSetContextCreate(CurrentMemoryContext,
@@ -5280,18 +5285,26 @@ strlist_to_textarray(List *list)
52805285
oldcxt=MemoryContextSwitchTo(memcxt);
52815286

52825287
datums= (Datum*)palloc(sizeof(Datum)*list_length(list));
5288+
nulls=palloc(sizeof(bool)*list_length(list));
52835289

52845290
foreach(cell,list)
52855291
{
52865292
char*name=lfirst(cell);
52875293

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;
52895301
}
52905302

52915303
MemoryContextSwitchTo(oldcxt);
52925304

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');
52955308

52965309
MemoryContextDelete(memcxt);
52975310

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp