File tree 3 files changed +38
-1
lines changed
3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -330,6 +330,21 @@ incompatible_module_error(const char *libname,
330
330
magic_data .version / 100 , library_version )));
331
331
}
332
332
333
+ /*
334
+ * Similarly, if the ABI extra field doesn't match, error out. Other
335
+ * fields below might also mismatch, but that isn't useful information if
336
+ * you're using the wrong product altogether.
337
+ */
338
+ if (strcmp (module_magic_data -> abi_extra , magic_data .abi_extra ) != 0 )
339
+ {
340
+ ereport (ERROR ,
341
+ (errmsg ("incompatible library \"%s\": ABI mismatch" ,
342
+ libname ),
343
+ errdetail ("Server has ABI \"%s\", library has \"%s\"." ,
344
+ magic_data .abi_extra ,
345
+ module_magic_data -> abi_extra )));
346
+ }
347
+
333
348
/*
334
349
* Otherwise, spell out which fields don't agree.
335
350
*
Original file line number Diff line number Diff line change @@ -458,6 +458,7 @@ typedef struct
458
458
int indexmaxkeys ; /* INDEX_MAX_KEYS */
459
459
int namedatalen ; /* NAMEDATALEN */
460
460
int float8byval ; /* FLOAT8PASSBYVAL */
461
+ char abi_extra [32 ]; /* see pg_config_manual.h */
461
462
} Pg_magic_struct ;
462
463
463
464
/* The actual data block contents */
@@ -468,9 +469,13 @@ typedef struct
468
469
FUNC_MAX_ARGS, \
469
470
INDEX_MAX_KEYS, \
470
471
NAMEDATALEN, \
471
- FLOAT8PASSBYVAL \
472
+ FLOAT8PASSBYVAL, \
473
+ FMGR_ABI_EXTRA, \
472
474
}
473
475
476
+ StaticAssertDecl (sizeof (FMGR_ABI_EXTRA ) <= sizeof (((Pg_magic_struct * )0 )-> abi_extra ),
477
+ "FMGR_ABI_EXTRA too long" );
478
+
474
479
/*
475
480
* Declare the module magic function. It needs to be a function as the dlsym
476
481
* in the backend is only guaranteed to work on functions, not data
Original file line number Diff line number Diff line change 42
42
*/
43
43
#define FUNC_MAX_ARGS 100
44
44
45
+ /*
46
+ * When creating a product derived from PostgreSQL with changes that cause
47
+ * incompatibilities for loadable modules, it is recommended to change this
48
+ * string so that dfmgr.c can refuse to load incompatible modules with a clean
49
+ * error message. Typical examples that cause incompatibilities are any
50
+ * changes to node tags or node structures. (Note that dfmgr.c already
51
+ * detects common sources of incompatibilities due to major version
52
+ * differences and due to some changed compile-time constants. This setting
53
+ * is for catching anything that cannot be detected in a straightforward way.)
54
+ *
55
+ * There is no prescribed format for the string. The suggestion is to include
56
+ * product or company name, and optionally any internally-relevant ABI
57
+ * version. Example: "ACME Postgres/1.2". Note that the string will appear
58
+ * in a user-facing error message if an ABI mismatch is detected.
59
+ */
60
+ #define FMGR_ABI_EXTRA "PostgreSQL"
61
+
45
62
/*
46
63
* Maximum number of columns in an index. There is little point in making
47
64
* this anything but a multiple of 32, because the main cost is associated
You can’t perform that action at this time.
0 commit comments