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

Commitddad002

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 parent2b1971c commitddad002

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
@@ -3815,7 +3815,10 @@ pg_identify_object_as_address(PG_FUNCTION_ARGS)
38153815
pfree(identity);
38163816

38173817
/* object_names */
3818-
values[1]=PointerGetDatum(strlist_to_textarray(names));
3818+
if (names!=NIL)
3819+
values[1]=PointerGetDatum(strlist_to_textarray(names));
3820+
else
3821+
values[1]=PointerGetDatum(construct_empty_array(TEXTOID));
38193822
nulls[1]= false;
38203823

38213824
/* object_args */
@@ -5134,28 +5137,38 @@ strlist_to_textarray(List *list)
51345137
{
51355138
ArrayType*arr;
51365139
Datum*datums;
5140+
bool*nulls;
51375141
intj=0;
51385142
ListCell*cell;
51395143
MemoryContextmemcxt;
51405144
MemoryContextoldcxt;
5145+
intlb[1];
51415146

51425147
memcxt=AllocSetContextCreate(CurrentMemoryContext,
51435148
"strlist to array",
51445149
ALLOCSET_DEFAULT_SIZES);
51455150
oldcxt=MemoryContextSwitchTo(memcxt);
51465151

51475152
datums=palloc(sizeof(text*)*list_length(list));
5153+
nulls=palloc(sizeof(bool)*list_length(list));
51485154
foreach(cell,list)
51495155
{
51505156
char*name=lfirst(cell);
51515157

5152-
datums[j++]=CStringGetTextDatum(name);
5158+
if (name)
5159+
{
5160+
nulls[j]= false;
5161+
datums[j++]=CStringGetTextDatum(name);
5162+
}
5163+
else
5164+
nulls[j++]= true;
51535165
}
51545166

51555167
MemoryContextSwitchTo(oldcxt);
51565168

5157-
arr=construct_array(datums,list_length(list),
5158-
TEXTOID,-1, false,'i');
5169+
lb[0]=1;
5170+
arr=construct_md_array(datums,nulls,1,&j,
5171+
lb,TEXTOID,-1, false,'i');
51595172
MemoryContextDelete(memcxt);
51605173

51615174
returnarr;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp