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,172 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* $Header$
|
|
3
|
+
*
|
|
4
|
+
* pgpool: a language independent connection pool server for PostgreSQL
|
|
5
|
+
* written by Tatsuo Ishii
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2003-2008 PgPool Global Development Group
|
|
8
|
+
*
|
|
9
|
+
* Permission to use, copy, modify, and distribute this software and
|
|
10
|
+
* its documentation for any purpose and without fee is hereby
|
|
11
|
+
* granted, provided that the above copyright notice appear in all
|
|
12
|
+
* copies and that both that copyright notice and this permission
|
|
13
|
+
* notice appear in supporting documentation, and that the name of the
|
|
14
|
+
* author not be used in advertising or publicity pertaining to
|
|
15
|
+
* distribution of the software without specific, written prior
|
|
16
|
+
* permission. The author makes no representations about the
|
|
17
|
+
* suitability of this software for any purpose. It is provided "as
|
|
18
|
+
* is" without express or implied warranty.
|
|
19
|
+
*
|
|
20
|
+
* Client program to send "attach node" command.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
#include <stdio.h>
|
|
24
|
+
#include <stdlib.h>
|
|
25
|
+
#include <string.h>
|
|
26
|
+
#include <unistd.h>
|
|
27
|
+
#ifdef HAVE_GETOPT_H
|
|
28
|
+
#include <getopt.h>
|
|
29
|
+
#else
|
|
30
|
+
#include "getopt_long.h"
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
#include "pcp.h"
|
|
34
|
+
|
|
35
|
+
static void usage(void);
|
|
36
|
+
static void myexit(ErrorCode e);
|
|
37
|
+
|
|
38
|
+
int
|
|
39
|
+
main(int argc, char **argv)
|
|
40
|
+
{
|
|
41
|
+
long timeout;
|
|
42
|
+
char host[MAX_DB_HOST_NAMELEN];
|
|
43
|
+
int port;
|
|
44
|
+
char user[MAX_USER_PASSWD_LEN];
|
|
45
|
+
char pass[MAX_USER_PASSWD_LEN];
|
|
46
|
+
int nodeID;
|
|
47
|
+
int ch;
|
|
48
|
+
int optindex;
|
|
49
|
+
|
|
50
|
+
static struct option long_options[] = {
|
|
51
|
+
{"debug", no_argument, NULL, 'd'},
|
|
52
|
+
{"help", no_argument, NULL, 'h'},
|
|
53
|
+
{NULL, 0, NULL, 0}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
while ((ch = getopt_long(argc, argv, "hd", long_options, &optindex)) != -1) {
|
|
57
|
+
switch (ch) {
|
|
58
|
+
case 'd':
|
|
59
|
+
pcp_enable_debug();
|
|
60
|
+
break;
|
|
61
|
+
|
|
62
|
+
case 'h':
|
|
63
|
+
case '?':
|
|
64
|
+
default:
|
|
65
|
+
usage();
|
|
66
|
+
exit(0);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
argc -= optind;
|
|
70
|
+
argv += optind;
|
|
71
|
+
|
|
72
|
+
if (argc != 6)
|
|
73
|
+
{
|
|
74
|
+
errorcode = INVALERR;
|
|
75
|
+
pcp_errorstr(errorcode);
|
|
76
|
+
myexit(errorcode);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
timeout = atol(argv[0]);
|
|
80
|
+
if (timeout < 0) {
|
|
81
|
+
errorcode = INVALERR;
|
|
82
|
+
pcp_errorstr(errorcode);
|
|
83
|
+
myexit(errorcode);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
|
|
87
|
+
{
|
|
88
|
+
errorcode = INVALERR;
|
|
89
|
+
pcp_errorstr(errorcode);
|
|
90
|
+
myexit(errorcode);
|
|
91
|
+
}
|
|
92
|
+
strcpy(host, argv[1]);
|
|
93
|
+
|
|
94
|
+
port = atoi(argv[2]);
|
|
95
|
+
if (port <= 1024 || port > 65535)
|
|
96
|
+
{
|
|
97
|
+
errorcode = INVALERR;
|
|
98
|
+
pcp_errorstr(errorcode);
|
|
99
|
+
myexit(errorcode);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
|
|
103
|
+
{
|
|
104
|
+
errorcode = INVALERR;
|
|
105
|
+
pcp_errorstr(errorcode);
|
|
106
|
+
myexit(errorcode);
|
|
107
|
+
}
|
|
108
|
+
strcpy(user, argv[3]);
|
|
109
|
+
|
|
110
|
+
if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
|
|
111
|
+
{
|
|
112
|
+
errorcode = INVALERR;
|
|
113
|
+
pcp_errorstr(errorcode);
|
|
114
|
+
myexit(errorcode);
|
|
115
|
+
}
|
|
116
|
+
strcpy(pass, argv[4]);
|
|
117
|
+
|
|
118
|
+
nodeID = atoi(argv[5]);
|
|
119
|
+
if (nodeID < 0 || nodeID > MAX_NUM_BACKENDS)
|
|
120
|
+
{
|
|
121
|
+
errorcode = INVALERR;
|
|
122
|
+
pcp_errorstr(errorcode);
|
|
123
|
+
myexit(errorcode);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
pcp_set_timeout(timeout);
|
|
127
|
+
|
|
128
|
+
if (pcp_connect(host, port, user, pass))
|
|
129
|
+
{
|
|
130
|
+
pcp_errorstr(errorcode);
|
|
131
|
+
myexit(errorcode);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (pcp_recovery_node(nodeID))
|
|
135
|
+
{
|
|
136
|
+
pcp_errorstr(errorcode);
|
|
137
|
+
pcp_disconnect();
|
|
138
|
+
myexit(errorcode);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
pcp_disconnect();
|
|
142
|
+
|
|
143
|
+
return 0;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
static void
|
|
147
|
+
usage(void)
|
|
148
|
+
{
|
|
149
|
+
fprintf(stderr, "pcp_recovery_node - recovery a node\n\n");
|
|
150
|
+
fprintf(stderr, "Usage: pcp_recovery_node [-d] timeout hostname port# username password nodeID\n");
|
|
151
|
+
fprintf(stderr, "Usage: pcp_recovery_node -h\n\n");
|
|
152
|
+
fprintf(stderr, " -d, --debug : enable debug message (optional)\n");
|
|
153
|
+
fprintf(stderr, " timeout : connection timeout value in seconds. command exits on timeout\n");
|
|
154
|
+
fprintf(stderr, " hostname : pgpool-II hostname\n");
|
|
155
|
+
fprintf(stderr, " port# : PCP port number\n");
|
|
156
|
+
fprintf(stderr, " username : username for PCP authentication\n");
|
|
157
|
+
fprintf(stderr, " password : password for PCP authentication\n");
|
|
158
|
+
fprintf(stderr, " nodeID : ID of a node to recover\n");
|
|
159
|
+
fprintf(stderr, " -h, --help : print this help\n");
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
static void
|
|
163
|
+
myexit(ErrorCode e)
|
|
164
|
+
{
|
|
165
|
+
if (e == INVALERR)
|
|
166
|
+
{
|
|
167
|
+
usage();
|
|
168
|
+
exit(e);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
exit(e);
|
|
172
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* $Header$
|
|
3
|
+
*
|
|
4
|
+
* pgpool: a language independent connection pool server for PostgreSQL
|
|
5
|
+
* written by Tatsuo Ishii
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2003-2013 PgPool Global Development Group
|
|
8
|
+
*
|
|
9
|
+
* Permission to use, copy, modify, and distribute this software and
|
|
10
|
+
* its documentation for any purpose and without fee is hereby
|
|
11
|
+
* granted, provided that the above copyright notice appear in all
|
|
12
|
+
* copies and that both that copyright notice and this permission
|
|
13
|
+
* notice appear in supporting documentation, and that the name of the
|
|
14
|
+
* author not be used in advertising or publicity pertaining to
|
|
15
|
+
* distribution of the software without specific, written prior
|
|
16
|
+
* permission. The author makes no representations about the
|
|
17
|
+
* suitability of this software for any purpose. It is provided "as
|
|
18
|
+
* is" without express or implied warranty.
|
|
19
|
+
*
|
|
20
|
+
* Client program to send "stop pgpool" command.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
#include <stdio.h>
|
|
24
|
+
#include <stdlib.h>
|
|
25
|
+
#include <string.h>
|
|
26
|
+
#include <unistd.h>
|
|
27
|
+
#ifdef HAVE_GETOPT_H
|
|
28
|
+
#include <getopt.h>
|
|
29
|
+
#else
|
|
30
|
+
#include "getopt_long.h"
|
|
31
|
+
#endif
|
|
32
|
+
|
|
33
|
+
#include "pcp.h"
|
|
34
|
+
|
|
35
|
+
static void usage(void);
|
|
36
|
+
static void myexit(ErrorCode e);
|
|
37
|
+
|
|
38
|
+
int
|
|
39
|
+
main(int argc, char **argv)
|
|
40
|
+
{
|
|
41
|
+
long timeout;
|
|
42
|
+
char host[MAX_DB_HOST_NAMELEN];
|
|
43
|
+
int port;
|
|
44
|
+
char user[MAX_USER_PASSWD_LEN];
|
|
45
|
+
char pass[MAX_USER_PASSWD_LEN];
|
|
46
|
+
char mode;
|
|
47
|
+
int ch;
|
|
48
|
+
int optindex;
|
|
49
|
+
|
|
50
|
+
static struct option long_options[] = {
|
|
51
|
+
{"debug", no_argument, NULL, 'd'},
|
|
52
|
+
{"help", no_argument, NULL, 'h'},
|
|
53
|
+
{NULL, 0, NULL, 0}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
while ((ch = getopt_long(argc, argv, "hd", long_options, &optindex)) != -1) {
|
|
57
|
+
switch (ch) {
|
|
58
|
+
case 'd':
|
|
59
|
+
pcp_enable_debug();
|
|
60
|
+
break;
|
|
61
|
+
|
|
62
|
+
case 'h':
|
|
63
|
+
case '?':
|
|
64
|
+
default:
|
|
65
|
+
usage();
|
|
66
|
+
exit(0);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
argc -= optind;
|
|
70
|
+
argv += optind;
|
|
71
|
+
|
|
72
|
+
if (argc != 6)
|
|
73
|
+
{
|
|
74
|
+
errorcode = INVALERR;
|
|
75
|
+
pcp_errorstr(errorcode);
|
|
76
|
+
myexit(errorcode);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
timeout = atol(argv[0]);
|
|
80
|
+
if (timeout < 0) {
|
|
81
|
+
errorcode = INVALERR;
|
|
82
|
+
pcp_errorstr(errorcode);
|
|
83
|
+
myexit(errorcode);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (strlen(argv[1]) >= MAX_DB_HOST_NAMELEN)
|
|
87
|
+
{
|
|
88
|
+
errorcode = INVALERR;
|
|
89
|
+
pcp_errorstr(errorcode);
|
|
90
|
+
myexit(errorcode);
|
|
91
|
+
}
|
|
92
|
+
strcpy(host, argv[1]);
|
|
93
|
+
|
|
94
|
+
port = atoi(argv[2]);
|
|
95
|
+
if (port <= 1024 || port > 65535)
|
|
96
|
+
{
|
|
97
|
+
errorcode = INVALERR;
|
|
98
|
+
pcp_errorstr(errorcode);
|
|
99
|
+
myexit(errorcode);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (strlen(argv[3]) >= MAX_USER_PASSWD_LEN)
|
|
103
|
+
{
|
|
104
|
+
errorcode = INVALERR;
|
|
105
|
+
pcp_errorstr(errorcode);
|
|
106
|
+
myexit(errorcode);
|
|
107
|
+
}
|
|
108
|
+
strcpy(user, argv[3]);
|
|
109
|
+
|
|
110
|
+
if (strlen(argv[4]) >= MAX_USER_PASSWD_LEN)
|
|
111
|
+
{
|
|
112
|
+
errorcode = INVALERR;
|
|
113
|
+
pcp_errorstr(errorcode);
|
|
114
|
+
myexit(errorcode);
|
|
115
|
+
}
|
|
116
|
+
strcpy(pass, argv[4]);
|
|
117
|
+
|
|
118
|
+
if (strlen(argv[5]) != 1)
|
|
119
|
+
{
|
|
120
|
+
errorcode = INVALERR;
|
|
121
|
+
pcp_errorstr(errorcode);
|
|
122
|
+
myexit(errorcode);
|
|
123
|
+
}
|
|
124
|
+
mode = argv[5][0];
|
|
125
|
+
if (mode != 's' && mode != 'f' && mode != 'i')
|
|
126
|
+
{
|
|
127
|
+
errorcode = INVALERR;
|
|
128
|
+
pcp_errorstr(errorcode);
|
|
129
|
+
myexit(errorcode);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
pcp_set_timeout(timeout);
|
|
133
|
+
|
|
134
|
+
if (pcp_connect(host, port, user, pass))
|
|
135
|
+
{
|
|
136
|
+
pcp_errorstr(errorcode);
|
|
137
|
+
myexit(errorcode);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (pcp_terminate_pgpool(mode))
|
|
141
|
+
{
|
|
142
|
+
pcp_errorstr(errorcode);
|
|
143
|
+
pcp_disconnect();
|
|
144
|
+
myexit(errorcode);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
pcp_disconnect();
|
|
148
|
+
|
|
149
|
+
return 0;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
static void
|
|
153
|
+
usage(void)
|
|
154
|
+
{
|
|
155
|
+
fprintf(stderr, "pcp_stop_pgpool - terminate pgpool-II\n\n");
|
|
156
|
+
fprintf(stderr, "Usage: pcp_stop_pgpool [-d] timeout hostname port# username password mode\n");
|
|
157
|
+
fprintf(stderr, "Usage: pcp_stop_pgpool -h\n\n");
|
|
158
|
+
fprintf(stderr, " -d, --debug : enable debug message (optional)\n");
|
|
159
|
+
fprintf(stderr, " timeout : connection timeout value in seconds. command exits on timeout\n");
|
|
160
|
+
fprintf(stderr, " hostname : pgpool-II hostname\n");
|
|
161
|
+
fprintf(stderr, " port# : PCP port number\n");
|
|
162
|
+
fprintf(stderr, " username : username for PCP authentication\n");
|
|
163
|
+
fprintf(stderr, " password : password for PCP authentication\n");
|
|
164
|
+
fprintf(stderr, " mode : shutdown mode\n");
|
|
165
|
+
fprintf(stderr, " s - smart shutdown f - fast shutdown i - immediate shutdown\n");
|
|
166
|
+
fprintf(stderr, " -h, --help : print this help\n");
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
static void
|
|
170
|
+
myexit(ErrorCode e)
|
|
171
|
+
{
|
|
172
|
+
if (e == INVALERR)
|
|
173
|
+
{
|
|
174
|
+
usage();
|
|
175
|
+
exit(e);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
exit(e);
|
|
179
|
+
}
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* $Header$
|
|
3
|
+
*
|
|
4
|
+
* pgpool: a language independent connection pool server for PostgreSQL
|
|
5
|
+
* written by Tatsuo Ishii
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2003-2010 PgPool Global Development Group
|
|
8
|
+
*
|
|
9
|
+
* Permission to use, copy, modify, and distribute this software and
|
|
10
|
+
* its documentation for any purpose and without fee is hereby
|
|
11
|
+
* granted, provided that the above copyright notice appear in all
|
|
12
|
+
* copies and that both that copyright notice and this permission
|
|
13
|
+
* notice appear in supporting documentation, and that the name of the
|
|
14
|
+
* author not be used in advertising or publicity pertaining to
|
|
15
|
+
* distribution of the software without specific, written prior
|
|
16
|
+
* permission. The author makes no representations about the
|
|
17
|
+
* suitability of this software for any purpose. It is provided "as
|
|
18
|
+
* is" without express or implied warranty.
|
|
19
|
+
*
|
|
20
|
+
* PCP buffer management module.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
#include <stdlib.h>
|
|
24
|
+
#include <string.h>
|
|
25
|
+
#include <errno.h>
|
|
26
|
+
#include <unistd.h>
|
|
27
|
+
#include <time.h>
|
|
28
|
+
#include <sys/types.h>
|
|
29
|
+
#include <sys/time.h>
|
|
30
|
+
#include <unistd.h>
|
|
31
|
+
|
|
32
|
+
#include "pcp.h"
|
|
33
|
+
#include "pcp_stream.h"
|
|
34
|
+
|
|
35
|
+
static int consume_pending_data(PCP_CONNECTION *pc, void *data, int len);
|
|
36
|
+
static int save_pending_data(PCP_CONNECTION *pc, void *data, int len);
|
|
37
|
+
static int pcp_check_fd(PCP_CONNECTION *pc, int notimeout);
|
|
38
|
+
|
|
39
|
+
/* --------------------------------
|
|
40
|
+
* pcp_open - allocate read & write buffers for PCP_CONNECTION
|
|
41
|
+
*
|
|
42
|
+
* return newly allocated PCP_CONNECTION on success, NULL if malloc() fails
|
|
43
|
+
* --------------------------------
|
|
44
|
+
*/
|
|
45
|
+
PCP_CONNECTION *
|
|
46
|
+
pcp_open(int fd)
|
|
47
|
+
{
|
|
48
|
+
PCP_CONNECTION *pc;
|
|
49
|
+
|
|
50
|
+
pc = (PCP_CONNECTION *)malloc(sizeof(PCP_CONNECTION));
|
|
51
|
+
if (pc == NULL)
|
|
52
|
+
{
|
|
53
|
+
errorcode = NOMEMERR;
|
|
54
|
+
return NULL;
|
|
55
|
+
}
|
|
56
|
+
memset(pc, 0, sizeof(*pc));
|
|
57
|
+
|
|
58
|
+
/* initialize write buffer */
|
|
59
|
+
pc->wbuf = malloc(WRITEBUFSZ);
|
|
60
|
+
if (pc->wbuf == NULL)
|
|
61
|
+
return NULL;
|
|
62
|
+
pc->wbufsz = WRITEBUFSZ;
|
|
63
|
+
pc->wbufpo = 0;
|
|
64
|
+
|
|
65
|
+
/* initialize pending data buffer */
|
|
66
|
+
pc->hp = malloc(READBUFSZ);
|
|
67
|
+
if (pc->hp == NULL)
|
|
68
|
+
{
|
|
69
|
+
errorcode = NOMEMERR;
|
|
70
|
+
return NULL;
|
|
71
|
+
}
|
|
72
|
+
pc->bufsz = READBUFSZ;
|
|
73
|
+
pc->po = 0;
|
|
74
|
+
pc->len = 0;
|
|
75
|
+
|
|
76
|
+
pc->fd = fd;
|
|
77
|
+
|
|
78
|
+
return pc;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* --------------------------------
|
|
82
|
+
* pcp_close - deallocate read & write buffers for PCP_CONNECTION
|
|
83
|
+
* --------------------------------
|
|
84
|
+
*/
|
|
85
|
+
void
|
|
86
|
+
pcp_close(PCP_CONNECTION *pc)
|
|
87
|
+
{
|
|
88
|
+
close(pc->fd);
|
|
89
|
+
free(pc->wbuf);
|
|
90
|
+
free(pc->hp);
|
|
91
|
+
free(pc);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* --------------------------------
|
|
95
|
+
* pcp_read - read 'len' bytes from 'pc'
|
|
96
|
+
*
|
|
97
|
+
* return 0 on success, -1 otherwise
|
|
98
|
+
* --------------------------------
|
|
99
|
+
*/
|
|
100
|
+
int
|
|
101
|
+
pcp_read(PCP_CONNECTION *pc, void *buf, int len)
|
|
102
|
+
{
|
|
103
|
+
static char readbuf[READBUFSZ];
|
|
104
|
+
|
|
105
|
+
int consume_size;
|
|
106
|
+
int readlen;
|
|
107
|
+
int notimeout = 0;
|
|
108
|
+
|
|
109
|
+
consume_size = consume_pending_data(pc, buf, len);
|
|
110
|
+
len -= consume_size;
|
|
111
|
+
buf += consume_size;
|
|
112
|
+
|
|
113
|
+
while (len > 0)
|
|
114
|
+
{
|
|
115
|
+
if (pcp_check_fd(pc, notimeout))
|
|
116
|
+
{
|
|
117
|
+
errorcode = TIMEOUTERR;
|
|
118
|
+
return -1;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
readlen = read(pc->fd, readbuf, READBUFSZ);
|
|
122
|
+
if (readlen == -1)
|
|
123
|
+
{
|
|
124
|
+
if (errno == EAGAIN || errno == EINTR)
|
|
125
|
+
continue;
|
|
126
|
+
|
|
127
|
+
errorcode = READERR;
|
|
128
|
+
return -1;
|
|
129
|
+
}
|
|
130
|
+
else if (readlen == 0)
|
|
131
|
+
{
|
|
132
|
+
errorcode = EOFERR;
|
|
133
|
+
return -1;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (len < readlen)
|
|
137
|
+
{
|
|
138
|
+
/* overrun. we need to save remaining data to pending buffer */
|
|
139
|
+
if (save_pending_data(pc, readbuf+len, readlen-len))
|
|
140
|
+
{
|
|
141
|
+
errorcode = NOMEMERR;
|
|
142
|
+
return -1;
|
|
143
|
+
}
|
|
144
|
+
memmove(buf, readbuf, len);
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
memmove(buf, readbuf, readlen);
|
|
149
|
+
buf += readlen;
|
|
150
|
+
len -= readlen;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return 0;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/* --------------------------------
|
|
157
|
+
* pcp_write - write 'len' bytes to 'pc' buffer
|
|
158
|
+
*
|
|
159
|
+
* return 0 on success, -1 otherwise
|
|
160
|
+
* --------------------------------
|
|
161
|
+
*/
|
|
162
|
+
int
|
|
163
|
+
pcp_write(PCP_CONNECTION *pc, void *buf, int len)
|
|
164
|
+
{
|
|
165
|
+
int reqlen;
|
|
166
|
+
|
|
167
|
+
if (len < 0)
|
|
168
|
+
{
|
|
169
|
+
errorcode = INVALERR;
|
|
170
|
+
return -1;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/* check buffer size */
|
|
174
|
+
reqlen = pc->wbufpo + len;
|
|
175
|
+
|
|
176
|
+
if (reqlen > pc->wbufsz)
|
|
177
|
+
{
|
|
178
|
+
char *p;
|
|
179
|
+
|
|
180
|
+
reqlen = (reqlen/WRITEBUFSZ+1)*WRITEBUFSZ;
|
|
181
|
+
p = realloc(pc->wbuf, reqlen);
|
|
182
|
+
if (p == NULL)
|
|
183
|
+
{
|
|
184
|
+
errorcode = NOMEMERR;
|
|
185
|
+
return -1;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
pc->wbuf = p;
|
|
189
|
+
pc->wbufsz = reqlen;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
memcpy(pc->wbuf+pc->wbufpo, buf, len);
|
|
193
|
+
pc->wbufpo += len;
|
|
194
|
+
|
|
195
|
+
return 0;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/* --------------------------------
|
|
199
|
+
* pcp_flush - send pending data in buffer to 'pc'
|
|
200
|
+
*
|
|
201
|
+
* return 0 on success, -1 otherwise
|
|
202
|
+
* --------------------------------
|
|
203
|
+
*/
|
|
204
|
+
int
|
|
205
|
+
pcp_flush(PCP_CONNECTION *pc)
|
|
206
|
+
{
|
|
207
|
+
int sts;
|
|
208
|
+
int wlen;
|
|
209
|
+
int offset;
|
|
210
|
+
wlen = pc->wbufpo;
|
|
211
|
+
|
|
212
|
+
if (wlen == 0)
|
|
213
|
+
{
|
|
214
|
+
return 0;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
offset = 0;
|
|
218
|
+
|
|
219
|
+
for (;;)
|
|
220
|
+
{
|
|
221
|
+
errno = 0;
|
|
222
|
+
|
|
223
|
+
sts = write(pc->fd, pc->wbuf + offset, wlen);
|
|
224
|
+
|
|
225
|
+
if (sts > 0)
|
|
226
|
+
{
|
|
227
|
+
wlen -= sts;
|
|
228
|
+
|
|
229
|
+
if (wlen == 0)
|
|
230
|
+
{
|
|
231
|
+
/* write completed */
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
else if (wlen < 0)
|
|
236
|
+
{
|
|
237
|
+
errorcode = WRITEERR;
|
|
238
|
+
return -1;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
else
|
|
242
|
+
{
|
|
243
|
+
/* need to write remaining data */
|
|
244
|
+
offset += sts;
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
else if (errno == EAGAIN || errno == EINTR)
|
|
249
|
+
{
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
else
|
|
253
|
+
{
|
|
254
|
+
errorcode = WRITEERR;
|
|
255
|
+
return -1;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
pc->wbufpo = 0;
|
|
260
|
+
|
|
261
|
+
return 0;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/* --------------------------------
|
|
265
|
+
* consume_pending_data - read pending data from 'pc' buffer
|
|
266
|
+
*
|
|
267
|
+
* return the size of data read in
|
|
268
|
+
* --------------------------------
|
|
269
|
+
*/
|
|
270
|
+
static int
|
|
271
|
+
consume_pending_data(PCP_CONNECTION *pc, void *data, int len)
|
|
272
|
+
{
|
|
273
|
+
int consume_size;
|
|
274
|
+
|
|
275
|
+
if (pc->len <= 0)
|
|
276
|
+
return 0;
|
|
277
|
+
|
|
278
|
+
consume_size = Min(len, pc->len);
|
|
279
|
+
memmove(data, pc->hp + pc->po, consume_size);
|
|
280
|
+
pc->len -= consume_size;
|
|
281
|
+
|
|
282
|
+
if (pc->len <= 0)
|
|
283
|
+
pc->po = 0;
|
|
284
|
+
else
|
|
285
|
+
pc->po += consume_size;
|
|
286
|
+
|
|
287
|
+
return consume_size;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/* --------------------------------
|
|
291
|
+
* save_pending_data - save excessively read data into 'pc' buffer
|
|
292
|
+
*
|
|
293
|
+
* return 0 on success, -1 otherwise
|
|
294
|
+
* --------------------------------
|
|
295
|
+
*/
|
|
296
|
+
static int
|
|
297
|
+
save_pending_data(PCP_CONNECTION *pc, void *data, int len)
|
|
298
|
+
{
|
|
299
|
+
int reqlen;
|
|
300
|
+
size_t realloc_size;
|
|
301
|
+
char *p;
|
|
302
|
+
|
|
303
|
+
/* to be safe */
|
|
304
|
+
if (pc->len == 0)
|
|
305
|
+
pc->po = 0;
|
|
306
|
+
|
|
307
|
+
reqlen = pc->po + pc->len + len;
|
|
308
|
+
|
|
309
|
+
/* pending buffer is enough? */
|
|
310
|
+
if (reqlen > pc->bufsz)
|
|
311
|
+
{
|
|
312
|
+
/* too small, enlarge it */
|
|
313
|
+
realloc_size = (reqlen/READBUFSZ+1)*READBUFSZ;
|
|
314
|
+
p = realloc(pc->hp, realloc_size);
|
|
315
|
+
if (p == NULL)
|
|
316
|
+
{
|
|
317
|
+
errorcode = NOMEMERR;
|
|
318
|
+
return -1;
|
|
319
|
+
}
|
|
320
|
+
pc->bufsz = realloc_size;
|
|
321
|
+
pc->hp = p;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
memmove(pc->hp + pc->po + pc->len, data, len);
|
|
325
|
+
pc->len += len;
|
|
326
|
+
|
|
327
|
+
return 0;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/* --------------------------------
|
|
331
|
+
* pcp_check_fd - watch for fd which is ready to be read
|
|
332
|
+
*
|
|
333
|
+
* return 0 on success, -1 otherwise
|
|
334
|
+
* --------------------------------
|
|
335
|
+
*/
|
|
336
|
+
static int
|
|
337
|
+
pcp_check_fd(PCP_CONNECTION *pc, int notimeout)
|
|
338
|
+
{
|
|
339
|
+
fd_set readmask;
|
|
340
|
+
fd_set exceptmask;
|
|
341
|
+
int fd;
|
|
342
|
+
int fds;
|
|
343
|
+
struct timeval timeout;
|
|
344
|
+
struct timeval *tp;
|
|
345
|
+
|
|
346
|
+
fd = pc->fd;
|
|
347
|
+
|
|
348
|
+
for (;;)
|
|
349
|
+
{
|
|
350
|
+
FD_ZERO(&readmask);
|
|
351
|
+
FD_ZERO(&exceptmask);
|
|
352
|
+
FD_SET(fd, &readmask);
|
|
353
|
+
FD_SET(fd, &exceptmask);
|
|
354
|
+
|
|
355
|
+
if (notimeout || (pcp_timeout.tv_sec + pcp_timeout.tv_usec) == 0)
|
|
356
|
+
tp = NULL;
|
|
357
|
+
else
|
|
358
|
+
{
|
|
359
|
+
/***** haven't got timeout option yet. hard-code it *****/
|
|
360
|
+
timeout.tv_sec = pcp_timeout.tv_sec;
|
|
361
|
+
timeout.tv_usec = pcp_timeout.tv_usec;
|
|
362
|
+
tp = &timeout;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
fds = select(fd+1, &readmask, NULL, &exceptmask, tp);
|
|
366
|
+
|
|
367
|
+
if (fds == -1)
|
|
368
|
+
{
|
|
369
|
+
if (errno == EAGAIN || errno == EINTR)
|
|
370
|
+
continue;
|
|
371
|
+
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
if (FD_ISSET(fd, &exceptmask))
|
|
376
|
+
break;
|
|
377
|
+
|
|
378
|
+
if (fds == 0)
|
|
379
|
+
break;
|
|
380
|
+
|
|
381
|
+
return 0;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
return -1;
|
|
385
|
+
}
|