File tree Expand file tree Collapse file tree 5 files changed +56
-0
lines changed
Expand file tree Collapse file tree 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'
1027510275 </listitem>
1027610276 </varlistentry>
1027710277
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+
1027810292 <varlistentry id="guc-ssl-library" xreflabel="ssl_library">
1027910293 <term><varname>ssl_library</varname> (<type>string</type>)
1028010294 <indexterm>
Original file line number Diff line number Diff line change @@ -1026,6 +1026,13 @@ PostmasterMain(int argc, char *argv[])
10261026 */
10271027 InitializeMaxBackends ();
10281028
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+
10291036 /*
10301037 * Set up shared memory and semaphores.
10311038 */
Original file line number Diff line number Diff line change @@ -313,3 +313,25 @@ CreateSharedMemoryAndSemaphores(void)
313313 if (shmem_startup_hook )
314314 shmem_startup_hook ();
315315}
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;
664664static int max_identifier_length ;
665665static int block_size ;
666666static int segment_size ;
667+ static int shared_memory_size_mb ;
667668static int wal_block_size ;
668669static bool data_checksums ;
669670static bool integer_datetimes ;
@@ -2337,6 +2338,17 @@ static struct config_int ConfigureNamesInt[] =
23372338 NULL , NULL , NULL
23382339 },
23392340
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+
23402352 {
23412353 {"temp_buffers" , PGC_USERSET , RESOURCES_MEM ,
23422354 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;
7979
8080extern Size CalculateShmemSize (int * num_semaphores );
8181extern void CreateSharedMemoryAndSemaphores (void );
82+ extern void InitializeShmemGUCs (void );
8283
8384#endif /* IPC_H */
You can’t perform that action at this time.
0 commit comments