File tree 5 files changed +56
-0
lines changed
5 files changed +56
-0
lines changed Original file line number Diff line number Diff line change @@ -10275,6 +10275,20 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
10275
10275
</listitem>
10276
10276
</varlistentry>
10277
10277
10278
+ <varlistentry id="guc-shared-memory-size" xreflabel="shared_memory_size">
10279
+ <term><varname>shared_memory_size</varname> (<type>integer</type>)
10280
+ <indexterm>
10281
+ <primary><varname>shared_memory_size</varname> configuration parameter</primary>
10282
+ </indexterm>
10283
+ </term>
10284
+ <listitem>
10285
+ <para>
10286
+ Reports the size of the main shared memory area, rounded up to the
10287
+ nearest megabyte.
10288
+ </para>
10289
+ </listitem>
10290
+ </varlistentry>
10291
+
10278
10292
<varlistentry id="guc-ssl-library" xreflabel="ssl_library">
10279
10293
<term><varname>ssl_library</varname> (<type>string</type>)
10280
10294
<indexterm>
Original file line number Diff line number Diff line change @@ -1026,6 +1026,13 @@ PostmasterMain(int argc, char *argv[])
1026
1026
*/
1027
1027
InitializeMaxBackends ();
1028
1028
1029
+ /*
1030
+ * Now that loadable modules have had their chance to request additional
1031
+ * shared memory, determine the value of any runtime-computed GUCs that
1032
+ * depend on the amount of shared memory required.
1033
+ */
1034
+ InitializeShmemGUCs ();
1035
+
1029
1036
/*
1030
1037
* Set up shared memory and semaphores.
1031
1038
*/
Original file line number Diff line number Diff line change @@ -313,3 +313,25 @@ CreateSharedMemoryAndSemaphores(void)
313
313
if (shmem_startup_hook )
314
314
shmem_startup_hook ();
315
315
}
316
+
317
+ /*
318
+ * InitializeShmemGUCs
319
+ *
320
+ * This function initializes runtime-computed GUCs related to the amount of
321
+ * shared memory required for the current configuration.
322
+ */
323
+ void
324
+ InitializeShmemGUCs (void )
325
+ {
326
+ char buf [64 ];
327
+ Size size_b ;
328
+ Size size_mb ;
329
+
330
+ /*
331
+ * Calculate the shared memory size and round up to the nearest megabyte.
332
+ */
333
+ size_b = CalculateShmemSize (NULL );
334
+ size_mb = add_size (size_b , (1024 * 1024 ) - 1 ) / (1024 * 1024 );
335
+ sprintf (buf , "%lu" , size_mb );
336
+ SetConfigOption ("shared_memory_size" , buf , PGC_INTERNAL , PGC_S_OVERRIDE );
337
+ }
Original file line number Diff line number Diff line change @@ -664,6 +664,7 @@ static int max_index_keys;
664
664
static int max_identifier_length ;
665
665
static int block_size ;
666
666
static int segment_size ;
667
+ static int shared_memory_size_mb ;
667
668
static int wal_block_size ;
668
669
static bool data_checksums ;
669
670
static bool integer_datetimes ;
@@ -2337,6 +2338,17 @@ static struct config_int ConfigureNamesInt[] =
2337
2338
NULL , NULL , NULL
2338
2339
},
2339
2340
2341
+ {
2342
+ {"shared_memory_size" , PGC_INTERNAL , RESOURCES_MEM ,
2343
+ gettext_noop ("Shows the size of the server's main shared memory area (rounded up to the nearest MB)." ),
2344
+ NULL ,
2345
+ GUC_NOT_IN_SAMPLE | GUC_DISALLOW_IN_FILE | GUC_UNIT_MB
2346
+ },
2347
+ & shared_memory_size_mb ,
2348
+ 0 , 0 , INT_MAX ,
2349
+ NULL , NULL , NULL
2350
+ },
2351
+
2340
2352
{
2341
2353
{"temp_buffers" , PGC_USERSET , RESOURCES_MEM ,
2342
2354
gettext_noop ("Sets the maximum number of temporary buffers used by each session." ),
Original file line number Diff line number Diff line change @@ -79,5 +79,6 @@ extern PGDLLIMPORT shmem_startup_hook_type shmem_startup_hook;
79
79
80
80
extern Size CalculateShmemSize (int * num_semaphores );
81
81
extern void CreateSharedMemoryAndSemaphores (void );
82
+ extern void InitializeShmemGUCs (void );
82
83
83
84
#endif /* IPC_H */
You can’t perform that action at this time.
0 commit comments