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,294 @@
|
|
1
|
+
/*-------------------------------------------------------------------------
|
2
|
+
*
|
3
|
+
* stringinfo.c
|
4
|
+
*
|
5
|
+
* StringInfo provides an indefinitely-extensible string data type.
|
6
|
+
* It can be used to buffer either ordinary C strings (null-terminated text)
|
7
|
+
* or arbitrary binary data. All storage is allocated with palloc().
|
8
|
+
*
|
9
|
+
* Portions Copyright (c) 2003-2013, PgPool Global Development Group
|
10
|
+
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
|
11
|
+
* Portions Copyright (c) 1994, Regents of the University of California
|
12
|
+
*
|
13
|
+
* src/backend/lib/stringinfo.c
|
14
|
+
*
|
15
|
+
*-------------------------------------------------------------------------
|
16
|
+
*/
|
17
|
+
#include <string.h>
|
18
|
+
#include <stdarg.h>
|
19
|
+
#include "pool_type.h"
|
20
|
+
#include "stringinfo.h"
|
21
|
+
#include "pool_memory.h"
|
22
|
+
|
23
|
+
/*
|
24
|
+
* makeStringInfo
|
25
|
+
*
|
26
|
+
* Create an empty 'StringInfoData' & return a pointer to it.
|
27
|
+
*/
|
28
|
+
StringInfo
|
29
|
+
makeStringInfo(void)
|
30
|
+
{
|
31
|
+
StringInfo res;
|
32
|
+
|
33
|
+
res = (StringInfo) palloc(sizeof(StringInfoData));
|
34
|
+
|
35
|
+
initStringInfo(res);
|
36
|
+
|
37
|
+
return res;
|
38
|
+
}
|
39
|
+
|
40
|
+
/*
|
41
|
+
* initStringInfo
|
42
|
+
*
|
43
|
+
* Initialize a StringInfoData struct (with previously undefined contents)
|
44
|
+
* to describe an empty string.
|
45
|
+
*/
|
46
|
+
void
|
47
|
+
initStringInfo(StringInfo str)
|
48
|
+
{
|
49
|
+
int size = 1024; /* initial default buffer size */
|
50
|
+
|
51
|
+
str->data = (char *) palloc(size);
|
52
|
+
str->maxlen = size;
|
53
|
+
resetStringInfo(str);
|
54
|
+
}
|
55
|
+
|
56
|
+
/*
|
57
|
+
* resetStringInfo
|
58
|
+
*
|
59
|
+
* Reset the StringInfo: the data buffer remains valid, but its
|
60
|
+
* previous content, if any, is cleared.
|
61
|
+
*/
|
62
|
+
void
|
63
|
+
resetStringInfo(StringInfo str)
|
64
|
+
{
|
65
|
+
str->data[0] = '\0';
|
66
|
+
str->len = 0;
|
67
|
+
str->cursor = 0;
|
68
|
+
}
|
69
|
+
|
70
|
+
/*
|
71
|
+
* appendStringInfo
|
72
|
+
*
|
73
|
+
* Format text data under the control of fmt (an sprintf-style format string)
|
74
|
+
* and append it to whatever is already in str. More space is allocated
|
75
|
+
* to str if necessary. This is sort of like a combination of sprintf and
|
76
|
+
* strcat.
|
77
|
+
*/
|
78
|
+
void
|
79
|
+
appendStringInfo(StringInfo str, const char *fmt,...)
|
80
|
+
{
|
81
|
+
for (;;)
|
82
|
+
{
|
83
|
+
va_list args;
|
84
|
+
bool success;
|
85
|
+
|
86
|
+
/* Try to format the data. */
|
87
|
+
va_start(args, fmt);
|
88
|
+
success = appendStringInfoVA(str, fmt, args);
|
89
|
+
va_end(args);
|
90
|
+
|
91
|
+
if (success)
|
92
|
+
break;
|
93
|
+
|
94
|
+
/* Double the buffer size and try again. */
|
95
|
+
enlargeStringInfo(str, str->maxlen);
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
/*
|
100
|
+
* appendStringInfoVA
|
101
|
+
*
|
102
|
+
* Attempt to format text data under the control of fmt (an sprintf-style
|
103
|
+
* format string) and append it to whatever is already in str. If successful
|
104
|
+
* return true; if not (because there's not enough space), return false
|
105
|
+
* without modifying str. Typically the caller would enlarge str and retry
|
106
|
+
* on false return --- see appendStringInfo for standard usage pattern.
|
107
|
+
*
|
108
|
+
* XXX This API is ugly, but there seems no alternative given the C spec's
|
109
|
+
* restrictions on what can portably be done with va_list arguments: you have
|
110
|
+
* to redo va_start before you can rescan the argument list, and we can't do
|
111
|
+
* that from here.
|
112
|
+
*/
|
113
|
+
bool
|
114
|
+
appendStringInfoVA(StringInfo str, const char *fmt, va_list args)
|
115
|
+
{
|
116
|
+
int avail,
|
117
|
+
nprinted;
|
118
|
+
|
119
|
+
/*
|
120
|
+
* If there's hardly any space, don't bother trying, just fail to make the
|
121
|
+
* caller enlarge the buffer first.
|
122
|
+
*/
|
123
|
+
avail = str->maxlen - str->len - 1;
|
124
|
+
if (avail < 16)
|
125
|
+
return false;
|
126
|
+
|
127
|
+
/*
|
128
|
+
* Assert check here is to catch buggy vsnprintf that overruns the
|
129
|
+
* specified buffer length. Solaris 7 in 64-bit mode is an example of a
|
130
|
+
* platform with such a bug.
|
131
|
+
*/
|
132
|
+
#ifdef USE_ASSERT_CHECKING
|
133
|
+
str->data[str->maxlen - 1] = '\0';
|
134
|
+
#endif
|
135
|
+
|
136
|
+
nprinted = vsnprintf(str->data + str->len, avail, fmt, args);
|
137
|
+
|
138
|
+
/*
|
139
|
+
* Note: some versions of vsnprintf return the number of chars actually
|
140
|
+
* stored, but at least one returns -1 on failure. Be conservative about
|
141
|
+
* believing whether the print worked.
|
142
|
+
*/
|
143
|
+
if (nprinted >= 0 && nprinted < avail - 1)
|
144
|
+
{
|
145
|
+
/* Success. Note nprinted does not include trailing null. */
|
146
|
+
str->len += nprinted;
|
147
|
+
return true;
|
148
|
+
}
|
149
|
+
|
150
|
+
/* Restore the trailing null so that str is unmodified. */
|
151
|
+
str->data[str->len] = '\0';
|
152
|
+
return false;
|
153
|
+
}
|
154
|
+
|
155
|
+
/*
|
156
|
+
* appendStringInfoString
|
157
|
+
*
|
158
|
+
* Append a null-terminated string to str.
|
159
|
+
* Like appendStringInfo(str, "%s", s) but faster.
|
160
|
+
*/
|
161
|
+
void
|
162
|
+
appendStringInfoString(StringInfo str, const char *s)
|
163
|
+
{
|
164
|
+
appendBinaryStringInfo(str, s, strlen(s));
|
165
|
+
}
|
166
|
+
|
167
|
+
/*
|
168
|
+
* appendStringInfoChar
|
169
|
+
*
|
170
|
+
* Append a single byte to str.
|
171
|
+
* Like appendStringInfo(str, "%c", ch) but much faster.
|
172
|
+
*/
|
173
|
+
void
|
174
|
+
appendStringInfoChar(StringInfo str, char ch)
|
175
|
+
{
|
176
|
+
/* Make more room if needed */
|
177
|
+
if (str->len + 1 >= str->maxlen)
|
178
|
+
enlargeStringInfo(str, 1);
|
179
|
+
|
180
|
+
/* OK, append the character */
|
181
|
+
str->data[str->len] = ch;
|
182
|
+
str->len++;
|
183
|
+
str->data[str->len] = '\0';
|
184
|
+
}
|
185
|
+
|
186
|
+
/*
|
187
|
+
* appendStringInfoSpaces
|
188
|
+
*
|
189
|
+
* Append the specified number of spaces to a buffer.
|
190
|
+
*/
|
191
|
+
void
|
192
|
+
appendStringInfoSpaces(StringInfo str, int count)
|
193
|
+
{
|
194
|
+
if (count > 0)
|
195
|
+
{
|
196
|
+
/* Make more room if needed */
|
197
|
+
enlargeStringInfo(str, count);
|
198
|
+
|
199
|
+
/* OK, append the spaces */
|
200
|
+
while (--count >= 0)
|
201
|
+
str->data[str->len++] = ' ';
|
202
|
+
str->data[str->len] = '\0';
|
203
|
+
}
|
204
|
+
}
|
205
|
+
|
206
|
+
/*
|
207
|
+
* appendBinaryStringInfo
|
208
|
+
*
|
209
|
+
* Append arbitrary binary data to a StringInfo, allocating more space
|
210
|
+
* if necessary.
|
211
|
+
*/
|
212
|
+
void
|
213
|
+
appendBinaryStringInfo(StringInfo str, const char *data, int datalen)
|
214
|
+
{
|
215
|
+
/* Make more room if needed */
|
216
|
+
enlargeStringInfo(str, datalen);
|
217
|
+
|
218
|
+
/* OK, append the data */
|
219
|
+
memcpy(str->data + str->len, data, datalen);
|
220
|
+
str->len += datalen;
|
221
|
+
|
222
|
+
/*
|
223
|
+
* Keep a trailing null in place, even though it's probably useless for
|
224
|
+
* binary data. (Some callers are dealing with text but call this because
|
225
|
+
* their input isn't null-terminated.)
|
226
|
+
*/
|
227
|
+
str->data[str->len] = '\0';
|
228
|
+
}
|
229
|
+
|
230
|
+
/*
|
231
|
+
* enlargeStringInfo
|
232
|
+
*
|
233
|
+
* Make sure there is enough space for 'needed' more bytes
|
234
|
+
* ('needed' does not include the terminating null).
|
235
|
+
*
|
236
|
+
* External callers usually need not concern themselves with this, since
|
237
|
+
* all stringinfo.c routines do it automatically. However, if a caller
|
238
|
+
* knows that a StringInfo will eventually become X bytes large, it
|
239
|
+
* can save some palloc overhead by enlarging the buffer before starting
|
240
|
+
* to store data in it.
|
241
|
+
*
|
242
|
+
* NB: because we use repalloc() to enlarge the buffer, the string buffer
|
243
|
+
* will remain allocated in the same memory context that was current when
|
244
|
+
* initStringInfo was called, even if another context is now current.
|
245
|
+
* This is the desired and indeed critical behavior!
|
246
|
+
*/
|
247
|
+
void
|
248
|
+
enlargeStringInfo(StringInfo str, int needed)
|
249
|
+
{
|
250
|
+
int newlen;
|
251
|
+
|
252
|
+
/*
|
253
|
+
* Guard against out-of-range "needed" values. Without this, we can get
|
254
|
+
* an overflow or infinite loop in the following.
|
255
|
+
*/
|
256
|
+
#if 0
|
257
|
+
if (needed < 0) /* should not happen */
|
258
|
+
elog(ERROR, "invalid string enlargement request size: %d", needed);
|
259
|
+
if (((Size) needed) >= (MaxAllocSize - (Size) str->len))
|
260
|
+
ereport(ERROR,
|
261
|
+
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
|
262
|
+
errmsg("out of memory"),
|
263
|
+
errdetail("Cannot enlarge string buffer containing %d bytes by %d more bytes.",
|
264
|
+
str->len, needed)));
|
265
|
+
#endif
|
266
|
+
|
267
|
+
needed += str->len + 1; /* total space required now */
|
268
|
+
|
269
|
+
/* Because of the above test, we now have needed <= MaxAllocSize */
|
270
|
+
|
271
|
+
if (needed <= str->maxlen)
|
272
|
+
return; /* got enough space already */
|
273
|
+
|
274
|
+
/*
|
275
|
+
* We don't want to allocate just a little more space with each append;
|
276
|
+
* for efficiency, double the buffer size each time it overflows.
|
277
|
+
* Actually, we might need to more than double it if 'needed' is big...
|
278
|
+
*/
|
279
|
+
newlen = 2 * str->maxlen;
|
280
|
+
while (needed > newlen)
|
281
|
+
newlen = 2 * newlen;
|
282
|
+
|
283
|
+
/*
|
284
|
+
* Clamp to MaxAllocSize in case we went past it. Note we are assuming
|
285
|
+
* here that MaxAllocSize <= INT_MAX/2, else the above loop could
|
286
|
+
* overflow. We will still have newlen >= needed.
|
287
|
+
*/
|
288
|
+
if (newlen > (int) MaxAllocSize)
|
289
|
+
newlen = (int) MaxAllocSize;
|
290
|
+
|
291
|
+
str->data = (char *) repalloc(str->data, newlen);
|
292
|
+
|
293
|
+
str->maxlen = newlen;
|
294
|
+
}
|
@@ -0,0 +1,178 @@
|
|
1
|
+
/*-------------------------------------------------------------------------
|
2
|
+
*
|
3
|
+
* stringinfo.h
|
4
|
+
* Declarations/definitions for "StringInfo" functions.
|
5
|
+
*
|
6
|
+
* StringInfo provides an indefinitely-extensible string data type.
|
7
|
+
* It can be used to buffer either ordinary C strings (null-terminated text)
|
8
|
+
* or arbitrary binary data. All storage is allocated with palloc().
|
9
|
+
*
|
10
|
+
* Portions Copyright (c) 2003-2013, PgPool Global Development Group
|
11
|
+
* Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
|
12
|
+
* Portions Copyright (c) 1994, Regents of the University of California
|
13
|
+
*
|
14
|
+
* src/include/lib/stringinfo.h
|
15
|
+
*
|
16
|
+
*-------------------------------------------------------------------------
|
17
|
+
*/
|
18
|
+
#ifndef STRINGINFO_H
|
19
|
+
#define STRINGINFO_H
|
20
|
+
|
21
|
+
#include "pg_config_manual.h"
|
22
|
+
|
23
|
+
/* port.h */
|
24
|
+
extern int pg_vsnprintf(char *str, size_t count, const char *fmt, va_list args);
|
25
|
+
|
26
|
+
/*
|
27
|
+
* The GCC-specific code below prevents the __attribute__(... 'printf')
|
28
|
+
* above from being replaced, and this is required because gcc doesn't
|
29
|
+
* know anything about pg_printf.
|
30
|
+
*/
|
31
|
+
#ifdef __GNUC__
|
32
|
+
#define vsnprintf(...) pg_vsnprintf(__VA_ARGS__)
|
33
|
+
#else
|
34
|
+
#define vsnprintf pg_vsnprintf
|
35
|
+
#endif
|
36
|
+
|
37
|
+
/* utils.memutils.h */
|
38
|
+
|
39
|
+
#include "pool_parser.h"
|
40
|
+
#define MaxAllocSize ((Size) 0x3fffffff) /* 1 gigabyte - 1 */
|
41
|
+
|
42
|
+
|
43
|
+
/*-------------------------
|
44
|
+
* StringInfoData holds information about an extensible string.
|
45
|
+
* data is the current buffer for the string (allocated with palloc).
|
46
|
+
* len is the current string length. There is guaranteed to be
|
47
|
+
* a terminating '\0' at data[len], although this is not very
|
48
|
+
* useful when the string holds binary data rather than text.
|
49
|
+
* maxlen is the allocated size in bytes of 'data', i.e. the maximum
|
50
|
+
* string size (including the terminating '\0' char) that we can
|
51
|
+
* currently store in 'data' without having to reallocate
|
52
|
+
* more space. We must always have maxlen > len.
|
53
|
+
* cursor is initialized to zero by makeStringInfo or initStringInfo,
|
54
|
+
* but is not otherwise touched by the stringinfo.c routines.
|
55
|
+
* Some routines use it to scan through a StringInfo.
|
56
|
+
*-------------------------
|
57
|
+
*/
|
58
|
+
typedef struct StringInfoData
|
59
|
+
{
|
60
|
+
char *data;
|
61
|
+
int len;
|
62
|
+
int maxlen;
|
63
|
+
int cursor;
|
64
|
+
} StringInfoData;
|
65
|
+
|
66
|
+
typedef StringInfoData *StringInfo;
|
67
|
+
|
68
|
+
|
69
|
+
/*------------------------
|
70
|
+
* There are two ways to create a StringInfo object initially:
|
71
|
+
*
|
72
|
+
* StringInfo stringptr = makeStringInfo();
|
73
|
+
* Both the StringInfoData and the data buffer are palloc'd.
|
74
|
+
*
|
75
|
+
* StringInfoData string;
|
76
|
+
* initStringInfo(&string);
|
77
|
+
* The data buffer is palloc'd but the StringInfoData is just local.
|
78
|
+
* This is the easiest approach for a StringInfo object that will
|
79
|
+
* only live as long as the current routine.
|
80
|
+
*
|
81
|
+
* To destroy a StringInfo, pfree() the data buffer, and then pfree() the
|
82
|
+
* StringInfoData if it was palloc'd. There's no special support for this.
|
83
|
+
*
|
84
|
+
* NOTE: some routines build up a string using StringInfo, and then
|
85
|
+
* release the StringInfoData but return the data string itself to their
|
86
|
+
* caller. At that point the data string looks like a plain palloc'd
|
87
|
+
* string.
|
88
|
+
*-------------------------
|
89
|
+
*/
|
90
|
+
/*------------------------
|
91
|
+
* makeStringInfo
|
92
|
+
* Create an empty 'StringInfoData' & return a pointer to it.
|
93
|
+
*/
|
94
|
+
extern StringInfo makeStringInfo(void);
|
95
|
+
|
96
|
+
/*------------------------
|
97
|
+
* initStringInfo
|
98
|
+
* Initialize a StringInfoData struct (with previously undefined contents)
|
99
|
+
* to describe an empty string.
|
100
|
+
*/
|
101
|
+
extern void initStringInfo(StringInfo str);
|
102
|
+
|
103
|
+
/*------------------------
|
104
|
+
* resetStringInfo
|
105
|
+
* Clears the current content of the StringInfo, if any. The
|
106
|
+
* StringInfo remains valid.
|
107
|
+
*/
|
108
|
+
extern void resetStringInfo(StringInfo str);
|
109
|
+
|
110
|
+
/*------------------------
|
111
|
+
* appendStringInfo
|
112
|
+
* Format text data under the control of fmt (an sprintf-style format string)
|
113
|
+
* and append it to whatever is already in str. More space is allocated
|
114
|
+
* to str if necessary. This is sort of like a combination of sprintf and
|
115
|
+
* strcat.
|
116
|
+
*/
|
117
|
+
extern void
|
118
|
+
appendStringInfo(StringInfo str, const char *fmt,...)
|
119
|
+
/* This extension allows gcc to check the format string */
|
120
|
+
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 3)));
|
121
|
+
|
122
|
+
/*------------------------
|
123
|
+
* appendStringInfoVA
|
124
|
+
* Attempt to format text data under the control of fmt (an sprintf-style
|
125
|
+
* format string) and append it to whatever is already in str. If successful
|
126
|
+
* return true; if not (because there's not enough space), return false
|
127
|
+
* without modifying str. Typically the caller would enlarge str and retry
|
128
|
+
* on false return --- see appendStringInfo for standard usage pattern.
|
129
|
+
*/
|
130
|
+
extern bool
|
131
|
+
appendStringInfoVA(StringInfo str, const char *fmt, va_list args)
|
132
|
+
__attribute__((format(PG_PRINTF_ATTRIBUTE, 2, 0)));
|
133
|
+
|
134
|
+
/*------------------------
|
135
|
+
* appendStringInfoString
|
136
|
+
* Append a null-terminated string to str.
|
137
|
+
* Like appendStringInfo(str, "%s", s) but faster.
|
138
|
+
*/
|
139
|
+
extern void appendStringInfoString(StringInfo str, const char *s);
|
140
|
+
|
141
|
+
/*------------------------
|
142
|
+
* appendStringInfoChar
|
143
|
+
* Append a single byte to str.
|
144
|
+
* Like appendStringInfo(str, "%c", ch) but much faster.
|
145
|
+
*/
|
146
|
+
extern void appendStringInfoChar(StringInfo str, char ch);
|
147
|
+
|
148
|
+
/*------------------------
|
149
|
+
* appendStringInfoCharMacro
|
150
|
+
* As above, but a macro for even more speed where it matters.
|
151
|
+
* Caution: str argument will be evaluated multiple times.
|
152
|
+
*/
|
153
|
+
#define appendStringInfoCharMacro(str,ch) \
|
154
|
+
(((str)->len + 1 >= (str)->maxlen) ? \
|
155
|
+
appendStringInfoChar(str, ch) : \
|
156
|
+
(void)((str)->data[(str)->len] = (ch), (str)->data[++(str)->len] = '\0'))
|
157
|
+
|
158
|
+
/*------------------------
|
159
|
+
* appendStringInfoSpaces
|
160
|
+
* Append a given number of spaces to str.
|
161
|
+
*/
|
162
|
+
extern void appendStringInfoSpaces(StringInfo str, int count);
|
163
|
+
|
164
|
+
/*------------------------
|
165
|
+
* appendBinaryStringInfo
|
166
|
+
* Append arbitrary binary data to a StringInfo, allocating more space
|
167
|
+
* if necessary.
|
168
|
+
*/
|
169
|
+
extern void appendBinaryStringInfo(StringInfo str,
|
170
|
+
const char *data, int datalen);
|
171
|
+
|
172
|
+
/*------------------------
|
173
|
+
* enlargeStringInfo
|
174
|
+
* Make sure a StringInfo's buffer can hold at least 'needed' more bytes.
|
175
|
+
*/
|
176
|
+
extern void enlargeStringInfo(StringInfo str, int needed);
|
177
|
+
|
178
|
+
#endif /* STRINGINFO_H */
|