? config.log ? GNUmakefile ? config.status ? src/Makefile.global ? src/include/pg_config.h ? src/include/stamp-h Index: src/backend/postmaster/postmaster.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/backend/postmaster/postmaster.c,v retrieving revision 1.285 diff -c -r1.285 postmaster.c *** src/backend/postmaster/postmaster.c 2002/08/18 03:03:25 1.285 --- src/backend/postmaster/postmaster.c 2002/08/25 22:27:47 *************** *** 151,156 **** --- 151,168 ---- */ int MaxBackends = DEF_MAXBACKENDS; + /* + * ReservedBackends is the number of backends reserved for superuser use. + * This number is taken out of the pool size given by MaxBackends so + * number of backend slots available to none super users is + * (MaxBackends - ReservedBackends). Note, existing super user + * connections are not taken into account once this lower limit has + * been reached, i.e. superuser connections made before the lower limit + * is reached always count towards that limit and are not taken from + * ReservedBackends. + */ + int ReservedBackends = 2; + static char *progname = (char *) NULL; *************** *** 566,571 **** --- 578,591 ---- SetDataDir(potential_DataDir); ProcessConfigFile(PGC_POSTMASTER); + + /* + * Force ReservedBackends is less than MaxBackends if need be. + * A cluster only allowing superuser connections seems silly whereas + * a cluster reserving none for superusers doesn't. + */ + if (ReservedBackends >= MaxBackends) + ReservedBackends = MaxBackends - 1; /* * Now that we are done processing the postmaster arguments, reset Index: src/backend/utils/init/postinit.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/backend/utils/init/postinit.c,v retrieving revision 1.109 diff -c -r1.109 postinit.c *** src/backend/utils/init/postinit.c 2002/07/20 05:16:59 1.109 --- src/backend/utils/init/postinit.c 2002/08/25 22:27:48 *************** *** 402,407 **** --- 402,417 ---- /* close the transaction we started above */ if (!bootstrap) CommitTransactionCommand(); + + /* + * Check a normal user hasn't connected to a superuser reserved slot. + * Do this here since we need the user information and that only happens + * after we've started bringing the shared memory online. So we wait + * until we've registered exit handlers and potentially shut an open + * transaction down for an as safety conscious rejection as possible. + */ + if (!superuser() && MyBackendId > MaxBackends - ReservedBackends) + elog(ERROR, "Normal user limit exceeded"); } /* Index: src/backend/utils/misc/guc.c =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/backend/utils/misc/guc.c,v retrieving revision 1.83 diff -c -r1.83 guc.c *** src/backend/utils/misc/guc.c 2002/08/18 03:03:25 1.83 --- src/backend/utils/misc/guc.c 2002/08/25 22:27:51 *************** *** 537,547 **** /* * Note: There is some postprocessing done in PostmasterMain() to make * sure the buffers are at least twice the number of backends, so the ! * constraints here are partially unused. */ { { "max_connections", PGC_POSTMASTER }, &MaxBackends, DEF_MAXBACKENDS, 1, INT_MAX, NULL, NULL }, { --- 537,553 ---- /* * Note: There is some postprocessing done in PostmasterMain() to make * sure the buffers are at least twice the number of backends, so the ! * constraints here are partially unused. Also the super user reserved ! * number is forced to less than the max backends number there. */ { { "max_connections", PGC_POSTMASTER }, &MaxBackends, DEF_MAXBACKENDS, 1, INT_MAX, NULL, NULL + }, + + { + { "superuser_reserved_connections", PGC_POSTMASTER }, &ReservedBackends, + 2, 0, INT_MAX, NULL, NULL }, { Index: src/backend/utils/misc/postgresql.conf.sample =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/backend/utils/misc/postgresql.conf.sample,v retrieving revision 1.45 diff -c -r1.45 postgresql.conf.sample *** src/backend/utils/misc/postgresql.conf.sample 2002/08/18 03:03:26 1.45 --- src/backend/utils/misc/postgresql.conf.sample 2002/08/25 22:27:51 *************** *** 31,36 **** --- 31,37 ---- #ssl = false #max_connections = 32 + #superuser_reserved_connections = 2 #port = 5432 #hostname_lookup = false Index: src/include/miscadmin.h =================================================================== RCS file: /projects/cvsroot/pgsql-server/src/include/miscadmin.h,v retrieving revision 1.106 diff -c -r1.106 miscadmin.h *** src/include/miscadmin.h 2002/06/20 20:29:42 1.106 --- src/include/miscadmin.h 2002/08/25 22:27:52 *************** *** 179,184 **** --- 179,185 ---- extern bool EnableSSL; extern bool SilentMode; extern int MaxBackends; + extern int ReservedBackends; extern int NBuffers; extern int PostPortNumber; extern int Unix_socket_permissions;