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,68 @@
|
|
|
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-2012 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_select_walker.h.: Walker functions for SELECT
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
#ifndef POOL_SELECT_WALKER_H
|
|
27
|
+
#define POOL_SELECT_WALKER_H
|
|
28
|
+
|
|
29
|
+
#include "pool.h"
|
|
30
|
+
#include "parser/nodes.h"
|
|
31
|
+
#include "parser/primnodes.h"
|
|
32
|
+
#include "parser/makefuncs.h"
|
|
33
|
+
|
|
34
|
+
#define POOL_MAX_SELECT_OIDS 128
|
|
35
|
+
#define POOL_NAMEDATALEN 64 /* from NAMEDATALEN of PostgreSQL */
|
|
36
|
+
|
|
37
|
+
typedef struct {
|
|
38
|
+
bool has_system_catalog; /* True if system catalog table is used */
|
|
39
|
+
bool has_temp_table; /* True if temporary table is used */
|
|
40
|
+
bool has_unlogged_table; /* True if unlogged table is used */
|
|
41
|
+
bool has_view; /* True if view is used */
|
|
42
|
+
bool has_function_call; /* True if write function call is used */
|
|
43
|
+
bool has_non_immutable_function_call; /* True if non immutable functions are used */
|
|
44
|
+
bool has_insertinto_or_locking_clause; /* True if it has SELECT INTO or FOR SHARE/UPDATE */
|
|
45
|
+
int num_oids; /* number of oids */
|
|
46
|
+
int table_oids[POOL_MAX_SELECT_OIDS]; /* table oids */
|
|
47
|
+
char table_names[POOL_MAX_SELECT_OIDS][POOL_NAMEDATALEN]; /* table names */
|
|
48
|
+
} SelectContext;
|
|
49
|
+
|
|
50
|
+
extern bool pool_has_function_call(Node *node);
|
|
51
|
+
extern bool pool_has_non_immutable_function_call(Node *node);
|
|
52
|
+
extern bool pool_has_system_catalog(Node *node);
|
|
53
|
+
extern bool pool_has_relation(Node *node);
|
|
54
|
+
extern bool pool_has_temp_table(Node *node);
|
|
55
|
+
extern void discard_temp_table_relcache(void);
|
|
56
|
+
extern bool pool_has_unlogged_table(Node *node);
|
|
57
|
+
extern bool pool_has_view(Node *node);
|
|
58
|
+
extern bool pool_has_insertinto_or_locking_clause(Node *node);
|
|
59
|
+
extern bool pool_has_pgpool_regclass(void);
|
|
60
|
+
extern bool raw_expression_tree_walker(Node *node, bool (*walker) (), void *context);
|
|
61
|
+
extern int pool_table_name_to_oid(char *table_name);
|
|
62
|
+
extern int pool_extract_table_oids_from_select_stmt(Node *node, SelectContext *ctx);
|
|
63
|
+
extern RangeVar *makeRangeVarFromNameList(List *names);
|
|
64
|
+
extern int pattern_compare(char *str, const int type, const char *param_name);
|
|
65
|
+
extern bool is_unlogged_table(char *table_name);
|
|
66
|
+
extern bool is_view(char *table_name);
|
|
67
|
+
|
|
68
|
+
#endif /* POOL_SELECT_WALKER_H */
|
data/pgpool2/pool_sema.c
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/* -*-pgsql-c-*- */
|
|
2
|
+
/*
|
|
3
|
+
* $Header$
|
|
4
|
+
*
|
|
5
|
+
* pgpool: a language independent connection pool server for PostgreSQL
|
|
6
|
+
* written by Tatsuo Ishii
|
|
7
|
+
*
|
|
8
|
+
* Portions Copyright (c) 2003-2009, PgPool Global Development Group
|
|
9
|
+
* Portions Copyright (c) 2003-2004, PostgreSQL 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
|
+
*/
|
|
23
|
+
#include "pool.h"
|
|
24
|
+
|
|
25
|
+
#include <errno.h>
|
|
26
|
+
#include <string.h>
|
|
27
|
+
#include <sys/sem.h>
|
|
28
|
+
|
|
29
|
+
#include "pool_ipc.h"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
#ifndef HAVE_UNION_SEMUN
|
|
33
|
+
union semun
|
|
34
|
+
{
|
|
35
|
+
int val;
|
|
36
|
+
struct semid_ds *buf;
|
|
37
|
+
unsigned short *array;
|
|
38
|
+
};
|
|
39
|
+
#endif
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
static int semId;
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
/*
|
|
46
|
+
* Removes a semaphore set.
|
|
47
|
+
*/
|
|
48
|
+
static void
|
|
49
|
+
IpcSemaphoreKill(int status, Datum semId)
|
|
50
|
+
{
|
|
51
|
+
union semun semun;
|
|
52
|
+
struct semid_ds seminfo;
|
|
53
|
+
|
|
54
|
+
/*
|
|
55
|
+
* Is a previously-existing sema segment still existing and in use?
|
|
56
|
+
*/
|
|
57
|
+
semun.buf = &seminfo;
|
|
58
|
+
if (semctl(semId, 0, IPC_STAT, semun) < 0
|
|
59
|
+
&& (errno == EINVAL || errno == EACCES
|
|
60
|
+
#ifdef EIDRM
|
|
61
|
+
|| errno == EIDRM
|
|
62
|
+
#endif
|
|
63
|
+
))
|
|
64
|
+
return;
|
|
65
|
+
|
|
66
|
+
semun.val = 0; /* unused, but keep compiler quiet */
|
|
67
|
+
|
|
68
|
+
if (semctl(semId, 0, IPC_RMID) < 0)
|
|
69
|
+
pool_log("semctl(%lu, 0, IPC_RMID, ...) failed: %s", semId, strerror(errno));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/*
|
|
73
|
+
* Create a semaphore set and initialize.
|
|
74
|
+
*/
|
|
75
|
+
int
|
|
76
|
+
pool_semaphore_create(int numSems)
|
|
77
|
+
{
|
|
78
|
+
int i;
|
|
79
|
+
|
|
80
|
+
/* Try to create new semaphore set */
|
|
81
|
+
semId = semget(IPC_PRIVATE, numSems, IPC_CREAT | IPC_EXCL | IPCProtection);
|
|
82
|
+
|
|
83
|
+
if (semId < 0)
|
|
84
|
+
{
|
|
85
|
+
pool_error("could not create %d semaphores: %s", numSems, strerror(errno));
|
|
86
|
+
return -1;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
on_shmem_exit(IpcSemaphoreKill, semId);
|
|
90
|
+
|
|
91
|
+
/* Initialize it to count 1 */
|
|
92
|
+
for (i = 0; i < numSems; i++)
|
|
93
|
+
{
|
|
94
|
+
union semun semun;
|
|
95
|
+
|
|
96
|
+
semun.val = 1;
|
|
97
|
+
if (semctl(semId, i, SETVAL, semun) < 0)
|
|
98
|
+
{
|
|
99
|
+
pool_error("semctl(%d, %d, SETVAL, %d) failed: %s",
|
|
100
|
+
semId, i, 1, strerror(errno));
|
|
101
|
+
return -1;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/*
|
|
109
|
+
* Lock a semaphore (decrement count), blocking if count would be < 0
|
|
110
|
+
*/
|
|
111
|
+
void
|
|
112
|
+
pool_semaphore_lock(int semNum)
|
|
113
|
+
{
|
|
114
|
+
int errStatus;
|
|
115
|
+
struct sembuf sops;
|
|
116
|
+
|
|
117
|
+
sops.sem_op = -1; /* decrement */
|
|
118
|
+
sops.sem_flg = 0;
|
|
119
|
+
sops.sem_num = semNum;
|
|
120
|
+
|
|
121
|
+
/*
|
|
122
|
+
* Note: if errStatus is -1 and errno == EINTR then it means we returned
|
|
123
|
+
* from the operation prematurely because we were sent a signal. So we
|
|
124
|
+
* try and lock the semaphore again.
|
|
125
|
+
*/
|
|
126
|
+
do
|
|
127
|
+
{
|
|
128
|
+
errStatus = semop(semId, &sops, 1);
|
|
129
|
+
} while (errStatus < 0 && errno == EINTR);
|
|
130
|
+
|
|
131
|
+
if (errStatus < 0)
|
|
132
|
+
pool_error("semop(id=%d) failed: %s", semId, strerror(errno));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/*
|
|
136
|
+
* Unlock a semaphore (increment count)
|
|
137
|
+
*/
|
|
138
|
+
void
|
|
139
|
+
pool_semaphore_unlock(int semNum)
|
|
140
|
+
{
|
|
141
|
+
int errStatus;
|
|
142
|
+
struct sembuf sops;
|
|
143
|
+
|
|
144
|
+
sops.sem_op = 1; /* increment */
|
|
145
|
+
sops.sem_flg = 0;
|
|
146
|
+
sops.sem_num = semNum;
|
|
147
|
+
|
|
148
|
+
/*
|
|
149
|
+
* Note: if errStatus is -1 and errno == EINTR then it means we returned
|
|
150
|
+
* from the operation prematurely because we were sent a signal. So we
|
|
151
|
+
* try and unlock the semaphore again. Not clear this can really happen,
|
|
152
|
+
* but might as well cope.
|
|
153
|
+
*/
|
|
154
|
+
do
|
|
155
|
+
{
|
|
156
|
+
errStatus = semop(semId, &sops, 1);
|
|
157
|
+
} while (errStatus < 0 && errno == EINTR);
|
|
158
|
+
|
|
159
|
+
if (errStatus < 0)
|
|
160
|
+
pool_error("semop(id=%d) failed: %s", semId, strerror(errno));
|
|
161
|
+
}
|
|
@@ -0,0 +1,952 @@
|
|
|
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
|
+
*/
|
|
23
|
+
#include <errno.h>
|
|
24
|
+
#include <stdlib.h>
|
|
25
|
+
#include <string.h>
|
|
26
|
+
|
|
27
|
+
#include "pool.h"
|
|
28
|
+
#include "pool_config.h"
|
|
29
|
+
#include "pool_session_context.h"
|
|
30
|
+
|
|
31
|
+
static POOL_SESSION_CONTEXT session_context_d;
|
|
32
|
+
static POOL_SESSION_CONTEXT *session_context = NULL;
|
|
33
|
+
|
|
34
|
+
static void init_sent_message_list(void);
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* Initialize per session context
|
|
38
|
+
*/
|
|
39
|
+
void pool_init_session_context(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *backend)
|
|
40
|
+
{
|
|
41
|
+
session_context = &session_context_d;
|
|
42
|
+
|
|
43
|
+
/* Get Process context */
|
|
44
|
+
session_context->process_context = pool_get_process_context();
|
|
45
|
+
if (!session_context->process_context)
|
|
46
|
+
{
|
|
47
|
+
pool_error("pool_init_session_context: cannot get process context");
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Set connection info */
|
|
52
|
+
session_context->frontend = frontend;
|
|
53
|
+
session_context->backend = backend;
|
|
54
|
+
|
|
55
|
+
/* Initialize query context */
|
|
56
|
+
session_context->query_context = NULL;
|
|
57
|
+
|
|
58
|
+
/* Initialize local session id */
|
|
59
|
+
pool_incremnet_local_session_id();
|
|
60
|
+
|
|
61
|
+
/* Initialize sent message list */
|
|
62
|
+
init_sent_message_list();
|
|
63
|
+
|
|
64
|
+
/* Create memory context */
|
|
65
|
+
session_context->memory_context = pool_memory_create(PREPARE_BLOCK_SIZE);
|
|
66
|
+
|
|
67
|
+
/* Choose load balancing node if necessary */
|
|
68
|
+
if (pool_config->load_balance_mode)
|
|
69
|
+
{
|
|
70
|
+
ProcessInfo *process_info = pool_get_my_process_info();
|
|
71
|
+
if (!process_info)
|
|
72
|
+
{
|
|
73
|
+
pool_error("pool_init_session_context: pool_get_my_process_info failed");
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
session_context->load_balance_node_id =
|
|
78
|
+
process_info->connection_info->load_balancing_node =
|
|
79
|
+
select_load_balancing_node();
|
|
80
|
+
|
|
81
|
+
pool_debug("selected load balancing node: %d", backend->info->load_balancing_node);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* Unset query is in progress */
|
|
85
|
+
pool_unset_query_in_progress();
|
|
86
|
+
|
|
87
|
+
/* The command in progress has not succeeded yet */
|
|
88
|
+
pool_unset_command_success();
|
|
89
|
+
|
|
90
|
+
/* We don't have a write query in this transaction yet */
|
|
91
|
+
pool_unset_writing_transaction();
|
|
92
|
+
|
|
93
|
+
/* Error doesn't occur in this transaction yet */
|
|
94
|
+
pool_unset_failed_transaction();
|
|
95
|
+
|
|
96
|
+
/* Forget transaction isolation mode */
|
|
97
|
+
pool_unset_transaction_isolation();
|
|
98
|
+
|
|
99
|
+
/* We don't skip reading from backends */
|
|
100
|
+
pool_unset_skip_reading_from_backends();
|
|
101
|
+
|
|
102
|
+
/* Backends have not ignored messages yet */
|
|
103
|
+
pool_unset_ignore_till_sync();
|
|
104
|
+
|
|
105
|
+
/* Initialize where to send map for PREPARE statements */
|
|
106
|
+
#ifdef NOT_USED
|
|
107
|
+
memset(&session_context->prep_where, 0, sizeof(session_context->prep_where));
|
|
108
|
+
session_context->prep_where.nelem = POOL_MAX_PREPARED_STATEMENTS;
|
|
109
|
+
#endif /* NOT_USED */
|
|
110
|
+
/* Reset flag to indicate difference in number of affected tuples
|
|
111
|
+
* in UPDATE/DELETE.
|
|
112
|
+
*/
|
|
113
|
+
session_context->mismatch_ntuples = false;
|
|
114
|
+
|
|
115
|
+
if (pool_config->memory_cache_enabled)
|
|
116
|
+
{
|
|
117
|
+
session_context->query_cache_array = pool_create_query_cache_array();
|
|
118
|
+
session_context->num_selects = 0;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/*
|
|
123
|
+
* Destroy session context.
|
|
124
|
+
*/
|
|
125
|
+
void pool_session_context_destroy(void)
|
|
126
|
+
{
|
|
127
|
+
if (session_context)
|
|
128
|
+
{
|
|
129
|
+
pool_clear_sent_message_list();
|
|
130
|
+
free(session_context->message_list.sent_messages);
|
|
131
|
+
pool_memory_delete(session_context->memory_context, 0);
|
|
132
|
+
if (pool_config->memory_cache_enabled)
|
|
133
|
+
{
|
|
134
|
+
pool_discard_query_cache_array(session_context->query_cache_array);
|
|
135
|
+
session_context->num_selects = 0;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (session_context->query_context)
|
|
139
|
+
pool_query_context_destroy(session_context->query_context);
|
|
140
|
+
}
|
|
141
|
+
/* XXX For now, just zap memory */
|
|
142
|
+
memset(&session_context_d, 0, sizeof(session_context_d));
|
|
143
|
+
session_context = NULL;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/*
|
|
147
|
+
* Return session context
|
|
148
|
+
*/
|
|
149
|
+
POOL_SESSION_CONTEXT *pool_get_session_context(void)
|
|
150
|
+
{
|
|
151
|
+
if (!session_context)
|
|
152
|
+
{
|
|
153
|
+
return NULL;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return session_context;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/*
|
|
160
|
+
* Return local session id
|
|
161
|
+
*/
|
|
162
|
+
int pool_get_local_session_id(void)
|
|
163
|
+
{
|
|
164
|
+
if (!session_context)
|
|
165
|
+
{
|
|
166
|
+
pool_error("pool_get_local_session_id: session context is not initialized");
|
|
167
|
+
return -1;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return session_context->process_context->local_session_id;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/*
|
|
174
|
+
* Return true if query is in progress
|
|
175
|
+
*/
|
|
176
|
+
bool pool_is_query_in_progress(void)
|
|
177
|
+
{
|
|
178
|
+
if (!session_context)
|
|
179
|
+
{
|
|
180
|
+
pool_error("pool_is_query_in_progress: session context is not initialized");
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return session_context->in_progress;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/*
|
|
188
|
+
* Set query is in progress
|
|
189
|
+
*/
|
|
190
|
+
void pool_set_query_in_progress(void)
|
|
191
|
+
{
|
|
192
|
+
if (!session_context)
|
|
193
|
+
{
|
|
194
|
+
pool_error("pool_set_query_in_progress: session context is not initialized");
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
pool_debug("pool_set_query_in_progress: done");
|
|
199
|
+
|
|
200
|
+
session_context->in_progress = true;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/*
|
|
204
|
+
* Unset query is in progress
|
|
205
|
+
*/
|
|
206
|
+
void pool_unset_query_in_progress(void)
|
|
207
|
+
{
|
|
208
|
+
if (!session_context)
|
|
209
|
+
{
|
|
210
|
+
pool_error("pool_unset_query_in_progress: session context is not initialized");
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
pool_debug("pool_unset_query_in_progress: done");
|
|
215
|
+
|
|
216
|
+
session_context->in_progress = false;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/*
|
|
220
|
+
* Return true if we skip reading from backends
|
|
221
|
+
*/
|
|
222
|
+
bool pool_is_skip_reading_from_backends(void)
|
|
223
|
+
{
|
|
224
|
+
if (!session_context)
|
|
225
|
+
{
|
|
226
|
+
pool_error("pool_is_skip_reading_from_backends: session context is not initialized");
|
|
227
|
+
return false;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return session_context->skip_reading_from_backends;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/*
|
|
234
|
+
* Set skip_reading_from_backends
|
|
235
|
+
*/
|
|
236
|
+
void pool_set_skip_reading_from_backends(void)
|
|
237
|
+
{
|
|
238
|
+
if (!session_context)
|
|
239
|
+
{
|
|
240
|
+
pool_error("pool_set_skip_reading_from_backends: session context is not initialized");
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
pool_debug("pool_set_skip_reading_from_backends: done");
|
|
245
|
+
|
|
246
|
+
session_context->skip_reading_from_backends = true;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/*
|
|
250
|
+
* Unset skip_reading_from_backends
|
|
251
|
+
*/
|
|
252
|
+
void pool_unset_skip_reading_from_backends(void)
|
|
253
|
+
{
|
|
254
|
+
if (!session_context)
|
|
255
|
+
{
|
|
256
|
+
pool_error("pool_unset_skip_reading_from_backends: session context is not initialized");
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
pool_debug("pool_unset_skip_reading_from_backends: done");
|
|
261
|
+
|
|
262
|
+
session_context->skip_reading_from_backends = false;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/*
|
|
266
|
+
* Return true if we are doing extended query message
|
|
267
|
+
*/
|
|
268
|
+
bool pool_is_doing_extended_query_message(void)
|
|
269
|
+
{
|
|
270
|
+
if (!session_context)
|
|
271
|
+
{
|
|
272
|
+
pool_error("pool_is_doing_extended_query_message: session context is not initialized");
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return session_context->doing_extended_query_message;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/*
|
|
280
|
+
* Set doing_extended_query_message
|
|
281
|
+
*/
|
|
282
|
+
void pool_set_doing_extended_query_message(void)
|
|
283
|
+
{
|
|
284
|
+
if (!session_context)
|
|
285
|
+
{
|
|
286
|
+
pool_error("pool_set_doing_extended_query_message: session context is not initialized");
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
pool_debug("pool_set_doing_extended_query_message: done");
|
|
291
|
+
|
|
292
|
+
session_context->doing_extended_query_message = true;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/*
|
|
296
|
+
* Unset doing_extended_query_message
|
|
297
|
+
*/
|
|
298
|
+
void pool_unset_doing_extended_query_message(void)
|
|
299
|
+
{
|
|
300
|
+
if (!session_context)
|
|
301
|
+
{
|
|
302
|
+
pool_error("pool_unset_doing_extended_query_message: session context is not initialized");
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
pool_debug("pool_unset_doing_extended_query_message: done");
|
|
307
|
+
|
|
308
|
+
session_context->doing_extended_query_message = false;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/*
|
|
312
|
+
* Return true if backends ignore extended query message
|
|
313
|
+
*/
|
|
314
|
+
bool pool_is_ignore_till_sync(void)
|
|
315
|
+
{
|
|
316
|
+
if (!session_context)
|
|
317
|
+
{
|
|
318
|
+
pool_error("pool_is_ignore_till_sync: session context is not initialized");
|
|
319
|
+
return false;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
return session_context->ignore_till_sync;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/*
|
|
326
|
+
* Set ignore_till_sync
|
|
327
|
+
*/
|
|
328
|
+
void pool_set_ignore_till_sync(void)
|
|
329
|
+
{
|
|
330
|
+
if (!session_context)
|
|
331
|
+
{
|
|
332
|
+
pool_error("pool_set_ignore_till_sync: session context is not initialized");
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
pool_debug("pool_set_ignore_till_sync: done");
|
|
337
|
+
|
|
338
|
+
session_context->ignore_till_sync = true;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/*
|
|
342
|
+
* Unset ignore_till_sync
|
|
343
|
+
*/
|
|
344
|
+
void pool_unset_ignore_till_sync(void)
|
|
345
|
+
{
|
|
346
|
+
if (!session_context)
|
|
347
|
+
{
|
|
348
|
+
pool_error("pool_unset_ignore_till_sync: session context is not initialized");
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
pool_debug("pool_unset_ignore_till_sync: done");
|
|
353
|
+
|
|
354
|
+
session_context->ignore_till_sync = false;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/*
|
|
358
|
+
* Remove a sent message
|
|
359
|
+
*/
|
|
360
|
+
bool pool_remove_sent_message(char kind, const char *name)
|
|
361
|
+
{
|
|
362
|
+
int i;
|
|
363
|
+
POOL_SENT_MESSAGE_LIST *msglist;
|
|
364
|
+
|
|
365
|
+
if (!session_context)
|
|
366
|
+
{
|
|
367
|
+
pool_error("pool_remove_sent_message: session context is not initialized");
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
msglist = &session_context->message_list;
|
|
372
|
+
|
|
373
|
+
for (i = 0; i < msglist->size; i++)
|
|
374
|
+
{
|
|
375
|
+
if (msglist->sent_messages[i]->kind == kind &&
|
|
376
|
+
!strcmp(msglist->sent_messages[i]->name, name))
|
|
377
|
+
{
|
|
378
|
+
pool_sent_message_destroy(msglist->sent_messages[i]);
|
|
379
|
+
break;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/* sent message not found */
|
|
384
|
+
if (i == msglist->size)
|
|
385
|
+
return false;
|
|
386
|
+
|
|
387
|
+
if (i != msglist->size - 1)
|
|
388
|
+
{
|
|
389
|
+
memmove(&msglist->sent_messages[i], &msglist->sent_messages[i+1],
|
|
390
|
+
sizeof(POOL_SENT_MESSAGE *) * (msglist->size - i - 1));
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
msglist->size--;
|
|
394
|
+
|
|
395
|
+
return true;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/*
|
|
399
|
+
* Remove same kind of sent messages
|
|
400
|
+
*/
|
|
401
|
+
void pool_remove_sent_messages(char kind)
|
|
402
|
+
{
|
|
403
|
+
int i;
|
|
404
|
+
POOL_SENT_MESSAGE_LIST *msglist;
|
|
405
|
+
|
|
406
|
+
if (!session_context)
|
|
407
|
+
{
|
|
408
|
+
pool_error("pool_remove_sent_messages: session context is not initialized");
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
msglist = &session_context->message_list;
|
|
413
|
+
|
|
414
|
+
for (i = 0; i < msglist->size; i++)
|
|
415
|
+
{
|
|
416
|
+
if (msglist->sent_messages[i]->kind == kind)
|
|
417
|
+
{
|
|
418
|
+
if (pool_remove_sent_message(kind, msglist->sent_messages[i]->name))
|
|
419
|
+
i--; /* for relocation by removing */
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/*
|
|
425
|
+
* Destroy sent message
|
|
426
|
+
*/
|
|
427
|
+
void pool_sent_message_destroy(POOL_SENT_MESSAGE *message)
|
|
428
|
+
{
|
|
429
|
+
bool in_progress;
|
|
430
|
+
POOL_QUERY_CONTEXT *qc = NULL;
|
|
431
|
+
|
|
432
|
+
if (!session_context)
|
|
433
|
+
{
|
|
434
|
+
pool_error("pool_sent_message_destroy: session context is not initialized");
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
in_progress = pool_is_query_in_progress();
|
|
439
|
+
|
|
440
|
+
if (message)
|
|
441
|
+
{
|
|
442
|
+
if (message->contents)
|
|
443
|
+
pool_memory_free(session_context->memory_context, message->contents);
|
|
444
|
+
|
|
445
|
+
if (message->name)
|
|
446
|
+
pool_memory_free(session_context->memory_context, message->name);
|
|
447
|
+
|
|
448
|
+
if (message->query_context)
|
|
449
|
+
{
|
|
450
|
+
if (session_context->query_context != message->query_context)
|
|
451
|
+
qc = session_context->query_context;
|
|
452
|
+
|
|
453
|
+
if (can_query_context_destroy(message->query_context))
|
|
454
|
+
{
|
|
455
|
+
pool_query_context_destroy(message->query_context);
|
|
456
|
+
/*
|
|
457
|
+
* set in_progress flag, because pool_query_context_destroy()
|
|
458
|
+
* unsets in_progress flag
|
|
459
|
+
*/
|
|
460
|
+
if (in_progress)
|
|
461
|
+
pool_set_query_in_progress();
|
|
462
|
+
/*
|
|
463
|
+
* set query_context of session_context, because
|
|
464
|
+
* pool_query_context_destroy() sets it to NULL.
|
|
465
|
+
*/
|
|
466
|
+
if (qc)
|
|
467
|
+
session_context->query_context = qc;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
if (session_context->memory_context)
|
|
472
|
+
pool_memory_free(session_context->memory_context, message);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/*
|
|
477
|
+
* Clear sent message list
|
|
478
|
+
*/
|
|
479
|
+
void pool_clear_sent_message_list(void)
|
|
480
|
+
{
|
|
481
|
+
POOL_SENT_MESSAGE_LIST *msglist;
|
|
482
|
+
|
|
483
|
+
if (!session_context)
|
|
484
|
+
{
|
|
485
|
+
pool_error("pool_clear_sent_message_list: session context is not initialized");
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
msglist = &session_context->message_list;
|
|
490
|
+
|
|
491
|
+
while (msglist->size > 0)
|
|
492
|
+
{
|
|
493
|
+
pool_remove_sent_messages(msglist->sent_messages[0]->kind);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/*
|
|
498
|
+
* Create a sent message
|
|
499
|
+
* kind: one of 'P':Parse, 'B':Bind or'Q':Query(PREPARE)
|
|
500
|
+
* len: message length that is not network byte order
|
|
501
|
+
* contents: message contents
|
|
502
|
+
* num_tsparams: number of timestamp parameters
|
|
503
|
+
* name: prepared statement name or portal name
|
|
504
|
+
*/
|
|
505
|
+
POOL_SENT_MESSAGE *pool_create_sent_message(char kind, int len, char *contents,
|
|
506
|
+
int num_tsparams, const char *name,
|
|
507
|
+
POOL_QUERY_CONTEXT *query_context)
|
|
508
|
+
{
|
|
509
|
+
POOL_SENT_MESSAGE *msg;
|
|
510
|
+
|
|
511
|
+
if (!session_context)
|
|
512
|
+
{
|
|
513
|
+
pool_error("pool_create_sent_message: session context is not initialized");
|
|
514
|
+
return NULL;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
msg = pool_memory_alloc(session_context->memory_context,
|
|
518
|
+
sizeof(POOL_SENT_MESSAGE));
|
|
519
|
+
msg->kind = kind;
|
|
520
|
+
msg->len = len;
|
|
521
|
+
msg->contents = pool_memory_alloc(session_context->memory_context, len);
|
|
522
|
+
memcpy(msg->contents, contents, len);
|
|
523
|
+
msg->num_tsparams = num_tsparams;
|
|
524
|
+
msg->name = pool_memory_strdup(session_context->memory_context, name);
|
|
525
|
+
msg->query_context = query_context;
|
|
526
|
+
|
|
527
|
+
return msg;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/*
|
|
531
|
+
* Add a sent message to sent message list
|
|
532
|
+
*/
|
|
533
|
+
void pool_add_sent_message(POOL_SENT_MESSAGE *message)
|
|
534
|
+
{
|
|
535
|
+
POOL_SENT_MESSAGE *old_msg;
|
|
536
|
+
POOL_SENT_MESSAGE_LIST *msglist;
|
|
537
|
+
|
|
538
|
+
if (!session_context)
|
|
539
|
+
{
|
|
540
|
+
pool_error("pool_add_sent_message: session context is not initialized");
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
if (!message)
|
|
545
|
+
{
|
|
546
|
+
pool_debug("pool_add_sent_message: message is NULL");
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
old_msg = pool_get_sent_message(message->kind, message->name);
|
|
551
|
+
msglist = &session_context->message_list;
|
|
552
|
+
|
|
553
|
+
if (old_msg)
|
|
554
|
+
{
|
|
555
|
+
if (message->kind == 'B')
|
|
556
|
+
pool_debug("pool_add_sent_message: portal \"%s\" already exists",
|
|
557
|
+
message->name);
|
|
558
|
+
else
|
|
559
|
+
pool_debug("pool_add_sent_message: prepared statement \"%s\" already exists",
|
|
560
|
+
message->name);
|
|
561
|
+
|
|
562
|
+
if (*message->name == '\0')
|
|
563
|
+
pool_remove_sent_message(old_msg->kind, old_msg->name);
|
|
564
|
+
else
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
if (msglist->size == msglist->capacity)
|
|
569
|
+
{
|
|
570
|
+
msglist->capacity *= 2;
|
|
571
|
+
msglist->sent_messages = realloc(msglist->sent_messages,
|
|
572
|
+
sizeof(POOL_SENT_MESSAGE *) * msglist->capacity);
|
|
573
|
+
if (!msglist->sent_messages)
|
|
574
|
+
{
|
|
575
|
+
pool_error("pool_add_sent_message: realloc failed: %s", strerror(errno));
|
|
576
|
+
exit(1);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
msglist->sent_messages[msglist->size++] = message;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/*
|
|
584
|
+
* Get a sent message
|
|
585
|
+
*/
|
|
586
|
+
POOL_SENT_MESSAGE *pool_get_sent_message(char kind, const char *name)
|
|
587
|
+
{
|
|
588
|
+
int i;
|
|
589
|
+
POOL_SENT_MESSAGE_LIST *msglist;
|
|
590
|
+
|
|
591
|
+
if (!session_context)
|
|
592
|
+
{
|
|
593
|
+
pool_error("pool_get_sent_message: session context is not initialized");
|
|
594
|
+
return NULL;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
msglist = &session_context->message_list;
|
|
598
|
+
|
|
599
|
+
for (i = 0; i < msglist->size; i++)
|
|
600
|
+
{
|
|
601
|
+
if (msglist->sent_messages[i]->kind == kind &&
|
|
602
|
+
!strcmp(msglist->sent_messages[i]->name, name))
|
|
603
|
+
return msglist->sent_messages[i];
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
return NULL;
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
/*
|
|
610
|
+
* We don't have a write query in this transaction yet.
|
|
611
|
+
*/
|
|
612
|
+
void pool_unset_writing_transaction(void)
|
|
613
|
+
{
|
|
614
|
+
if (!session_context)
|
|
615
|
+
{
|
|
616
|
+
pool_error("pool_unset_writing_transaction: session context is not initialized");
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
pool_debug("pool_unset_writing_transaction: done");
|
|
620
|
+
session_context->writing_transaction = false;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
/*
|
|
624
|
+
* We have a write query in this transaction.
|
|
625
|
+
*/
|
|
626
|
+
void pool_set_writing_transaction(void)
|
|
627
|
+
{
|
|
628
|
+
if (!session_context)
|
|
629
|
+
{
|
|
630
|
+
pool_error("pool_set_writing_transaction: session context is not initialized");
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
pool_debug("pool_set_writing_transaction: done");
|
|
634
|
+
session_context->writing_transaction = true;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/*
|
|
638
|
+
* Do we have a write query in this transaction?
|
|
639
|
+
*/
|
|
640
|
+
bool pool_is_writing_transaction(void)
|
|
641
|
+
{
|
|
642
|
+
if (!session_context)
|
|
643
|
+
{
|
|
644
|
+
pool_error("pool_is_writing_transaction: session context is not initialized");
|
|
645
|
+
return false;
|
|
646
|
+
}
|
|
647
|
+
return session_context->writing_transaction;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/*
|
|
651
|
+
* Error doesn't occur in this transaction yet.
|
|
652
|
+
*/
|
|
653
|
+
void pool_unset_failed_transaction(void)
|
|
654
|
+
{
|
|
655
|
+
if (!session_context)
|
|
656
|
+
{
|
|
657
|
+
pool_error("pool_unset_failed_transaction: session context is not initialized");
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
pool_debug("pool_unset_failed_transaction: done");
|
|
661
|
+
session_context->failed_transaction = false;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/*
|
|
665
|
+
* Error occurred in this transaction.
|
|
666
|
+
*/
|
|
667
|
+
void pool_set_failed_transaction(void)
|
|
668
|
+
{
|
|
669
|
+
if (!session_context)
|
|
670
|
+
{
|
|
671
|
+
pool_error("pool_set_failed_transaction: session context is not initialized");
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
pool_debug("pool_set_failed_transaction: done");
|
|
675
|
+
session_context->failed_transaction = true;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
/*
|
|
679
|
+
* Did error occur in this transaction?
|
|
680
|
+
*/
|
|
681
|
+
bool pool_is_failed_transaction(void)
|
|
682
|
+
{
|
|
683
|
+
if (!session_context)
|
|
684
|
+
{
|
|
685
|
+
pool_error("pool_is_failed_transaction: session context is not initialized");
|
|
686
|
+
return false;
|
|
687
|
+
}
|
|
688
|
+
return session_context->failed_transaction;
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/*
|
|
692
|
+
* Forget transaction isolation mode
|
|
693
|
+
*/
|
|
694
|
+
void pool_unset_transaction_isolation(void)
|
|
695
|
+
{
|
|
696
|
+
if (!session_context)
|
|
697
|
+
{
|
|
698
|
+
pool_error("pool_unset_transaction_isolation: session context is not initialized");
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
pool_debug("pool_unset_transaction_isolation: done");
|
|
702
|
+
session_context->transaction_isolation = POOL_UNKNOWN;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/*
|
|
706
|
+
* Set transaction isolation mode
|
|
707
|
+
*/
|
|
708
|
+
void pool_set_transaction_isolation(POOL_TRANSACTION_ISOLATION isolation_level)
|
|
709
|
+
{
|
|
710
|
+
if (!session_context)
|
|
711
|
+
{
|
|
712
|
+
pool_error("pool_set_transaction_isolation: session context is not initialized");
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
pool_debug("pool_set_transaction_isolation: done");
|
|
716
|
+
session_context->transaction_isolation = isolation_level;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
/*
|
|
720
|
+
* Get or return cached transaction isolation mode
|
|
721
|
+
*/
|
|
722
|
+
POOL_TRANSACTION_ISOLATION pool_get_transaction_isolation(void)
|
|
723
|
+
{
|
|
724
|
+
POOL_STATUS status;
|
|
725
|
+
POOL_SELECT_RESULT *res;
|
|
726
|
+
POOL_TRANSACTION_ISOLATION ret;
|
|
727
|
+
|
|
728
|
+
if (!session_context)
|
|
729
|
+
{
|
|
730
|
+
pool_error("pool_get_transaction_isolation: session context is not initialized");
|
|
731
|
+
return POOL_UNKNOWN;
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
/* It seems cached result is usable. Return it. */
|
|
735
|
+
if (session_context->transaction_isolation != POOL_UNKNOWN)
|
|
736
|
+
return session_context->transaction_isolation;
|
|
737
|
+
|
|
738
|
+
/* No cached data is available. Ask backend. */
|
|
739
|
+
status = do_query(MASTER(session_context->backend),
|
|
740
|
+
"SELECT current_setting('transaction_isolation')", &res, MAJOR(session_context->backend));
|
|
741
|
+
|
|
742
|
+
if (res->numrows <= 0)
|
|
743
|
+
{
|
|
744
|
+
pool_error("pool_get_transaction_isolation: do_query returns no rows");
|
|
745
|
+
free_select_result(res);
|
|
746
|
+
return POOL_UNKNOWN;
|
|
747
|
+
}
|
|
748
|
+
if (res->data[0] == NULL)
|
|
749
|
+
{
|
|
750
|
+
pool_error("pool_get_transaction_isolation: do_query returns no data");
|
|
751
|
+
free_select_result(res);
|
|
752
|
+
return POOL_UNKNOWN;
|
|
753
|
+
}
|
|
754
|
+
if (res->nullflags[0] == -1)
|
|
755
|
+
{
|
|
756
|
+
pool_error("pool_get_transaction_isolation: do_query returns NULL");
|
|
757
|
+
free_select_result(res);
|
|
758
|
+
return POOL_UNKNOWN;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
if (!strcmp(res->data[0], "read uncommitted"))
|
|
762
|
+
ret = POOL_READ_UNCOMMITTED;
|
|
763
|
+
else if (!strcmp(res->data[0], "read committed"))
|
|
764
|
+
ret = POOL_READ_COMMITTED;
|
|
765
|
+
else if (!strcmp(res->data[0], "repeatable read"))
|
|
766
|
+
ret = POOL_REPEATABLE_READ;
|
|
767
|
+
else if (!strcmp(res->data[0], "serializable"))
|
|
768
|
+
ret = POOL_SERIALIZABLE;
|
|
769
|
+
else
|
|
770
|
+
{
|
|
771
|
+
pool_error("pool_get_transaction_isolation: unknown transaction isolation level:%s",
|
|
772
|
+
res->data[0]);
|
|
773
|
+
ret = POOL_UNKNOWN;
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
free_select_result(res);
|
|
777
|
+
|
|
778
|
+
if (ret != POOL_UNKNOWN)
|
|
779
|
+
session_context->transaction_isolation = ret;
|
|
780
|
+
|
|
781
|
+
return ret;
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
/*
|
|
785
|
+
* The command in progress has not succeeded yet.
|
|
786
|
+
*/
|
|
787
|
+
void pool_unset_command_success(void)
|
|
788
|
+
{
|
|
789
|
+
if (!session_context)
|
|
790
|
+
{
|
|
791
|
+
pool_error("pool_unset_command_success: session context is not initialized");
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
pool_debug("pool_unset_command_success: done");
|
|
795
|
+
session_context->command_success = false;
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
/*
|
|
799
|
+
* The command in progress has succeeded.
|
|
800
|
+
*/
|
|
801
|
+
void pool_set_command_success(void)
|
|
802
|
+
{
|
|
803
|
+
if (!session_context)
|
|
804
|
+
{
|
|
805
|
+
pool_error("pool_set_command_success: session context is not initialized");
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
pool_debug("pool_set_command_success: done");
|
|
809
|
+
session_context->command_success = true;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
/*
|
|
813
|
+
* Has the command in progress succeeded?
|
|
814
|
+
*/
|
|
815
|
+
bool pool_is_command_success(void)
|
|
816
|
+
{
|
|
817
|
+
if (!session_context)
|
|
818
|
+
{
|
|
819
|
+
pool_error("pool_is_command_success: session context is not initialized");
|
|
820
|
+
return false;
|
|
821
|
+
}
|
|
822
|
+
return session_context->command_success;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
/*
|
|
826
|
+
* Copy send map
|
|
827
|
+
*/
|
|
828
|
+
void pool_copy_prep_where(bool *src, bool *dest)
|
|
829
|
+
{
|
|
830
|
+
memcpy(dest, src, sizeof(bool)*MAX_NUM_BACKENDS);
|
|
831
|
+
}
|
|
832
|
+
#ifdef NOT_USED
|
|
833
|
+
/*
|
|
834
|
+
* Add to send map a PREPARED statement
|
|
835
|
+
*/
|
|
836
|
+
void pool_add_prep_where(char *name, bool *map)
|
|
837
|
+
{
|
|
838
|
+
int i;
|
|
839
|
+
|
|
840
|
+
if (!session_context)
|
|
841
|
+
{
|
|
842
|
+
pool_error("pool_add_prep_where: session context is not initialized");
|
|
843
|
+
return;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
for (i=0;i<POOL_MAX_PREPARED_STATEMENTS;i++)
|
|
847
|
+
{
|
|
848
|
+
if (*session_context->prep_where.name[i] == '\0')
|
|
849
|
+
{
|
|
850
|
+
strncpy(session_context->prep_where.name[i], name, POOL_MAX_PREPARED_NAME);
|
|
851
|
+
pool_copy_prep_where(map, session_context->prep_where.where_to_send[i]);
|
|
852
|
+
return;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
pool_error("pool_add_prep_where: no empty slot found");
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
/*
|
|
859
|
+
* Search send map by PREPARED statement name
|
|
860
|
+
*/
|
|
861
|
+
bool *pool_get_prep_where(char *name)
|
|
862
|
+
{
|
|
863
|
+
int i;
|
|
864
|
+
|
|
865
|
+
if (!session_context)
|
|
866
|
+
{
|
|
867
|
+
pool_error("pool_get_prep_where: session context is not initialized");
|
|
868
|
+
return NULL;
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
for (i=0;i<POOL_MAX_PREPARED_STATEMENTS;i++)
|
|
872
|
+
{
|
|
873
|
+
if (!strcmp(session_context->prep_where.name[i], name))
|
|
874
|
+
{
|
|
875
|
+
return session_context->prep_where.where_to_send[i];
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
return NULL;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
/*
|
|
882
|
+
* Remove PREPARED statement by name
|
|
883
|
+
*/
|
|
884
|
+
void pool_delete_prep_where(char *name)
|
|
885
|
+
{
|
|
886
|
+
int i;
|
|
887
|
+
|
|
888
|
+
if (!session_context)
|
|
889
|
+
{
|
|
890
|
+
pool_error("pool_delete_prep_where: session context is not initialized");
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
for (i=0;i<POOL_MAX_PREPARED_STATEMENTS;i++)
|
|
895
|
+
{
|
|
896
|
+
if (!strcmp(session_context->prep_where.name[i], name))
|
|
897
|
+
{
|
|
898
|
+
memset(&session_context->prep_where.where_to_send[i], 0, sizeof(bool)*MAX_NUM_BACKENDS);
|
|
899
|
+
*session_context->prep_where.name[i] = '\0';
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
#endif /* NOT_USED */
|
|
905
|
+
/*
|
|
906
|
+
* Initialize sent message list
|
|
907
|
+
*/
|
|
908
|
+
static void init_sent_message_list(void)
|
|
909
|
+
{
|
|
910
|
+
POOL_SENT_MESSAGE_LIST *msglist;
|
|
911
|
+
|
|
912
|
+
msglist = &session_context->message_list;
|
|
913
|
+
msglist->size = 0;
|
|
914
|
+
msglist->capacity = INIT_LIST_SIZE;
|
|
915
|
+
msglist->sent_messages = malloc(sizeof(POOL_SENT_MESSAGE *) * INIT_LIST_SIZE);
|
|
916
|
+
if (!msglist->sent_messages)
|
|
917
|
+
{
|
|
918
|
+
pool_error("init_sent_message_list: malloc failed: %s", strerror(errno));
|
|
919
|
+
exit(1);
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
/*
|
|
924
|
+
* Look for extended message list to check if given query context qc
|
|
925
|
+
* is used. Returns true if it is not used.
|
|
926
|
+
*/
|
|
927
|
+
bool can_query_context_destroy(POOL_QUERY_CONTEXT *qc)
|
|
928
|
+
{
|
|
929
|
+
int i;
|
|
930
|
+
int count = 0;
|
|
931
|
+
POOL_SENT_MESSAGE_LIST *msglist;
|
|
932
|
+
|
|
933
|
+
msglist = &session_context->message_list;
|
|
934
|
+
|
|
935
|
+
for (i = 0; i < msglist->size; i++)
|
|
936
|
+
{
|
|
937
|
+
if (msglist->sent_messages[i]->query_context == qc)
|
|
938
|
+
{
|
|
939
|
+
pool_debug("can_query_context_destroy: query context %p is still used. query:%s",
|
|
940
|
+
qc, qc->original_query);
|
|
941
|
+
count++;
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
if (count > 1)
|
|
945
|
+
{
|
|
946
|
+
pool_debug("can_query_context_destroy: query context %p is still used for %d times.",
|
|
947
|
+
qc, count);
|
|
948
|
+
return false;
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
return true;
|
|
952
|
+
}
|