22
22
*
23
23
*
24
24
* 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 $
26
26
*
27
27
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
28
28
*
@@ -2928,6 +2928,15 @@ dumpTypes(Archive *fout, FuncInfo *finfo, int numFuncs,
2928
2928
char * elemType ;
2929
2929
2930
2930
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
+
2931
2940
appendPQExpBuffer (q , ", element = %s, delimiter = " , elemType );
2932
2941
formatStringLiteral (q , tinfo [i ].typdelim );
2933
2942
}
@@ -3086,6 +3095,7 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo, int i,
3086
3095
char * listSep ;
3087
3096
char * listSepComma = "," ;
3088
3097
char * listSepNone = "" ;
3098
+ char * rettypename ;
3089
3099
3090
3100
if (finfo [i ].dumped )
3091
3101
return ;
@@ -3147,6 +3157,21 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo, int i,
3147
3157
char * typname ;
3148
3158
3149
3159
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
+
3150
3175
appendPQExpBuffer (fn , "%s%s" ,
3151
3176
(j > 0 ) ? "," : "" ,
3152
3177
typname );
@@ -3159,11 +3184,28 @@ dumpOneFunc(Archive *fout, FuncInfo *finfo, int i,
3159
3184
resetPQExpBuffer (delqry );
3160
3185
appendPQExpBuffer (delqry , "DROP FUNCTION %s;\n" , fn -> data );
3161
3186
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
+
3162
3204
resetPQExpBuffer (q );
3163
3205
appendPQExpBuffer (q , "CREATE FUNCTION %s " , fn -> data );
3164
3206
appendPQExpBuffer (q , "RETURNS %s%s %s LANGUAGE " ,
3165
3207
(finfo [i ].retset ) ? "SETOF " : "" ,
3166
- findTypeByOid ( tinfo , numTypes , finfo [ i ]. prorettype , zeroAsOpaque ) ,
3208
+ rettypename ,
3167
3209
asPart -> data );
3168
3210
formatStringLiteral (q , func_lang );
3169
3211
@@ -3208,6 +3250,12 @@ void
3208
3250
dumpOprs (Archive * fout , OprInfo * oprinfo , int numOperators ,
3209
3251
TypeInfo * tinfo , int numTypes )
3210
3252
{
3253
+ #define OPR_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
+
3211
3259
int i ;
3212
3260
PQExpBuffer q = createPQExpBuffer ();
3213
3261
PQExpBuffer delq = createPQExpBuffer ();
@@ -3222,6 +3270,7 @@ dumpOprs(Archive *fout, OprInfo *oprinfo, int numOperators,
3222
3270
3223
3271
for (i = 0 ; i < numOperators ; i ++ )
3224
3272
{
3273
+ char * name ;
3225
3274
3226
3275
resetPQExpBuffer (leftarg );
3227
3276
resetPQExpBuffer (rightarg );
@@ -3250,22 +3299,50 @@ dumpOprs(Archive *fout, OprInfo *oprinfo, int numOperators,
3250
3299
if (strcmp (oprinfo [i ].oprkind , "r" ) == 0 ||
3251
3300
strcmp (oprinfo [i ].oprkind , "b" ) == 0 )
3252
3301
{
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 );
3255
3310
}
3311
+
3256
3312
if (strcmp (oprinfo [i ].oprkind , "l" ) == 0 ||
3257
3313
strcmp (oprinfo [i ].oprkind , "b" ) == 0 )
3258
3314
{
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 );
3261
3323
}
3324
+
3262
3325
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
+ }
3265
3335
3266
3336
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
+ }
3269
3346
3270
3347
if (!(strcmp (oprinfo [i ].oprrest , "-" ) == 0 ))
3271
3348
appendPQExpBuffer (restrictor , ",\n\tRESTRICT = %s " , oprinfo [i ].oprrest );
@@ -3274,16 +3351,30 @@ dumpOprs(Archive *fout, OprInfo *oprinfo, int numOperators,
3274
3351
appendPQExpBuffer (join , ",\n\tJOIN = %s " , oprinfo [i ].oprjoin );
3275
3352
3276
3353
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
+ }
3279
3363
3280
3364
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
+ }
3283
3374
3284
3375
resetPQExpBuffer (delq );
3285
3376
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 ) );
3287
3378
appendPQExpBuffer (delq , ", %s);\n" ,
3288
3379
findTypeByOid (tinfo , numTypes , oprinfo [i ].oprright , zeroAsOpaque ) );
3289
3380
@@ -3317,6 +3408,12 @@ void
3317
3408
dumpAggs (Archive * fout , AggInfo * agginfo , int numAggs ,
3318
3409
TypeInfo * tinfo , int numTypes )
3319
3410
{
3411
+ #define AGG_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
+
3320
3417
int i ;
3321
3418
PQExpBuffer q = createPQExpBuffer ();
3322
3419
PQExpBuffer delq = createPQExpBuffer ();
@@ -3325,20 +3422,31 @@ dumpAggs(Archive *fout, AggInfo *agginfo, int numAggs,
3325
3422
3326
3423
for (i = 0 ; i < numAggs ; i ++ )
3327
3424
{
3425
+ char * name ;
3426
+
3328
3427
resetPQExpBuffer (details );
3329
3428
3330
3429
/* skip all the builtin oids */
3331
3430
if (atooid (agginfo [i ].oid ) <= g_last_builtin_oid )
3332
3431
continue ;
3333
3432
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 );
3337
3440
3441
+ name = findTypeByOid (tinfo , numTypes , agginfo [i ].aggtranstype , zeroAsOpaque + useBaseTypeName );
3442
+ if (name == NULL )
3443
+ {
3444
+ AGG_NOTICE (aggtranstype );
3445
+ continue ;
3446
+ }
3338
3447
appendPQExpBuffer (details ,
3339
3448
"SFUNC = %s, STYPE = %s" ,
3340
- agginfo [i ].aggtransfn ,
3341
- findTypeByOid (tinfo , numTypes , agginfo [i ].aggtranstype , zeroAsOpaque + useBaseTypeName ));
3449
+ agginfo [i ].aggtransfn , name );
3342
3450
3343
3451
if (agginfo [i ].agginitval )
3344
3452
{
0 commit comments