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

Commit2f9bdff

Browse files
committed
Applied (slightly modified) patches from Tatsuo:
Ok. I have made patches for fixing some of pg_dump problems(seeattached patches). The patches address the problem with user definedfunctions, operators and aggregates.
1 parentd7f0b7e commit2f9bdff

File tree

2 files changed

+134
-26
lines changed

2 files changed

+134
-26
lines changed

‎src/bin/pg_dump/common.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.50 2001/01/24 19:43:18 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.51 2001/01/28 02:57:06 pjw Exp $
1212
*
1313
* Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2
1414
*
@@ -86,10 +86,8 @@ findTypeByOid(TypeInfo *tinfo, int numTypes, const char *oid, OidOptions opts)
8686
}
8787
}
8888

89-
/* should never get here */
90-
fprintf(stderr,"failed sanity check, type with oid %s was not found\n",
91-
oid);
92-
exit(2);
89+
/* no suitable type name was found */
90+
return(NULL);
9391
}
9492

9593
/*
@@ -114,7 +112,9 @@ findOprByOid(OprInfo *oprinfo, int numOprs, const char *oid)
114112
/* should never get here */
115113
fprintf(stderr,"failed sanity check, opr with oid %s was not found\n",
116114
oid);
117-
exit(2);
115+
116+
/* no suitable operator name was found */
117+
return(NULL);
118118
}
119119

120120

‎src/bin/pg_dump/pg_dump.c

Lines changed: 128 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
*
2424
* IDENTIFICATION
25-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.188 2001/01/24 19:43:18 momjian Exp $
25+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.189 2001/01/28 02:57:06 pjw Exp $
2626
*
2727
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
2828
*
@@ -2928,6 +2928,15 @@ dumpTypes(Archive *fout, FuncInfo *finfo, int numFuncs,
29282928
char*elemType;
29292929

29302930
elemType=findTypeByOid(tinfo,numTypes,tinfo[i].typelem,zeroAsOpaque);
2931+
if (elemType==NULL)
2932+
{
2933+
fprintf(stderr,"Notice: array type %s - type for elements (oid %s) is not dumped.\n",
2934+
tinfo[i].typname,tinfo[i].typelem);
2935+
resetPQExpBuffer(q);
2936+
resetPQExpBuffer(delq);
2937+
continue;
2938+
}
2939+
29312940
appendPQExpBuffer(q,", element = %s, delimiter = ",elemType);
29322941
formatStringLiteral(q,tinfo[i].typdelim);
29332942
}
@@ -3086,6 +3095,7 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo, int i,
30863095
char*listSep;
30873096
char*listSepComma=",";
30883097
char*listSepNone="";
3098+
char*rettypename;
30893099

30903100
if (finfo[i].dumped)
30913101
return;
@@ -3147,6 +3157,21 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo, int i,
31473157
char*typname;
31483158

31493159
typname=findTypeByOid(tinfo,numTypes,finfo[i].argtypes[j],zeroAsOpaque);
3160+
if (typname==NULL)
3161+
{
3162+
fprintf(stderr,"Notice: function \"%s\" is not dumped.\n",
3163+
finfo[i].proname);
3164+
3165+
fprintf(stderr,"Reason: the %d th argument type name (oid %s) not found.\n",
3166+
j,finfo[i].argtypes[j]);
3167+
resetPQExpBuffer(q);
3168+
resetPQExpBuffer(fn);
3169+
resetPQExpBuffer(delqry);
3170+
resetPQExpBuffer(fnlist);
3171+
resetPQExpBuffer(asPart);
3172+
return;
3173+
}
3174+
31503175
appendPQExpBuffer(fn,"%s%s",
31513176
(j>0) ?"," :"",
31523177
typname);
@@ -3159,11 +3184,28 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo, int i,
31593184
resetPQExpBuffer(delqry);
31603185
appendPQExpBuffer(delqry,"DROP FUNCTION %s;\n",fn->data );
31613186

3187+
rettypename=findTypeByOid(tinfo,numTypes,finfo[i].prorettype,zeroAsOpaque);
3188+
3189+
if (rettypename==NULL)
3190+
{
3191+
fprintf(stderr,"Notice: function \"%s\" is not dumped.\n",
3192+
finfo[i].proname);
3193+
3194+
fprintf(stderr,"Reason: return type name (oid %s) not found.\n",
3195+
finfo[i].prorettype);
3196+
resetPQExpBuffer(q);
3197+
resetPQExpBuffer(fn);
3198+
resetPQExpBuffer(delqry);
3199+
resetPQExpBuffer(fnlist);
3200+
resetPQExpBuffer(asPart);
3201+
return;
3202+
}
3203+
31623204
resetPQExpBuffer(q);
31633205
appendPQExpBuffer(q,"CREATE FUNCTION %s ",fn->data );
31643206
appendPQExpBuffer(q,"RETURNS %s%s %s LANGUAGE ",
31653207
(finfo[i].retset) ?"SETOF " :"",
3166-
findTypeByOid(tinfo,numTypes,finfo[i].prorettype,zeroAsOpaque),
3208+
rettypename,
31673209
asPart->data);
31683210
formatStringLiteral(q,func_lang);
31693211

@@ -3208,6 +3250,12 @@ void
32083250
dumpOprs(Archive*fout,OprInfo*oprinfo,intnumOperators,
32093251
TypeInfo*tinfo,intnumTypes)
32103252
{
3253+
#defineOPR_NOTICE(arg) {\
3254+
fprintf(stderr, "Notice: operator \"%s\"(oid %s) is not dumped.\n",oprinfo[i].oprname, oprinfo[i].oid);\
3255+
fprintf(stderr, "Reason: " CppAsString(arg));\
3256+
fprintf (stderr, " (oid %s) not found.\n",oprinfo[i].arg);\
3257+
}
3258+
32113259
inti;
32123260
PQExpBufferq=createPQExpBuffer();
32133261
PQExpBufferdelq=createPQExpBuffer();
@@ -3222,6 +3270,7 @@ dumpOprs(Archive *fout, OprInfo *oprinfo, int numOperators,
32223270

32233271
for (i=0;i<numOperators;i++)
32243272
{
3273+
char*name;
32253274

32263275
resetPQExpBuffer(leftarg);
32273276
resetPQExpBuffer(rightarg);
@@ -3250,22 +3299,50 @@ dumpOprs(Archive *fout, OprInfo *oprinfo, int numOperators,
32503299
if (strcmp(oprinfo[i].oprkind,"r")==0||
32513300
strcmp(oprinfo[i].oprkind,"b")==0)
32523301
{
3253-
appendPQExpBuffer(leftarg,",\n\tLEFTARG = %s ",
3254-
findTypeByOid(tinfo,numTypes,oprinfo[i].oprleft,zeroAsOpaque) );
3302+
name=findTypeByOid(tinfo,numTypes,
3303+
oprinfo[i].oprleft,zeroAsOpaque);
3304+
if (name==NULL)
3305+
{
3306+
OPR_NOTICE(oprleft);
3307+
continue;
3308+
}
3309+
appendPQExpBuffer(leftarg,",\n\tLEFTARG = %s ",name);
32553310
}
3311+
32563312
if (strcmp(oprinfo[i].oprkind,"l")==0||
32573313
strcmp(oprinfo[i].oprkind,"b")==0)
32583314
{
3259-
appendPQExpBuffer(rightarg,",\n\tRIGHTARG = %s ",
3260-
findTypeByOid(tinfo,numTypes,oprinfo[i].oprright,zeroAsOpaque) );
3315+
name=findTypeByOid(tinfo,numTypes,
3316+
oprinfo[i].oprright,zeroAsOpaque);
3317+
if (name==NULL)
3318+
{
3319+
OPR_NOTICE(oprright);
3320+
continue;
3321+
}
3322+
appendPQExpBuffer(rightarg,",\n\tRIGHTARG = %s ",name);
32613323
}
3324+
32623325
if (!(strcmp(oprinfo[i].oprcom,"0")==0))
3263-
appendPQExpBuffer(commutator,",\n\tCOMMUTATOR = %s ",
3264-
findOprByOid(oprinfo,numOperators,oprinfo[i].oprcom));
3326+
{
3327+
name=findOprByOid(oprinfo,numOperators,oprinfo[i].oprcom);
3328+
if (name==NULL)
3329+
{
3330+
OPR_NOTICE(oprcom);
3331+
continue;
3332+
}
3333+
appendPQExpBuffer(commutator,",\n\tCOMMUTATOR = %s ",name);
3334+
}
32653335

32663336
if (!(strcmp(oprinfo[i].oprnegate,"0")==0))
3267-
appendPQExpBuffer(negator,",\n\tNEGATOR = %s ",
3268-
findOprByOid(oprinfo,numOperators,oprinfo[i].oprnegate));
3337+
{
3338+
name=findOprByOid(oprinfo,numOperators,oprinfo[i].oprnegate);
3339+
if (name==NULL)
3340+
{
3341+
OPR_NOTICE(oprnegate);
3342+
continue;
3343+
}
3344+
appendPQExpBuffer(negator,",\n\tNEGATOR = %s ",name);
3345+
}
32693346

32703347
if (!(strcmp(oprinfo[i].oprrest,"-")==0))
32713348
appendPQExpBuffer(restrictor,",\n\tRESTRICT = %s ",oprinfo[i].oprrest);
@@ -3274,16 +3351,30 @@ dumpOprs(Archive *fout, OprInfo *oprinfo, int numOperators,
32743351
appendPQExpBuffer(join,",\n\tJOIN = %s ",oprinfo[i].oprjoin);
32753352

32763353
if (!(strcmp(oprinfo[i].oprlsortop,"0")==0))
3277-
appendPQExpBuffer(sort1,",\n\tSORT1 = %s ",
3278-
findOprByOid(oprinfo,numOperators,oprinfo[i].oprlsortop));
3354+
{
3355+
name=findOprByOid(oprinfo,numOperators,oprinfo[i].oprlsortop);
3356+
if (name==NULL)
3357+
{
3358+
OPR_NOTICE(oprlsortop);
3359+
continue;
3360+
}
3361+
appendPQExpBuffer(sort1,",\n\tSORT1 = %s ",name);
3362+
}
32793363

32803364
if (!(strcmp(oprinfo[i].oprrsortop,"0")==0))
3281-
appendPQExpBuffer(sort2,",\n\tSORT2 = %s ",
3282-
findOprByOid(oprinfo,numOperators,oprinfo[i].oprrsortop));
3365+
{
3366+
name=findOprByOid(oprinfo,numOperators,oprinfo[i].oprrsortop);
3367+
if (name==NULL)
3368+
{
3369+
OPR_NOTICE(oprrsortop);
3370+
continue;
3371+
}
3372+
appendPQExpBuffer(sort2,",\n\tSORT2 = %s ",name);
3373+
}
32833374

32843375
resetPQExpBuffer(delq);
32853376
appendPQExpBuffer(delq,"DROP OPERATOR %s (%s",oprinfo[i].oprname,
3286-
findTypeByOid(tinfo,numTypes,oprinfo[i].oprleft,zeroAsOpaque) );
3377+
findTypeByOid(tinfo,numTypes,oprinfo[i].oprleft,zeroAsOpaque) );
32873378
appendPQExpBuffer(delq,", %s);\n",
32883379
findTypeByOid(tinfo,numTypes,oprinfo[i].oprright,zeroAsOpaque) );
32893380

@@ -3317,6 +3408,12 @@ void
33173408
dumpAggs(Archive*fout,AggInfo*agginfo,intnumAggs,
33183409
TypeInfo*tinfo,intnumTypes)
33193410
{
3411+
#defineAGG_NOTICE(arg) {\
3412+
fprintf(stderr, "Notice: aggregate \"%s\"(oid %s) is not dumped.\n",agginfo[i].aggname, agginfo[i].oid);\
3413+
fprintf(stderr, "Reason: " CppAsString(arg) );\
3414+
fprintf (stderr, " (oid %s) not found.\n",agginfo[i].arg);\
3415+
}
3416+
33203417
inti;
33213418
PQExpBufferq=createPQExpBuffer();
33223419
PQExpBufferdelq=createPQExpBuffer();
@@ -3325,20 +3422,31 @@ dumpAggs(Archive *fout, AggInfo *agginfo, int numAggs,
33253422

33263423
for (i=0;i<numAggs;i++)
33273424
{
3425+
char*name;
3426+
33283427
resetPQExpBuffer(details);
33293428

33303429
/* skip all the builtin oids */
33313430
if (atooid(agginfo[i].oid) <=g_last_builtin_oid)
33323431
continue;
33333432

3334-
appendPQExpBuffer(details,
3335-
"BASETYPE = %s, ",
3336-
findTypeByOid(tinfo,numTypes,agginfo[i].aggbasetype,zeroAsAny+useBaseTypeName));
3433+
name=findTypeByOid(tinfo,numTypes,agginfo[i].aggbasetype,zeroAsAny+useBaseTypeName);
3434+
if (name==NULL)
3435+
{
3436+
AGG_NOTICE(aggbasetype);
3437+
continue;
3438+
}
3439+
appendPQExpBuffer(details,"BASETYPE = %s, ",name);
33373440

3441+
name=findTypeByOid(tinfo,numTypes,agginfo[i].aggtranstype,zeroAsOpaque+useBaseTypeName);
3442+
if (name==NULL)
3443+
{
3444+
AGG_NOTICE(aggtranstype);
3445+
continue;
3446+
}
33383447
appendPQExpBuffer(details,
33393448
"SFUNC = %s, STYPE = %s",
3340-
agginfo[i].aggtransfn,
3341-
findTypeByOid(tinfo,numTypes,agginfo[i].aggtranstype,zeroAsOpaque+useBaseTypeName));
3449+
agginfo[i].aggtransfn,name);
33423450

33433451
if (agginfo[i].agginitval)
33443452
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp