Tue Mar 8 22:52:41 PST 2005
- Previous message: [Slony1-commit] By cbbrowne: Major changes to log shipping, allowing it to support
- Next message: [Slony1-commit] By smsimms: Removed a "my" keyword that limits the scope of Slony sets
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Log Message: ----------- Add new conf option: sql_on_connection. Description: Execute the enclosed SQL on each node serviced by this slon daemon at connect time it is usefull for setting ogging levels, or to tune the planner/memory memory used by slon. Modified Files: -------------- slony1-engine/doc/adminguide: slonconf.sgml (r1.2 -> r1.3) slony1-engine/share: slon.conf-sample (r1.2 -> r1.3) slony1-engine/src/slon: conf-file.l (r1.2 -> r1.3) confoptions.h (r1.16 -> r1.17) dbutils.c (r1.15 -> r1.16) slon.h (r1.46 -> r1.47) -------------- next part -------------- Index: slonconf.sgml =================================================================== RCS file: /usr/local/cvsroot/slony1/slony1-engine/doc/adminguide/slonconf.sgml,v retrieving revision 1.2 retrieving revision 1.3 diff -Ldoc/adminguide/slonconf.sgml -Ldoc/adminguide/slonconf.sgml -u -w -r1.2 -r1.3 --- doc/adminguide/slonconf.sgml +++ doc/adminguide/slonconf.sgml @@ -165,6 +165,21 @@ </para> </listitem> </varlistentry> + + <varlistentry id="slon-config-sql-on-connection" xreflabel="slon_conf_sql_on_connection"> + <term><varname>sql_on_connection (<type>string</type>)</term> + <indexterm> + <primary><varname>sql_on_connection</varname> configuration parameter</primary> + </indexterm> + <listitem> + <para> + Execute this SQL on each node at slon connect time. Useful to set logging + levels, or to tune the planner/memory settings. You can specify multiple + statements by seperating them with a ; + </para> + </listitem> + </varlistentry> + </variablelist> </sect1> <sect1 id="slon-config-interval"> Index: slon.conf-sample =================================================================== RCS file: /usr/local/cvsroot/slony1/slony1-engine/share/slon.conf-sample,v retrieving revision 1.2 retrieving revision 1.3 diff -Lshare/slon.conf-sample -Lshare/slon.conf-sample -u -w -r1.2 -r1.3 --- share/slon.conf-sample +++ share/slon.conf-sample @@ -72,3 +72,8 @@ # Range [10000,600000], default 60000. #desired_sync_time=60000 +# Execute the following SQL on each node at slon connect time +# useful to set logging levels, or to tune the planner/memory +# settings. You can specify multiple statements by seperating +# them with a ; +#sql_on_connection="SET log_min_duration_statement TO '1000';" Index: confoptions.h =================================================================== RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slon/confoptions.h,v retrieving revision 1.16 retrieving revision 1.17 diff -Lsrc/slon/confoptions.h -Lsrc/slon/confoptions.h -u -w -r1.16 -r1.17 --- src/slon/confoptions.h +++ src/slon/confoptions.h @@ -28,10 +28,11 @@ char *Syslog_ident; char *Syslog_facility; int Use_syslog; + bool logpid; bool logtimestamp; char *log_timestamp_format; - +char *sql_on_connection; enum config_type { @@ -283,6 +284,19 @@ &archive_dir, NULL }, + { + { + (const char *)"sql_on_connection", + gettext_noop("SQL to send to each connected node on " + "connection establishment, usefull to enable " + "duration logging, or to adjust any other " + "connection settable GUC"), + NULL, + SLON_C_STRING + }, + &sql_on_connection, + NULL + }, #ifdef HAVE_SYSLOG { { Index: conf-file.l =================================================================== RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slon/conf-file.l,v retrieving revision 1.2 retrieving revision 1.3 diff -Lsrc/slon/conf-file.l -Lsrc/slon/conf-file.l -u -w -r1.2 -r1.3 --- src/slon/conf-file.l +++ src/slon/conf-file.l @@ -28,6 +28,7 @@ SLON_EQUALS = 5, SLON_UNQUOTED_STRING = 6, SLON_QUALIFIED_ID = 7, + SLON_ESCAPED_STRING = 8, SLON_EOL = 99, SLON_FERROR = 100 }; @@ -62,7 +63,7 @@ UNQUOTED_STRING {LETTER}({LETTER_OR_DIGIT}|[-._:/])* STRING \'([^'\n]|\\.)*\' - +ESCAPED_STRING \"([^"\n]|\\.)*\" %% \n ConfigFileLineno++; return SLON_EOL; @@ -73,6 +74,7 @@ {QUALIFIED_ID} return SLON_QUALIFIED_ID; {STRING} return SLON_STRING; {UNQUOTED_STRING} return SLON_UNQUOTED_STRING; +{ESCAPED_STRING} return SLON_ESCAPED_STRING; {INTEGER} return SLON_INTEGER; {REAL} return SLON_REAL; = return SLON_EQUALS; @@ -172,12 +174,12 @@ { token = yylex(); } - if (token != SLON_ID && token != SLON_STRING && token != SLON_INTEGER && token != SLON_REAL && token != SLON_UNQUOTED_STRING) + if (token != SLON_ID && token != SLON_STRING && token != SLON_INTEGER && token != SLON_REAL && token != SLON_UNQUOTED_STRING && token != SLON_ESCAPED_STRING) { goto parse_error; } opt_value = strdup(yytext); - if (token == SLON_STRING) + if (token == SLON_STRING || token == SLON_ESCAPED_STRING) { memmove(opt_value,opt_value+1,strlen(opt_value)-1); opt_value[strlen(opt_value)-2]='\0'; Index: dbutils.c =================================================================== RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slon/dbutils.c,v retrieving revision 1.15 retrieving revision 1.16 diff -Lsrc/slon/dbutils.c -Lsrc/slon/dbutils.c -u -w -r1.15 -r1.16 --- src/slon/dbutils.c +++ src/slon/dbutils.c @@ -73,6 +73,24 @@ PQfinish(dbconn); return NULL; } + if (sql_on_connection != NULL) + { + + PGresult *res; + SlonDString query; + + dstring_init(&query); + slon_mkquery(&query, "%s", sql_on_connection); + res = PQexec(dbconn, dstring_data(&query)); + if ( ! ((PQresultStatus(res) == PGRES_TUPLES_OK) || + (PQresultStatus(res) == PGRES_COMMAND_OK)) ) + { + slon_log(SLON_ERROR, + "query %s failed\n", + dstring_data(&query)); + } + PQclear(res); + } /* * Embed it into a SlonConn structure used to exchange it with the Index: slon.h =================================================================== RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/slon/slon.h,v retrieving revision 1.46 retrieving revision 1.47 diff -Lsrc/slon/slon.h -Lsrc/slon/slon.h -u -w -r1.46 -r1.47 --- src/slon/slon.h +++ src/slon/slon.h @@ -508,7 +508,7 @@ extern int slon_mkquery(SlonDString * ds, char *fmt,...); extern int slon_appendquery(SlonDString * ds, char *fmt,...); - +extern char *sql_on_connection; /* ---------- * Globals in misc.c
- Previous message: [Slony1-commit] By cbbrowne: Major changes to log shipping, allowing it to support
- Next message: [Slony1-commit] By smsimms: Removed a "my" keyword that limits the scope of Slony sets
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Slony1-commit mailing list