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

Commit2802668

Browse files
committed
Repair core dump when trying to delete an entry from an already-NULL
datconfig or useconfig field. Per report from Dustin Sallings.
1 parentdfebfc1 commit2802668

File tree

3 files changed

+46
-20
lines changed

3 files changed

+46
-20
lines changed

‎src/backend/commands/dbcommands.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.107 2002/11/0218:41:21 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.108 2002/12/0205:20:47 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -561,7 +561,10 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt)
561561
else
562562
a=GUCArrayDelete(a,stmt->variable);
563563

564-
repl_val[Anum_pg_database_datconfig-1]=PointerGetDatum(a);
564+
if (a)
565+
repl_val[Anum_pg_database_datconfig-1]=PointerGetDatum(a);
566+
else
567+
repl_null[Anum_pg_database_datconfig-1]='n';
565568
}
566569

567570
newtuple=heap_modifytuple(tuple,rel,repl_val,repl_null,repl_repl);

‎src/backend/commands/user.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.113 2002/10/21 19:46:45 tgl Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.114 2002/12/02 05:20:47 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -915,8 +915,10 @@ AlterUserSet(AlterUserSetStmt *stmt)
915915

916916
repl_repl[Anum_pg_shadow_useconfig-1]='r';
917917
if (strcmp(stmt->variable,"all")==0&&valuestr==NULL)
918+
{
918919
/* RESET ALL */
919920
repl_null[Anum_pg_shadow_useconfig-1]='n';
921+
}
920922
else
921923
{
922924
Datumdatum;
@@ -935,7 +937,10 @@ AlterUserSet(AlterUserSetStmt *stmt)
935937
else
936938
array=GUCArrayDelete(array,stmt->variable);
937939

938-
repl_val[Anum_pg_shadow_useconfig-1]=PointerGetDatum(array);
940+
if (array)
941+
repl_val[Anum_pg_shadow_useconfig-1]=PointerGetDatum(array);
942+
else
943+
repl_null[Anum_pg_shadow_useconfig-1]='n';
939944
}
940945

941946
newtuple=heap_modifytuple(oldtuple,rel,repl_val,repl_null,repl_repl);

‎src/backend/utils/misc/guc.c

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* command, configuration file, and command line options.
66
* See src/backend/utils/misc/README for more information.
77
*
8-
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.107 2002/11/21 00:42:19 tgl Exp $
8+
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.108 2002/12/02 05:20:47 tgl Exp $
99
*
1010
* Copyright 2000 by PostgreSQL Global Development Group
1111
* Written by Peter Eisentraut <peter_e@gmx.net>.
@@ -2754,7 +2754,7 @@ assign_defaultxactisolevel(const char *newval, bool doit, bool interactive)
27542754

27552755
/*
27562756
* Handle options fetched from pg_database.datconfig or pg_shadow.useconfig.
2757-
* The array parameter must be an array of TEXT.
2757+
* The array parameter must be an array of TEXT (it must not be NULL).
27582758
*/
27592759
void
27602760
ProcessGUCArray(ArrayType*array,GucSourcesource)
@@ -2809,7 +2809,10 @@ ProcessGUCArray(ArrayType *array, GucSource source)
28092809
}
28102810

28112811

2812-
2812+
/*
2813+
* Add an entry to an option array. The array parameter may be NULL
2814+
* to indicate the current table entry is NULL.
2815+
*/
28132816
ArrayType*
28142817
GUCArrayAdd(ArrayType*array,constchar*name,constchar*value)
28152818
{
@@ -2880,7 +2883,11 @@ GUCArrayAdd(ArrayType *array, const char *name, const char *value)
28802883
}
28812884

28822885

2883-
2886+
/*
2887+
* Delete an entry from an option array. The array parameter may be NULL
2888+
* to indicate the current table entry is NULL. Also, if the return value
2889+
* is NULL then a null should be stored.
2890+
*/
28842891
ArrayType*
28852892
GUCArrayDelete(ArrayType*array,constchar*name)
28862893
{
@@ -2889,16 +2896,17 @@ GUCArrayDelete(ArrayType *array, const char *name)
28892896
intindex;
28902897

28912898
Assert(name);
2892-
Assert(array);
28932899

28942900
/* test if the option is valid */
28952901
set_config_option(name,NULL,
28962902
superuser() ?PGC_SUSET :PGC_USERSET,
28972903
PGC_S_SESSION, false, false);
28982904

2899-
newarray=construct_array(NULL,0,
2900-
TEXTOID,
2901-
-1, false,'i');
2905+
/* if array is currently null, then surely nothing to delete */
2906+
if (!array)
2907+
returnNULL;
2908+
2909+
newarray=NULL;
29022910
index=1;
29032911

29042912
for (i=1;i <=ARR_DIMS(array)[0];i++)
@@ -2917,18 +2925,28 @@ GUCArrayDelete(ArrayType *array, const char *name)
29172925
continue;
29182926
val=DatumGetCString(DirectFunctionCall1(textout,d));
29192927

2928+
/* ignore entry if it's what we want to delete */
29202929
if (strncmp(val,name,strlen(name))==0
29212930
&&val[strlen(name)]=='=')
29222931
continue;
29232932

2924-
isnull= false;
2925-
newarray=array_set(newarray,1,&index,
2926-
d,
2927-
-1/* varlenarray */ ,
2928-
-1/* TEXT's typlen */ ,
2929-
false/* TEXT's typbyval */ ,
2930-
'i'/* TEXT's typalign */ ,
2931-
&isnull);
2933+
/* else add it to the output array */
2934+
if (newarray)
2935+
{
2936+
isnull= false;
2937+
newarray=array_set(newarray,1,&index,
2938+
d,
2939+
-1/* varlenarray */ ,
2940+
-1/* TEXT's typlen */ ,
2941+
false/* TEXT's typbyval */ ,
2942+
'i'/* TEXT's typalign */ ,
2943+
&isnull);
2944+
}
2945+
else
2946+
newarray=construct_array(&d,1,
2947+
TEXTOID,
2948+
-1, false,'i');
2949+
29322950
index++;
29332951
}
29342952

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp