prestogres 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +20 -0
- data/LICENSE +202 -0
- data/NOTICE +22 -0
- data/README.md +217 -0
- data/Rakefile +13 -0
- data/VERSION +1 -0
- data/bin/prestogres +254 -0
- data/config/pcp.conf.sample +28 -0
- data/config/pgpool.conf +678 -0
- data/config/pool_hba.conf +84 -0
- data/config/pool_passwd +0 -0
- data/config/postgresql.conf +2 -0
- data/ext/.gitignore +6 -0
- data/ext/depend +26 -0
- data/ext/extconf.rb +4 -0
- data/ext/prestogres_config.c +12 -0
- data/pgpool2/.gitignore +36 -0
- data/pgpool2/AUTHORS +4 -0
- data/pgpool2/COPYING +12 -0
- data/pgpool2/ChangeLog +1 -0
- data/pgpool2/INSTALL +1 -0
- data/pgpool2/Makefile.am +159 -0
- data/pgpool2/Makefile.in +1187 -0
- data/pgpool2/NEWS +4960 -0
- data/pgpool2/README +1 -0
- data/pgpool2/README.euc_jp +1 -0
- data/pgpool2/README.online-recovery +62 -0
- data/pgpool2/TODO +103 -0
- data/pgpool2/ac_func_accept_argtypes.m4 +85 -0
- data/pgpool2/aclocal.m4 +1088 -0
- data/pgpool2/c-compiler.m4 +134 -0
- data/pgpool2/c-library.m4 +325 -0
- data/pgpool2/child.c +2097 -0
- data/pgpool2/config.guess +1532 -0
- data/pgpool2/config.h.in +332 -0
- data/pgpool2/config.sub +1640 -0
- data/pgpool2/configure +15752 -0
- data/pgpool2/configure.in +392 -0
- data/pgpool2/depcomp +522 -0
- data/pgpool2/doc/basebackup.sh +17 -0
- data/pgpool2/doc/pgpool-de.html +4220 -0
- data/pgpool2/doc/pgpool-en.html +5738 -0
- data/pgpool2/doc/pgpool-fr.html +4118 -0
- data/pgpool2/doc/pgpool-ja.css +198 -0
- data/pgpool2/doc/pgpool-ja.html +11279 -0
- data/pgpool2/doc/pgpool-zh_cn.html +4445 -0
- data/pgpool2/doc/pgpool.css +280 -0
- data/pgpool2/doc/pgpool_remote_start +13 -0
- data/pgpool2/doc/recovery.conf.sample +117 -0
- data/pgpool2/doc/tutorial-en.html +707 -0
- data/pgpool2/doc/tutorial-ja.html +422 -0
- data/pgpool2/doc/tutorial-memqcache-en.html +325 -0
- data/pgpool2/doc/tutorial-memqcache-ja.html +370 -0
- data/pgpool2/doc/tutorial-memqcache-zh_cn.html +322 -0
- data/pgpool2/doc/tutorial-watchdog-en.html +306 -0
- data/pgpool2/doc/tutorial-watchdog-ja.html +343 -0
- data/pgpool2/doc/tutorial-watchdog-zh_cn.html +301 -0
- data/pgpool2/doc/tutorial-zh_cn.html +537 -0
- data/pgpool2/doc/watchdog.png +0 -0
- data/pgpool2/doc/wd-en.html +236 -0
- data/pgpool2/doc/wd-en.jpg +0 -0
- data/pgpool2/doc/wd-ja.html +219 -0
- data/pgpool2/doc/wd-ja.jpg +0 -0
- data/pgpool2/doc/wd-zh_cn.html +201 -0
- data/pgpool2/doc/where_to_send_queries.odg +0 -0
- data/pgpool2/doc/where_to_send_queries.pdf +0 -0
- data/pgpool2/general.m4 +166 -0
- data/pgpool2/getopt_long.c +200 -0
- data/pgpool2/getopt_long.h +44 -0
- data/pgpool2/install-sh +251 -0
- data/pgpool2/ltmain.sh +8406 -0
- data/pgpool2/m4/libtool.m4 +7360 -0
- data/pgpool2/m4/ltoptions.m4 +368 -0
- data/pgpool2/m4/ltsugar.m4 +123 -0
- data/pgpool2/m4/ltversion.m4 +23 -0
- data/pgpool2/m4/lt~obsolete.m4 +92 -0
- data/pgpool2/main.c +2971 -0
- data/pgpool2/md5.c +444 -0
- data/pgpool2/md5.h +28 -0
- data/pgpool2/missing +360 -0
- data/pgpool2/mkinstalldirs +40 -0
- data/pgpool2/parser/Makefile.am +50 -0
- data/pgpool2/parser/Makefile.in +559 -0
- data/pgpool2/parser/copyfuncs.c +3310 -0
- data/pgpool2/parser/gram.c +39100 -0
- data/pgpool2/parser/gram.h +940 -0
- data/pgpool2/parser/gram.y +13408 -0
- data/pgpool2/parser/gramparse.h +74 -0
- data/pgpool2/parser/keywords.c +32 -0
- data/pgpool2/parser/keywords.h +39 -0
- data/pgpool2/parser/kwlist.h +425 -0
- data/pgpool2/parser/kwlookup.c +88 -0
- data/pgpool2/parser/list.c +1156 -0
- data/pgpool2/parser/makefuncs.c +518 -0
- data/pgpool2/parser/makefuncs.h +83 -0
- data/pgpool2/parser/memnodes.h +79 -0
- data/pgpool2/parser/nodes.c +29 -0
- data/pgpool2/parser/nodes.h +609 -0
- data/pgpool2/parser/outfuncs.c +5790 -0
- data/pgpool2/parser/parsenodes.h +2615 -0
- data/pgpool2/parser/parser.c +262 -0
- data/pgpool2/parser/parser.h +46 -0
- data/pgpool2/parser/pg_class.h +158 -0
- data/pgpool2/parser/pg_config_manual.h +273 -0
- data/pgpool2/parser/pg_list.h +352 -0
- data/pgpool2/parser/pg_trigger.h +147 -0
- data/pgpool2/parser/pg_wchar.h +492 -0
- data/pgpool2/parser/pool_memory.c +342 -0
- data/pgpool2/parser/pool_memory.h +77 -0
- data/pgpool2/parser/pool_parser.h +222 -0
- data/pgpool2/parser/pool_string.c +121 -0
- data/pgpool2/parser/pool_string.h +37 -0
- data/pgpool2/parser/primnodes.h +1280 -0
- data/pgpool2/parser/scan.c +4094 -0
- data/pgpool2/parser/scan.l +1451 -0
- data/pgpool2/parser/scanner.h +120 -0
- data/pgpool2/parser/scansup.c +221 -0
- data/pgpool2/parser/scansup.h +28 -0
- data/pgpool2/parser/snprintf.c +1102 -0
- data/pgpool2/parser/stringinfo.c +294 -0
- data/pgpool2/parser/stringinfo.h +178 -0
- data/pgpool2/parser/value.c +78 -0
- data/pgpool2/parser/value.h +62 -0
- data/pgpool2/parser/wchar.c +2048 -0
- data/pgpool2/pcp.conf.sample +28 -0
- data/pgpool2/pcp/Makefile.am +40 -0
- data/pgpool2/pcp/Makefile.in +771 -0
- data/pgpool2/pcp/libpcp_ext.h +250 -0
- data/pgpool2/pcp/md5.c +444 -0
- data/pgpool2/pcp/md5.h +28 -0
- data/pgpool2/pcp/pcp.c +1652 -0
- data/pgpool2/pcp/pcp.h +61 -0
- data/pgpool2/pcp/pcp_attach_node.c +172 -0
- data/pgpool2/pcp/pcp_detach_node.c +185 -0
- data/pgpool2/pcp/pcp_error.c +87 -0
- data/pgpool2/pcp/pcp_node_count.c +160 -0
- data/pgpool2/pcp/pcp_node_info.c +198 -0
- data/pgpool2/pcp/pcp_pool_status.c +166 -0
- data/pgpool2/pcp/pcp_proc_count.c +166 -0
- data/pgpool2/pcp/pcp_proc_info.c +261 -0
- data/pgpool2/pcp/pcp_promote_node.c +185 -0
- data/pgpool2/pcp/pcp_recovery_node.c +172 -0
- data/pgpool2/pcp/pcp_stop_pgpool.c +179 -0
- data/pgpool2/pcp/pcp_stream.c +385 -0
- data/pgpool2/pcp/pcp_stream.h +52 -0
- data/pgpool2/pcp/pcp_systemdb_info.c +194 -0
- data/pgpool2/pcp/pcp_watchdog_info.c +211 -0
- data/pgpool2/pcp_child.c +1493 -0
- data/pgpool2/pg_md5.c +305 -0
- data/pgpool2/pgpool.8.in +121 -0
- data/pgpool2/pgpool.conf +553 -0
- data/pgpool2/pgpool.conf.sample +666 -0
- data/pgpool2/pgpool.conf.sample-master-slave +665 -0
- data/pgpool2/pgpool.conf.sample-replication +664 -0
- data/pgpool2/pgpool.conf.sample-stream +664 -0
- data/pgpool2/pgpool.spec +264 -0
- data/pgpool2/pgpool_adm/TODO +7 -0
- data/pgpool2/pgpool_adm/pgpool_adm--1.0.sql +85 -0
- data/pgpool2/pgpool_adm/pgpool_adm.c +558 -0
- data/pgpool2/pgpool_adm/pgpool_adm.control +5 -0
- data/pgpool2/pgpool_adm/pgpool_adm.h +46 -0
- data/pgpool2/pgpool_adm/pgpool_adm.sql.in +85 -0
- data/pgpool2/pool.h +655 -0
- data/pgpool2/pool_auth.c +1390 -0
- data/pgpool2/pool_config.c +5007 -0
- data/pgpool2/pool_config.h +284 -0
- data/pgpool2/pool_config.l +3281 -0
- data/pgpool2/pool_config_md5.c +29 -0
- data/pgpool2/pool_connection_pool.c +812 -0
- data/pgpool2/pool_error.c +242 -0
- data/pgpool2/pool_globals.c +27 -0
- data/pgpool2/pool_hba.c +1723 -0
- data/pgpool2/pool_hba.conf.sample +67 -0
- data/pgpool2/pool_ip.c +567 -0
- data/pgpool2/pool_ip.h +65 -0
- data/pgpool2/pool_ipc.h +38 -0
- data/pgpool2/pool_lobj.c +242 -0
- data/pgpool2/pool_lobj.h +32 -0
- data/pgpool2/pool_memqcache.c +3818 -0
- data/pgpool2/pool_memqcache.h +268 -0
- data/pgpool2/pool_params.c +163 -0
- data/pgpool2/pool_passwd.c +249 -0
- data/pgpool2/pool_passwd.h +41 -0
- data/pgpool2/pool_path.c +193 -0
- data/pgpool2/pool_path.h +81 -0
- data/pgpool2/pool_process_context.c +247 -0
- data/pgpool2/pool_process_context.h +62 -0
- data/pgpool2/pool_process_query.c +5001 -0
- data/pgpool2/pool_process_reporting.c +1671 -0
- data/pgpool2/pool_process_reporting.h +44 -0
- data/pgpool2/pool_proto2.c +671 -0
- data/pgpool2/pool_proto_modules.c +3524 -0
- data/pgpool2/pool_proto_modules.h +185 -0
- data/pgpool2/pool_query_cache.c +1020 -0
- data/pgpool2/pool_query_context.c +1871 -0
- data/pgpool2/pool_query_context.h +105 -0
- data/pgpool2/pool_relcache.c +284 -0
- data/pgpool2/pool_relcache.h +78 -0
- data/pgpool2/pool_rewrite_outfuncs.c +9060 -0
- data/pgpool2/pool_rewrite_query.c +715 -0
- data/pgpool2/pool_rewrite_query.h +192 -0
- data/pgpool2/pool_select_walker.c +1150 -0
- data/pgpool2/pool_select_walker.h +68 -0
- data/pgpool2/pool_sema.c +161 -0
- data/pgpool2/pool_session_context.c +952 -0
- data/pgpool2/pool_session_context.h +203 -0
- data/pgpool2/pool_shmem.c +185 -0
- data/pgpool2/pool_signal.c +158 -0
- data/pgpool2/pool_signal.h +61 -0
- data/pgpool2/pool_ssl.c +339 -0
- data/pgpool2/pool_stream.c +962 -0
- data/pgpool2/pool_stream.h +61 -0
- data/pgpool2/pool_system.c +659 -0
- data/pgpool2/pool_timestamp.c +1215 -0
- data/pgpool2/pool_timestamp.h +38 -0
- data/pgpool2/pool_type.h +171 -0
- data/pgpool2/pool_worker_child.c +384 -0
- data/pgpool2/ps_status.c +404 -0
- data/pgpool2/recovery.c +435 -0
- data/pgpool2/redhat/pgpool.conf.sample.patch +52 -0
- data/pgpool2/redhat/pgpool.init +201 -0
- data/pgpool2/redhat/pgpool.sysconfig +7 -0
- data/pgpool2/redhat/rpm_installer/basebackup-replication.sh +53 -0
- data/pgpool2/redhat/rpm_installer/basebackup-stream.sh +55 -0
- data/pgpool2/redhat/rpm_installer/config_for_script +17 -0
- data/pgpool2/redhat/rpm_installer/failover.sh +64 -0
- data/pgpool2/redhat/rpm_installer/getsources.sh +141 -0
- data/pgpool2/redhat/rpm_installer/install.sh +1363 -0
- data/pgpool2/redhat/rpm_installer/pgpool_recovery_pitr +47 -0
- data/pgpool2/redhat/rpm_installer/pgpool_remote_start +15 -0
- data/pgpool2/redhat/rpm_installer/recovery.conf +4 -0
- data/pgpool2/redhat/rpm_installer/uninstall.sh +57 -0
- data/pgpool2/sample/dist_def_pgbench.sql +73 -0
- data/pgpool2/sample/pgpool.pam +3 -0
- data/pgpool2/sample/pgpool_recovery +20 -0
- data/pgpool2/sample/pgpool_recovery_pitr +19 -0
- data/pgpool2/sample/pgpool_remote_start +13 -0
- data/pgpool2/sample/replicate_def_pgbench.sql +18 -0
- data/pgpool2/sql/insert_lock.sql +15 -0
- data/pgpool2/sql/pgpool-recovery/pgpool-recovery.c +280 -0
- data/pgpool2/sql/pgpool-recovery/pgpool-recovery.sql.in +19 -0
- data/pgpool2/sql/pgpool-recovery/pgpool_recovery--1.0.sql +24 -0
- data/pgpool2/sql/pgpool-recovery/pgpool_recovery.control +5 -0
- data/pgpool2/sql/pgpool-recovery/uninstall_pgpool-recovery.sql +3 -0
- data/pgpool2/sql/pgpool-regclass/pgpool-regclass.c +206 -0
- data/pgpool2/sql/pgpool-regclass/pgpool-regclass.sql.in +4 -0
- data/pgpool2/sql/pgpool-regclass/pgpool_regclass--1.0.sql +7 -0
- data/pgpool2/sql/pgpool-regclass/pgpool_regclass.control +5 -0
- data/pgpool2/sql/pgpool-regclass/uninstall_pgpool-regclass.sql +1 -0
- data/pgpool2/sql/system_db.sql +38 -0
- data/pgpool2/strlcpy.c +85 -0
- data/pgpool2/test/C/test_extended.c +98 -0
- data/pgpool2/test/jdbc/.cvsignore +2 -0
- data/pgpool2/test/jdbc/AutoCommitTest.java +45 -0
- data/pgpool2/test/jdbc/BatchTest.java +55 -0
- data/pgpool2/test/jdbc/ColumnTest.java +60 -0
- data/pgpool2/test/jdbc/CreateTempTableTest.java +48 -0
- data/pgpool2/test/jdbc/InsertTest.java +34 -0
- data/pgpool2/test/jdbc/LockTest.java +36 -0
- data/pgpool2/test/jdbc/PgpoolTest.java +75 -0
- data/pgpool2/test/jdbc/README.euc_jp +73 -0
- data/pgpool2/test/jdbc/RunTest.java +83 -0
- data/pgpool2/test/jdbc/SelectTest.java +37 -0
- data/pgpool2/test/jdbc/UpdateTest.java +32 -0
- data/pgpool2/test/jdbc/expected/CreateTempTable +1 -0
- data/pgpool2/test/jdbc/expected/autocommit +10 -0
- data/pgpool2/test/jdbc/expected/batch +1 -0
- data/pgpool2/test/jdbc/expected/column +100 -0
- data/pgpool2/test/jdbc/expected/insert +1 -0
- data/pgpool2/test/jdbc/expected/lock +100 -0
- data/pgpool2/test/jdbc/expected/select +2 -0
- data/pgpool2/test/jdbc/expected/update +1 -0
- data/pgpool2/test/jdbc/pgpool.properties +7 -0
- data/pgpool2/test/jdbc/prepare.sql +54 -0
- data/pgpool2/test/jdbc/run.sh +6 -0
- data/pgpool2/test/parser/.cvsignore +6 -0
- data/pgpool2/test/parser/README +32 -0
- data/pgpool2/test/parser/expected/copy.out +17 -0
- data/pgpool2/test/parser/expected/create.out +64 -0
- data/pgpool2/test/parser/expected/cursor.out +37 -0
- data/pgpool2/test/parser/expected/delete.out +10 -0
- data/pgpool2/test/parser/expected/drop.out +12 -0
- data/pgpool2/test/parser/expected/insert.out +13 -0
- data/pgpool2/test/parser/expected/misc.out +28 -0
- data/pgpool2/test/parser/expected/prepare.out +4 -0
- data/pgpool2/test/parser/expected/privileges.out +31 -0
- data/pgpool2/test/parser/expected/scanner.out +30 -0
- data/pgpool2/test/parser/expected/select.out +89 -0
- data/pgpool2/test/parser/expected/transaction.out +38 -0
- data/pgpool2/test/parser/expected/update.out +11 -0
- data/pgpool2/test/parser/expected/v84.out +37 -0
- data/pgpool2/test/parser/expected/v90.out +25 -0
- data/pgpool2/test/parser/expected/var.out +22 -0
- data/pgpool2/test/parser/input/alter.sql +2 -0
- data/pgpool2/test/parser/input/copy.sql +17 -0
- data/pgpool2/test/parser/input/create.sql +64 -0
- data/pgpool2/test/parser/input/cursor.sql +37 -0
- data/pgpool2/test/parser/input/delete.sql +10 -0
- data/pgpool2/test/parser/input/drop.sql +12 -0
- data/pgpool2/test/parser/input/insert.sql +13 -0
- data/pgpool2/test/parser/input/misc.sql +28 -0
- data/pgpool2/test/parser/input/prepare.sql +4 -0
- data/pgpool2/test/parser/input/privileges.sql +31 -0
- data/pgpool2/test/parser/input/scanner.sql +34 -0
- data/pgpool2/test/parser/input/select.sql +89 -0
- data/pgpool2/test/parser/input/transaction.sql +38 -0
- data/pgpool2/test/parser/input/update.sql +11 -0
- data/pgpool2/test/parser/input/v84.sql +37 -0
- data/pgpool2/test/parser/input/v90.sql +38 -0
- data/pgpool2/test/parser/input/var.sql +22 -0
- data/pgpool2/test/parser/main.c +96 -0
- data/pgpool2/test/parser/parse_schedule +16 -0
- data/pgpool2/test/parser/pool.h +13 -0
- data/pgpool2/test/parser/run-test +62 -0
- data/pgpool2/test/pdo-test/README.euc_jp +58 -0
- data/pgpool2/test/pdo-test/SQLlist/test1.sql +3 -0
- data/pgpool2/test/pdo-test/SQLlist/test2.sql +3 -0
- data/pgpool2/test/pdo-test/collections.inc +11 -0
- data/pgpool2/test/pdo-test/def.inc +7 -0
- data/pgpool2/test/pdo-test/log.txt +0 -0
- data/pgpool2/test/pdo-test/mod/database.inc +36 -0
- data/pgpool2/test/pdo-test/mod/def.inc +0 -0
- data/pgpool2/test/pdo-test/mod/errorhandler.inc +27 -0
- data/pgpool2/test/pdo-test/pdotest.php +11 -0
- data/pgpool2/test/pdo-test/regsql.inc +56 -0
- data/pgpool2/test/pgpool_setup +898 -0
- data/pgpool2/test/regression/README +39 -0
- data/pgpool2/test/regression/clean.sh +21 -0
- data/pgpool2/test/regression/libs.sh +16 -0
- data/pgpool2/test/regression/regress.sh +166 -0
- data/pgpool2/test/regression/tests/001.load_balance/test.sh +128 -0
- data/pgpool2/test/regression/tests/002.native_replication/PgTester.java +47 -0
- data/pgpool2/test/regression/tests/002.native_replication/create.sql +6 -0
- data/pgpool2/test/regression/tests/002.native_replication/test.sh +71 -0
- data/pgpool2/test/regression/tests/003.failover/expected.r +6 -0
- data/pgpool2/test/regression/tests/003.failover/expected.s +6 -0
- data/pgpool2/test/regression/tests/003.failover/test.sh +45 -0
- data/pgpool2/test/regression/tests/004.watchdog/master.conf +12 -0
- data/pgpool2/test/regression/tests/004.watchdog/standby.conf +19 -0
- data/pgpool2/test/regression/tests/004.watchdog/test.sh +52 -0
- data/pgpool2/test/regression/tests/050.bug58/test.sh +50 -0
- data/pgpool2/test/regression/tests/051.bug60/bug.sql +12 -0
- data/pgpool2/test/regression/tests/051.bug60/database-clean.sql +6 -0
- data/pgpool2/test/regression/tests/051.bug60/database-setup.sql +28 -0
- data/pgpool2/test/regression/tests/051.bug60/test.sh +79 -0
- data/pgpool2/test/regression/tests/052.do_query/test.sh +44 -0
- data/pgpool2/test/regression/tests/053.insert_lock_hangs/test.sh +81 -0
- data/pgpool2/test/regression/tests/054.postgres_fdw/test.sh +67 -0
- data/pgpool2/test/regression/tests/055.backend_all_down/test.sh +52 -0
- data/pgpool2/test/regression/tests/056.bug63/jdbctest2.java +66 -0
- data/pgpool2/test/regression/tests/056.bug63/test.sh +47 -0
- data/pgpool2/test/regression/tests/057.bug61/test.sh +40 -0
- data/pgpool2/test/regression/tests/058.bug68/jdbctest3.java +45 -0
- data/pgpool2/test/regression/tests/058.bug68/test.sh +47 -0
- data/pgpool2/test/timestamp/expected/insert.out +16 -0
- data/pgpool2/test/timestamp/expected/misc.out +3 -0
- data/pgpool2/test/timestamp/expected/update.out +6 -0
- data/pgpool2/test/timestamp/input/insert.sql +16 -0
- data/pgpool2/test/timestamp/input/misc.sql +3 -0
- data/pgpool2/test/timestamp/input/update.sql +6 -0
- data/pgpool2/test/timestamp/main.c +129 -0
- data/pgpool2/test/timestamp/parse_schedule +3 -0
- data/pgpool2/test/timestamp/run-test +69 -0
- data/pgpool2/version.h +1 -0
- data/pgpool2/watchdog/Makefile.am +17 -0
- data/pgpool2/watchdog/Makefile.in +505 -0
- data/pgpool2/watchdog/test/stab.c +266 -0
- data/pgpool2/watchdog/test/test.c +85 -0
- data/pgpool2/watchdog/test/wd_child_t.c +87 -0
- data/pgpool2/watchdog/test/wd_lifecheck_t.c +87 -0
- data/pgpool2/watchdog/test/wd_packet_t.c +87 -0
- data/pgpool2/watchdog/test/wd_ping_t.c +20 -0
- data/pgpool2/watchdog/watchdog.c +408 -0
- data/pgpool2/watchdog/watchdog.h +209 -0
- data/pgpool2/watchdog/wd_child.c +444 -0
- data/pgpool2/watchdog/wd_ext.h +123 -0
- data/pgpool2/watchdog/wd_heartbeat.c +577 -0
- data/pgpool2/watchdog/wd_if.c +216 -0
- data/pgpool2/watchdog/wd_init.c +126 -0
- data/pgpool2/watchdog/wd_interlock.c +347 -0
- data/pgpool2/watchdog/wd_lifecheck.c +512 -0
- data/pgpool2/watchdog/wd_list.c +429 -0
- data/pgpool2/watchdog/wd_packet.c +1159 -0
- data/pgpool2/watchdog/wd_ping.c +330 -0
- data/pgpool2/ylwrap +223 -0
- data/pgsql/presto_client.py +346 -0
- data/pgsql/prestogres.py +156 -0
- data/pgsql/setup_functions.sql +21 -0
- data/pgsql/setup_language.sql +3 -0
- data/prestogres.gemspec +23 -0
- metadata +496 -0
@@ -0,0 +1,1671 @@
|
|
1
|
+
/* -*-pgsql-c-*- */
|
2
|
+
/*
|
3
|
+
* $Header$
|
4
|
+
*
|
5
|
+
* pgpool: a language independent connection pool server for PostgreSQL
|
6
|
+
* written by Tatsuo Ishii
|
7
|
+
*
|
8
|
+
* Copyright (c) 2003-2013 PgPool Global Development Group
|
9
|
+
*
|
10
|
+
* Permission to use, copy, modify, and distribute this software and
|
11
|
+
* its documentation for any purpose and without fee is hereby
|
12
|
+
* granted, provided that the above copyright notice appear in all
|
13
|
+
* copies and that both that copyright notice and this permission
|
14
|
+
* notice appear in supporting documentation, and that the name of the
|
15
|
+
* author not be used in advertising or publicity pertaining to
|
16
|
+
* distribution of the software without specific, written prior
|
17
|
+
* permission. The author makes no representations about the
|
18
|
+
* suitability of this software for any purpose. It is provided "as
|
19
|
+
* is" without express or implied warranty.
|
20
|
+
*
|
21
|
+
* Process pgPool-II "SHOW" queries.
|
22
|
+
*/
|
23
|
+
#include "pool.h"
|
24
|
+
#include "pool_proto_modules.h"
|
25
|
+
#include "pool_stream.h"
|
26
|
+
#include "pool_config.h"
|
27
|
+
#include "pool_memqcache.h"
|
28
|
+
#include "version.h"
|
29
|
+
|
30
|
+
#include <stdlib.h>
|
31
|
+
#include <string.h>
|
32
|
+
#include <netinet/in.h>
|
33
|
+
|
34
|
+
void send_row_description(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend,
|
35
|
+
short num_fields, char **field_names)
|
36
|
+
{
|
37
|
+
static char *cursorname = "blank";
|
38
|
+
static int oid = 0;
|
39
|
+
static short fsize = -1;
|
40
|
+
static int mod = 0;
|
41
|
+
short n;
|
42
|
+
int i;
|
43
|
+
short s;
|
44
|
+
int len;
|
45
|
+
short colnum;
|
46
|
+
|
47
|
+
if (MAJOR(backend) == PROTO_MAJOR_V2)
|
48
|
+
{
|
49
|
+
/* cursor response */
|
50
|
+
pool_write(frontend, "P", 1);
|
51
|
+
pool_write(frontend, cursorname, strlen(cursorname)+1);
|
52
|
+
}
|
53
|
+
|
54
|
+
/* row description */
|
55
|
+
pool_write(frontend, "T", 1);
|
56
|
+
|
57
|
+
if (MAJOR(backend) == PROTO_MAJOR_V3)
|
58
|
+
{
|
59
|
+
/* information about computed byte in section "RowDescription (B)" here:
|
60
|
+
* http://www.postgresql.org/docs/current/static/protocol-message-formats.html */
|
61
|
+
|
62
|
+
len = 6; /* int32 + int16 */
|
63
|
+
|
64
|
+
for (i=0;i<num_fields;i++)
|
65
|
+
{
|
66
|
+
/* String + '\0' + 3* int32 + 3* int16 */
|
67
|
+
len += strlen(field_names[i]) +1 +18;
|
68
|
+
}
|
69
|
+
|
70
|
+
len = htonl(len);
|
71
|
+
pool_write(frontend, &len, sizeof(len));
|
72
|
+
}
|
73
|
+
|
74
|
+
n = htons(num_fields);
|
75
|
+
pool_write(frontend, &n, sizeof(short));
|
76
|
+
|
77
|
+
for (i=0;i<num_fields;i++)
|
78
|
+
{
|
79
|
+
pool_write(frontend, field_names[i], strlen(field_names[i])+1); /* field name */
|
80
|
+
|
81
|
+
if (MAJOR(backend) == PROTO_MAJOR_V3)
|
82
|
+
{
|
83
|
+
pool_write(frontend, &oid, sizeof(oid)); /* table oid */
|
84
|
+
colnum = htons(i);
|
85
|
+
pool_write(frontend, &colnum, sizeof(colnum)); /* column number */
|
86
|
+
}
|
87
|
+
|
88
|
+
pool_write(frontend, &oid, sizeof(oid)); /* data type oid */
|
89
|
+
s = htons(fsize);
|
90
|
+
pool_write(frontend, &s, sizeof(fsize)); /* field size */
|
91
|
+
pool_write(frontend, &mod, sizeof(mod)); /* modifier */
|
92
|
+
|
93
|
+
if (MAJOR(backend) == PROTO_MAJOR_V3)
|
94
|
+
{
|
95
|
+
s = htons(0);
|
96
|
+
pool_write(frontend, &s, sizeof(fsize)); /* field format (text) */
|
97
|
+
}
|
98
|
+
}
|
99
|
+
pool_flush(frontend);
|
100
|
+
}
|
101
|
+
|
102
|
+
void send_complete_and_ready(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend, const int num_rows)
|
103
|
+
{
|
104
|
+
int len;
|
105
|
+
int msg_len;
|
106
|
+
char msg[16];
|
107
|
+
|
108
|
+
msg_len = snprintf(msg, 16, "SELECT %d", num_rows);
|
109
|
+
|
110
|
+
/* if we had more than 16 bytes, including '\0', the string was truncatured
|
111
|
+
* shouldn't happen though, as it would means more than "SELECT 99999999" */
|
112
|
+
if (msg_len > 15) msg_len = 15;
|
113
|
+
|
114
|
+
/* complete command response */
|
115
|
+
pool_write(frontend, "C", 1);
|
116
|
+
if (MAJOR(backend) == PROTO_MAJOR_V3)
|
117
|
+
{
|
118
|
+
len = htonl(4 + strlen(msg)+1);
|
119
|
+
pool_write(frontend, &len, sizeof(len));
|
120
|
+
}
|
121
|
+
pool_write(frontend, msg, strlen(msg)+1);
|
122
|
+
|
123
|
+
/* ready for query */
|
124
|
+
pool_write(frontend, "Z", 1);
|
125
|
+
if (MAJOR(backend) == PROTO_MAJOR_V3)
|
126
|
+
{
|
127
|
+
len = htonl(5);
|
128
|
+
pool_write(frontend, &len, sizeof(len));
|
129
|
+
pool_write(frontend, "I", 1);
|
130
|
+
}
|
131
|
+
|
132
|
+
pool_flush(frontend);
|
133
|
+
}
|
134
|
+
|
135
|
+
POOL_REPORT_CONFIG* get_config(int *nrows)
|
136
|
+
{
|
137
|
+
int i, j;
|
138
|
+
int len;
|
139
|
+
|
140
|
+
/*
|
141
|
+
* Report data buffer.
|
142
|
+
* 128 is the max number of configuration items.
|
143
|
+
* In addition, we need MAX_NUM_BACKENDS*4
|
144
|
+
* for backend descriptions.
|
145
|
+
*/
|
146
|
+
#define MAXITEMS (256 + MAX_NUM_BACKENDS*4)
|
147
|
+
|
148
|
+
POOL_REPORT_CONFIG* status = malloc(MAXITEMS * sizeof(POOL_REPORT_CONFIG));
|
149
|
+
|
150
|
+
/* we initialize the array with NULL values so when looping
|
151
|
+
* on it, we can use it as stop condition */
|
152
|
+
memset(status, 0, sizeof(POOL_REPORT_CONFIG) * MAXITEMS);
|
153
|
+
|
154
|
+
i = 0;
|
155
|
+
|
156
|
+
/* CONNECTIONS */
|
157
|
+
|
158
|
+
/* - pgpool Connection Settings - */
|
159
|
+
strncpy(status[i].name, "listen_addresses", POOLCONFIG_MAXNAMELEN);
|
160
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->listen_addresses);
|
161
|
+
strncpy(status[i].desc, "host name(s) or IP address(es) to listen to", POOLCONFIG_MAXDESCLEN);
|
162
|
+
i++;
|
163
|
+
|
164
|
+
strncpy(status[i].name, "port", POOLCONFIG_MAXNAMELEN);
|
165
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->port);
|
166
|
+
strncpy(status[i].desc, "pgpool accepting port number", POOLCONFIG_MAXDESCLEN);
|
167
|
+
i++;
|
168
|
+
|
169
|
+
/* - pgpool Communication Manager Connection Settings - */
|
170
|
+
strncpy(status[i].name, "socket_dir", POOLCONFIG_MAXNAMELEN);
|
171
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->socket_dir);
|
172
|
+
strncpy(status[i].desc, "pgpool socket directory", POOLCONFIG_MAXDESCLEN);
|
173
|
+
i++;
|
174
|
+
|
175
|
+
strncpy(status[i].name, "pcp_port", POOLCONFIG_MAXNAMELEN);
|
176
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->pcp_port);
|
177
|
+
strncpy(status[i].desc, "PCP port # to bind", POOLCONFIG_MAXDESCLEN);
|
178
|
+
i++;
|
179
|
+
|
180
|
+
strncpy(status[i].name, "pcp_socket_dir", POOLCONFIG_MAXNAMELEN);
|
181
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->pcp_socket_dir);
|
182
|
+
strncpy(status[i].desc, "PCP socket directory", POOLCONFIG_MAXDESCLEN);
|
183
|
+
i++;
|
184
|
+
|
185
|
+
/* # - Authentication - */
|
186
|
+
strncpy(status[i].name, "enable_pool_hba", POOLCONFIG_MAXNAMELEN);
|
187
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->enable_pool_hba);
|
188
|
+
strncpy(status[i].desc, "if true, use pool_hba.conf for client authentication", POOLCONFIG_MAXDESCLEN);
|
189
|
+
i++;
|
190
|
+
|
191
|
+
strncpy(status[i].name, "pool_passwd", POOLCONFIG_MAXNAMELEN);
|
192
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->pool_passwd);
|
193
|
+
strncpy(status[i].desc, "file name of pool_passwd for md5 authentication", POOLCONFIG_MAXDESCLEN);
|
194
|
+
i++;
|
195
|
+
|
196
|
+
strncpy(status[i].name, "authentication_timeout", POOLCONFIG_MAXNAMELEN);
|
197
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->authentication_timeout);
|
198
|
+
strncpy(status[i].desc, "maximum time in seconds to complete client authentication", POOLCONFIG_MAXNAMELEN);
|
199
|
+
i++;
|
200
|
+
|
201
|
+
/* - SSL Connections - */
|
202
|
+
strncpy(status[i].name, "ssl", POOLCONFIG_MAXNAMELEN);
|
203
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->ssl);
|
204
|
+
strncpy(status[i].desc, "SSL support", POOLCONFIG_MAXDESCLEN);
|
205
|
+
i++;
|
206
|
+
|
207
|
+
strncpy(status[i].name, "ssl_key", POOLCONFIG_MAXNAMELEN);
|
208
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->ssl_key);
|
209
|
+
strncpy(status[i].desc, "path to the SSL private key file", POOLCONFIG_MAXDESCLEN);
|
210
|
+
i++;
|
211
|
+
|
212
|
+
strncpy(status[i].name, "ssl_cert", POOLCONFIG_MAXNAMELEN);
|
213
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->ssl_cert);
|
214
|
+
strncpy(status[i].desc, "path to the SSL public certificate file", POOLCONFIG_MAXDESCLEN);
|
215
|
+
i++;
|
216
|
+
|
217
|
+
strncpy(status[i].name, "ssl_ca_cert", POOLCONFIG_MAXNAMELEN);
|
218
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->ssl_ca_cert);
|
219
|
+
strncpy(status[i].desc, "path to a single PEM format file", POOLCONFIG_MAXDESCLEN);
|
220
|
+
i++;
|
221
|
+
|
222
|
+
strncpy(status[i].name, "ssl_ca_cert_dir", POOLCONFIG_MAXNAMELEN);
|
223
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->ssl_ca_cert_dir);
|
224
|
+
strncpy(status[i].desc, "directory containing CA root certificate(s)", POOLCONFIG_MAXDESCLEN);
|
225
|
+
i++;
|
226
|
+
|
227
|
+
/* POOLS */
|
228
|
+
|
229
|
+
/* - Pool size - */
|
230
|
+
strncpy(status[i].name, "num_init_children", POOLCONFIG_MAXNAMELEN);
|
231
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->num_init_children);
|
232
|
+
strncpy(status[i].desc, "# of children initially pre-forked", POOLCONFIG_MAXDESCLEN);
|
233
|
+
i++;
|
234
|
+
|
235
|
+
strncpy(status[i].name, "max_pool", POOLCONFIG_MAXNAMELEN);
|
236
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->max_pool);
|
237
|
+
strncpy(status[i].desc, "max # of connection pool per child", POOLCONFIG_MAXDESCLEN);
|
238
|
+
i++;
|
239
|
+
|
240
|
+
/* - Life time - */
|
241
|
+
strncpy(status[i].name, "child_life_time", POOLCONFIG_MAXNAMELEN);
|
242
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->child_life_time);
|
243
|
+
strncpy(status[i].desc, "if idle for this seconds, child exits", POOLCONFIG_MAXDESCLEN);
|
244
|
+
i++;
|
245
|
+
|
246
|
+
strncpy(status[i].name, "child_max_connections", POOLCONFIG_MAXNAMELEN);
|
247
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->child_max_connections);
|
248
|
+
strncpy(status[i].desc, "if max_connections received, chile exits", POOLCONFIG_MAXDESCLEN);
|
249
|
+
i++;
|
250
|
+
|
251
|
+
strncpy(status[i].name, "connection_life_time", POOLCONFIG_MAXNAMELEN);
|
252
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->connection_life_time);
|
253
|
+
strncpy(status[i].desc, "if idle for this seconds, connection closes", POOLCONFIG_MAXDESCLEN);
|
254
|
+
i++;
|
255
|
+
|
256
|
+
strncpy(status[i].name, "client_idle_limit", POOLCONFIG_MAXNAMELEN);
|
257
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->client_idle_limit);
|
258
|
+
strncpy(status[i].desc, "if idle for this seconds, child connection closes", POOLCONFIG_MAXDESCLEN);
|
259
|
+
i++;
|
260
|
+
|
261
|
+
/* LOGS */
|
262
|
+
|
263
|
+
/* - Where to log - */
|
264
|
+
strncpy(status[i].name, "log_destination", POOLCONFIG_MAXNAMELEN);
|
265
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->log_destination);
|
266
|
+
strncpy(status[i].desc, "logging destination", POOLCONFIG_MAXDESCLEN);
|
267
|
+
i++;
|
268
|
+
|
269
|
+
/* - What to log - */
|
270
|
+
strncpy(status[i].name, "print_timestamp", POOLCONFIG_MAXNAMELEN);
|
271
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->print_timestamp);
|
272
|
+
strncpy(status[i].desc, "if true print time stamp to each log line", POOLCONFIG_MAXDESCLEN);
|
273
|
+
i++;
|
274
|
+
|
275
|
+
strncpy(status[i].name, "log_connections", POOLCONFIG_MAXNAMELEN);
|
276
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->log_connections);
|
277
|
+
strncpy(status[i].desc, "if true, print incoming connections to the log", POOLCONFIG_MAXDESCLEN);
|
278
|
+
i++;
|
279
|
+
|
280
|
+
strncpy(status[i].name, "log_hostname", POOLCONFIG_MAXNAMELEN);
|
281
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->log_hostname);
|
282
|
+
strncpy(status[i].desc, "if true, resolve hostname for ps and log print", POOLCONFIG_MAXDESCLEN);
|
283
|
+
i++;
|
284
|
+
|
285
|
+
strncpy(status[i].name, "log_statement", POOLCONFIG_MAXNAMELEN);
|
286
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->log_statement);
|
287
|
+
strncpy(status[i].desc, "if non 0, logs all SQL statements", POOLCONFIG_MAXDESCLEN);
|
288
|
+
i++;
|
289
|
+
|
290
|
+
strncpy(status[i].name, "log_per_node_statement", POOLCONFIG_MAXNAMELEN);
|
291
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->log_per_node_statement);
|
292
|
+
strncpy(status[i].desc, "if non 0, logs all SQL statements on each node", POOLCONFIG_MAXDESCLEN);
|
293
|
+
i++;
|
294
|
+
|
295
|
+
strncpy(status[i].name, "log_standby_delay", POOLCONFIG_MAXNAMELEN);
|
296
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->log_standby_delay);
|
297
|
+
strncpy(status[i].desc, "how to log standby delay", POOLCONFIG_MAXDESCLEN);
|
298
|
+
i++;
|
299
|
+
|
300
|
+
/* - Syslog specific - */
|
301
|
+
strncpy(status[i].name, "syslog_facility", POOLCONFIG_MAXNAMELEN);
|
302
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "LOCAL%d", (pool_config->syslog_facility/8) - 16);
|
303
|
+
strncpy(status[i].desc, "syslog local faclity", POOLCONFIG_MAXDESCLEN);
|
304
|
+
i++;
|
305
|
+
|
306
|
+
strncpy(status[i].name, "syslog_ident", POOLCONFIG_MAXNAMELEN);
|
307
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->syslog_ident);
|
308
|
+
strncpy(status[i].desc, "syslog program ident string", POOLCONFIG_MAXDESCLEN);
|
309
|
+
i++;
|
310
|
+
|
311
|
+
/* - Debug - */
|
312
|
+
strncpy(status[i].name, "debug_level", POOLCONFIG_MAXNAMELEN);
|
313
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->debug_level);
|
314
|
+
strncpy(status[i].desc, "debug message level", POOLCONFIG_MAXDESCLEN);
|
315
|
+
i++;
|
316
|
+
|
317
|
+
/* FILE LOCATIONS */
|
318
|
+
|
319
|
+
strncpy(status[i].name, "pid_file_name", POOLCONFIG_MAXNAMELEN);
|
320
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->pid_file_name);
|
321
|
+
strncpy(status[i].desc, "path to pid file", POOLCONFIG_MAXDESCLEN);
|
322
|
+
i++;
|
323
|
+
|
324
|
+
strncpy(status[i].name, "logdir", POOLCONFIG_MAXNAMELEN);
|
325
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->logdir);
|
326
|
+
strncpy(status[i].desc, "PgPool status file logging directory", POOLCONFIG_MAXDESCLEN);
|
327
|
+
i++;
|
328
|
+
|
329
|
+
/* CONNECTION POOLING */
|
330
|
+
|
331
|
+
strncpy(status[i].name, "connection_cache", POOLCONFIG_MAXNAMELEN);
|
332
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->connection_cache);
|
333
|
+
strncpy(status[i].desc, "if true, cache connection pool", POOLCONFIG_MAXDESCLEN);
|
334
|
+
i++;
|
335
|
+
|
336
|
+
strncpy(status[i].name, "reset_query_list", POOLCONFIG_MAXNAMELEN);
|
337
|
+
*(status[i].value) = '\0';
|
338
|
+
for (j=0;j<pool_config->num_reset_queries;j++)
|
339
|
+
{
|
340
|
+
len = POOLCONFIG_MAXVALLEN - strlen(status[i].value);
|
341
|
+
strncat(status[i].value, pool_config->reset_query_list[j], len);
|
342
|
+
len = POOLCONFIG_MAXVALLEN - strlen(status[i].value);
|
343
|
+
if (j != pool_config->num_reset_queries-1)
|
344
|
+
strncat(status[i].value, ";", len);
|
345
|
+
}
|
346
|
+
strncpy(status[i].desc, "queries issued at the end of session", POOLCONFIG_MAXDESCLEN);
|
347
|
+
i++;
|
348
|
+
|
349
|
+
/* REPLICATION MODE */
|
350
|
+
|
351
|
+
strncpy(status[i].name, "replication_mode", POOLCONFIG_MAXNAMELEN);
|
352
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->replication_mode);
|
353
|
+
strncpy(status[i].desc, "non 0 if operating in replication mode", POOLCONFIG_MAXDESCLEN);
|
354
|
+
i++;
|
355
|
+
|
356
|
+
strncpy(status[i].name, "replicate_select", POOLCONFIG_MAXNAMELEN);
|
357
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->replicate_select);
|
358
|
+
strncpy(status[i].desc, "non 0 if SELECT statement is replicated", POOLCONFIG_MAXDESCLEN);
|
359
|
+
i++;
|
360
|
+
|
361
|
+
strncpy(status[i].name, "insert_lock", POOLCONFIG_MAXNAMELEN);
|
362
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->insert_lock);
|
363
|
+
strncpy(status[i].desc, "insert lock", POOLCONFIG_MAXDESCLEN);
|
364
|
+
i++;
|
365
|
+
|
366
|
+
strncpy(status[i].name, "lobj_lock_table", POOLCONFIG_MAXNAMELEN);
|
367
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->lobj_lock_table);
|
368
|
+
strncpy(status[i].desc, "table name used for large object replication control", POOLCONFIG_MAXDESCLEN);
|
369
|
+
i++;
|
370
|
+
|
371
|
+
/* - Degenerate handling - */
|
372
|
+
strncpy(status[i].name, "replication_stop_on_mismatch", POOLCONFIG_MAXNAMELEN);
|
373
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->replication_stop_on_mismatch);
|
374
|
+
strncpy(status[i].desc, "stop replication mode on fatal error", POOLCONFIG_MAXDESCLEN);
|
375
|
+
i++;
|
376
|
+
|
377
|
+
strncpy(status[i].name, "failover_if_affected_tuples_mismatch", POOLCONFIG_MAXNAMELEN);
|
378
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->failover_if_affected_tuples_mismatch);
|
379
|
+
strncpy(status[i].desc, "failover if affected tuples are mismatch", POOLCONFIG_MAXDESCLEN);
|
380
|
+
i++;
|
381
|
+
|
382
|
+
/* LOAD BALANCING MODE */
|
383
|
+
|
384
|
+
strncpy(status[i].name, "load_balance_mode", POOLCONFIG_MAXNAMELEN);
|
385
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->load_balance_mode);
|
386
|
+
strncpy(status[i].desc, "non 0 if operating in load balancing mode", POOLCONFIG_MAXDESCLEN);
|
387
|
+
i++;
|
388
|
+
|
389
|
+
strncpy(status[i].name, "ignore_leading_white_space", POOLCONFIG_MAXNAMELEN);
|
390
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->ignore_leading_white_space);
|
391
|
+
strncpy(status[i].desc, "ignore leading white spaces", POOLCONFIG_MAXDESCLEN);
|
392
|
+
i++;
|
393
|
+
|
394
|
+
strncpy(status[i].name, "white_function_list", POOLCONFIG_MAXNAMELEN);
|
395
|
+
*(status[i].value) = '\0';
|
396
|
+
for (j=0;j<pool_config->num_white_function_list;j++)
|
397
|
+
{
|
398
|
+
len = POOLCONFIG_MAXVALLEN - strlen(status[i].value);
|
399
|
+
strncat(status[i].value, pool_config->white_function_list[j], len);
|
400
|
+
len = POOLCONFIG_MAXVALLEN - strlen(status[i].value);
|
401
|
+
if (j != pool_config->num_white_function_list-1)
|
402
|
+
strncat(status[i].value, ",", len);
|
403
|
+
}
|
404
|
+
strncpy(status[i].desc, "functions those do not write to database", POOLCONFIG_MAXDESCLEN);
|
405
|
+
i++;
|
406
|
+
|
407
|
+
strncpy(status[i].name, "black_function_list", POOLCONFIG_MAXNAMELEN);
|
408
|
+
*(status[i].value) = '\0';
|
409
|
+
for (j=0;j<pool_config->num_black_function_list;j++)
|
410
|
+
{
|
411
|
+
len = POOLCONFIG_MAXVALLEN - strlen(status[i].value);
|
412
|
+
strncat(status[i].value, pool_config->black_function_list[j], len);
|
413
|
+
len = POOLCONFIG_MAXVALLEN - strlen(status[i].value);
|
414
|
+
if (j != pool_config->num_black_function_list-1)
|
415
|
+
strncat(status[i].value, ",", len);
|
416
|
+
}
|
417
|
+
strncpy(status[i].desc, "functions those write to database", POOLCONFIG_MAXDESCLEN);
|
418
|
+
i++;
|
419
|
+
|
420
|
+
/* MASTER/SLAVE MODE */
|
421
|
+
|
422
|
+
strncpy(status[i].name, "master_slave_mode", POOLCONFIG_MAXNAMELEN);
|
423
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->master_slave_mode);
|
424
|
+
strncpy(status[i].desc, "if true, operate in master/slave mode", POOLCONFIG_MAXDESCLEN);
|
425
|
+
i++;
|
426
|
+
|
427
|
+
strncpy(status[i].name, "master_slave_sub_mode", POOLCONFIG_MAXNAMELEN);
|
428
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->master_slave_sub_mode);
|
429
|
+
strncpy(status[i].desc, "master/slave sub mode", POOLCONFIG_MAXDESCLEN);
|
430
|
+
i++;
|
431
|
+
|
432
|
+
/* - Streaming - */
|
433
|
+
strncpy(status[i].name, "sr_check_period", POOLCONFIG_MAXNAMELEN);
|
434
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->sr_check_period);
|
435
|
+
strncpy(status[i].desc, "sr check period", POOLCONFIG_MAXDESCLEN);
|
436
|
+
i++;
|
437
|
+
|
438
|
+
strncpy(status[i].name, "sr_check_user", POOLCONFIG_MAXNAMELEN);
|
439
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->sr_check_user);
|
440
|
+
strncpy(status[i].desc, "sr check user", POOLCONFIG_MAXDESCLEN);
|
441
|
+
i++;
|
442
|
+
#ifdef NOT_USED /* for security reason */
|
443
|
+
strncpy(status[i].name, "sr_check_password", POOLCONFIG_MAXNAMELEN);
|
444
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->sr_check_password);
|
445
|
+
strncpy(status[i].desc, "sr check password", POOLCONFIG_MAXDESCLEN);
|
446
|
+
i++;
|
447
|
+
#endif
|
448
|
+
strncpy(status[i].name, "delay_threshold", POOLCONFIG_MAXNAMELEN);
|
449
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%lld", pool_config->delay_threshold);
|
450
|
+
strncpy(status[i].desc, "standby delay threshold", POOLCONFIG_MAXDESCLEN);
|
451
|
+
i++;
|
452
|
+
|
453
|
+
/* - Special commands - */
|
454
|
+
strncpy(status[i].name, "follow_master_command", POOLCONFIG_MAXNAMELEN);
|
455
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->follow_master_command);
|
456
|
+
strncpy(status[i].desc, "follow master command", POOLCONFIG_MAXDESCLEN);
|
457
|
+
i++;
|
458
|
+
|
459
|
+
/* PARALLEL MODE AND QUERY CACHE */
|
460
|
+
|
461
|
+
strncpy(status[i].name, "parallel_mode", POOLCONFIG_MAXNAMELEN);
|
462
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->parallel_mode);
|
463
|
+
strncpy(status[i].desc, "if non 0, run in parallel query mode", POOLCONFIG_MAXDESCLEN);
|
464
|
+
i++;
|
465
|
+
|
466
|
+
strncpy(status[i].name, "enable_query_cache", POOLCONFIG_MAXNAMELEN);
|
467
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->enable_query_cache);
|
468
|
+
strncpy(status[i].desc, "if non 0, use query cache", POOLCONFIG_MAXDESCLEN);
|
469
|
+
i++;
|
470
|
+
|
471
|
+
strncpy(status[i].name, "pgpool2_hostname", POOLCONFIG_MAXNAMELEN);
|
472
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->pgpool2_hostname);
|
473
|
+
strncpy(status[i].desc, "pgpool2 hostname", POOLCONFIG_MAXDESCLEN);
|
474
|
+
i++;
|
475
|
+
|
476
|
+
/* - System DB info - */
|
477
|
+
strncpy(status[i].name, "system_db_hostname", POOLCONFIG_MAXNAMELEN);
|
478
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->system_db_hostname);
|
479
|
+
strncpy(status[i].desc, "system DB hostname", POOLCONFIG_MAXDESCLEN);
|
480
|
+
i++;
|
481
|
+
|
482
|
+
strncpy(status[i].name, "system_db_port", POOLCONFIG_MAXNAMELEN);
|
483
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->system_db_port);
|
484
|
+
strncpy(status[i].desc, "system DB port number", POOLCONFIG_MAXDESCLEN);
|
485
|
+
i++;
|
486
|
+
|
487
|
+
strncpy(status[i].name, "system_db_dbname", POOLCONFIG_MAXNAMELEN);
|
488
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->system_db_dbname);
|
489
|
+
strncpy(status[i].desc, "system DB name", POOLCONFIG_MAXDESCLEN);
|
490
|
+
i++;
|
491
|
+
|
492
|
+
strncpy(status[i].name, "system_db_schema", POOLCONFIG_MAXNAMELEN);
|
493
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->system_db_schema);
|
494
|
+
strncpy(status[i].desc, "system DB schema name", POOLCONFIG_MAXDESCLEN);
|
495
|
+
i++;
|
496
|
+
|
497
|
+
strncpy(status[i].name, "system_db_user", POOLCONFIG_MAXNAMELEN);
|
498
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->system_db_user);
|
499
|
+
strncpy(status[i].desc, "user name to access system DB", POOLCONFIG_MAXDESCLEN);
|
500
|
+
i++;
|
501
|
+
|
502
|
+
/* HEALTH CHECK */
|
503
|
+
|
504
|
+
strncpy(status[i].name, "health_check_period", POOLCONFIG_MAXNAMELEN);
|
505
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->health_check_period);
|
506
|
+
strncpy(status[i].desc, "health check period", POOLCONFIG_MAXDESCLEN);
|
507
|
+
i++;
|
508
|
+
|
509
|
+
strncpy(status[i].name, "health_check_timeout", POOLCONFIG_MAXNAMELEN);
|
510
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->health_check_timeout);
|
511
|
+
strncpy(status[i].desc, "health check timeout", POOLCONFIG_MAXDESCLEN);
|
512
|
+
i++;
|
513
|
+
|
514
|
+
strncpy(status[i].name, "health_check_user", POOLCONFIG_MAXNAMELEN);
|
515
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->health_check_user);
|
516
|
+
strncpy(status[i].desc, "health check user", POOLCONFIG_MAXDESCLEN);
|
517
|
+
i++;
|
518
|
+
#ifdef NOT_USED /* for security reason */
|
519
|
+
strncpy(status[i].name, "health_check_password", POOLCONFIG_MAXNAMELEN);
|
520
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->health_check_password);
|
521
|
+
strncpy(status[i].desc, "health check password", POOLCONFIG_MAXDESCLEN);
|
522
|
+
i++;
|
523
|
+
#endif
|
524
|
+
strncpy(status[i].name, "health_check_max_retries", POOLCONFIG_MAXNAMELEN);
|
525
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->health_check_max_retries);
|
526
|
+
strncpy(status[i].desc, "health check max retries", POOLCONFIG_MAXDESCLEN);
|
527
|
+
i++;
|
528
|
+
|
529
|
+
strncpy(status[i].name, "health_check_retry_delay", POOLCONFIG_MAXNAMELEN);
|
530
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->health_check_retry_delay);
|
531
|
+
strncpy(status[i].desc, "health check retry delay", POOLCONFIG_MAXDESCLEN);
|
532
|
+
i++;
|
533
|
+
|
534
|
+
/* FAILOVER AND FAILBACK */
|
535
|
+
|
536
|
+
strncpy(status[i].name, "failover_command", POOLCONFIG_MAXNAMELEN);
|
537
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->failover_command);
|
538
|
+
strncpy(status[i].desc, "failover command", POOLCONFIG_MAXDESCLEN);
|
539
|
+
i++;
|
540
|
+
|
541
|
+
strncpy(status[i].name, "failback_command", POOLCONFIG_MAXNAMELEN);
|
542
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->failback_command);
|
543
|
+
strncpy(status[i].desc, "failback command", POOLCONFIG_MAXDESCLEN);
|
544
|
+
i++;
|
545
|
+
|
546
|
+
strncpy(status[i].name, "fail_over_on_backend_error", POOLCONFIG_MAXNAMELEN);
|
547
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->fail_over_on_backend_error);
|
548
|
+
strncpy(status[i].desc, "fail over on backend error", POOLCONFIG_MAXDESCLEN);
|
549
|
+
i++;
|
550
|
+
|
551
|
+
/* ONLINE RECOVERY */
|
552
|
+
|
553
|
+
strncpy(status[i].name, "recovery_user", POOLCONFIG_MAXNAMELEN);
|
554
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->recovery_user);
|
555
|
+
strncpy(status[i].desc, "online recovery user", POOLCONFIG_MAXDESCLEN);
|
556
|
+
i++;
|
557
|
+
|
558
|
+
strncpy(status[i].name, "recovery_1st_stage_command", POOLCONFIG_MAXNAMELEN);
|
559
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->recovery_1st_stage_command);
|
560
|
+
strncpy(status[i].desc, "execute a command in first stage.", POOLCONFIG_MAXDESCLEN);
|
561
|
+
i++;
|
562
|
+
|
563
|
+
strncpy(status[i].name, "recovery_2nd_stage_command", POOLCONFIG_MAXNAMELEN);
|
564
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->recovery_2nd_stage_command);
|
565
|
+
strncpy(status[i].desc, "execute a command in second stage.", POOLCONFIG_MAXDESCLEN);
|
566
|
+
i++;
|
567
|
+
|
568
|
+
strncpy(status[i].name, "recovery_timeout", POOLCONFIG_MAXNAMELEN);
|
569
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->recovery_timeout);
|
570
|
+
strncpy(status[i].desc, "max time in seconds to wait for the recovering node's postmaster", POOLCONFIG_MAXDESCLEN);
|
571
|
+
i++;
|
572
|
+
|
573
|
+
strncpy(status[i].name, "search_primary_node_timeout", POOLCONFIG_MAXNAMELEN);
|
574
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->search_primary_node_timeout);
|
575
|
+
strncpy(status[i].desc, "max time in seconds to search for primary node after failover", POOLCONFIG_MAXDESCLEN);
|
576
|
+
i++;
|
577
|
+
|
578
|
+
strncpy(status[i].name, "client_idle_limit_in_recovery", POOLCONFIG_MAXNAMELEN);
|
579
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->client_idle_limit_in_recovery);
|
580
|
+
strncpy(status[i].desc, "if idle for this seconds, child connection closes in recovery 2nd statge", POOLCONFIG_MAXDESCLEN);
|
581
|
+
i++;
|
582
|
+
|
583
|
+
/* OTHERS */
|
584
|
+
|
585
|
+
strncpy(status[i].name, "relcache_expire", POOLCONFIG_MAXNAMELEN);
|
586
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%ld", pool_config->relcache_expire);
|
587
|
+
strncpy(status[i].desc, "relation cache expiration time in seconds", POOLCONFIG_MAXDESCLEN);
|
588
|
+
i++;
|
589
|
+
|
590
|
+
strncpy(status[i].name, "parallel_mode", POOLCONFIG_MAXNAMELEN);
|
591
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->parallel_mode);
|
592
|
+
strncpy(status[i].desc, "if non 0, run in parallel query mode", POOLCONFIG_MAXDESCLEN);
|
593
|
+
i++;
|
594
|
+
|
595
|
+
strncpy(status[i].name, "enable_query_cache", POOLCONFIG_MAXNAMELEN);
|
596
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->enable_query_cache);
|
597
|
+
strncpy(status[i].desc, "if non 0, use query cache", POOLCONFIG_MAXDESCLEN);
|
598
|
+
i++;
|
599
|
+
|
600
|
+
strncpy(status[i].name, "pgpool2_hostname", POOLCONFIG_MAXNAMELEN);
|
601
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->pgpool2_hostname);
|
602
|
+
strncpy(status[i].desc, "pgpool2 hostname", POOLCONFIG_MAXDESCLEN);
|
603
|
+
i++;
|
604
|
+
|
605
|
+
strncpy(status[i].name, "system_db_hostname", POOLCONFIG_MAXNAMELEN);
|
606
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->system_db_hostname);
|
607
|
+
strncpy(status[i].desc, "system DB hostname", POOLCONFIG_MAXDESCLEN);
|
608
|
+
i++;
|
609
|
+
|
610
|
+
strncpy(status[i].name, "system_db_port", POOLCONFIG_MAXNAMELEN);
|
611
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->system_db_port);
|
612
|
+
strncpy(status[i].desc, "system DB port number", POOLCONFIG_MAXDESCLEN);
|
613
|
+
i++;
|
614
|
+
|
615
|
+
strncpy(status[i].name, "system_db_dbname", POOLCONFIG_MAXNAMELEN);
|
616
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->system_db_dbname);
|
617
|
+
strncpy(status[i].desc, "system DB name", POOLCONFIG_MAXDESCLEN);
|
618
|
+
i++;
|
619
|
+
|
620
|
+
strncpy(status[i].name, "system_db_schema", POOLCONFIG_MAXNAMELEN);
|
621
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->system_db_schema);
|
622
|
+
strncpy(status[i].desc, "system DB schema name", POOLCONFIG_MAXDESCLEN);
|
623
|
+
i++;
|
624
|
+
|
625
|
+
strncpy(status[i].name, "system_db_user", POOLCONFIG_MAXNAMELEN);
|
626
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->system_db_user);
|
627
|
+
strncpy(status[i].desc, "user name to access system DB", POOLCONFIG_MAXDESCLEN);
|
628
|
+
i++;
|
629
|
+
|
630
|
+
/*
|
631
|
+
* add for watchdog
|
632
|
+
*/
|
633
|
+
strncpy(status[i].name, "use_watchdog", POOLCONFIG_MAXNAMELEN);
|
634
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->use_watchdog);
|
635
|
+
strncpy(status[i].desc, "non 0 if operating in use_watchdog", POOLCONFIG_MAXDESCLEN);
|
636
|
+
i++;
|
637
|
+
|
638
|
+
strncpy(status[i].name, "wd_lifecheck_method", POOLCONFIG_MAXNAMELEN);
|
639
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->wd_lifecheck_method);
|
640
|
+
strncpy(status[i].desc, "method of watchdog lifecheck", POOLCONFIG_MAXDESCLEN);
|
641
|
+
i++;
|
642
|
+
|
643
|
+
strncpy(status[i].name, "clear_memqcache_on_escalation", POOLCONFIG_MAXNAMELEN);
|
644
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->clear_memqcache_on_escalation);
|
645
|
+
strncpy(status[i].desc, "If true, clear all the query caches in shared memory when escalation occurs", POOLCONFIG_MAXDESCLEN);
|
646
|
+
i++;
|
647
|
+
|
648
|
+
strncpy(status[i].name, "wd_escalation_command", POOLCONFIG_MAXNAMELEN);
|
649
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->wd_escalation_command);
|
650
|
+
strncpy(status[i].desc, "command executed when escalation occurs", POOLCONFIG_MAXDESCLEN);
|
651
|
+
i++;
|
652
|
+
|
653
|
+
strncpy(status[i].name, "trusted_servers", POOLCONFIG_MAXNAMELEN);
|
654
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->trusted_servers);
|
655
|
+
strncpy(status[i].desc, "upper server list to observe connection", POOLCONFIG_MAXDESCLEN);
|
656
|
+
i++;
|
657
|
+
|
658
|
+
strncpy(status[i].name, "delegate_IP", POOLCONFIG_MAXNAMELEN);
|
659
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->delegate_IP);
|
660
|
+
strncpy(status[i].desc, "delegate IP address of master pgpool", POOLCONFIG_MAXDESCLEN);
|
661
|
+
i++;
|
662
|
+
|
663
|
+
strncpy(status[i].name, "wd_hostname", POOLCONFIG_MAXNAMELEN);
|
664
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->wd_hostname);
|
665
|
+
strncpy(status[i].desc, "Host name or IP address of this watchdog", POOLCONFIG_MAXDESCLEN);
|
666
|
+
i++;
|
667
|
+
|
668
|
+
strncpy(status[i].name, "wd_port", POOLCONFIG_MAXNAMELEN);
|
669
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->wd_port);
|
670
|
+
strncpy(status[i].desc, "watchdog port number", POOLCONFIG_MAXDESCLEN);
|
671
|
+
i++;
|
672
|
+
|
673
|
+
strncpy(status[i].name, "wd_interval", POOLCONFIG_MAXNAMELEN);
|
674
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->wd_interval);
|
675
|
+
strncpy(status[i].desc, "life check interval (second)", POOLCONFIG_MAXDESCLEN);
|
676
|
+
i++;
|
677
|
+
|
678
|
+
strncpy(status[i].name, "ping_path", POOLCONFIG_MAXNAMELEN);
|
679
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->ping_path);
|
680
|
+
strncpy(status[i].desc, "path to ping command", POOLCONFIG_MAXDESCLEN);
|
681
|
+
i++;
|
682
|
+
|
683
|
+
strncpy(status[i].name, "ifconfig_path", POOLCONFIG_MAXNAMELEN);
|
684
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->ifconfig_path);
|
685
|
+
strncpy(status[i].desc, "path to ifconfig command", POOLCONFIG_MAXDESCLEN);
|
686
|
+
i++;
|
687
|
+
|
688
|
+
strncpy(status[i].name, "if_up_cmd", POOLCONFIG_MAXNAMELEN);
|
689
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->if_up_cmd);
|
690
|
+
strncpy(status[i].desc, "virtual interface up command with full parameters", POOLCONFIG_MAXDESCLEN);
|
691
|
+
i++;
|
692
|
+
|
693
|
+
strncpy(status[i].name, "if_down_cmd", POOLCONFIG_MAXNAMELEN);
|
694
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->if_down_cmd);
|
695
|
+
strncpy(status[i].desc, "virtual interface down command with full parameters", POOLCONFIG_MAXDESCLEN);
|
696
|
+
i++;
|
697
|
+
|
698
|
+
strncpy(status[i].name, "arping_path", POOLCONFIG_MAXNAMELEN);
|
699
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->arping_path);
|
700
|
+
strncpy(status[i].desc, "path to arping command", POOLCONFIG_MAXDESCLEN);
|
701
|
+
i++;
|
702
|
+
|
703
|
+
strncpy(status[i].name, "arping_cmd", POOLCONFIG_MAXNAMELEN);
|
704
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->arping_cmd);
|
705
|
+
strncpy(status[i].desc, "send ARP REQUESTi to neighbour host", POOLCONFIG_MAXDESCLEN);
|
706
|
+
i++;
|
707
|
+
|
708
|
+
strncpy(status[i].name, "wd_heartbeat_port", POOLCONFIG_MAXNAMELEN);
|
709
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->wd_heartbeat_port);
|
710
|
+
strncpy(status[i].desc, "port number for receiving heartbeat signal", POOLCONFIG_MAXDESCLEN);
|
711
|
+
i++;
|
712
|
+
|
713
|
+
strncpy(status[i].name, "wd_heartbeat_keepalive", POOLCONFIG_MAXNAMELEN);
|
714
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->wd_heartbeat_keepalive);
|
715
|
+
strncpy(status[i].desc, "interval time of sending heartbeat siganl (sec)", POOLCONFIG_MAXDESCLEN);
|
716
|
+
i++;
|
717
|
+
|
718
|
+
strncpy(status[i].name, "wd_heartbeat_deadtime", POOLCONFIG_MAXNAMELEN);
|
719
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->wd_heartbeat_deadtime);
|
720
|
+
strncpy(status[i].desc, "deadtime interval for heartbeat siganl (sec)", POOLCONFIG_MAXDESCLEN);
|
721
|
+
i++;
|
722
|
+
|
723
|
+
strncpy(status[i].name, "wd_life_point", POOLCONFIG_MAXNAMELEN);
|
724
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->wd_life_point);
|
725
|
+
strncpy(status[i].desc, "retry times of life check", POOLCONFIG_MAXDESCLEN);
|
726
|
+
i++;
|
727
|
+
|
728
|
+
strncpy(status[i].name, "wd_lifecheck_query", POOLCONFIG_MAXNAMELEN);
|
729
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->wd_lifecheck_query);
|
730
|
+
strncpy(status[i].desc, "lifecheck query to pgpool from watchdog", POOLCONFIG_MAXDESCLEN);
|
731
|
+
i++;
|
732
|
+
|
733
|
+
strncpy(status[i].name, "wd_lifecheck_dbname", POOLCONFIG_MAXNAMELEN);
|
734
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->wd_lifecheck_dbname);
|
735
|
+
strncpy(status[i].desc, "database name connected for lifecheck", POOLCONFIG_MAXDESCLEN);
|
736
|
+
i++;
|
737
|
+
|
738
|
+
strncpy(status[i].name, "wd_lifecheck_user", POOLCONFIG_MAXNAMELEN);
|
739
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->wd_lifecheck_user);
|
740
|
+
strncpy(status[i].desc, "watchdog user monitoring pgpools in lifecheck", POOLCONFIG_MAXDESCLEN);
|
741
|
+
i++;
|
742
|
+
|
743
|
+
strncpy(status[i].name, "wd_lifecheck_password", POOLCONFIG_MAXNAMELEN);
|
744
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->wd_lifecheck_password);
|
745
|
+
strncpy(status[i].desc, "password for watchdog user in lifecheck", POOLCONFIG_MAXDESCLEN);
|
746
|
+
i++;
|
747
|
+
|
748
|
+
/*
|
749
|
+
* end of watchdog
|
750
|
+
*/
|
751
|
+
|
752
|
+
strncpy(status[i].name, "memory_cache_enabled", POOLCONFIG_MAXNAMELEN);
|
753
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->memory_cache_enabled);
|
754
|
+
strncpy(status[i].desc, "If true, use the memory cache functionality, false by default", POOLCONFIG_MAXDESCLEN);
|
755
|
+
i++;
|
756
|
+
|
757
|
+
strncpy(status[i].name, "memqcache_method", POOLCONFIG_MAXNAMELEN);
|
758
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->memqcache_method);
|
759
|
+
strncpy(status[i].desc, "Cache store method. either shmem(shared memory) or Memcached. shmem by default", POOLCONFIG_MAXDESCLEN);
|
760
|
+
i++;
|
761
|
+
|
762
|
+
strncpy(status[i].name, "memqcache_memcached_host", POOLCONFIG_MAXNAMELEN);
|
763
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->memqcache_memcached_host);
|
764
|
+
strncpy(status[i].desc, "Memcached host name. Mandatory if memqcache_method=memcached", POOLCONFIG_MAXDESCLEN);
|
765
|
+
i++;
|
766
|
+
|
767
|
+
strncpy(status[i].name, "memqcache_memcached_port", POOLCONFIG_MAXNAMELEN);
|
768
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->memqcache_memcached_port);
|
769
|
+
strncpy(status[i].desc, "Memcached port number. Mondatory if memqcache_method=memcached", POOLCONFIG_MAXDESCLEN);
|
770
|
+
i++;
|
771
|
+
|
772
|
+
strncpy(status[i].name, "memqcache_total_size", POOLCONFIG_MAXNAMELEN);
|
773
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->memqcache_total_size);
|
774
|
+
strncpy(status[i].desc, "Total memory size in bytes for storing memory cache. Mandatory if memqcache_method=shmem", POOLCONFIG_MAXDESCLEN);
|
775
|
+
i++;
|
776
|
+
|
777
|
+
strncpy(status[i].name, "memqcache_max_num_cache", POOLCONFIG_MAXNAMELEN);
|
778
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->memqcache_max_num_cache);
|
779
|
+
strncpy(status[i].desc, "Total number of cache entries", POOLCONFIG_MAXDESCLEN);
|
780
|
+
i++;
|
781
|
+
|
782
|
+
strncpy(status[i].name, "memqcache_expire", POOLCONFIG_MAXNAMELEN);
|
783
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->memqcache_expire);
|
784
|
+
strncpy(status[i].desc, "Memory cache entry life time specified in seconds. 60 by default", POOLCONFIG_MAXDESCLEN);
|
785
|
+
i++;
|
786
|
+
|
787
|
+
strncpy(status[i].name, "memqcache_auto_cache_invalidation", POOLCONFIG_MAXNAMELEN);
|
788
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->memqcache_auto_cache_invalidation);
|
789
|
+
strncpy(status[i].desc, "If true, invalidation of query cache is triggered by corresponding DDL/DML/DCL(and memqcache_expire). If false, it is only triggered by memqcache_expire. True by default.", POOLCONFIG_MAXDESCLEN);
|
790
|
+
i++;
|
791
|
+
|
792
|
+
strncpy(status[i].name, "memqcache_maxcache", POOLCONFIG_MAXNAMELEN);
|
793
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->memqcache_maxcache);
|
794
|
+
strncpy(status[i].desc, "Maximum SELECT result size in bytes", POOLCONFIG_MAXDESCLEN);
|
795
|
+
i++;
|
796
|
+
|
797
|
+
strncpy(status[i].name, "memqcache_cache_block_size", POOLCONFIG_MAXNAMELEN);
|
798
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", pool_config->memqcache_cache_block_size);
|
799
|
+
strncpy(status[i].desc, "Cache block size in bytes. 8192 by default", POOLCONFIG_MAXDESCLEN);
|
800
|
+
i++;
|
801
|
+
|
802
|
+
strncpy(status[i].name, "memqcache_cache_oiddir", POOLCONFIG_MAXNAMELEN);
|
803
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_config->memqcache_oiddir);
|
804
|
+
strncpy(status[i].desc, "Tempory work directory to record table oids", POOLCONFIG_MAXDESCLEN);
|
805
|
+
i++;
|
806
|
+
|
807
|
+
strncpy(status[i].name, "memqcache_stats_start_time", POOLCONFIG_MAXNAMELEN);
|
808
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", ctime(&pool_get_memqcache_stats()->start_time));
|
809
|
+
strncpy(status[i].desc, "Start time of query cache stats", POOLCONFIG_MAXDESCLEN);
|
810
|
+
i++;
|
811
|
+
|
812
|
+
strncpy(status[i].name, "memqcache_no_cache_hits", POOLCONFIG_MAXNAMELEN);
|
813
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%lld", pool_get_memqcache_stats()->num_selects);
|
814
|
+
strncpy(status[i].desc, "Number of SELECTs not hitting query cache", POOLCONFIG_MAXDESCLEN);
|
815
|
+
i++;
|
816
|
+
|
817
|
+
strncpy(status[i].name, "memqcache_cache_hits", POOLCONFIG_MAXNAMELEN);
|
818
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%lld", pool_get_memqcache_stats()->num_cache_hits);
|
819
|
+
strncpy(status[i].desc, "Number of SELECTs hitting query cache", POOLCONFIG_MAXDESCLEN);
|
820
|
+
i++;
|
821
|
+
|
822
|
+
strncpy(status[i].name, "white_memqcache_table_list", POOLCONFIG_MAXNAMELEN);
|
823
|
+
*(status[i].value) = '\0';
|
824
|
+
for (j=0;j<pool_config->num_white_memqcache_table_list;j++)
|
825
|
+
{
|
826
|
+
len = POOLCONFIG_MAXVALLEN - strlen(status[i].value);
|
827
|
+
strncat(status[i].value, pool_config->white_memqcache_table_list[j], len);
|
828
|
+
len = POOLCONFIG_MAXVALLEN - strlen(status[i].value);
|
829
|
+
if (j != pool_config->num_white_memqcache_table_list - 1)
|
830
|
+
strncat(status[i].value, ",", len);
|
831
|
+
}
|
832
|
+
strncpy(status[i].desc, "tables to memqcache", POOLCONFIG_MAXDESCLEN);
|
833
|
+
i++;
|
834
|
+
|
835
|
+
strncpy(status[i].name, "black_memqcache_table_list", POOLCONFIG_MAXNAMELEN);
|
836
|
+
*(status[i].value) = '\0';
|
837
|
+
for (j=0;j<pool_config->num_black_memqcache_table_list;j++)
|
838
|
+
{
|
839
|
+
len = POOLCONFIG_MAXVALLEN - strlen(status[i].value);
|
840
|
+
strncat(status[i].value, pool_config->black_memqcache_table_list[j], len);
|
841
|
+
len = POOLCONFIG_MAXVALLEN - strlen(status[i].value);
|
842
|
+
if (j != pool_config->num_black_memqcache_table_list - 1)
|
843
|
+
strncat(status[i].value, ",", len);
|
844
|
+
}
|
845
|
+
strncpy(status[i].desc, "tables not to memqcache", POOLCONFIG_MAXDESCLEN);
|
846
|
+
i++;
|
847
|
+
|
848
|
+
/* BACKENDS */
|
849
|
+
|
850
|
+
for (j = 0; j < NUM_BACKENDS; j++)
|
851
|
+
{
|
852
|
+
if (BACKEND_INFO(j).backend_port == 0)
|
853
|
+
continue;
|
854
|
+
|
855
|
+
snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "backend_hostname%d", j);
|
856
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", BACKEND_INFO(j).backend_hostname);
|
857
|
+
snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "backend #%d hostname", j);
|
858
|
+
i++;
|
859
|
+
|
860
|
+
snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "backend_port%d", j);
|
861
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", BACKEND_INFO(j).backend_port);
|
862
|
+
snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "backend #%d port number", j);
|
863
|
+
i++;
|
864
|
+
|
865
|
+
snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "backend_weight%d", j);
|
866
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%f", BACKEND_INFO(j).backend_weight/RAND_MAX);
|
867
|
+
snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "weight of backend #%d", j);
|
868
|
+
i++;
|
869
|
+
|
870
|
+
snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "backend_data_directory%d", j);
|
871
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", BACKEND_INFO(j).backend_data_directory);
|
872
|
+
snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "data directory for backend #%d", j);
|
873
|
+
i++;
|
874
|
+
|
875
|
+
snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "backend_status%d", j);
|
876
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", BACKEND_INFO(j).backend_status);
|
877
|
+
snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "status of backend #%d", j);
|
878
|
+
i++;
|
879
|
+
|
880
|
+
snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "standby_delay%d", j);
|
881
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%lld", BACKEND_INFO(j).standby_delay);
|
882
|
+
snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "standby delay of backend #%d", j);
|
883
|
+
i++;
|
884
|
+
|
885
|
+
snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "backend_flag%d", j);
|
886
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", pool_flag_to_str(BACKEND_INFO(j).flag));
|
887
|
+
snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "backend #%d flag", j);
|
888
|
+
i++;
|
889
|
+
}
|
890
|
+
|
891
|
+
for (j = 0; j < MAX_WATCHDOG_NUM; j++)
|
892
|
+
{
|
893
|
+
if (WD_INFO(j).pgpool_port == 0)
|
894
|
+
continue;
|
895
|
+
|
896
|
+
snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "other_pgpool_hostname%d", j);
|
897
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", WD_INFO(j).hostname);
|
898
|
+
snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "pgpool #%d hostname", j);
|
899
|
+
i++;
|
900
|
+
|
901
|
+
snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "other_pgpool_port%d", j);
|
902
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", WD_INFO(j).pgpool_port);
|
903
|
+
snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "pgpool #%d port number", j);
|
904
|
+
i++;
|
905
|
+
|
906
|
+
snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "other_pgpool_wd_port%d", j);
|
907
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", WD_INFO(j).wd_port);
|
908
|
+
snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "pgpool #%d watchdog port number", j);
|
909
|
+
i++;
|
910
|
+
|
911
|
+
}
|
912
|
+
|
913
|
+
for (j =0; j < pool_config->num_hb_if; j++)
|
914
|
+
{
|
915
|
+
snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "heartbeat_device%d", j);
|
916
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", WD_HB_IF(j).if_name);
|
917
|
+
snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "name of NIC device #%d for sending hearbeat", j);
|
918
|
+
i++;
|
919
|
+
|
920
|
+
snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "heartbeat_destination%d", j);
|
921
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%s", WD_HB_IF(j).addr);
|
922
|
+
snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "destination host for sending heartbeat using NIC device %d", j);
|
923
|
+
i++;
|
924
|
+
|
925
|
+
snprintf(status[i].name, POOLCONFIG_MAXNAMELEN, "heartbeat_destination_port%d", j);
|
926
|
+
snprintf(status[i].value, POOLCONFIG_MAXVALLEN, "%d", WD_HB_IF(j).dest_port);
|
927
|
+
snprintf(status[i].desc, POOLCONFIG_MAXDESCLEN, "destination port for sending heartbeat using NIC device %d", j);
|
928
|
+
i++;
|
929
|
+
}
|
930
|
+
|
931
|
+
*nrows = i;
|
932
|
+
return status;
|
933
|
+
}
|
934
|
+
|
935
|
+
void config_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
|
936
|
+
{
|
937
|
+
static char *field_names[] = {"item", "value", "description"};
|
938
|
+
static unsigned char nullmap[2] = {0xff, 0xff};
|
939
|
+
static short num_fields = 3;
|
940
|
+
short s;
|
941
|
+
int nbytes = (num_fields + 7)/8;
|
942
|
+
int len;
|
943
|
+
int nrows;
|
944
|
+
int size;
|
945
|
+
int hsize;
|
946
|
+
int i;
|
947
|
+
|
948
|
+
POOL_REPORT_CONFIG *status = get_config(&nrows);
|
949
|
+
|
950
|
+
send_row_description(frontend, backend, num_fields, field_names);
|
951
|
+
|
952
|
+
if (MAJOR(backend) == PROTO_MAJOR_V2)
|
953
|
+
{
|
954
|
+
/* ascii row */
|
955
|
+
for (i=0;i<nrows;i++)
|
956
|
+
{
|
957
|
+
pool_write(frontend, "D", 1);
|
958
|
+
pool_write_and_flush(frontend, nullmap, nbytes);
|
959
|
+
|
960
|
+
size = strlen(status[i].name);
|
961
|
+
hsize = htonl(size+4);
|
962
|
+
pool_write(frontend, &hsize, sizeof(hsize));
|
963
|
+
pool_write(frontend, status[i].name, size);
|
964
|
+
|
965
|
+
size = strlen(status[i].value);
|
966
|
+
hsize = htonl(size+4);
|
967
|
+
pool_write(frontend, &hsize, sizeof(hsize));
|
968
|
+
pool_write(frontend, status[i].value, size);
|
969
|
+
|
970
|
+
size = strlen(status[i].desc);
|
971
|
+
hsize = htonl(size+4);
|
972
|
+
pool_write(frontend, &hsize, sizeof(hsize));
|
973
|
+
pool_write(frontend, status[i].desc, size);
|
974
|
+
}
|
975
|
+
}
|
976
|
+
else
|
977
|
+
{
|
978
|
+
/* data row */
|
979
|
+
for (i=0;i<nrows;i++)
|
980
|
+
{
|
981
|
+
pool_write(frontend, "D", 1);
|
982
|
+
len = 6; /* int32 + int16; */
|
983
|
+
len += 4 + strlen(status[i].name); /* int32 + data; */
|
984
|
+
len += 4 + strlen(status[i].value); /* int32 + data; */
|
985
|
+
len += 4 + strlen(status[i].desc); /* int32 + data; */
|
986
|
+
len = htonl(len);
|
987
|
+
pool_write(frontend, &len, sizeof(len));
|
988
|
+
s = htons(num_fields);
|
989
|
+
pool_write(frontend, &s, sizeof(s));
|
990
|
+
|
991
|
+
len = htonl(strlen(status[i].name));
|
992
|
+
pool_write(frontend, &len, sizeof(len));
|
993
|
+
pool_write(frontend, status[i].name, strlen(status[i].name));
|
994
|
+
|
995
|
+
len = htonl(strlen(status[i].value));
|
996
|
+
pool_write(frontend, &len, sizeof(len));
|
997
|
+
pool_write(frontend, status[i].value, strlen(status[i].value));
|
998
|
+
|
999
|
+
len = htonl(strlen(status[i].desc));
|
1000
|
+
pool_write(frontend, &len, sizeof(len));
|
1001
|
+
pool_write(frontend, status[i].desc, strlen(status[i].desc));
|
1002
|
+
}
|
1003
|
+
}
|
1004
|
+
|
1005
|
+
send_complete_and_ready(frontend, backend, nrows);
|
1006
|
+
|
1007
|
+
free(status);
|
1008
|
+
}
|
1009
|
+
|
1010
|
+
POOL_REPORT_NODES* get_nodes(int *nrows)
|
1011
|
+
{
|
1012
|
+
int i;
|
1013
|
+
POOL_REPORT_NODES* nodes = malloc(NUM_BACKENDS * sizeof(POOL_REPORT_NODES));
|
1014
|
+
BackendInfo *bi = NULL;
|
1015
|
+
|
1016
|
+
for (i = 0; i < NUM_BACKENDS; i++)
|
1017
|
+
{
|
1018
|
+
bi = pool_get_node_info(i);
|
1019
|
+
|
1020
|
+
snprintf(nodes[i].node_id, POOLCONFIG_MAXSTATLEN, "%d", i);
|
1021
|
+
strncpy(nodes[i].hostname, bi->backend_hostname, strlen(bi->backend_hostname)+1);
|
1022
|
+
snprintf(nodes[i].port, POOLCONFIG_MAXIDENTLEN, "%d", bi->backend_port);
|
1023
|
+
snprintf(nodes[i].status, POOLCONFIG_MAXSTATLEN, "%d", bi->backend_status);
|
1024
|
+
snprintf(nodes[i].lb_weight, POOLCONFIG_MAXWEIGHTLEN, "%f", bi->backend_weight/RAND_MAX);
|
1025
|
+
|
1026
|
+
if (MASTER_SLAVE && !strcmp(pool_config->master_slave_sub_mode, MODE_STREAMREP))
|
1027
|
+
if (i == REAL_PRIMARY_NODE_ID)
|
1028
|
+
snprintf(nodes[i].role, POOLCONFIG_MAXWEIGHTLEN, "%s", "primary");
|
1029
|
+
else
|
1030
|
+
snprintf(nodes[i].role, POOLCONFIG_MAXWEIGHTLEN, "%s", "standby");
|
1031
|
+
else
|
1032
|
+
{
|
1033
|
+
if (i == REAL_MASTER_NODE_ID)
|
1034
|
+
snprintf(nodes[i].role, POOLCONFIG_MAXWEIGHTLEN, "%s", "master");
|
1035
|
+
else
|
1036
|
+
snprintf(nodes[i].role, POOLCONFIG_MAXWEIGHTLEN, "%s", "slave");
|
1037
|
+
}
|
1038
|
+
}
|
1039
|
+
|
1040
|
+
*nrows = i;
|
1041
|
+
|
1042
|
+
return nodes;
|
1043
|
+
}
|
1044
|
+
|
1045
|
+
void nodes_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
|
1046
|
+
{
|
1047
|
+
static char *field_names[] = {"node_id","hostname", "port", "status", "lb_weight", "role"};
|
1048
|
+
short num_fields = sizeof(field_names)/sizeof(char *);
|
1049
|
+
int i;
|
1050
|
+
short s;
|
1051
|
+
int len;
|
1052
|
+
int nrows;
|
1053
|
+
int size;
|
1054
|
+
int hsize;
|
1055
|
+
static unsigned char nullmap[2] = {0xff, 0xff};
|
1056
|
+
int nbytes = (num_fields + 7)/8;
|
1057
|
+
|
1058
|
+
POOL_REPORT_NODES* nodes = get_nodes(&nrows);
|
1059
|
+
|
1060
|
+
send_row_description(frontend, backend, num_fields, field_names);
|
1061
|
+
|
1062
|
+
if (MAJOR(backend) == PROTO_MAJOR_V2)
|
1063
|
+
{
|
1064
|
+
/* ascii row */
|
1065
|
+
for (i=0;i<nrows;i++)
|
1066
|
+
{
|
1067
|
+
pool_write(frontend, "D", 1);
|
1068
|
+
pool_write_and_flush(frontend, nullmap, nbytes);
|
1069
|
+
|
1070
|
+
size = strlen(nodes[i].node_id);
|
1071
|
+
hsize = htonl(size+4);
|
1072
|
+
pool_write(frontend, &hsize, sizeof(hsize));
|
1073
|
+
pool_write(frontend, nodes[i].node_id, size);
|
1074
|
+
|
1075
|
+
size = strlen(nodes[i].hostname);
|
1076
|
+
hsize = htonl(size+4);
|
1077
|
+
pool_write(frontend, &hsize, sizeof(hsize));
|
1078
|
+
pool_write(frontend, nodes[i].hostname, size);
|
1079
|
+
|
1080
|
+
size = strlen(nodes[i].port);
|
1081
|
+
hsize = htonl(size+4);
|
1082
|
+
pool_write(frontend, &hsize, sizeof(hsize));
|
1083
|
+
pool_write(frontend, nodes[i].port, size);
|
1084
|
+
|
1085
|
+
size = strlen(nodes[i].status);
|
1086
|
+
hsize = htonl(size+4);
|
1087
|
+
pool_write(frontend, &hsize, sizeof(hsize));
|
1088
|
+
pool_write(frontend, nodes[i].status, size);
|
1089
|
+
|
1090
|
+
size = strlen(nodes[i].lb_weight);
|
1091
|
+
hsize = htonl(size+4);
|
1092
|
+
pool_write(frontend, &hsize, sizeof(hsize));
|
1093
|
+
pool_write(frontend, nodes[i].lb_weight, size);
|
1094
|
+
|
1095
|
+
size = strlen(nodes[i].role);
|
1096
|
+
hsize = htonl(size+4);
|
1097
|
+
pool_write(frontend, &hsize, sizeof(hsize));
|
1098
|
+
pool_write(frontend, nodes[i].role, size);
|
1099
|
+
}
|
1100
|
+
}
|
1101
|
+
else
|
1102
|
+
{
|
1103
|
+
/* data row */
|
1104
|
+
for (i=0;i<nrows;i++)
|
1105
|
+
{
|
1106
|
+
pool_write(frontend, "D", 1);
|
1107
|
+
len = 6; /* int32 + int16; */
|
1108
|
+
len += 4 + strlen(nodes[i].node_id); /* int32 + data; */
|
1109
|
+
len += 4 + strlen(nodes[i].hostname); /* int32 + data; */
|
1110
|
+
len += 4 + strlen(nodes[i].port); /* int32 + data; */
|
1111
|
+
len += 4 + strlen(nodes[i].status); /* int32 + data; */
|
1112
|
+
len += 4 + strlen(nodes[i].lb_weight); /* int32 + data; */
|
1113
|
+
len += 4 + strlen(nodes[i].role); /* int32 + data; */
|
1114
|
+
len = htonl(len);
|
1115
|
+
pool_write(frontend, &len, sizeof(len));
|
1116
|
+
s = htons(num_fields);
|
1117
|
+
pool_write(frontend, &s, sizeof(s));
|
1118
|
+
|
1119
|
+
len = htonl(strlen(nodes[i].node_id));
|
1120
|
+
pool_write(frontend, &len, sizeof(len));
|
1121
|
+
pool_write(frontend, nodes[i].node_id, strlen(nodes[i].node_id));
|
1122
|
+
|
1123
|
+
len = htonl(strlen(nodes[i].hostname));
|
1124
|
+
pool_write(frontend, &len, sizeof(len));
|
1125
|
+
pool_write(frontend, nodes[i].hostname, strlen(nodes[i].hostname));
|
1126
|
+
|
1127
|
+
len = htonl(strlen(nodes[i].port));
|
1128
|
+
pool_write(frontend, &len, sizeof(len));
|
1129
|
+
pool_write(frontend, nodes[i].port, strlen(nodes[i].port));
|
1130
|
+
|
1131
|
+
len = htonl(strlen(nodes[i].status));
|
1132
|
+
pool_write(frontend, &len, sizeof(len));
|
1133
|
+
pool_write(frontend, nodes[i].status, strlen(nodes[i].status));
|
1134
|
+
|
1135
|
+
len = htonl(strlen(nodes[i].lb_weight));
|
1136
|
+
pool_write(frontend, &len, sizeof(len));
|
1137
|
+
pool_write(frontend, nodes[i].lb_weight, strlen(nodes[i].lb_weight));
|
1138
|
+
|
1139
|
+
len = htonl(strlen(nodes[i].role));
|
1140
|
+
pool_write(frontend, &len, sizeof(len));
|
1141
|
+
pool_write(frontend, nodes[i].role, strlen(nodes[i].role));
|
1142
|
+
}
|
1143
|
+
}
|
1144
|
+
|
1145
|
+
send_complete_and_ready(frontend, backend, nrows);
|
1146
|
+
|
1147
|
+
free(nodes);
|
1148
|
+
}
|
1149
|
+
|
1150
|
+
|
1151
|
+
POOL_REPORT_POOLS* get_pools(int *nrows)
|
1152
|
+
{
|
1153
|
+
int child, pool, poolBE, backend_id;
|
1154
|
+
|
1155
|
+
ProcessInfo *pi = NULL;
|
1156
|
+
int proc_id;
|
1157
|
+
|
1158
|
+
int lines = 0;
|
1159
|
+
|
1160
|
+
POOL_REPORT_POOLS* pools = malloc(
|
1161
|
+
pool_config->num_init_children * pool_config->max_pool * NUM_BACKENDS * sizeof(POOL_REPORT_POOLS)
|
1162
|
+
);
|
1163
|
+
|
1164
|
+
for (child = 0; child < pool_config->num_init_children; child++)
|
1165
|
+
{
|
1166
|
+
proc_id = process_info[child].pid;
|
1167
|
+
pi = pool_get_process_info(proc_id);
|
1168
|
+
|
1169
|
+
for (pool = 0; pool < pool_config->max_pool; pool++)
|
1170
|
+
{
|
1171
|
+
for (backend_id = 0; backend_id < NUM_BACKENDS; backend_id++)
|
1172
|
+
{
|
1173
|
+
poolBE = pool*MAX_NUM_BACKENDS+backend_id;
|
1174
|
+
pools[lines].pool_pid = proc_id;
|
1175
|
+
pools[lines].start_time = pi->start_time;
|
1176
|
+
pools[lines].pool_id = pool;
|
1177
|
+
pools[lines].backend_id = backend_id;
|
1178
|
+
if (strlen(pi->connection_info[poolBE].database) == 0)
|
1179
|
+
{
|
1180
|
+
strncpy(pools[lines].database, "", POOLCONFIG_MAXIDENTLEN);
|
1181
|
+
strncpy(pools[lines].username, "", POOLCONFIG_MAXIDENTLEN);
|
1182
|
+
pools[lines].create_time = 0;
|
1183
|
+
pools[lines].pool_majorversion = 0;
|
1184
|
+
pools[lines].pool_minorversion = 0;
|
1185
|
+
}
|
1186
|
+
else
|
1187
|
+
{
|
1188
|
+
strncpy(pools[lines].database, pi->connection_info[poolBE].database, POOLCONFIG_MAXIDENTLEN);
|
1189
|
+
strncpy(pools[lines].username, pi->connection_info[poolBE].user, POOLCONFIG_MAXIDENTLEN);
|
1190
|
+
pools[lines].create_time = pi->connection_info[poolBE].create_time;
|
1191
|
+
pools[lines].pool_majorversion = pi->connection_info[poolBE].major;
|
1192
|
+
pools[lines].pool_minorversion = pi->connection_info[poolBE].minor;
|
1193
|
+
}
|
1194
|
+
pools[lines].pool_counter = pi->connection_info[poolBE].counter;
|
1195
|
+
pools[lines].pool_backendpid = ntohl(pi->connection_info[poolBE].pid);
|
1196
|
+
pools[lines].pool_connected = pi->connection_info[poolBE].connected;
|
1197
|
+
lines++;
|
1198
|
+
}
|
1199
|
+
}
|
1200
|
+
}
|
1201
|
+
|
1202
|
+
*nrows = lines;
|
1203
|
+
return pools;
|
1204
|
+
}
|
1205
|
+
|
1206
|
+
void pools_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
|
1207
|
+
{
|
1208
|
+
static short num_fields = 12;
|
1209
|
+
static char *field_names[] = {"pool_pid", "start_time", "pool_id", "backend_id", "database", "username", "create_time",
|
1210
|
+
"majorversion", "minorversion", "pool_counter", "pool_backendpid", "pool_connected"};
|
1211
|
+
short s;
|
1212
|
+
int len;
|
1213
|
+
int i;
|
1214
|
+
static unsigned char nullmap[2] = {0xff, 0xff};
|
1215
|
+
int nbytes = (num_fields + 7)/8;
|
1216
|
+
int nrows;
|
1217
|
+
int size;
|
1218
|
+
int hsize;
|
1219
|
+
char proc_pid[16];
|
1220
|
+
char pool_id[16];
|
1221
|
+
char proc_start_time[20];
|
1222
|
+
char proc_create_time[20];
|
1223
|
+
char majorversion[5];
|
1224
|
+
char minorversion[5];
|
1225
|
+
char pool_counter[16];
|
1226
|
+
char backend_id[16];
|
1227
|
+
char backend_pid[16];
|
1228
|
+
char connected[2];
|
1229
|
+
|
1230
|
+
POOL_REPORT_POOLS *pools = get_pools(&nrows);
|
1231
|
+
|
1232
|
+
send_row_description(frontend, backend, num_fields, field_names);
|
1233
|
+
|
1234
|
+
if (MAJOR(backend) == PROTO_MAJOR_V2) hsize = 4;
|
1235
|
+
else hsize = 0;
|
1236
|
+
|
1237
|
+
/* ascii row */
|
1238
|
+
for (i=0;i<nrows;i++)
|
1239
|
+
{
|
1240
|
+
snprintf(proc_pid, sizeof(proc_pid), "%d", pools[i].pool_pid);
|
1241
|
+
snprintf(pool_id, sizeof(pool_id), "%d", pools[i].pool_id);
|
1242
|
+
if (pools[i].start_time)
|
1243
|
+
strftime(proc_start_time, sizeof(proc_start_time), "%Y-%m-%d %H:%M:%S", localtime(&pools[i].start_time));
|
1244
|
+
else
|
1245
|
+
*proc_start_time = '\0';
|
1246
|
+
if (pools[i].create_time)
|
1247
|
+
strftime(proc_create_time, sizeof(proc_create_time), "%Y-%m-%d %H:%M:%S", localtime(&pools[i].create_time));
|
1248
|
+
else
|
1249
|
+
*proc_create_time = '\0';
|
1250
|
+
snprintf(majorversion, sizeof(majorversion), "%d", pools[i].pool_majorversion);
|
1251
|
+
snprintf(minorversion, sizeof(minorversion), "%d", pools[i].pool_minorversion);
|
1252
|
+
snprintf(pool_counter, sizeof(pool_counter), "%d", pools[i].pool_counter);
|
1253
|
+
snprintf(backend_id, sizeof(backend_pid), "%d", pools[i].backend_id);
|
1254
|
+
snprintf(backend_pid, sizeof(backend_pid), "%d", pools[i].pool_backendpid);
|
1255
|
+
snprintf(connected, sizeof(connected), "%d", pools[i].pool_connected);
|
1256
|
+
|
1257
|
+
if (MAJOR(backend) == PROTO_MAJOR_V2)
|
1258
|
+
{
|
1259
|
+
pool_write(frontend, "D", 1);
|
1260
|
+
pool_write_and_flush(frontend, nullmap, nbytes);
|
1261
|
+
}
|
1262
|
+
else
|
1263
|
+
{
|
1264
|
+
pool_write(frontend, "D", 1);
|
1265
|
+
len = 6; /* int32 + int16; */
|
1266
|
+
len += 4 + strlen(proc_pid); /* int32 + data */
|
1267
|
+
len += 4 + strlen(proc_start_time); /* int32 + data */
|
1268
|
+
len += 4 + strlen(pool_id); /* int32 + data */
|
1269
|
+
len += 4 + strlen(backend_id); /* int32 + data */
|
1270
|
+
len += 4 + strlen(pools[i].database); /* int32 + data */
|
1271
|
+
len += 4 + strlen(pools[i].username); /* int32 + data */
|
1272
|
+
len += 4 + strlen(proc_create_time); /* int32 + data */
|
1273
|
+
len += 4 + strlen(majorversion); /* int32 + data */
|
1274
|
+
len += 4 + strlen(minorversion); /* int32 + data */
|
1275
|
+
len += 4 + strlen(pool_counter); /* int32 + data */
|
1276
|
+
len += 4 + strlen(backend_pid); /* int32 + data */
|
1277
|
+
len += 4 + strlen(connected); /* int32 + data */
|
1278
|
+
|
1279
|
+
len = htonl(len);
|
1280
|
+
pool_write(frontend, &len, sizeof(len));
|
1281
|
+
s = htons(num_fields);
|
1282
|
+
pool_write(frontend, &s, sizeof(s));
|
1283
|
+
}
|
1284
|
+
|
1285
|
+
len = strlen(proc_pid);
|
1286
|
+
size = htonl(len+hsize);
|
1287
|
+
pool_write(frontend, &size, sizeof(size));
|
1288
|
+
pool_write(frontend, proc_pid, len);
|
1289
|
+
|
1290
|
+
len = strlen(proc_start_time);
|
1291
|
+
size = htonl(len+hsize);
|
1292
|
+
pool_write(frontend, &size, sizeof(size));
|
1293
|
+
pool_write(frontend, proc_start_time, len);
|
1294
|
+
|
1295
|
+
len = strlen(pool_id);
|
1296
|
+
size = htonl(len+hsize);
|
1297
|
+
pool_write(frontend, &size, sizeof(size));
|
1298
|
+
pool_write(frontend, pool_id, len);
|
1299
|
+
|
1300
|
+
len = strlen(backend_id);
|
1301
|
+
size = htonl(len+hsize);
|
1302
|
+
pool_write(frontend, &size, sizeof(size));
|
1303
|
+
pool_write(frontend, backend_id, len);
|
1304
|
+
|
1305
|
+
len = strlen(pools[i].database);
|
1306
|
+
size = htonl(len+hsize);
|
1307
|
+
pool_write(frontend, &size, sizeof(size));
|
1308
|
+
pool_write(frontend, pools[i].database, len);
|
1309
|
+
|
1310
|
+
len = strlen(pools[i].username);
|
1311
|
+
size = htonl(len+hsize);
|
1312
|
+
pool_write(frontend, &size, sizeof(size));
|
1313
|
+
pool_write(frontend, pools[i].username, len);
|
1314
|
+
|
1315
|
+
len = strlen(proc_create_time);
|
1316
|
+
size = htonl(len+hsize);
|
1317
|
+
pool_write(frontend, &size, sizeof(size));
|
1318
|
+
pool_write(frontend, proc_create_time, len);
|
1319
|
+
|
1320
|
+
len = strlen(majorversion);
|
1321
|
+
size = htonl(len+hsize);
|
1322
|
+
pool_write(frontend, &size, sizeof(size));
|
1323
|
+
pool_write(frontend, majorversion, len);
|
1324
|
+
|
1325
|
+
len = strlen(minorversion);
|
1326
|
+
size = htonl(len+hsize);
|
1327
|
+
pool_write(frontend, &size, sizeof(size));
|
1328
|
+
pool_write(frontend, minorversion, len);
|
1329
|
+
|
1330
|
+
len = strlen(pool_counter);
|
1331
|
+
size = htonl(len+hsize);
|
1332
|
+
pool_write(frontend, &size, sizeof(size));
|
1333
|
+
pool_write(frontend, pool_counter, len);
|
1334
|
+
|
1335
|
+
len = strlen(backend_pid);
|
1336
|
+
size = htonl(len+hsize);
|
1337
|
+
pool_write(frontend, &size, sizeof(size));
|
1338
|
+
pool_write(frontend, backend_pid, len);
|
1339
|
+
|
1340
|
+
len = strlen(connected);
|
1341
|
+
size = htonl(len+hsize);
|
1342
|
+
pool_write(frontend, &size, sizeof(size));
|
1343
|
+
pool_write(frontend, connected, len);
|
1344
|
+
}
|
1345
|
+
|
1346
|
+
send_complete_and_ready(frontend, backend, nrows);
|
1347
|
+
|
1348
|
+
free(pools);
|
1349
|
+
}
|
1350
|
+
|
1351
|
+
POOL_REPORT_PROCESSES* get_processes(int *nrows)
|
1352
|
+
{
|
1353
|
+
int child;
|
1354
|
+
int pool;
|
1355
|
+
int poolBE;
|
1356
|
+
ProcessInfo *pi = NULL;
|
1357
|
+
int proc_id;
|
1358
|
+
|
1359
|
+
POOL_REPORT_PROCESSES* processes = malloc(pool_config->num_init_children * sizeof(POOL_REPORT_PROCESSES));
|
1360
|
+
|
1361
|
+
for (child = 0; child < pool_config->num_init_children; child++)
|
1362
|
+
{
|
1363
|
+
proc_id = process_info[child].pid;
|
1364
|
+
pi = pool_get_process_info(proc_id);
|
1365
|
+
|
1366
|
+
snprintf(processes[child].pool_pid, POOLCONFIG_MAXCOUNTLEN, "%d", proc_id);
|
1367
|
+
strftime(processes[child].start_time, POOLCONFIG_MAXDATELEN, "%Y-%m-%d %H:%M:%S", localtime(&pi->start_time));
|
1368
|
+
strncpy(processes[child].database, "", POOLCONFIG_MAXIDENTLEN);
|
1369
|
+
strncpy(processes[child].username, "", POOLCONFIG_MAXIDENTLEN);
|
1370
|
+
strncpy(processes[child].create_time, "", POOLCONFIG_MAXDATELEN);
|
1371
|
+
strncpy(processes[child].pool_counter, "", POOLCONFIG_MAXCOUNTLEN);
|
1372
|
+
|
1373
|
+
for (pool = 0; pool < pool_config->max_pool; pool++)
|
1374
|
+
{
|
1375
|
+
poolBE = pool*MAX_NUM_BACKENDS;
|
1376
|
+
if (pi->connection_info[poolBE].connected && strlen(pi->connection_info[poolBE].database) > 0 && strlen(pi->connection_info[poolBE].user) > 0)
|
1377
|
+
{
|
1378
|
+
strncpy(processes[child].database, pi->connection_info[poolBE].database, POOLCONFIG_MAXIDENTLEN);
|
1379
|
+
strncpy(processes[child].username, pi->connection_info[poolBE].user, POOLCONFIG_MAXIDENTLEN);
|
1380
|
+
strftime(processes[child].create_time, POOLCONFIG_MAXDATELEN, "%Y-%m-%d %H:%M:%S", localtime(&pi->connection_info[poolBE].create_time));
|
1381
|
+
snprintf(processes[child].pool_counter, POOLCONFIG_MAXCOUNTLEN, "%d", pi->connection_info[poolBE].counter);
|
1382
|
+
}
|
1383
|
+
}
|
1384
|
+
}
|
1385
|
+
|
1386
|
+
*nrows = child;
|
1387
|
+
|
1388
|
+
return processes;
|
1389
|
+
}
|
1390
|
+
|
1391
|
+
void processes_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
|
1392
|
+
{
|
1393
|
+
static short num_fields = 6;
|
1394
|
+
static char *field_names[] = {"pool_pid", "start_time", "database", "username", "create_time", "pool_counter"};
|
1395
|
+
short s;
|
1396
|
+
int len;
|
1397
|
+
int nrows;
|
1398
|
+
int size;
|
1399
|
+
int hsize;
|
1400
|
+
int i;
|
1401
|
+
static unsigned char nullmap[2] = {0xff, 0xff};
|
1402
|
+
int nbytes = (num_fields + 7)/8;
|
1403
|
+
|
1404
|
+
POOL_REPORT_PROCESSES *processes = get_processes(&nrows);
|
1405
|
+
|
1406
|
+
send_row_description(frontend, backend, num_fields, field_names);
|
1407
|
+
|
1408
|
+
if (MAJOR(backend) == PROTO_MAJOR_V2)
|
1409
|
+
{
|
1410
|
+
/* ascii row */
|
1411
|
+
for (i=0;i<nrows;i++)
|
1412
|
+
{
|
1413
|
+
pool_write(frontend, "D", 1);
|
1414
|
+
pool_write_and_flush(frontend, nullmap, nbytes);
|
1415
|
+
|
1416
|
+
size = strlen(processes[i].pool_pid);
|
1417
|
+
hsize = htonl(size+4);
|
1418
|
+
pool_write(frontend, &hsize, sizeof(hsize));
|
1419
|
+
pool_write(frontend, processes[i].pool_pid, size);
|
1420
|
+
|
1421
|
+
size = strlen(processes[i].start_time);
|
1422
|
+
hsize = htonl(size+4);
|
1423
|
+
pool_write(frontend, &hsize, sizeof(hsize));
|
1424
|
+
pool_write(frontend, processes[i].start_time, size);
|
1425
|
+
|
1426
|
+
size = strlen(processes[i].database);
|
1427
|
+
hsize = htonl(size+4);
|
1428
|
+
pool_write(frontend, &hsize, sizeof(hsize));
|
1429
|
+
pool_write(frontend, processes[i].database, size);
|
1430
|
+
|
1431
|
+
size = strlen(processes[i].username);
|
1432
|
+
hsize = htonl(size+4);
|
1433
|
+
pool_write(frontend, &hsize, sizeof(hsize));
|
1434
|
+
pool_write(frontend, processes[i].username, size);
|
1435
|
+
|
1436
|
+
size = strlen(processes[i].create_time);
|
1437
|
+
hsize = htonl(size+4);
|
1438
|
+
pool_write(frontend, &hsize, sizeof(hsize));
|
1439
|
+
pool_write(frontend, processes[i].create_time, size);
|
1440
|
+
|
1441
|
+
size = strlen(processes[i].pool_counter);
|
1442
|
+
hsize = htonl(size+4);
|
1443
|
+
pool_write(frontend, &hsize, sizeof(hsize));
|
1444
|
+
pool_write(frontend, processes[i].pool_counter, size);
|
1445
|
+
}
|
1446
|
+
}
|
1447
|
+
else
|
1448
|
+
{
|
1449
|
+
/* data row */
|
1450
|
+
for (i=0;i<nrows;i++)
|
1451
|
+
{
|
1452
|
+
pool_write(frontend, "D", 1);
|
1453
|
+
len = 6; /* int32 + int16; */
|
1454
|
+
len += 4 + strlen(processes[i].pool_pid); /* int32 + data */
|
1455
|
+
len += 4 + strlen(processes[i].start_time); /* int32 + data */
|
1456
|
+
len += 4 + strlen(processes[i].database); /* int32 + data */
|
1457
|
+
len += 4 + strlen(processes[i].username); /* int32 + data */
|
1458
|
+
len += 4 + strlen(processes[i].create_time); /* int32 + data */
|
1459
|
+
len += 4 + strlen(processes[i].pool_counter); /* int32 + data */
|
1460
|
+
len = htonl(len);
|
1461
|
+
pool_write(frontend, &len, sizeof(len));
|
1462
|
+
s = htons(num_fields);
|
1463
|
+
pool_write(frontend, &s, sizeof(s));
|
1464
|
+
|
1465
|
+
len = htonl(strlen(processes[i].pool_pid));
|
1466
|
+
pool_write(frontend, &len, sizeof(len));
|
1467
|
+
pool_write(frontend, processes[i].pool_pid, strlen(processes[i].pool_pid));
|
1468
|
+
|
1469
|
+
len = htonl(strlen(processes[i].start_time));
|
1470
|
+
pool_write(frontend, &len, sizeof(len));
|
1471
|
+
pool_write(frontend, processes[i].start_time, strlen(processes[i].start_time));
|
1472
|
+
|
1473
|
+
len = htonl(strlen(processes[i].database));
|
1474
|
+
pool_write(frontend, &len, sizeof(len));
|
1475
|
+
pool_write(frontend, processes[i].database, strlen(processes[i].database));
|
1476
|
+
|
1477
|
+
len = htonl(strlen(processes[i].username));
|
1478
|
+
pool_write(frontend, &len, sizeof(len));
|
1479
|
+
pool_write(frontend, processes[i].username, strlen(processes[i].username));
|
1480
|
+
|
1481
|
+
len = htonl(strlen(processes[i].create_time));
|
1482
|
+
pool_write(frontend, &len, sizeof(len));
|
1483
|
+
pool_write(frontend, processes[i].create_time, strlen(processes[i].create_time));
|
1484
|
+
|
1485
|
+
len = htonl(strlen(processes[i].pool_counter));
|
1486
|
+
pool_write(frontend, &len, sizeof(len));
|
1487
|
+
pool_write(frontend, processes[i].pool_counter, strlen(processes[i].pool_counter));
|
1488
|
+
}
|
1489
|
+
}
|
1490
|
+
|
1491
|
+
send_complete_and_ready(frontend, backend, nrows);
|
1492
|
+
|
1493
|
+
free(processes);
|
1494
|
+
}
|
1495
|
+
|
1496
|
+
POOL_REPORT_VERSION* get_version(void)
|
1497
|
+
{
|
1498
|
+
POOL_REPORT_VERSION *version = malloc(sizeof(POOL_REPORT_VERSION));
|
1499
|
+
|
1500
|
+
snprintf(version[0].version, POOLCONFIG_MAXVALLEN, "%s (%s)", VERSION, PGPOOLVERSION);
|
1501
|
+
|
1502
|
+
return version;
|
1503
|
+
}
|
1504
|
+
|
1505
|
+
void version_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
|
1506
|
+
{
|
1507
|
+
static short num_fields = 1;
|
1508
|
+
static char *field_names[] = {"pool_version"};
|
1509
|
+
short s;
|
1510
|
+
int len;
|
1511
|
+
int size;
|
1512
|
+
int hsize;
|
1513
|
+
|
1514
|
+
static unsigned char nullmap[2] = {0xff, 0xff};
|
1515
|
+
int nbytes = (num_fields + 7)/8;
|
1516
|
+
|
1517
|
+
POOL_REPORT_VERSION *version = get_version();
|
1518
|
+
|
1519
|
+
send_row_description(frontend, backend, num_fields, field_names);
|
1520
|
+
|
1521
|
+
if (MAJOR(backend) == PROTO_MAJOR_V2)
|
1522
|
+
{
|
1523
|
+
/* ascii row */
|
1524
|
+
pool_write(frontend, "D", 1);
|
1525
|
+
pool_write_and_flush(frontend, nullmap, nbytes);
|
1526
|
+
|
1527
|
+
size = strlen(version[0].version);
|
1528
|
+
hsize = htonl(size+4);
|
1529
|
+
pool_write(frontend, &hsize, sizeof(hsize));
|
1530
|
+
pool_write(frontend, version[0].version, size);
|
1531
|
+
}
|
1532
|
+
else
|
1533
|
+
{
|
1534
|
+
/* data row */
|
1535
|
+
pool_write(frontend, "D", 1);
|
1536
|
+
len = 6; /* int32 + int16; */
|
1537
|
+
len += 4 + strlen(version[0].version); /* int32 + data */
|
1538
|
+
len = htonl(len);
|
1539
|
+
pool_write(frontend, &len, sizeof(len));
|
1540
|
+
s = htons(num_fields);
|
1541
|
+
pool_write(frontend, &s, sizeof(s));
|
1542
|
+
|
1543
|
+
len = htonl(strlen(version[0].version));
|
1544
|
+
pool_write(frontend, &len, sizeof(len));
|
1545
|
+
pool_write(frontend, version[0].version, strlen(version[0].version));
|
1546
|
+
}
|
1547
|
+
|
1548
|
+
send_complete_and_ready(frontend, backend, 1);
|
1549
|
+
|
1550
|
+
free(version);
|
1551
|
+
}
|
1552
|
+
|
1553
|
+
/*
|
1554
|
+
* Show on memory cache reporting
|
1555
|
+
*/
|
1556
|
+
void cache_reporting(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
|
1557
|
+
{
|
1558
|
+
static char *field_names[] = {"num_cache_hits", "num_selects", "cache_hit_ratio", "num_hash_entries", "used_hash_entries", "num_cache_entries", "used_cache_entries_size", "free_cache_entries_size", "fragment_cache_entries_size"};
|
1559
|
+
short num_fields = sizeof(field_names)/sizeof(char *);
|
1560
|
+
int i;
|
1561
|
+
short s;
|
1562
|
+
int len;
|
1563
|
+
int size;
|
1564
|
+
int hsize;
|
1565
|
+
static unsigned char nullmap[2] = {0xff, 0xff};
|
1566
|
+
int nbytes = (num_fields + 7)/8;
|
1567
|
+
volatile POOL_SHMEM_STATS *mystats;
|
1568
|
+
#ifdef HAVE_SIGPROCMASK
|
1569
|
+
sigset_t oldmask;
|
1570
|
+
#else
|
1571
|
+
int oldmask;
|
1572
|
+
#endif
|
1573
|
+
double ratio;
|
1574
|
+
|
1575
|
+
#define POOL_CACHE_STATS_MAX_STRING_LEN 32
|
1576
|
+
typedef struct {
|
1577
|
+
int len; /* length of string excluding null terminate */
|
1578
|
+
char string[POOL_CACHE_STATS_MAX_STRING_LEN+1];
|
1579
|
+
} MY_STRING_CACHE_STATS;
|
1580
|
+
|
1581
|
+
MY_STRING_CACHE_STATS *strp;
|
1582
|
+
|
1583
|
+
strp = malloc(num_fields*sizeof(MY_STRING_CACHE_STATS));
|
1584
|
+
if (!strp)
|
1585
|
+
{
|
1586
|
+
pool_error("cache_reporting: malloc failed");
|
1587
|
+
return;
|
1588
|
+
}
|
1589
|
+
|
1590
|
+
/*
|
1591
|
+
* Get raw cache stat data
|
1592
|
+
*/
|
1593
|
+
POOL_SETMASK2(&BlockSig, &oldmask);
|
1594
|
+
pool_shmem_lock();
|
1595
|
+
mystats = pool_get_shmem_storage_stats();
|
1596
|
+
pool_shmem_unlock();
|
1597
|
+
POOL_SETMASK(&oldmask);
|
1598
|
+
|
1599
|
+
/*
|
1600
|
+
* Convert to string
|
1601
|
+
*/
|
1602
|
+
i = 0;
|
1603
|
+
snprintf(strp[i++].string, POOL_CACHE_STATS_MAX_STRING_LEN+1, "%lld", mystats->cache_stats.num_cache_hits);
|
1604
|
+
snprintf(strp[i++].string, POOL_CACHE_STATS_MAX_STRING_LEN+1, "%lld", mystats->cache_stats.num_selects);
|
1605
|
+
if ((mystats->cache_stats.num_cache_hits + mystats->cache_stats.num_selects) == 0)
|
1606
|
+
{
|
1607
|
+
ratio = 0.0;
|
1608
|
+
}
|
1609
|
+
else
|
1610
|
+
{
|
1611
|
+
ratio = (double)mystats->cache_stats.num_cache_hits/(mystats->cache_stats.num_selects + mystats->cache_stats.num_cache_hits);
|
1612
|
+
}
|
1613
|
+
snprintf(strp[i++].string, POOL_CACHE_STATS_MAX_STRING_LEN+1, "%.2f", ratio);
|
1614
|
+
snprintf(strp[i++].string, POOL_CACHE_STATS_MAX_STRING_LEN+1, "%d", mystats->num_hash_entries);
|
1615
|
+
snprintf(strp[i++].string, POOL_CACHE_STATS_MAX_STRING_LEN+1, "%d", mystats->used_hash_entries);
|
1616
|
+
snprintf(strp[i++].string, POOL_CACHE_STATS_MAX_STRING_LEN+1, "%d", mystats->num_cache_entries);
|
1617
|
+
snprintf(strp[i++].string, POOL_CACHE_STATS_MAX_STRING_LEN+1, "%ld", mystats->used_cache_entries_size);
|
1618
|
+
snprintf(strp[i++].string, POOL_CACHE_STATS_MAX_STRING_LEN+1, "%ld", mystats->free_cache_entries_size);
|
1619
|
+
snprintf(strp[i++].string, POOL_CACHE_STATS_MAX_STRING_LEN+1, "%ld", mystats->fragment_cache_entries_size);
|
1620
|
+
|
1621
|
+
/*
|
1622
|
+
* Calculate total data length
|
1623
|
+
*/
|
1624
|
+
len = 2; /* number of fields (int16) */
|
1625
|
+
for (i=0;i<num_fields;i++)
|
1626
|
+
{
|
1627
|
+
strp[i].len = strlen(strp[i].string);
|
1628
|
+
len += 4 /* length of string (int32) */
|
1629
|
+
+ strp[i].len;
|
1630
|
+
}
|
1631
|
+
|
1632
|
+
/* Send row description */
|
1633
|
+
send_row_description(frontend, backend, num_fields, field_names);
|
1634
|
+
|
1635
|
+
/* Send each field */
|
1636
|
+
if (MAJOR(backend) == PROTO_MAJOR_V2)
|
1637
|
+
{
|
1638
|
+
pool_write(frontend, "D", 1);
|
1639
|
+
pool_write(frontend, nullmap, nbytes);
|
1640
|
+
|
1641
|
+
for (i=0;i<num_fields;i++)
|
1642
|
+
{
|
1643
|
+
size = strp[i].len + 1;
|
1644
|
+
hsize = htonl(size+4);
|
1645
|
+
pool_write(frontend, &hsize, sizeof(hsize));
|
1646
|
+
pool_write(frontend, strp[i].string, size);
|
1647
|
+
}
|
1648
|
+
}
|
1649
|
+
else
|
1650
|
+
{
|
1651
|
+
/* Kind */
|
1652
|
+
pool_write(frontend, "D", 1);
|
1653
|
+
/* Packet length */
|
1654
|
+
len = htonl(len+sizeof(int32));
|
1655
|
+
pool_write(frontend, &len, sizeof(len));
|
1656
|
+
/* Number of fields */
|
1657
|
+
s = htons(num_fields);
|
1658
|
+
pool_write(frontend, &s, sizeof(s));
|
1659
|
+
|
1660
|
+
for (i=0;i<num_fields;i++)
|
1661
|
+
{
|
1662
|
+
hsize = htonl(strp[i].len);
|
1663
|
+
pool_write(frontend, &hsize, sizeof(hsize));
|
1664
|
+
pool_write(frontend, strp[i].string, strp[i].len);
|
1665
|
+
}
|
1666
|
+
}
|
1667
|
+
|
1668
|
+
send_complete_and_ready(frontend, backend, 1);
|
1669
|
+
|
1670
|
+
free(strp);
|
1671
|
+
}
|