On 16-11-2012 12:27, Hannu Krosing wrote: > Why not just make the sending SIGHUP a separate command as it is now ? > > SELECT pg_reload_config(); > ... or even a RELOAD command. I've already coded a WIP patch for such command.
-- Euler Taveira de Oliveira - Timbira http://www.timbira.com.br/ PostgreSQL: Consultoria, Desenvolvimento, Suporte 24x7 e Treinamento
diff --git a/doc/src/sgml/ref/allfiles.sgml b/doc/src/sgml/ref/allfiles.sgml index df84054..f7abb57 100644 --- a/doc/src/sgml/ref/allfiles.sgml +++ b/doc/src/sgml/ref/allfiles.sgml @@ -137,6 +137,7 @@ Complete list of usable sgml source files in this directory. <!ENTITY reassignOwned SYSTEM "reassign_owned.sgml"> <!ENTITY reindex SYSTEM "reindex.sgml"> <!ENTITY releaseSavepoint SYSTEM "release_savepoint.sgml"> +<!ENTITY reload SYSTEM "reload.sgml"> <!ENTITY reset SYSTEM "reset.sgml"> <!ENTITY revoke SYSTEM "revoke.sgml"> <!ENTITY rollback SYSTEM "rollback.sgml"> diff --git a/doc/src/sgml/ref/reload.sgml b/doc/src/sgml/ref/reload.sgml new file mode 100644 index 0000000..42baab9 --- /dev/null +++ b/doc/src/sgml/ref/reload.sgml @@ -0,0 +1,51 @@ +<!-- doc/src/sgml/ref/reload.sgml --> + +<refentry id="sql-reload"> + <refmeta> + <refentrytitle>RELOAD</refentrytitle> + <manvolnum>7</manvolnum> + <refmiscinfo>SQL - Language Statements</refmiscinfo> + </refmeta> + + <refnamediv> + <refname>RELOAD</refname> + <refpurpose>reread configuration files</refpurpose> + </refnamediv> + + <indexterm zone="sql-reload"> + <primary>RELOAD</primary> + </indexterm> + + <refsynopsisdiv> +<synopsis> +RELOAD +</synopsis> + </refsynopsisdiv> + + <refsect1> + <title>Description</title> + + <para> + The <command>RELOAD</command> command triggers <command>postgres</command> to + reread its configuration files (<filename>postgresql.conf</filename>, + <filename>pg_hba.conf</filename>, etc.). This allows changing of + configuration-file options that do not require a complete restart to take + effect. <command>RELOAD</command> command has the same behavior as + <command>pg_ctl</command> <option>reload</option> option (see <xref + linkend="app-pg-ctl">). + </para> + + <para> + Only superusers can call <command>RELOAD</command>. + </para> + </refsect1> + + <refsect1> + <title>Compatibility</title> + + <para> + The <command>RELOAD</command> command is a + <productname>PostgreSQL</productname> language extension. + </para> + </refsect1> +</refentry> diff --git a/doc/src/sgml/reference.sgml b/doc/src/sgml/reference.sgml index 0872168..ae5fb67 100644 --- a/doc/src/sgml/reference.sgml +++ b/doc/src/sgml/reference.sgml @@ -165,6 +165,7 @@ &reassignOwned; &reindex; &releaseSavepoint; + &reload; &reset; &revoke; &rollback; diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index 9387ee9..5dd6d0e 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -4394,6 +4394,9 @@ copyObject(const void *from) case T_CheckPointStmt: retval = (void *) makeNode(CheckPointStmt); break; + case T_ReloadStmt: + retval = (void *) makeNode(ReloadStmt); + break; case T_CreateSchemaStmt: retval = _copyCreateSchemaStmt(from); break; diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c index 95a95f4..7118bb6 100644 --- a/src/backend/nodes/equalfuncs.c +++ b/src/backend/nodes/equalfuncs.c @@ -2881,6 +2881,9 @@ equal(const void *a, const void *b) case T_CheckPointStmt: retval = true; break; + case T_ReloadStmt: + retval = true; + break; case T_CreateSchemaStmt: retval = _equalCreateSchemaStmt(a, b); break; diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index e4ff76e..b853e8f 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -245,7 +245,7 @@ static void processCASbits(int cas_bits, int location, const char *constrType, VariableResetStmt VariableSetStmt VariableShowStmt ViewStmt CheckPointStmt CreateConversionStmt DeallocateStmt PrepareStmt ExecuteStmt - DropOwnedStmt ReassignOwnedStmt + DropOwnedStmt ReassignOwnedStmt ReloadStmt AlterTSConfigurationStmt AlterTSDictionaryStmt %type <node> select_no_parens select_with_parens select_clause @@ -571,7 +571,7 @@ static void processCASbits(int cas_bits, int location, const char *constrType, QUOTE RANGE READ REAL REASSIGN RECHECK RECURSIVE REF REFERENCES REINDEX - RELATIVE_P RELEASE RENAME REPEATABLE REPLACE REPLICA + RELATIVE_P RELEASE RELOAD RENAME REPEATABLE REPLACE REPLICA RESET RESTART RESTRICT RETURNING RETURNS REVOKE RIGHT ROLE ROLLBACK ROW ROWS RULE @@ -794,6 +794,7 @@ stmt : | PrepareStmt | ReassignOwnedStmt | ReindexStmt + | ReloadStmt | RemoveAggrStmt | RemoveFuncStmt | RemoveOperStmt @@ -1657,6 +1658,20 @@ CheckPointStmt: } ; +/***************************************************************************** + * + * RELOAD + * + *****************************************************************************/ + +ReloadStmt: + RELOAD + { + ReloadStmt *n = makeNode(ReloadStmt); + $$ = (Node *)n; + } + ; + /***************************************************************************** * @@ -12605,6 +12620,7 @@ unreserved_keyword: | REINDEX | RELATIVE_P | RELEASE + | RELOAD | RENAME | REPEATABLE | REPLACE diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index b223fee..a0e55df 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -2116,6 +2116,15 @@ reset_shared(int port) CreateSharedMemoryAndSemaphores(false, port); } +/* + * RELOAD command -- rereads configuration files + */ +void +ReloadConfiguration(void) +{ + signal_child(PostmasterPid, SIGHUP); +} + /* * SIGHUP -- reread config files, and tell children to do same diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index 491bd29..5e0f9c9 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -54,6 +54,7 @@ #include "miscadmin.h" #include "parser/parse_utilcmd.h" #include "postmaster/bgwriter.h" +#include "postmaster/postmaster.h" #include "rewrite/rewriteDefine.h" #include "rewrite/rewriteRemove.h" #include "storage/fd.h" @@ -1258,6 +1259,15 @@ standard_ProcessUtility(Node *parsetree, (RecoveryInProgress() ? 0 : CHECKPOINT_FORCE)); break; + case T_ReloadStmt: + if (!superuser()) + ereport(ERROR, + (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), + errmsg("must be superuser to do RELOAD"))); + + ReloadConfiguration(); + break; + case T_ReindexStmt: { ReindexStmt *stmt = (ReindexStmt *) parsetree; @@ -2190,6 +2200,10 @@ CreateCommandTag(Node *parsetree) tag = "CHECKPOINT"; break; + case T_ReloadStmt: + tag = "RELOAD"; + break; + case T_ReindexStmt: tag = "REINDEX"; break; @@ -2697,6 +2711,10 @@ GetCommandLogLevel(Node *parsetree) lev = LOGSTMT_ALL; break; + case T_ReloadStmt: + lev = LOGSTMT_ALL; + break; + case T_ReindexStmt: lev = LOGSTMT_ALL; /* should this be DDL? */ break; diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index 438a1d9..d9331ad 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -361,6 +361,7 @@ typedef enum NodeTag T_AlterExtensionContentsStmt, T_CreateEventTrigStmt, T_AlterEventTrigStmt, + T_ReloadStmt, /* * TAGS FOR PARSE TREE NODES (parsenodes.h) diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index 8834499..15d400a 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -2459,6 +2459,15 @@ typedef struct CheckPointStmt } CheckPointStmt; /* ---------------------- + * Reload Statement + * ---------------------- + */ +typedef struct ReloadStmt +{ + NodeTag type; +} ReloadStmt; + +/* ---------------------- * Discard Statement * ---------------------- */ diff --git a/src/include/parser/kwlist.h b/src/include/parser/kwlist.h index af60dac..389f201 100644 --- a/src/include/parser/kwlist.h +++ b/src/include/parser/kwlist.h @@ -304,6 +304,7 @@ PG_KEYWORD("references", REFERENCES, RESERVED_KEYWORD) PG_KEYWORD("reindex", REINDEX, UNRESERVED_KEYWORD) PG_KEYWORD("relative", RELATIVE_P, UNRESERVED_KEYWORD) PG_KEYWORD("release", RELEASE, UNRESERVED_KEYWORD) +PG_KEYWORD("reload", RELOAD, UNRESERVED_KEYWORD) PG_KEYWORD("rename", RENAME, UNRESERVED_KEYWORD) PG_KEYWORD("repeatable", REPEATABLE, UNRESERVED_KEYWORD) PG_KEYWORD("replace", REPLACE, UNRESERVED_KEYWORD) diff --git a/src/include/postmaster/postmaster.h b/src/include/postmaster/postmaster.h index 0fe7ec2..444f72e 100644 --- a/src/include/postmaster/postmaster.h +++ b/src/include/postmaster/postmaster.h @@ -49,6 +49,8 @@ extern const char *progname; extern void PostmasterMain(int argc, char *argv[]) __attribute__((noreturn)); extern void ClosePostmasterPorts(bool am_syslogger); +extern void ReloadConfiguration(void); + extern int MaxLivePostmasterChildren(void); #ifdef EXEC_BACKEND
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers