@@ -8252,6 +8252,9 @@ dumpShellType(Archive *fout, ShellTypeInfo *stinfo)
8252
8252
* For some backwards compatibility with the older behavior, we forcibly
8253
8253
* dump a PL if its handler function (and validator if any) are in a
8254
8254
* dumpable namespace. That case is not checked here.
8255
+ *
8256
+ * Also, if the PL belongs to an extension, we do not use this heuristic.
8257
+ * That case isn't checked here either.
8255
8258
*/
8256
8259
static bool
8257
8260
shouldDumpProcLangs (void )
@@ -8316,13 +8319,22 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
8316
8319
* If the functions are dumpable then emit a traditional CREATE LANGUAGE
8317
8320
* with parameters. Otherwise, dump only if shouldDumpProcLangs() says to
8318
8321
* dump it.
8322
+ *
8323
+ * However, for a language that belongs to an extension, we must not use
8324
+ * the shouldDumpProcLangs heuristic, but just dump the language iff we're
8325
+ * told to (via dobj.dump). Generally the support functions will belong
8326
+ * to the same extension and so have the same dump flags ... if they don't,
8327
+ * this might not work terribly nicely.
8319
8328
*/
8320
8329
useParams = (funcInfo != NULL &&
8321
8330
(inlineInfo != NULL || !OidIsValid (plang -> laninline )) &&
8322
8331
(validatorInfo != NULL || !OidIsValid (plang -> lanvalidator )));
8323
8332
8324
- if (!useParams && !shouldDumpProcLangs ())
8325
- return ;
8333
+ if (!plang -> dobj .ext_member )
8334
+ {
8335
+ if (!useParams && !shouldDumpProcLangs ())
8336
+ return ;
8337
+ }
8326
8338
8327
8339
defqry = createPQExpBuffer ();
8328
8340
delqry = createPQExpBuffer ();
@@ -9013,13 +9025,12 @@ dumpCast(Archive *fout, CastInfo *cast)
9013
9025
PQExpBuffer delqry ;
9014
9026
PQExpBuffer labelq ;
9015
9027
FuncInfo * funcInfo = NULL ;
9016
- TypeInfo * sourceInfo ;
9017
- TypeInfo * targetInfo ;
9018
9028
9019
9029
/* Skip if not to be dumped */
9020
9030
if (!cast -> dobj .dump || dataOnly )
9021
9031
return ;
9022
9032
9033
+ /* Cannot dump if we don't have the cast function's info */
9023
9034
if (OidIsValid (cast -> castfunc ))
9024
9035
{
9025
9036
funcInfo = findFuncByOid (cast -> castfunc );
@@ -9032,43 +9043,49 @@ dumpCast(Archive *fout, CastInfo *cast)
9032
9043
* objects (the conversion function and the two data types) are not
9033
9044
* builtin AND if all of the non-builtin objects are included in the dump.
9034
9045
* Builtin meaning, the namespace name does not start with "pg_".
9046
+ *
9047
+ * However, for a cast that belongs to an extension, we must not use this
9048
+ * heuristic, but just dump the cast iff we're told to (via dobj.dump).
9035
9049
*/
9036
- sourceInfo = findTypeByOid (cast -> castsource );
9037
- targetInfo = findTypeByOid (cast -> casttarget );
9050
+ if (!cast -> dobj .ext_member )
9051
+ {
9052
+ TypeInfo * sourceInfo = findTypeByOid (cast -> castsource );
9053
+ TypeInfo * targetInfo = findTypeByOid (cast -> casttarget );
9038
9054
9039
- if (sourceInfo == NULL || targetInfo == NULL )
9040
- return ;
9055
+ if (sourceInfo == NULL || targetInfo == NULL )
9056
+ return ;
9041
9057
9042
- /*
9043
- * Skip this cast if all objects are from pg_
9044
- */
9045
- if ((funcInfo == NULL ||
9046
- strncmp (funcInfo -> dobj .namespace -> dobj .name , "pg_" , 3 ) == 0 ) &&
9047
- strncmp (sourceInfo -> dobj .namespace -> dobj .name , "pg_" , 3 ) == 0 &&
9048
- strncmp (targetInfo -> dobj .namespace -> dobj .name , "pg_" , 3 ) == 0 )
9049
- return ;
9058
+ /*
9059
+ * Skip this cast if all objects are from pg_
9060
+ */
9061
+ if ((funcInfo == NULL ||
9062
+ strncmp (funcInfo -> dobj .namespace -> dobj .name , "pg_" , 3 ) == 0 ) &&
9063
+ strncmp (sourceInfo -> dobj .namespace -> dobj .name , "pg_" , 3 ) == 0 &&
9064
+ strncmp (targetInfo -> dobj .namespace -> dobj .name , "pg_" , 3 ) == 0 )
9065
+ return ;
9050
9066
9051
- /*
9052
- * Skip cast if function isn't from pg_ and is not to be dumped.
9053
- */
9054
- if (funcInfo &&
9055
- strncmp (funcInfo -> dobj .namespace -> dobj .name , "pg_" , 3 ) != 0 &&
9056
- !funcInfo -> dobj .dump )
9057
- return ;
9067
+ /*
9068
+ * Skip cast if function isn't from pg_ and is not to be dumped.
9069
+ */
9070
+ if (funcInfo &&
9071
+ strncmp (funcInfo -> dobj .namespace -> dobj .name , "pg_" , 3 ) != 0 &&
9072
+ !funcInfo -> dobj .dump )
9073
+ return ;
9058
9074
9059
- /*
9060
- * Same for the source type
9061
- */
9062
- if (strncmp (sourceInfo -> dobj .namespace -> dobj .name , "pg_" , 3 ) != 0 &&
9063
- !sourceInfo -> dobj .dump )
9064
- return ;
9075
+ /*
9076
+ * Same for the source type
9077
+ */
9078
+ if (strncmp (sourceInfo -> dobj .namespace -> dobj .name , "pg_" , 3 ) != 0 &&
9079
+ !sourceInfo -> dobj .dump )
9080
+ return ;
9065
9081
9066
- /*
9067
- * and the target type.
9068
- */
9069
- if (strncmp (targetInfo -> dobj .namespace -> dobj .name , "pg_" , 3 ) != 0 &&
9070
- !targetInfo -> dobj .dump )
9071
- return ;
9082
+ /*
9083
+ * and the target type.
9084
+ */
9085
+ if (strncmp (targetInfo -> dobj .namespace -> dobj .name , "pg_" , 3 ) != 0 &&
9086
+ !targetInfo -> dobj .dump )
9087
+ return ;
9088
+ }
9072
9089
9073
9090
/* Make sure we are in proper schema (needed for getFormattedTypeName) */
9074
9091
selectSourceSchema ("pg_catalog" );
0 commit comments