prestogres 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,38 @@
|
|
|
1
|
+
/* -*-pgsql-c-*- */
|
|
2
|
+
/*
|
|
3
|
+
*
|
|
4
|
+
* $Header$
|
|
5
|
+
*
|
|
6
|
+
* pgpool: a language independent connection pool server for PostgreSQL
|
|
7
|
+
* written by Tatsuo Ishii
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2003-2011 PgPool Global Development Group
|
|
10
|
+
*
|
|
11
|
+
* Permission to use, copy, modify, and distribute this software and
|
|
12
|
+
* its documentation for any purpose and without fee is hereby
|
|
13
|
+
* granted, provided that the above copyright notice appear in all
|
|
14
|
+
* copies and that both that copyright notice and this permission
|
|
15
|
+
* notice appear in supporting documentation, and that the name of the
|
|
16
|
+
* author not be used in advertising or publicity pertaining to
|
|
17
|
+
* distribution of the software without specific, written prior
|
|
18
|
+
* permission. The author makes no representations about the
|
|
19
|
+
* suitability of this software for any purpose. It is provided "as
|
|
20
|
+
* is" without express or implied warranty.
|
|
21
|
+
*
|
|
22
|
+
* pool_timestamp.h.: header file for pool_timestamp.c,
|
|
23
|
+
* pool_process_query.c, pool_proto_modules.c
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
#ifndef POOL_TIMESTAMP_H
|
|
28
|
+
#define POOL_TIMESTAMP_H
|
|
29
|
+
#include "pool.h"
|
|
30
|
+
#include "pool_proto_modules.h"
|
|
31
|
+
#include "parser/nodes.h"
|
|
32
|
+
#include "pool_session_context.h"
|
|
33
|
+
|
|
34
|
+
extern char *rewrite_timestamp(POOL_CONNECTION_POOL *backend, Node *node, bool rewrite_to_params, POOL_SENT_MESSAGE *message);
|
|
35
|
+
extern char *bind_rewrite_timestamp(POOL_CONNECTION_POOL *backend, POOL_SENT_MESSAGE *message, const char *orig_msg, int *len);
|
|
36
|
+
extern bool isSystemType(Node *node, const char *name);
|
|
37
|
+
|
|
38
|
+
#endif /* POOL_TIMESTAMP_H */
|
data/pgpool2/pool_type.h
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/* -*-pgsql-c-*- */
|
|
2
|
+
/*
|
|
3
|
+
*
|
|
4
|
+
* $Header$
|
|
5
|
+
*
|
|
6
|
+
* pgpool: a language independent connection pool server for PostgreSQL
|
|
7
|
+
* written by Tatsuo Ishii
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) 2003-2011 PgPool Global Development Group
|
|
10
|
+
*
|
|
11
|
+
* Permission to use, copy, modify, and distribute this software and
|
|
12
|
+
* its documentation for any purpose and without fee is hereby
|
|
13
|
+
* granted, provided that the above copyright notice appear in all
|
|
14
|
+
* copies and that both that copyright notice and this permission
|
|
15
|
+
* notice appear in supporting documentation, and that the name of the
|
|
16
|
+
* author not be used in advertising or publicity pertaining to
|
|
17
|
+
* distribution of the software without specific, written prior
|
|
18
|
+
* permission. The author makes no representations about the
|
|
19
|
+
* suitability of this software for any purpose. It is provided "as
|
|
20
|
+
* is" without express or implied warranty.
|
|
21
|
+
*
|
|
22
|
+
* pool_type.h.: type definition header file
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
#ifndef POOL_TYPE_H
|
|
27
|
+
#define POOL_TYPE_H
|
|
28
|
+
|
|
29
|
+
#include "config.h"
|
|
30
|
+
#include <sys/types.h>
|
|
31
|
+
#include <sys/socket.h>
|
|
32
|
+
#include "pcp/libpcp_ext.h"
|
|
33
|
+
|
|
34
|
+
/* Define common boolean type. C++ and BEOS already has it so exclude them. */
|
|
35
|
+
#ifdef c_plusplus
|
|
36
|
+
#ifndef __cplusplus
|
|
37
|
+
#define __cplusplus
|
|
38
|
+
#endif /* __cplusplus */
|
|
39
|
+
#endif /* c_plusplus */
|
|
40
|
+
|
|
41
|
+
#ifndef __BEOS__
|
|
42
|
+
#ifndef __cplusplus
|
|
43
|
+
#ifndef bool
|
|
44
|
+
typedef char bool;
|
|
45
|
+
#endif
|
|
46
|
+
#ifndef true
|
|
47
|
+
#define true ((bool) 1)
|
|
48
|
+
#endif
|
|
49
|
+
#ifndef TRUE
|
|
50
|
+
#define TRUE ((bool) 1)
|
|
51
|
+
#endif
|
|
52
|
+
#ifndef false
|
|
53
|
+
#define false ((bool) 0)
|
|
54
|
+
#endif
|
|
55
|
+
#ifndef FALSE
|
|
56
|
+
#define FALSE ((bool) 0)
|
|
57
|
+
#endif
|
|
58
|
+
#endif /* not C++ */
|
|
59
|
+
#endif /* __BEOS__ */
|
|
60
|
+
|
|
61
|
+
typedef signed char int8; /* == 8 bits */
|
|
62
|
+
typedef signed short int16; /* == 16 bits */
|
|
63
|
+
typedef signed int int32; /* == 32 bits */
|
|
64
|
+
|
|
65
|
+
/*
|
|
66
|
+
* uintN
|
|
67
|
+
* Unsigned integer, EXACTLY N BITS IN SIZE,
|
|
68
|
+
* used for numerical computations and the
|
|
69
|
+
* frontend/backend protocol.
|
|
70
|
+
*/
|
|
71
|
+
typedef unsigned char uint8; /* == 8 bits */
|
|
72
|
+
typedef unsigned short uint16; /* == 16 bits */
|
|
73
|
+
typedef unsigned int uint32; /* == 32 bits */
|
|
74
|
+
|
|
75
|
+
typedef long int int64;
|
|
76
|
+
|
|
77
|
+
typedef enum {
|
|
78
|
+
LOAD_UNSELECTED = 0,
|
|
79
|
+
LOAD_SELECTED
|
|
80
|
+
} LOAD_BALANCE_STATUS;
|
|
81
|
+
|
|
82
|
+
/*
|
|
83
|
+
* Backend status record file
|
|
84
|
+
*/
|
|
85
|
+
typedef struct {
|
|
86
|
+
BACKEND_STATUS status[MAX_NUM_BACKENDS];
|
|
87
|
+
} BackendStatusRecord;
|
|
88
|
+
|
|
89
|
+
/*
|
|
90
|
+
* It seems that sockaddr_storage is now commonly used in place of sockaddr.
|
|
91
|
+
* So, define it if it is not define yet, and create new SockAddr structure
|
|
92
|
+
* that uses sockaddr_storage.
|
|
93
|
+
*/
|
|
94
|
+
#ifdef HAVE_STRUCT_SOCKADDR_STORAGE
|
|
95
|
+
|
|
96
|
+
#ifndef HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY
|
|
97
|
+
#ifdef HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY
|
|
98
|
+
#define ss_family __ss_family
|
|
99
|
+
#else
|
|
100
|
+
#error struct sockaddr_storage does not provide an ss_family member
|
|
101
|
+
#endif /* HAVE_STRUCT_SOCKADDR_STORAGE___SS_FAMILY */
|
|
102
|
+
#endif /* HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY */
|
|
103
|
+
|
|
104
|
+
#ifdef HAVE_STRUCT_SOCKADDR_STORAGE___SS_LEN
|
|
105
|
+
#define ss_len __ss_len
|
|
106
|
+
#define HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN 1
|
|
107
|
+
#endif /* HAVE_STRUCT_SOCKADDR_STORAGE___SS_LEN */
|
|
108
|
+
|
|
109
|
+
#else /* !HAVE_STRUCT_SOCKADDR_STORAGE */
|
|
110
|
+
|
|
111
|
+
/* Define a struct sockaddr_storage if we don't have one. */
|
|
112
|
+
struct sockaddr_storage
|
|
113
|
+
{
|
|
114
|
+
union
|
|
115
|
+
{
|
|
116
|
+
struct sockaddr sa; /* get the system-dependent fields */
|
|
117
|
+
long int ss_align; /* ensures struct is properly aligned. original uses int64 */
|
|
118
|
+
char ss_pad[128]; /* ensures struct has desired size */
|
|
119
|
+
}
|
|
120
|
+
ss_stuff;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
#define ss_family ss_stuff.sa.sa_family
|
|
124
|
+
/* It should have an ss_len field if sockaddr has sa_len. */
|
|
125
|
+
#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
|
|
126
|
+
#define ss_len ss_stuff.sa.sa_len
|
|
127
|
+
#define HAVE_STRUCT_SOCKADDR_STORAGE_SS_LEN 1
|
|
128
|
+
#endif
|
|
129
|
+
#endif /* HAVE_STRUCT_SOCKADDR_STORAGE */
|
|
130
|
+
|
|
131
|
+
typedef struct
|
|
132
|
+
{
|
|
133
|
+
struct sockaddr_storage addr;
|
|
134
|
+
/* ACCEPT_TYPE_ARG3 - Third argument type of accept().
|
|
135
|
+
* It is defined in ac_func_accept_argtypes.m4
|
|
136
|
+
*/
|
|
137
|
+
ACCEPT_TYPE_ARG3 salen;
|
|
138
|
+
}
|
|
139
|
+
SockAddr;
|
|
140
|
+
|
|
141
|
+
/* UserAuth type used for HBA which indicates the authentication method */
|
|
142
|
+
typedef enum UserAuth
|
|
143
|
+
{
|
|
144
|
+
uaReject,
|
|
145
|
+
/* uaKrb4, */
|
|
146
|
+
/* uaKrb5, */
|
|
147
|
+
uaTrust,
|
|
148
|
+
/* uaIdent, */
|
|
149
|
+
/* uaPassword, */
|
|
150
|
+
/* uaCrypt, */
|
|
151
|
+
uaMD5
|
|
152
|
+
#ifdef USE_PAM
|
|
153
|
+
,uaPAM
|
|
154
|
+
#endif /* USE_PAM */
|
|
155
|
+
,uaPrestogresMD5
|
|
156
|
+
,uaPrestogresExternal
|
|
157
|
+
}
|
|
158
|
+
UserAuth;
|
|
159
|
+
|
|
160
|
+
#define AUTH_REQ_OK 0 /* User is authenticated */
|
|
161
|
+
#define AUTH_REQ_KRB4 1 /* Kerberos V4 */
|
|
162
|
+
#define AUTH_REQ_KRB5 2 /* Kerberos V5 */
|
|
163
|
+
#define AUTH_REQ_PASSWORD 3 /* Password */
|
|
164
|
+
#define AUTH_REQ_CRYPT 4 /* crypt password */
|
|
165
|
+
#define AUTH_REQ_MD5 5 /* md5 password */
|
|
166
|
+
#define AUTH_REQ_SCM_CREDS 6 /* transfer SCM credentials */
|
|
167
|
+
|
|
168
|
+
typedef unsigned int AuthRequest;
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
#endif /* POOL_TYPE_H */
|
|
@@ -0,0 +1,384 @@
|
|
|
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
|
+
* child.c: worker child process main
|
|
22
|
+
*
|
|
23
|
+
*/
|
|
24
|
+
#include "config.h"
|
|
25
|
+
|
|
26
|
+
#include <sys/types.h>
|
|
27
|
+
#include <sys/socket.h>
|
|
28
|
+
#include <netinet/in.h>
|
|
29
|
+
#include <sys/un.h>
|
|
30
|
+
#include <arpa/inet.h>
|
|
31
|
+
#include <netdb.h>
|
|
32
|
+
#ifdef HAVE_NETINET_TCP_H
|
|
33
|
+
#include <netinet/tcp.h>
|
|
34
|
+
#endif
|
|
35
|
+
#ifdef HAVE_SYS_SELECT_H
|
|
36
|
+
#include <sys/select.h>
|
|
37
|
+
#endif
|
|
38
|
+
|
|
39
|
+
#include <signal.h>
|
|
40
|
+
|
|
41
|
+
#include <stdio.h>
|
|
42
|
+
#include <errno.h>
|
|
43
|
+
#include <string.h>
|
|
44
|
+
#include <unistd.h>
|
|
45
|
+
#include <stdlib.h>
|
|
46
|
+
#include <sys/time.h>
|
|
47
|
+
|
|
48
|
+
#ifdef HAVE_CRYPT_H
|
|
49
|
+
#include <crypt.h>
|
|
50
|
+
#endif
|
|
51
|
+
|
|
52
|
+
#include "pool.h"
|
|
53
|
+
#include "pool_process_context.h"
|
|
54
|
+
#include "pool_session_context.h"
|
|
55
|
+
#include "pool_config.h"
|
|
56
|
+
#include "pool_ip.h"
|
|
57
|
+
#include "md5.h"
|
|
58
|
+
#include "pool_stream.h"
|
|
59
|
+
|
|
60
|
+
extern int myargc;
|
|
61
|
+
extern char **myargv;
|
|
62
|
+
|
|
63
|
+
char remote_ps_data[NI_MAXHOST]; /* used for set_ps_display */
|
|
64
|
+
static POOL_CONNECTION_POOL_SLOT *slots[MAX_NUM_BACKENDS];
|
|
65
|
+
static volatile sig_atomic_t reload_config_request = 0;
|
|
66
|
+
static volatile sig_atomic_t restart_request = 0;
|
|
67
|
+
|
|
68
|
+
static void establish_persistent_connection(void);
|
|
69
|
+
static void discard_persistent_connection(void);
|
|
70
|
+
static void check_replication_time_lag(void);
|
|
71
|
+
static long text_to_lsn(char *text);
|
|
72
|
+
static RETSIGTYPE my_signal_handler(int sig);
|
|
73
|
+
static RETSIGTYPE reload_config_handler(int sig);
|
|
74
|
+
static void reload_config(void);
|
|
75
|
+
|
|
76
|
+
#define CHECK_REQUEST \
|
|
77
|
+
do { \
|
|
78
|
+
if (reload_config_request) \
|
|
79
|
+
{ \
|
|
80
|
+
reload_config(); \
|
|
81
|
+
reload_config_request = 0; \
|
|
82
|
+
} else if (restart_request) \
|
|
83
|
+
{ \
|
|
84
|
+
pool_log("worker process received restart request"); \
|
|
85
|
+
exit(1); \
|
|
86
|
+
} \
|
|
87
|
+
} while (0)
|
|
88
|
+
|
|
89
|
+
/*
|
|
90
|
+
* worker child main loop
|
|
91
|
+
*/
|
|
92
|
+
void do_worker_child(void)
|
|
93
|
+
{
|
|
94
|
+
pool_debug("I am %d", getpid());
|
|
95
|
+
|
|
96
|
+
/* Identify myself via ps */
|
|
97
|
+
init_ps_display("", "", "", "");
|
|
98
|
+
set_ps_display("worker process", false);
|
|
99
|
+
|
|
100
|
+
/* set up signal handlers */
|
|
101
|
+
signal(SIGALRM, SIG_DFL);
|
|
102
|
+
signal(SIGTERM, my_signal_handler);
|
|
103
|
+
signal(SIGINT, my_signal_handler);
|
|
104
|
+
signal(SIGHUP, reload_config_handler);
|
|
105
|
+
signal(SIGQUIT, my_signal_handler);
|
|
106
|
+
signal(SIGCHLD, SIG_IGN);
|
|
107
|
+
signal(SIGUSR1, my_signal_handler);
|
|
108
|
+
signal(SIGUSR2, SIG_IGN);
|
|
109
|
+
signal(SIGPIPE, SIG_IGN);
|
|
110
|
+
|
|
111
|
+
/* Initialize my backend status */
|
|
112
|
+
pool_initialize_private_backend_status();
|
|
113
|
+
|
|
114
|
+
/* Initialize per process context */
|
|
115
|
+
pool_init_process_context();
|
|
116
|
+
|
|
117
|
+
for (;;)
|
|
118
|
+
{
|
|
119
|
+
CHECK_REQUEST;
|
|
120
|
+
|
|
121
|
+
if (pool_config->sr_check_period <= 0)
|
|
122
|
+
{
|
|
123
|
+
sleep(30);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/*
|
|
127
|
+
* If streaming replication mode, do time lag checking
|
|
128
|
+
*/
|
|
129
|
+
|
|
130
|
+
if (pool_config->sr_check_period > 0 && MASTER_SLAVE && !strcmp(pool_config->master_slave_sub_mode, MODE_STREAMREP))
|
|
131
|
+
{
|
|
132
|
+
/* Check and establish persistent connections to the backend */
|
|
133
|
+
establish_persistent_connection();
|
|
134
|
+
|
|
135
|
+
/* Do replication time lag checking */
|
|
136
|
+
check_replication_time_lag();
|
|
137
|
+
|
|
138
|
+
/* Discard persistent connections */
|
|
139
|
+
discard_persistent_connection();
|
|
140
|
+
}
|
|
141
|
+
sleep(pool_config->sr_check_period);
|
|
142
|
+
}
|
|
143
|
+
exit(0);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/*
|
|
147
|
+
* Establish persistent connection to backend
|
|
148
|
+
*/
|
|
149
|
+
static void establish_persistent_connection(void)
|
|
150
|
+
{
|
|
151
|
+
int i;
|
|
152
|
+
BackendInfo *bkinfo;
|
|
153
|
+
POOL_CONNECTION_POOL_SLOT *s;
|
|
154
|
+
|
|
155
|
+
for (i=0;i<NUM_BACKENDS;i++)
|
|
156
|
+
{
|
|
157
|
+
if (!VALID_BACKEND(i))
|
|
158
|
+
continue;
|
|
159
|
+
|
|
160
|
+
if (slots[i] == NULL)
|
|
161
|
+
{
|
|
162
|
+
bkinfo = pool_get_node_info(i);
|
|
163
|
+
s = make_persistent_db_connection(bkinfo->backend_hostname,
|
|
164
|
+
bkinfo->backend_port,
|
|
165
|
+
"postgres",
|
|
166
|
+
pool_config->sr_check_user,
|
|
167
|
+
pool_config->sr_check_password, true);
|
|
168
|
+
if (s)
|
|
169
|
+
slots[i] = s;
|
|
170
|
+
else
|
|
171
|
+
slots[i] = NULL;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/*
|
|
177
|
+
* Discard persistent connection to backend
|
|
178
|
+
*/
|
|
179
|
+
static void discard_persistent_connection(void)
|
|
180
|
+
{
|
|
181
|
+
int i;
|
|
182
|
+
|
|
183
|
+
for (i=0;i<NUM_BACKENDS;i++)
|
|
184
|
+
{
|
|
185
|
+
if (slots[i])
|
|
186
|
+
{
|
|
187
|
+
discard_persistent_db_connection(slots[i]);
|
|
188
|
+
slots[i] = NULL;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/*
|
|
194
|
+
* Check replication time lag
|
|
195
|
+
*/
|
|
196
|
+
static void check_replication_time_lag(void)
|
|
197
|
+
{
|
|
198
|
+
int i;
|
|
199
|
+
int active_nodes = 0;
|
|
200
|
+
POOL_STATUS sts;
|
|
201
|
+
POOL_SELECT_RESULT *res;
|
|
202
|
+
unsigned long long int lsn[MAX_NUM_BACKENDS];
|
|
203
|
+
char *query;
|
|
204
|
+
BackendInfo *bkinfo;
|
|
205
|
+
unsigned long long int lag;
|
|
206
|
+
|
|
207
|
+
if (NUM_BACKENDS <= 1)
|
|
208
|
+
{
|
|
209
|
+
/* If there's only one node, there's no point to do checking */
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/* Count healthy nodes */
|
|
214
|
+
for (i=0;i<NUM_BACKENDS;i++)
|
|
215
|
+
{
|
|
216
|
+
if (VALID_BACKEND(i))
|
|
217
|
+
active_nodes++;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (active_nodes <= 1)
|
|
221
|
+
{
|
|
222
|
+
/* If there's only one or less active node, there's no point
|
|
223
|
+
* to do checking */
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
for (i=0;i<NUM_BACKENDS;i++)
|
|
228
|
+
{
|
|
229
|
+
if (!VALID_BACKEND(i))
|
|
230
|
+
continue;
|
|
231
|
+
|
|
232
|
+
if (!slots[i])
|
|
233
|
+
{
|
|
234
|
+
pool_debug("check_replication_time_lag: DB node is valid but no persistent connection");
|
|
235
|
+
pool_error("check_replication_time_lag: could not connect to DB node %d, check sr_check_user and sr_check_password", i);
|
|
236
|
+
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (PRIMARY_NODE_ID == i)
|
|
241
|
+
{
|
|
242
|
+
query = "SELECT pg_current_xlog_location()";
|
|
243
|
+
}
|
|
244
|
+
else
|
|
245
|
+
{
|
|
246
|
+
query = "SELECT pg_last_xlog_replay_location()";
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
sts = do_query(slots[i]->con, query, &res, PROTO_MAJOR_V3);
|
|
250
|
+
if (sts != POOL_CONTINUE)
|
|
251
|
+
{
|
|
252
|
+
if (res)
|
|
253
|
+
free_select_result(res);
|
|
254
|
+
pool_error("check_replication_time_lag: %s failed", query);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
if (!res)
|
|
258
|
+
{
|
|
259
|
+
pool_error("check_replication_time_lag: %s result is null", query);
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
if (res->numrows <= 0)
|
|
263
|
+
{
|
|
264
|
+
pool_error("check_replication_time_lag: %s returns no rows", query);
|
|
265
|
+
free_select_result(res);
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
if (res->data[0] == NULL)
|
|
269
|
+
{
|
|
270
|
+
pool_error("check_replication_time_lag: %s returns no data", query);
|
|
271
|
+
free_select_result(res);
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (res->nullflags[0] == -1)
|
|
276
|
+
{
|
|
277
|
+
pool_log("check_replication_time_lag: %s returns NULL", query);
|
|
278
|
+
free_select_result(res);
|
|
279
|
+
lsn[i] = 0;
|
|
280
|
+
}
|
|
281
|
+
else
|
|
282
|
+
{
|
|
283
|
+
lsn[i] = text_to_lsn(res->data[0]);
|
|
284
|
+
free_select_result(res);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
for (i=0;i<NUM_BACKENDS;i++)
|
|
289
|
+
{
|
|
290
|
+
if (!VALID_BACKEND(i))
|
|
291
|
+
continue;
|
|
292
|
+
|
|
293
|
+
/* Set standby delay value */
|
|
294
|
+
bkinfo = pool_get_node_info(i);
|
|
295
|
+
lag = (lsn[PRIMARY_NODE_ID] > lsn[i]) ? lsn[PRIMARY_NODE_ID] - lsn[i] : 0;
|
|
296
|
+
|
|
297
|
+
if (PRIMARY_NODE_ID == i)
|
|
298
|
+
{
|
|
299
|
+
bkinfo->standby_delay = 0;
|
|
300
|
+
}
|
|
301
|
+
else
|
|
302
|
+
{
|
|
303
|
+
bkinfo->standby_delay = lag;
|
|
304
|
+
|
|
305
|
+
/* Log delay if necessary */
|
|
306
|
+
if ((!strcmp(pool_config->log_standby_delay, "always") && lag > 0) ||
|
|
307
|
+
(pool_config->delay_threshold &&
|
|
308
|
+
!strcmp(pool_config->log_standby_delay, "if_over_threshold") &&
|
|
309
|
+
lag > pool_config->delay_threshold))
|
|
310
|
+
{
|
|
311
|
+
pool_log("Replication of node:%d is behind %llu bytes from the primary server (node:%d)",
|
|
312
|
+
i, lsn[PRIMARY_NODE_ID] - lsn[i], PRIMARY_NODE_ID);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/*
|
|
319
|
+
* Convert logid/recoff style text to 64bit log location (LSN)
|
|
320
|
+
*/
|
|
321
|
+
static long text_to_lsn(char *text)
|
|
322
|
+
{
|
|
323
|
+
/*
|
|
324
|
+
* WAL segment size in bytes. XXX We should fetch this from
|
|
325
|
+
* PostgreSQL, rather than having fixed value.
|
|
326
|
+
*/
|
|
327
|
+
#define WALSEGMENTSIZE 16 * 1024 * 1024
|
|
328
|
+
|
|
329
|
+
unsigned int xlogid;
|
|
330
|
+
unsigned int xrecoff;
|
|
331
|
+
unsigned long long int lsn;
|
|
332
|
+
|
|
333
|
+
if (sscanf(text, "%X/%X", &xlogid, &xrecoff) != 2)
|
|
334
|
+
{
|
|
335
|
+
pool_error("text_to_lsn: wrong log location format: %s", text);
|
|
336
|
+
return 0;
|
|
337
|
+
}
|
|
338
|
+
lsn = xlogid * ((unsigned long long int)0xffffffff - WALSEGMENTSIZE) + xrecoff;
|
|
339
|
+
#ifdef DEBUG
|
|
340
|
+
pool_log("lsn: %X %X %llX", xlogid, xrecoff, lsn);
|
|
341
|
+
#endif
|
|
342
|
+
return lsn;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
static RETSIGTYPE my_signal_handler(int sig)
|
|
346
|
+
{
|
|
347
|
+
POOL_SETMASK(&BlockSig);
|
|
348
|
+
|
|
349
|
+
switch (sig)
|
|
350
|
+
{
|
|
351
|
+
case SIGTERM:
|
|
352
|
+
case SIGINT:
|
|
353
|
+
case SIGQUIT:
|
|
354
|
+
exit(0);
|
|
355
|
+
break;
|
|
356
|
+
|
|
357
|
+
/* Failback or new node added */
|
|
358
|
+
case SIGUSR1:
|
|
359
|
+
restart_request = 1;
|
|
360
|
+
break;
|
|
361
|
+
|
|
362
|
+
default:
|
|
363
|
+
exit(1);
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
POOL_SETMASK(&UnBlockSig);
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
static RETSIGTYPE reload_config_handler(int sig)
|
|
371
|
+
{
|
|
372
|
+
POOL_SETMASK(&BlockSig);
|
|
373
|
+
reload_config_request = 1;
|
|
374
|
+
POOL_SETMASK(&UnBlockSig);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
static void reload_config(void)
|
|
378
|
+
{
|
|
379
|
+
pool_log("reload config files.");
|
|
380
|
+
pool_get_config(get_config_file_name(), RELOAD_CONFIG);
|
|
381
|
+
if (pool_config->enable_pool_hba)
|
|
382
|
+
load_hba(get_hba_file_name());
|
|
383
|
+
reload_config_request = 0;
|
|
384
|
+
}
|