prestogres 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (393) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +20 -0
  4. data/LICENSE +202 -0
  5. data/NOTICE +22 -0
  6. data/README.md +217 -0
  7. data/Rakefile +13 -0
  8. data/VERSION +1 -0
  9. data/bin/prestogres +254 -0
  10. data/config/pcp.conf.sample +28 -0
  11. data/config/pgpool.conf +678 -0
  12. data/config/pool_hba.conf +84 -0
  13. data/config/pool_passwd +0 -0
  14. data/config/postgresql.conf +2 -0
  15. data/ext/.gitignore +6 -0
  16. data/ext/depend +26 -0
  17. data/ext/extconf.rb +4 -0
  18. data/ext/prestogres_config.c +12 -0
  19. data/pgpool2/.gitignore +36 -0
  20. data/pgpool2/AUTHORS +4 -0
  21. data/pgpool2/COPYING +12 -0
  22. data/pgpool2/ChangeLog +1 -0
  23. data/pgpool2/INSTALL +1 -0
  24. data/pgpool2/Makefile.am +159 -0
  25. data/pgpool2/Makefile.in +1187 -0
  26. data/pgpool2/NEWS +4960 -0
  27. data/pgpool2/README +1 -0
  28. data/pgpool2/README.euc_jp +1 -0
  29. data/pgpool2/README.online-recovery +62 -0
  30. data/pgpool2/TODO +103 -0
  31. data/pgpool2/ac_func_accept_argtypes.m4 +85 -0
  32. data/pgpool2/aclocal.m4 +1088 -0
  33. data/pgpool2/c-compiler.m4 +134 -0
  34. data/pgpool2/c-library.m4 +325 -0
  35. data/pgpool2/child.c +2097 -0
  36. data/pgpool2/config.guess +1532 -0
  37. data/pgpool2/config.h.in +332 -0
  38. data/pgpool2/config.sub +1640 -0
  39. data/pgpool2/configure +15752 -0
  40. data/pgpool2/configure.in +392 -0
  41. data/pgpool2/depcomp +522 -0
  42. data/pgpool2/doc/basebackup.sh +17 -0
  43. data/pgpool2/doc/pgpool-de.html +4220 -0
  44. data/pgpool2/doc/pgpool-en.html +5738 -0
  45. data/pgpool2/doc/pgpool-fr.html +4118 -0
  46. data/pgpool2/doc/pgpool-ja.css +198 -0
  47. data/pgpool2/doc/pgpool-ja.html +11279 -0
  48. data/pgpool2/doc/pgpool-zh_cn.html +4445 -0
  49. data/pgpool2/doc/pgpool.css +280 -0
  50. data/pgpool2/doc/pgpool_remote_start +13 -0
  51. data/pgpool2/doc/recovery.conf.sample +117 -0
  52. data/pgpool2/doc/tutorial-en.html +707 -0
  53. data/pgpool2/doc/tutorial-ja.html +422 -0
  54. data/pgpool2/doc/tutorial-memqcache-en.html +325 -0
  55. data/pgpool2/doc/tutorial-memqcache-ja.html +370 -0
  56. data/pgpool2/doc/tutorial-memqcache-zh_cn.html +322 -0
  57. data/pgpool2/doc/tutorial-watchdog-en.html +306 -0
  58. data/pgpool2/doc/tutorial-watchdog-ja.html +343 -0
  59. data/pgpool2/doc/tutorial-watchdog-zh_cn.html +301 -0
  60. data/pgpool2/doc/tutorial-zh_cn.html +537 -0
  61. data/pgpool2/doc/watchdog.png +0 -0
  62. data/pgpool2/doc/wd-en.html +236 -0
  63. data/pgpool2/doc/wd-en.jpg +0 -0
  64. data/pgpool2/doc/wd-ja.html +219 -0
  65. data/pgpool2/doc/wd-ja.jpg +0 -0
  66. data/pgpool2/doc/wd-zh_cn.html +201 -0
  67. data/pgpool2/doc/where_to_send_queries.odg +0 -0
  68. data/pgpool2/doc/where_to_send_queries.pdf +0 -0
  69. data/pgpool2/general.m4 +166 -0
  70. data/pgpool2/getopt_long.c +200 -0
  71. data/pgpool2/getopt_long.h +44 -0
  72. data/pgpool2/install-sh +251 -0
  73. data/pgpool2/ltmain.sh +8406 -0
  74. data/pgpool2/m4/libtool.m4 +7360 -0
  75. data/pgpool2/m4/ltoptions.m4 +368 -0
  76. data/pgpool2/m4/ltsugar.m4 +123 -0
  77. data/pgpool2/m4/ltversion.m4 +23 -0
  78. data/pgpool2/m4/lt~obsolete.m4 +92 -0
  79. data/pgpool2/main.c +2971 -0
  80. data/pgpool2/md5.c +444 -0
  81. data/pgpool2/md5.h +28 -0
  82. data/pgpool2/missing +360 -0
  83. data/pgpool2/mkinstalldirs +40 -0
  84. data/pgpool2/parser/Makefile.am +50 -0
  85. data/pgpool2/parser/Makefile.in +559 -0
  86. data/pgpool2/parser/copyfuncs.c +3310 -0
  87. data/pgpool2/parser/gram.c +39100 -0
  88. data/pgpool2/parser/gram.h +940 -0
  89. data/pgpool2/parser/gram.y +13408 -0
  90. data/pgpool2/parser/gramparse.h +74 -0
  91. data/pgpool2/parser/keywords.c +32 -0
  92. data/pgpool2/parser/keywords.h +39 -0
  93. data/pgpool2/parser/kwlist.h +425 -0
  94. data/pgpool2/parser/kwlookup.c +88 -0
  95. data/pgpool2/parser/list.c +1156 -0
  96. data/pgpool2/parser/makefuncs.c +518 -0
  97. data/pgpool2/parser/makefuncs.h +83 -0
  98. data/pgpool2/parser/memnodes.h +79 -0
  99. data/pgpool2/parser/nodes.c +29 -0
  100. data/pgpool2/parser/nodes.h +609 -0
  101. data/pgpool2/parser/outfuncs.c +5790 -0
  102. data/pgpool2/parser/parsenodes.h +2615 -0
  103. data/pgpool2/parser/parser.c +262 -0
  104. data/pgpool2/parser/parser.h +46 -0
  105. data/pgpool2/parser/pg_class.h +158 -0
  106. data/pgpool2/parser/pg_config_manual.h +273 -0
  107. data/pgpool2/parser/pg_list.h +352 -0
  108. data/pgpool2/parser/pg_trigger.h +147 -0
  109. data/pgpool2/parser/pg_wchar.h +492 -0
  110. data/pgpool2/parser/pool_memory.c +342 -0
  111. data/pgpool2/parser/pool_memory.h +77 -0
  112. data/pgpool2/parser/pool_parser.h +222 -0
  113. data/pgpool2/parser/pool_string.c +121 -0
  114. data/pgpool2/parser/pool_string.h +37 -0
  115. data/pgpool2/parser/primnodes.h +1280 -0
  116. data/pgpool2/parser/scan.c +4094 -0
  117. data/pgpool2/parser/scan.l +1451 -0
  118. data/pgpool2/parser/scanner.h +120 -0
  119. data/pgpool2/parser/scansup.c +221 -0
  120. data/pgpool2/parser/scansup.h +28 -0
  121. data/pgpool2/parser/snprintf.c +1102 -0
  122. data/pgpool2/parser/stringinfo.c +294 -0
  123. data/pgpool2/parser/stringinfo.h +178 -0
  124. data/pgpool2/parser/value.c +78 -0
  125. data/pgpool2/parser/value.h +62 -0
  126. data/pgpool2/parser/wchar.c +2048 -0
  127. data/pgpool2/pcp.conf.sample +28 -0
  128. data/pgpool2/pcp/Makefile.am +40 -0
  129. data/pgpool2/pcp/Makefile.in +771 -0
  130. data/pgpool2/pcp/libpcp_ext.h +250 -0
  131. data/pgpool2/pcp/md5.c +444 -0
  132. data/pgpool2/pcp/md5.h +28 -0
  133. data/pgpool2/pcp/pcp.c +1652 -0
  134. data/pgpool2/pcp/pcp.h +61 -0
  135. data/pgpool2/pcp/pcp_attach_node.c +172 -0
  136. data/pgpool2/pcp/pcp_detach_node.c +185 -0
  137. data/pgpool2/pcp/pcp_error.c +87 -0
  138. data/pgpool2/pcp/pcp_node_count.c +160 -0
  139. data/pgpool2/pcp/pcp_node_info.c +198 -0
  140. data/pgpool2/pcp/pcp_pool_status.c +166 -0
  141. data/pgpool2/pcp/pcp_proc_count.c +166 -0
  142. data/pgpool2/pcp/pcp_proc_info.c +261 -0
  143. data/pgpool2/pcp/pcp_promote_node.c +185 -0
  144. data/pgpool2/pcp/pcp_recovery_node.c +172 -0
  145. data/pgpool2/pcp/pcp_stop_pgpool.c +179 -0
  146. data/pgpool2/pcp/pcp_stream.c +385 -0
  147. data/pgpool2/pcp/pcp_stream.h +52 -0
  148. data/pgpool2/pcp/pcp_systemdb_info.c +194 -0
  149. data/pgpool2/pcp/pcp_watchdog_info.c +211 -0
  150. data/pgpool2/pcp_child.c +1493 -0
  151. data/pgpool2/pg_md5.c +305 -0
  152. data/pgpool2/pgpool.8.in +121 -0
  153. data/pgpool2/pgpool.conf +553 -0
  154. data/pgpool2/pgpool.conf.sample +666 -0
  155. data/pgpool2/pgpool.conf.sample-master-slave +665 -0
  156. data/pgpool2/pgpool.conf.sample-replication +664 -0
  157. data/pgpool2/pgpool.conf.sample-stream +664 -0
  158. data/pgpool2/pgpool.spec +264 -0
  159. data/pgpool2/pgpool_adm/TODO +7 -0
  160. data/pgpool2/pgpool_adm/pgpool_adm--1.0.sql +85 -0
  161. data/pgpool2/pgpool_adm/pgpool_adm.c +558 -0
  162. data/pgpool2/pgpool_adm/pgpool_adm.control +5 -0
  163. data/pgpool2/pgpool_adm/pgpool_adm.h +46 -0
  164. data/pgpool2/pgpool_adm/pgpool_adm.sql.in +85 -0
  165. data/pgpool2/pool.h +655 -0
  166. data/pgpool2/pool_auth.c +1390 -0
  167. data/pgpool2/pool_config.c +5007 -0
  168. data/pgpool2/pool_config.h +284 -0
  169. data/pgpool2/pool_config.l +3281 -0
  170. data/pgpool2/pool_config_md5.c +29 -0
  171. data/pgpool2/pool_connection_pool.c +812 -0
  172. data/pgpool2/pool_error.c +242 -0
  173. data/pgpool2/pool_globals.c +27 -0
  174. data/pgpool2/pool_hba.c +1723 -0
  175. data/pgpool2/pool_hba.conf.sample +67 -0
  176. data/pgpool2/pool_ip.c +567 -0
  177. data/pgpool2/pool_ip.h +65 -0
  178. data/pgpool2/pool_ipc.h +38 -0
  179. data/pgpool2/pool_lobj.c +242 -0
  180. data/pgpool2/pool_lobj.h +32 -0
  181. data/pgpool2/pool_memqcache.c +3818 -0
  182. data/pgpool2/pool_memqcache.h +268 -0
  183. data/pgpool2/pool_params.c +163 -0
  184. data/pgpool2/pool_passwd.c +249 -0
  185. data/pgpool2/pool_passwd.h +41 -0
  186. data/pgpool2/pool_path.c +193 -0
  187. data/pgpool2/pool_path.h +81 -0
  188. data/pgpool2/pool_process_context.c +247 -0
  189. data/pgpool2/pool_process_context.h +62 -0
  190. data/pgpool2/pool_process_query.c +5001 -0
  191. data/pgpool2/pool_process_reporting.c +1671 -0
  192. data/pgpool2/pool_process_reporting.h +44 -0
  193. data/pgpool2/pool_proto2.c +671 -0
  194. data/pgpool2/pool_proto_modules.c +3524 -0
  195. data/pgpool2/pool_proto_modules.h +185 -0
  196. data/pgpool2/pool_query_cache.c +1020 -0
  197. data/pgpool2/pool_query_context.c +1871 -0
  198. data/pgpool2/pool_query_context.h +105 -0
  199. data/pgpool2/pool_relcache.c +284 -0
  200. data/pgpool2/pool_relcache.h +78 -0
  201. data/pgpool2/pool_rewrite_outfuncs.c +9060 -0
  202. data/pgpool2/pool_rewrite_query.c +715 -0
  203. data/pgpool2/pool_rewrite_query.h +192 -0
  204. data/pgpool2/pool_select_walker.c +1150 -0
  205. data/pgpool2/pool_select_walker.h +68 -0
  206. data/pgpool2/pool_sema.c +161 -0
  207. data/pgpool2/pool_session_context.c +952 -0
  208. data/pgpool2/pool_session_context.h +203 -0
  209. data/pgpool2/pool_shmem.c +185 -0
  210. data/pgpool2/pool_signal.c +158 -0
  211. data/pgpool2/pool_signal.h +61 -0
  212. data/pgpool2/pool_ssl.c +339 -0
  213. data/pgpool2/pool_stream.c +962 -0
  214. data/pgpool2/pool_stream.h +61 -0
  215. data/pgpool2/pool_system.c +659 -0
  216. data/pgpool2/pool_timestamp.c +1215 -0
  217. data/pgpool2/pool_timestamp.h +38 -0
  218. data/pgpool2/pool_type.h +171 -0
  219. data/pgpool2/pool_worker_child.c +384 -0
  220. data/pgpool2/ps_status.c +404 -0
  221. data/pgpool2/recovery.c +435 -0
  222. data/pgpool2/redhat/pgpool.conf.sample.patch +52 -0
  223. data/pgpool2/redhat/pgpool.init +201 -0
  224. data/pgpool2/redhat/pgpool.sysconfig +7 -0
  225. data/pgpool2/redhat/rpm_installer/basebackup-replication.sh +53 -0
  226. data/pgpool2/redhat/rpm_installer/basebackup-stream.sh +55 -0
  227. data/pgpool2/redhat/rpm_installer/config_for_script +17 -0
  228. data/pgpool2/redhat/rpm_installer/failover.sh +64 -0
  229. data/pgpool2/redhat/rpm_installer/getsources.sh +141 -0
  230. data/pgpool2/redhat/rpm_installer/install.sh +1363 -0
  231. data/pgpool2/redhat/rpm_installer/pgpool_recovery_pitr +47 -0
  232. data/pgpool2/redhat/rpm_installer/pgpool_remote_start +15 -0
  233. data/pgpool2/redhat/rpm_installer/recovery.conf +4 -0
  234. data/pgpool2/redhat/rpm_installer/uninstall.sh +57 -0
  235. data/pgpool2/sample/dist_def_pgbench.sql +73 -0
  236. data/pgpool2/sample/pgpool.pam +3 -0
  237. data/pgpool2/sample/pgpool_recovery +20 -0
  238. data/pgpool2/sample/pgpool_recovery_pitr +19 -0
  239. data/pgpool2/sample/pgpool_remote_start +13 -0
  240. data/pgpool2/sample/replicate_def_pgbench.sql +18 -0
  241. data/pgpool2/sql/insert_lock.sql +15 -0
  242. data/pgpool2/sql/pgpool-recovery/pgpool-recovery.c +280 -0
  243. data/pgpool2/sql/pgpool-recovery/pgpool-recovery.sql.in +19 -0
  244. data/pgpool2/sql/pgpool-recovery/pgpool_recovery--1.0.sql +24 -0
  245. data/pgpool2/sql/pgpool-recovery/pgpool_recovery.control +5 -0
  246. data/pgpool2/sql/pgpool-recovery/uninstall_pgpool-recovery.sql +3 -0
  247. data/pgpool2/sql/pgpool-regclass/pgpool-regclass.c +206 -0
  248. data/pgpool2/sql/pgpool-regclass/pgpool-regclass.sql.in +4 -0
  249. data/pgpool2/sql/pgpool-regclass/pgpool_regclass--1.0.sql +7 -0
  250. data/pgpool2/sql/pgpool-regclass/pgpool_regclass.control +5 -0
  251. data/pgpool2/sql/pgpool-regclass/uninstall_pgpool-regclass.sql +1 -0
  252. data/pgpool2/sql/system_db.sql +38 -0
  253. data/pgpool2/strlcpy.c +85 -0
  254. data/pgpool2/test/C/test_extended.c +98 -0
  255. data/pgpool2/test/jdbc/.cvsignore +2 -0
  256. data/pgpool2/test/jdbc/AutoCommitTest.java +45 -0
  257. data/pgpool2/test/jdbc/BatchTest.java +55 -0
  258. data/pgpool2/test/jdbc/ColumnTest.java +60 -0
  259. data/pgpool2/test/jdbc/CreateTempTableTest.java +48 -0
  260. data/pgpool2/test/jdbc/InsertTest.java +34 -0
  261. data/pgpool2/test/jdbc/LockTest.java +36 -0
  262. data/pgpool2/test/jdbc/PgpoolTest.java +75 -0
  263. data/pgpool2/test/jdbc/README.euc_jp +73 -0
  264. data/pgpool2/test/jdbc/RunTest.java +83 -0
  265. data/pgpool2/test/jdbc/SelectTest.java +37 -0
  266. data/pgpool2/test/jdbc/UpdateTest.java +32 -0
  267. data/pgpool2/test/jdbc/expected/CreateTempTable +1 -0
  268. data/pgpool2/test/jdbc/expected/autocommit +10 -0
  269. data/pgpool2/test/jdbc/expected/batch +1 -0
  270. data/pgpool2/test/jdbc/expected/column +100 -0
  271. data/pgpool2/test/jdbc/expected/insert +1 -0
  272. data/pgpool2/test/jdbc/expected/lock +100 -0
  273. data/pgpool2/test/jdbc/expected/select +2 -0
  274. data/pgpool2/test/jdbc/expected/update +1 -0
  275. data/pgpool2/test/jdbc/pgpool.properties +7 -0
  276. data/pgpool2/test/jdbc/prepare.sql +54 -0
  277. data/pgpool2/test/jdbc/run.sh +6 -0
  278. data/pgpool2/test/parser/.cvsignore +6 -0
  279. data/pgpool2/test/parser/README +32 -0
  280. data/pgpool2/test/parser/expected/copy.out +17 -0
  281. data/pgpool2/test/parser/expected/create.out +64 -0
  282. data/pgpool2/test/parser/expected/cursor.out +37 -0
  283. data/pgpool2/test/parser/expected/delete.out +10 -0
  284. data/pgpool2/test/parser/expected/drop.out +12 -0
  285. data/pgpool2/test/parser/expected/insert.out +13 -0
  286. data/pgpool2/test/parser/expected/misc.out +28 -0
  287. data/pgpool2/test/parser/expected/prepare.out +4 -0
  288. data/pgpool2/test/parser/expected/privileges.out +31 -0
  289. data/pgpool2/test/parser/expected/scanner.out +30 -0
  290. data/pgpool2/test/parser/expected/select.out +89 -0
  291. data/pgpool2/test/parser/expected/transaction.out +38 -0
  292. data/pgpool2/test/parser/expected/update.out +11 -0
  293. data/pgpool2/test/parser/expected/v84.out +37 -0
  294. data/pgpool2/test/parser/expected/v90.out +25 -0
  295. data/pgpool2/test/parser/expected/var.out +22 -0
  296. data/pgpool2/test/parser/input/alter.sql +2 -0
  297. data/pgpool2/test/parser/input/copy.sql +17 -0
  298. data/pgpool2/test/parser/input/create.sql +64 -0
  299. data/pgpool2/test/parser/input/cursor.sql +37 -0
  300. data/pgpool2/test/parser/input/delete.sql +10 -0
  301. data/pgpool2/test/parser/input/drop.sql +12 -0
  302. data/pgpool2/test/parser/input/insert.sql +13 -0
  303. data/pgpool2/test/parser/input/misc.sql +28 -0
  304. data/pgpool2/test/parser/input/prepare.sql +4 -0
  305. data/pgpool2/test/parser/input/privileges.sql +31 -0
  306. data/pgpool2/test/parser/input/scanner.sql +34 -0
  307. data/pgpool2/test/parser/input/select.sql +89 -0
  308. data/pgpool2/test/parser/input/transaction.sql +38 -0
  309. data/pgpool2/test/parser/input/update.sql +11 -0
  310. data/pgpool2/test/parser/input/v84.sql +37 -0
  311. data/pgpool2/test/parser/input/v90.sql +38 -0
  312. data/pgpool2/test/parser/input/var.sql +22 -0
  313. data/pgpool2/test/parser/main.c +96 -0
  314. data/pgpool2/test/parser/parse_schedule +16 -0
  315. data/pgpool2/test/parser/pool.h +13 -0
  316. data/pgpool2/test/parser/run-test +62 -0
  317. data/pgpool2/test/pdo-test/README.euc_jp +58 -0
  318. data/pgpool2/test/pdo-test/SQLlist/test1.sql +3 -0
  319. data/pgpool2/test/pdo-test/SQLlist/test2.sql +3 -0
  320. data/pgpool2/test/pdo-test/collections.inc +11 -0
  321. data/pgpool2/test/pdo-test/def.inc +7 -0
  322. data/pgpool2/test/pdo-test/log.txt +0 -0
  323. data/pgpool2/test/pdo-test/mod/database.inc +36 -0
  324. data/pgpool2/test/pdo-test/mod/def.inc +0 -0
  325. data/pgpool2/test/pdo-test/mod/errorhandler.inc +27 -0
  326. data/pgpool2/test/pdo-test/pdotest.php +11 -0
  327. data/pgpool2/test/pdo-test/regsql.inc +56 -0
  328. data/pgpool2/test/pgpool_setup +898 -0
  329. data/pgpool2/test/regression/README +39 -0
  330. data/pgpool2/test/regression/clean.sh +21 -0
  331. data/pgpool2/test/regression/libs.sh +16 -0
  332. data/pgpool2/test/regression/regress.sh +166 -0
  333. data/pgpool2/test/regression/tests/001.load_balance/test.sh +128 -0
  334. data/pgpool2/test/regression/tests/002.native_replication/PgTester.java +47 -0
  335. data/pgpool2/test/regression/tests/002.native_replication/create.sql +6 -0
  336. data/pgpool2/test/regression/tests/002.native_replication/test.sh +71 -0
  337. data/pgpool2/test/regression/tests/003.failover/expected.r +6 -0
  338. data/pgpool2/test/regression/tests/003.failover/expected.s +6 -0
  339. data/pgpool2/test/regression/tests/003.failover/test.sh +45 -0
  340. data/pgpool2/test/regression/tests/004.watchdog/master.conf +12 -0
  341. data/pgpool2/test/regression/tests/004.watchdog/standby.conf +19 -0
  342. data/pgpool2/test/regression/tests/004.watchdog/test.sh +52 -0
  343. data/pgpool2/test/regression/tests/050.bug58/test.sh +50 -0
  344. data/pgpool2/test/regression/tests/051.bug60/bug.sql +12 -0
  345. data/pgpool2/test/regression/tests/051.bug60/database-clean.sql +6 -0
  346. data/pgpool2/test/regression/tests/051.bug60/database-setup.sql +28 -0
  347. data/pgpool2/test/regression/tests/051.bug60/test.sh +79 -0
  348. data/pgpool2/test/regression/tests/052.do_query/test.sh +44 -0
  349. data/pgpool2/test/regression/tests/053.insert_lock_hangs/test.sh +81 -0
  350. data/pgpool2/test/regression/tests/054.postgres_fdw/test.sh +67 -0
  351. data/pgpool2/test/regression/tests/055.backend_all_down/test.sh +52 -0
  352. data/pgpool2/test/regression/tests/056.bug63/jdbctest2.java +66 -0
  353. data/pgpool2/test/regression/tests/056.bug63/test.sh +47 -0
  354. data/pgpool2/test/regression/tests/057.bug61/test.sh +40 -0
  355. data/pgpool2/test/regression/tests/058.bug68/jdbctest3.java +45 -0
  356. data/pgpool2/test/regression/tests/058.bug68/test.sh +47 -0
  357. data/pgpool2/test/timestamp/expected/insert.out +16 -0
  358. data/pgpool2/test/timestamp/expected/misc.out +3 -0
  359. data/pgpool2/test/timestamp/expected/update.out +6 -0
  360. data/pgpool2/test/timestamp/input/insert.sql +16 -0
  361. data/pgpool2/test/timestamp/input/misc.sql +3 -0
  362. data/pgpool2/test/timestamp/input/update.sql +6 -0
  363. data/pgpool2/test/timestamp/main.c +129 -0
  364. data/pgpool2/test/timestamp/parse_schedule +3 -0
  365. data/pgpool2/test/timestamp/run-test +69 -0
  366. data/pgpool2/version.h +1 -0
  367. data/pgpool2/watchdog/Makefile.am +17 -0
  368. data/pgpool2/watchdog/Makefile.in +505 -0
  369. data/pgpool2/watchdog/test/stab.c +266 -0
  370. data/pgpool2/watchdog/test/test.c +85 -0
  371. data/pgpool2/watchdog/test/wd_child_t.c +87 -0
  372. data/pgpool2/watchdog/test/wd_lifecheck_t.c +87 -0
  373. data/pgpool2/watchdog/test/wd_packet_t.c +87 -0
  374. data/pgpool2/watchdog/test/wd_ping_t.c +20 -0
  375. data/pgpool2/watchdog/watchdog.c +408 -0
  376. data/pgpool2/watchdog/watchdog.h +209 -0
  377. data/pgpool2/watchdog/wd_child.c +444 -0
  378. data/pgpool2/watchdog/wd_ext.h +123 -0
  379. data/pgpool2/watchdog/wd_heartbeat.c +577 -0
  380. data/pgpool2/watchdog/wd_if.c +216 -0
  381. data/pgpool2/watchdog/wd_init.c +126 -0
  382. data/pgpool2/watchdog/wd_interlock.c +347 -0
  383. data/pgpool2/watchdog/wd_lifecheck.c +512 -0
  384. data/pgpool2/watchdog/wd_list.c +429 -0
  385. data/pgpool2/watchdog/wd_packet.c +1159 -0
  386. data/pgpool2/watchdog/wd_ping.c +330 -0
  387. data/pgpool2/ylwrap +223 -0
  388. data/pgsql/presto_client.py +346 -0
  389. data/pgsql/prestogres.py +156 -0
  390. data/pgsql/setup_functions.sql +21 -0
  391. data/pgsql/setup_language.sql +3 -0
  392. data/prestogres.gemspec +23 -0
  393. metadata +496 -0
@@ -0,0 +1,284 @@
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-2013 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_config.h.: pool_config.l related header file
23
+ *
24
+ */
25
+
26
+ #ifndef POOL_CONFIG_H
27
+ #define POOL_CONFIG_H
28
+
29
+ /*
30
+ * watchdog
31
+ */
32
+ #include "watchdog/watchdog.h"
33
+
34
+ /*
35
+ * Master/slave sub mode
36
+ */
37
+ #define MODE_STREAMREP "stream" /* Streaming Replication */
38
+ #define MODE_SLONY "slony" /* Slony-I */
39
+
40
+ /*
41
+ * watchdog lifecheck method
42
+ */
43
+ #define MODE_HEARTBEAT "heartbeat"
44
+ #define MODE_QUERY "query"
45
+
46
+ /*
47
+ * Regex support in white and black list function
48
+ */
49
+ #include <regex.h>
50
+ #define BLACKLIST 0
51
+ #define WHITELIST 1
52
+ #define PATTERN_ARR_SIZE 16 /* Default length of regex array: 16 patterns */
53
+ typedef struct {
54
+ char *pattern;
55
+ int type;
56
+ int flag;
57
+ regex_t regexv;
58
+ } RegPattern;
59
+
60
+ /*
61
+ * Flags for backendN_flag
62
+ */
63
+ #define POOL_FAILOVER 0x0001 /* allow or disallow failover */
64
+ #define POOL_DISALLOW_TO_FAILOVER(x) ((unsigned short)(x) & POOL_FAILOVER)
65
+ #define POOL_ALLOW_TO_FAILOVER(x) (!(POOL_DISALLOW_TO_FAILOVER(x)))
66
+
67
+ /*
68
+ * configuration parameters
69
+ */
70
+ typedef struct {
71
+ char *listen_addresses; /* hostnames/IP addresses to listen on */
72
+ int port; /* port # to bind */
73
+ int pcp_port; /* PCP port # to bind */
74
+ char *socket_dir; /* pgpool socket directory */
75
+ char *pcp_socket_dir; /* PCP socket directory */
76
+ int pcp_timeout; /* PCP timeout for an idle client */
77
+ int num_init_children; /* # of children initially pre-forked */
78
+ int child_life_time; /* if idle for this seconds, child exits */
79
+ int connection_life_time; /* if idle for this seconds, connection closes */
80
+ int child_max_connections; /* if max_connections received, child exits */
81
+ int client_idle_limit; /* If client_idle_limit is n (n > 0), the client is forced to be
82
+ disconnected after n seconds idle */
83
+ int authentication_timeout; /* maximum time in seconds to complete client authentication */
84
+ int max_pool; /* max # of connection pool per child */
85
+ char *logdir; /* logging directory */
86
+ char *log_destination; /* log destination: stderr or syslog */
87
+ int syslog_facility; /* syslog facility: LOCAL0, LOCAL1, ... */
88
+ char *syslog_ident; /* syslog ident string: pgpool */
89
+ char *pid_file_name; /* pid file name */
90
+ char *backend_socket_dir; /* Unix domain socket directory for the PostgreSQL server */
91
+ int replication_mode; /* replication mode */
92
+
93
+ int log_connections; /* 0:false, 1:true - logs incoming connections */
94
+ int log_hostname; /* 0:false, 1:true - resolve hostname */
95
+ int enable_pool_hba; /* 0:false, 1:true - enables pool_hba.conf file authentication */
96
+ char *pool_passwd; /* pool_passwd file name. "" disables pool_passwd */
97
+
98
+ char *presto_server; /* Presto default server address, and optionally :port */
99
+ char *presto_catalog; /* Presto default catalog name */
100
+ char *presto_schema; /* Presto default schema name */
101
+ char *presto_external_auth_prog; /* Presto default external authentication program */
102
+
103
+ int load_balance_mode; /* load balance mode */
104
+
105
+ int replication_stop_on_mismatch; /* if there's a data mismatch between master and secondary
106
+ * start degeneration to stop replication mode
107
+ */
108
+
109
+ /* If there's a disagreement with the number of affected tuples in
110
+ * UPDATE/DELETE, then degenerate the node which is most likely
111
+ * "minority". # If false, just abort the transaction to keep the
112
+ * consistency.*/
113
+ int failover_if_affected_tuples_mismatch;
114
+
115
+ int replicate_select; /* if non 0, replicate SELECT statement when load balancing is disabled. */
116
+ char **reset_query_list; /* comma separated list of queries to be issued at the end of session */
117
+ char **white_function_list; /* list of functions with no side effects */
118
+ char **black_function_list; /* list of functions with side effects */
119
+ int print_timestamp; /* if non 0, print time stamp to each log line */
120
+ int master_slave_mode; /* if non 0, operate in master/slave mode */
121
+ char *master_slave_sub_mode; /* either "slony" or "stream" */
122
+ unsigned long long int delay_threshold; /* If the standby server delays more than delay_threshold,
123
+ * any query goes to the primary only. The unit is in bytes.
124
+ * 0 disables the check. Default is 0.
125
+ * Note that health_check_period required to be greater than 0
126
+ * to enable the functionality. */
127
+ char *log_standby_delay; /* how to log standby lag */
128
+ int connection_cache; /* if non 0, cache connection pool */
129
+ int health_check_timeout; /* health check timeout */
130
+ int health_check_period; /* health check period */
131
+ char *health_check_user; /* PostgreSQL user name for health check */
132
+ char *health_check_password; /* password for health check username */
133
+ int health_check_max_retries; /* health check max retries */
134
+ int health_check_retry_delay; /* amount of time to wait between retries */
135
+ int sr_check_period; /* streaming replication check period */
136
+ char *sr_check_user; /* PostgreSQL user name streaming replication check */
137
+ char *sr_check_password; /* password for sr_check_user */
138
+ char *failover_command; /* execute command when failover happens */
139
+ char *follow_master_command; /* execute command when failover is ended */
140
+ char *failback_command; /* execute command when failback happens */
141
+
142
+ /*
143
+ * If true, trigger fail over when writing to the backend
144
+ * communication socket fails. This is the same behavior of
145
+ * pgpool-II 2.2.x or earlier. If set to false, pgpool will report
146
+ * an error and disconnect the session.
147
+ */
148
+ int fail_over_on_backend_error;
149
+
150
+ char *recovery_user; /* PostgreSQL user name for online recovery */
151
+ char *recovery_password; /* PostgreSQL user password for online recovery */
152
+ char *recovery_1st_stage_command; /* Online recovery command in 1st stage */
153
+ char *recovery_2nd_stage_command; /* Online recovery command in 2nd stage */
154
+ int recovery_timeout; /* maximum time in seconds to wait for remote start-up */
155
+ int search_primary_node_timeout; /* maximum time in seconds to search for new primary
156
+ * node after failover */
157
+ int client_idle_limit_in_recovery; /* If > 0, the client is forced to be
158
+ * disconnected after n seconds idle
159
+ * This parameter is only valid while in recovery 2nd stage */
160
+ int insert_lock; /* if non 0, automatically lock table with INSERT to keep SERIAL
161
+ data consistency */
162
+ int ignore_leading_white_space; /* ignore leading white spaces of each query */
163
+ int log_statement; /* 0:false, 1: true - logs all SQL statements */
164
+ int log_per_node_statement; /* 0:false, 1: true - logs per node detailed SQL statements */
165
+
166
+ int parallel_mode; /* if non 0, run in parallel query mode */
167
+
168
+ int enable_query_cache; /* if non 0, use query cache. 0 by default */
169
+
170
+ char *pgpool2_hostname; /* pgpool2 hostname */
171
+ char *system_db_hostname; /* system DB hostname */
172
+ int system_db_port; /* system DB port number */
173
+ char *system_db_dbname; /* system DB name */
174
+ char *system_db_schema; /* system DB schema name */
175
+ char *system_db_user; /* user name to access system DB */
176
+ char *system_db_password; /* password to access system DB */
177
+
178
+ char *lobj_lock_table; /* table name to lock for rewriting lo_creat */
179
+
180
+ int debug_level; /* debug message verbosity level.
181
+ * 0: no message, 1 <= : more verbose
182
+ */
183
+
184
+ BackendDesc *backend_desc; /* PostgreSQL Server description. Placed on shared memory */
185
+
186
+ LOAD_BALANCE_STATUS load_balance_status[MAX_NUM_BACKENDS]; /* to remember which DB node is selected for load balancing */
187
+
188
+ /* followings do not exist in the configuration file */
189
+ int num_reset_queries; /* number of queries in reset_query_list */
190
+ int num_white_function_list; /* number of functions in white_function_list */
191
+ int num_black_function_list; /* number of functions in black_function_list */
192
+ int num_white_memqcache_table_list; /* number of functions in white_memqcache_table_list */
193
+ int num_black_memqcache_table_list; /* number of functions in black_memqcache_table_list */
194
+ int logsyslog; /* flag used to start logging to syslog */
195
+
196
+ /* ssl configuration */
197
+ int ssl; /* if non 0, activate ssl support (frontend+backend) */
198
+ char *ssl_cert; /* path to ssl certificate (frontend only) */
199
+ char *ssl_key; /* path to ssl key (frontend only) */
200
+ char *ssl_ca_cert; /* path to root (CA) certificate */
201
+ char *ssl_ca_cert_dir; /* path to directory containing CA certificates */
202
+
203
+ time_t relcache_expire; /* relation cache life time in seconds */
204
+ int relcache_size; /* number of relation cache life entry */
205
+ int check_temp_table; /* enable temporary table check */
206
+
207
+ /* followings are for regex support and do not exist in the configuration file */
208
+ RegPattern *lists_patterns; /* Precompiled regex patterns for black/white lists */
209
+ int pattc; /* number of regexp pattern */
210
+ int current_pattern_size; /* size of the regex pattern array */
211
+
212
+ int memory_cache_enabled; /* if true, use the memory cache functionality, false by default */
213
+ char *memqcache_method; /* Cache store method. Either 'shmem'(shared memory) or 'memcached'. 'shmem' by default */
214
+ char *memqcache_memcached_host; /* Memcached host name. Mandatory if memqcache_method=memcached. */
215
+ int memqcache_memcached_port; /* Memcached port number. Mandatory if memqcache_method=memcached. */
216
+ int memqcache_total_size; /* Total memory size in bytes for storing memory cache. Mandatory if memqcache_method=shmem. */
217
+ int memqcache_max_num_cache; /* Total number of cache entries. Mandatory if memqcache_method=shmem. */
218
+ int memqcache_expire; /* Memory cache entry life time specified in seconds. 60 by default. */
219
+ int memqcache_auto_cache_invalidation; /* If true, invalidation of query cache is triggered by corresponding */
220
+ /* DDL/DML/DCL(and memqcache_expire). If false, it is only triggered */
221
+ /* by memqcache_expire. True by default. */
222
+ int memqcache_maxcache; /* Maximum SELECT result size in bytes. */
223
+ int memqcache_cache_block_size; /* Cache block size in bytes. 8192 by default */
224
+ char *memqcache_oiddir; /* Temporary work directory to record table oids */
225
+ char **white_memqcache_table_list; /* list of tables to memqcache */
226
+ char **black_memqcache_table_list; /* list of tables not to memqcache */
227
+
228
+ RegPattern *lists_memqcache_table_patterns; /* Precompiled regex patterns for black/white lists */
229
+ int memqcache_table_pattc; /* number of regexp pattern */
230
+ int current_memqcache_table_pattern_size; /* size of the regex pattern array */
231
+
232
+ /*
233
+ * add for watchdog
234
+ */
235
+ int use_watchdog; /* if non 0, use watchdog */
236
+ char *wd_lifecheck_method; /* method of lifecheck. 'heartbeat' or 'query' */
237
+ int clear_memqcache_on_escalation; /* if no 0, clear query cache on shmem when escalating */
238
+ char *wd_escalation_command; /* Executes this command at escalation on new active pgpool.*/
239
+ char *wd_hostname; /* watchdog hostname */
240
+ int wd_port; /* watchdog port */
241
+ WdDesc * other_wd; /* watchdog lists */
242
+ char * trusted_servers; /* icmp reachable server list (A,B,C) */
243
+ char * delegate_IP; /* delegate IP address */
244
+ int wd_interval; /* lifecheck interval (sec) */
245
+ char *wd_authkey; /* Authentication key for watchdog communication */
246
+ char * ping_path; /* path to ping command */
247
+ char * ifconfig_path; /* path to ifconfig command */
248
+ char * if_up_cmd; /* ifup command */
249
+ char * if_down_cmd; /* ifdown command */
250
+ char * arping_path; /* path to arping command */
251
+ char * arping_cmd; /* arping command */
252
+ int wd_life_point; /* life point (retry times at lifecheck) */
253
+ char *wd_lifecheck_query; /* lifecheck query */
254
+ char *wd_lifecheck_dbname; /* Database name connected for lifecheck */
255
+ char *wd_lifecheck_user; /* PostgreSQL user name for watchdog */
256
+ char *wd_lifecheck_password; /* password for watchdog user */
257
+ int wd_heartbeat_port; /* Port number for heartbeat lifecheck */
258
+ int wd_heartbeat_keepalive; /* Interval time of sending heartbeat signal (sec) */
259
+ int wd_heartbeat_deadtime; /* Deadtime interval for heartbeat signal (sec) */
260
+ WdHbIf hb_if[WD_MAX_IF_NUM]; /* interface devices */
261
+ int num_hb_if; /* number of interface devices */
262
+ } POOL_CONFIG;
263
+
264
+ typedef enum {
265
+ INIT_CONFIG = 1, /* 0x01 */
266
+ RELOAD_CONFIG = 2 /* 0x02 */
267
+ } POOL_CONFIG_CONTEXT;
268
+
269
+ extern POOL_CONFIG *pool_config; /* configuration values */
270
+
271
+ extern int pool_init_config(void);
272
+ extern int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context);
273
+ extern int eval_logical(char *str);
274
+ extern char *pool_flag_to_str(unsigned short flag);
275
+
276
+ /* method use for syslog support */
277
+ extern int set_syslog_facility (char *);
278
+
279
+ /* methods used for regexp support */
280
+ extern int add_regex_pattern(char *type, char *s);
281
+ extern int growFunctionPatternArray(RegPattern item);
282
+ extern int growMemqcacheTablePatternArray(RegPattern item);
283
+
284
+ #endif /* POOL_CONFIG_H */
@@ -0,0 +1,3281 @@
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-2013 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_config.l: read configuration file
23
+ *
24
+ */
25
+
26
+ %{
27
+
28
+ #include "pool.h"
29
+ #include "pool_config.h"
30
+
31
+ #include <stdio.h>
32
+ #include <stdlib.h>
33
+ #include <string.h>
34
+
35
+ #define CHECK_CONTEXT(mask, context) ((mask) & (context))
36
+
37
+ /* to shut off compiler warnings */
38
+ int yylex(void);
39
+
40
+ POOL_CONFIG *pool_config; /* configuration values */
41
+ POOL_SYSTEMDB_CONNECTION_POOL *system_db_info;
42
+ static unsigned Lineno;
43
+ static char *default_reset_query_list[] = {"ABORT", "DISCARD ALL"};
44
+ static char *default_black_function_list[] = {"nextval", "setval"};
45
+
46
+ typedef enum {
47
+ POOL_KEY = 1,
48
+ POOL_INTEGER,
49
+ POOL_REAL,
50
+ POOL_STRING,
51
+ POOL_UNQUOTED_STRING,
52
+ POOL_EQUALS,
53
+ POOL_EOL,
54
+ POOL_PARSE_ERROR
55
+ } POOL_TOKEN;
56
+
57
+ static char *extract_string(char *value, POOL_TOKEN token);
58
+ static char **extract_string_tokens(char *str, char *delim, int *n);
59
+ static void clear_host_entry(int slot);
60
+
61
+ %}
62
+
63
+ %option 8bit
64
+ %option never-interactive
65
+ %option nounput
66
+ %option noyywrap
67
+
68
+ SIGN ("-"|"+")
69
+ DIGIT [0-9]
70
+ HEXDIGIT [0-9a-fA-F]
71
+
72
+ INTEGER {SIGN}?({DIGIT}+|0x{HEXDIGIT}+)
73
+
74
+ EXPONENT [Ee]{SIGN}?{DIGIT}+
75
+ REAL {SIGN}?{DIGIT}*"."{DIGIT}*{EXPONENT}?
76
+
77
+ LETTER [A-Za-z_\200-\377]
78
+ LETTER_OR_DIGIT [A-Za-z_0-9\200-\377]
79
+
80
+ KEY {LETTER}{LETTER_OR_DIGIT}*
81
+
82
+ UNQUOTED_STRING {LETTER}({LETTER_OR_DIGIT}|[-._:/])*
83
+ STRING \'([^'\n]|\\.)*\'
84
+
85
+ %%
86
+
87
+ \n Lineno++; return POOL_EOL;
88
+ [ \t\r]+ /* eat whitespace */
89
+ #.*$ /* eat comment */
90
+
91
+ {KEY} return POOL_KEY;
92
+ {STRING} return POOL_STRING;
93
+ {UNQUOTED_STRING} return POOL_UNQUOTED_STRING;
94
+ {INTEGER} return POOL_INTEGER;
95
+ {REAL} return POOL_REAL;
96
+ = return POOL_EQUALS;
97
+
98
+ . return POOL_PARSE_ERROR;
99
+
100
+ %%
101
+
102
+ int pool_init_config(void)
103
+ {
104
+ int res;
105
+ static char localhostname[256];
106
+ int i;
107
+
108
+ pool_config = malloc(sizeof(POOL_CONFIG));
109
+ if (pool_config == NULL)
110
+ {
111
+ pool_error("failed to allocate pool_config");
112
+ return(-1);
113
+ }
114
+
115
+ memset(pool_config, 0, sizeof(POOL_CONFIG));
116
+
117
+ #ifndef POOL_PRIVATE
118
+ pool_config->backend_desc = pool_shared_memory_create(sizeof(BackendDesc));
119
+ if (pool_config->backend_desc == NULL)
120
+ {
121
+ pool_error("failed to allocate pool_config->backend_desc");
122
+ return -1;
123
+ }
124
+ #else
125
+ pool_config->backend_desc = malloc(sizeof(BackendDesc));
126
+ if (pool_config->backend_desc == NULL)
127
+ {
128
+ pool_error("failed to allocate pool_config->backend_desc");
129
+ return -1;
130
+ }
131
+ #endif
132
+
133
+ /*
134
+ * add for watchdog
135
+ */
136
+ pool_config->other_wd = malloc(sizeof(WdDesc));
137
+ if (pool_config->other_wd == NULL)
138
+ {
139
+ pool_error("failed to allocate pool_config->cwother_wd");
140
+ return -1;
141
+ }
142
+ memset(pool_config->other_wd, 0, sizeof(WdDesc));
143
+
144
+ /* set hardcoded default values */
145
+ pool_config->listen_addresses = "localhost";
146
+ pool_config->port = 9999;
147
+ pool_config->pcp_port = 9898;
148
+ pool_config->socket_dir = DEFAULT_SOCKET_DIR;
149
+ pool_config->pcp_socket_dir = DEFAULT_SOCKET_DIR;
150
+ pool_config->backend_socket_dir = NULL;
151
+ pool_config->pcp_timeout = 10;
152
+ pool_config->num_init_children = 32;
153
+ pool_config->max_pool = 4;
154
+ pool_config->child_life_time = 300;
155
+ pool_config->client_idle_limit = 0;
156
+ pool_config->connection_life_time = 0;
157
+ pool_config->child_max_connections = 0;
158
+ pool_config->authentication_timeout = 60;
159
+ pool_config->logdir = DEFAULT_LOGDIR;
160
+ pool_config->logsyslog = 0;
161
+ pool_config->log_destination = "stderr";
162
+ pool_config->syslog_facility = LOG_LOCAL0;
163
+ pool_config->syslog_ident = "pgpool";
164
+ pool_config->pid_file_name = DEFAULT_PID_FILE_NAME;
165
+ pool_config->log_statement = 0;
166
+ pool_config->log_per_node_statement = 0;
167
+ pool_config->log_connections = 0;
168
+ pool_config->log_hostname = 0;
169
+ pool_config->enable_pool_hba = 0;
170
+ pool_config->pool_passwd = "pool_passwd";
171
+
172
+ pool_config->presto_server = "";
173
+ pool_config->presto_catalog = "";
174
+ pool_config->presto_schema = "default";
175
+ pool_config->presto_external_auth_prog = NULL;
176
+
177
+ pool_config->replication_mode = 0;
178
+ pool_config->load_balance_mode = 0;
179
+ pool_config->replication_stop_on_mismatch = 0;
180
+ pool_config->failover_if_affected_tuples_mismatch = 0;
181
+ pool_config->replicate_select = 0;
182
+ pool_config->reset_query_list = default_reset_query_list;
183
+ pool_config->num_reset_queries = sizeof(default_reset_query_list)/sizeof(char *);
184
+ pool_config->white_function_list = NULL;
185
+ pool_config->num_white_function_list = 0;
186
+ pool_config->black_function_list = default_black_function_list;
187
+ pool_config->num_black_function_list = sizeof(default_black_function_list)/sizeof(char *);
188
+ pool_config->print_timestamp = 1;
189
+ pool_config->master_slave_mode = 0;
190
+ pool_config->master_slave_sub_mode = "slony";
191
+ pool_config->delay_threshold = 0;
192
+ pool_config->log_standby_delay = "none";
193
+ pool_config->connection_cache = 1;
194
+ pool_config->health_check_timeout = 20;
195
+ pool_config->health_check_period = 0;
196
+ pool_config->health_check_user = "nobody";
197
+ pool_config->health_check_password = "";
198
+ pool_config->health_check_max_retries = 0;
199
+ pool_config->health_check_retry_delay = 1;
200
+ pool_config->sr_check_period = 0;
201
+ pool_config->sr_check_user = "nobody";
202
+ pool_config->sr_check_password = "";
203
+ pool_config->failover_command = "";
204
+ pool_config->follow_master_command = "";
205
+ pool_config->failback_command = "";
206
+ pool_config->fail_over_on_backend_error = 1;
207
+ pool_config->insert_lock = 1;
208
+ pool_config->ignore_leading_white_space = 1;
209
+ pool_config->parallel_mode = 0;
210
+ pool_config->enable_query_cache = 0;
211
+ pool_config->system_db_hostname = "localhost";
212
+ pool_config->system_db_port = 5432;
213
+ pool_config->system_db_dbname = "pgpool";
214
+ pool_config->system_db_schema = "pgpool_catalog";
215
+ pool_config->system_db_user = "pgpool";
216
+ pool_config->system_db_password = "";
217
+ pool_config->backend_desc->num_backends = 0;
218
+ pool_config->recovery_user = "";
219
+ pool_config->recovery_password = "";
220
+ pool_config->recovery_1st_stage_command = "";
221
+ pool_config->recovery_2nd_stage_command = "";
222
+ pool_config->recovery_timeout = 90;
223
+ pool_config->search_primary_node_timeout = 10;
224
+ pool_config->client_idle_limit_in_recovery = 0;
225
+ pool_config->lobj_lock_table = "";
226
+ pool_config->ssl = 0;
227
+ pool_config->ssl_cert = "";
228
+ pool_config->ssl_key = "";
229
+ pool_config->ssl_ca_cert = "";
230
+ pool_config->ssl_ca_cert_dir = "";
231
+ pool_config->debug_level = 0;
232
+ pool_config->relcache_expire = 0;
233
+ pool_config->relcache_size = 256;
234
+ pool_config->check_temp_table = 1;
235
+ pool_config->lists_patterns = NULL;
236
+ pool_config->pattc = 0;
237
+ pool_config->current_pattern_size = 0;
238
+ /*
239
+ * add for watchdog
240
+ */
241
+ pool_config->use_watchdog = 0;
242
+ pool_config->wd_lifecheck_method = MODE_HEARTBEAT;
243
+ pool_config->clear_memqcache_on_escalation = 1;
244
+ pool_config->wd_escalation_command = "";
245
+ pool_config->trusted_servers = "";
246
+ pool_config->delegate_IP = "";
247
+ res = gethostname(localhostname,sizeof(localhostname));
248
+ if(res !=0 )
249
+ {
250
+ pool_debug("failed to get this hostname");
251
+ }
252
+ pool_config->wd_hostname = localhostname;
253
+ pool_config->wd_port = 9000;
254
+ pool_config->other_wd->num_wd = 0;
255
+ pool_config->wd_interval = 10;
256
+ pool_config->wd_authkey = "";
257
+ pool_config->ping_path = "/bin";
258
+ pool_config->ifconfig_path = "/sbin";
259
+ pool_config->if_up_cmd = "ifconfig eth0:0 inet $_IP_$ netmask 255.255.255.0";
260
+ pool_config->if_down_cmd = "ifconfig eth0:0 down";
261
+ pool_config->arping_path = "/usr/sbin";
262
+ pool_config->arping_cmd = "arping -U $_IP_$ -w 1";
263
+ pool_config->wd_life_point = 3;
264
+ pool_config->wd_lifecheck_query = "SELECT 1";
265
+ pool_config->wd_lifecheck_dbname = "template1";
266
+ pool_config->wd_lifecheck_user = "nobody";
267
+ pool_config->wd_lifecheck_password = "";
268
+ pool_config->wd_heartbeat_port = 9694;
269
+ pool_config->wd_heartbeat_keepalive = 2;
270
+ pool_config->wd_heartbeat_deadtime = 30;
271
+ pool_config->num_hb_if = 0;
272
+
273
+ pool_config->memory_cache_enabled = 0;
274
+ pool_config->memqcache_method = "shmem";
275
+ pool_config->memqcache_memcached_host = "localhost";
276
+ pool_config->memqcache_memcached_port = 11211;
277
+ pool_config->memqcache_total_size = 67108864;
278
+ pool_config->memqcache_max_num_cache = 1000000;
279
+ pool_config->memqcache_expire = 0;
280
+ pool_config->memqcache_auto_cache_invalidation = 1;
281
+ pool_config->memqcache_maxcache = 409600;
282
+ pool_config->memqcache_cache_block_size = 1048576;
283
+ pool_config->memqcache_oiddir = "/var/log/pgpool/oiddir";
284
+ pool_config->white_memqcache_table_list = NULL;
285
+ pool_config->num_white_memqcache_table_list = 0;
286
+ pool_config->black_memqcache_table_list = NULL;
287
+ pool_config->num_black_memqcache_table_list = 0;
288
+ pool_config->lists_memqcache_table_patterns = NULL;
289
+ pool_config->memqcache_table_pattc = 0;
290
+ pool_config->current_memqcache_table_pattern_size = 0;
291
+
292
+ res = gethostname(localhostname,sizeof(localhostname));
293
+ if(res !=0 )
294
+ {
295
+ pool_debug("failed to get this hostname");
296
+ }
297
+ pool_config->pgpool2_hostname = localhostname;
298
+
299
+ for (i=0;i<MAX_CONNECTION_SLOTS;i++)
300
+ {
301
+ clear_host_entry(i);
302
+ }
303
+ return 0;
304
+ }
305
+
306
+ /*
307
+ * Add regex expression to patterns array
308
+ * The supported type are: black_function_list and white_function_list
309
+ * Return 0 on error, 1 on success
310
+ */
311
+ int add_regex_pattern(char *type, char *s)
312
+ {
313
+ int regex_flags = REG_NOSUB;
314
+ RegPattern currItem;
315
+ /* force case insensitive pattern matching */
316
+ regex_flags |= REG_ICASE;
317
+ /* Add extended regex search */
318
+ regex_flags |= REG_EXTENDED;
319
+ /* Fill the pattern type */
320
+ if (strcmp(type, "black_function_list") == 0 ||
321
+ strcmp(type, "black_memqcache_table_list") == 0)
322
+ {
323
+ currItem.type = BLACKLIST;
324
+ }
325
+ else if (strcmp(type, "white_function_list") == 0 ||
326
+ strcmp(type, "white_memqcache_table_list") == 0)
327
+ {
328
+ currItem.type = WHITELIST;
329
+ }
330
+ else
331
+ {
332
+ pool_error("add_to_patterns: bad pattern type %s", type);
333
+ return 0;
334
+ }
335
+ /* Fill the pattern flag */
336
+ currItem.flag = regex_flags;
337
+
338
+ /* Fill pattern array */
339
+ currItem.pattern = malloc(sizeof(char)*(strlen(s)+3));
340
+ if (currItem.pattern == NULL)
341
+ {
342
+ pool_error("add_to_patterns: unable to allocate new pattern");
343
+ return 0;
344
+ }
345
+ /* Force exact matching of function name with ^ and $ on the regex
346
+ if required to prevent partial matching. It also allow backward
347
+ compatibility.
348
+ */
349
+ if (strncmp(s, "^", 1) != 0) {
350
+ strncpy(currItem.pattern, "^", 2);
351
+ strncat(currItem.pattern, s, strlen(s) + 1);
352
+ } else {
353
+ strncpy(currItem.pattern, s, strlen(s) + 1);
354
+ }
355
+ if (s[strlen(s)-1] != '$') {
356
+ strncat(currItem.pattern, "$", 2);
357
+ }
358
+ pool_debug("add_to_patterns: regex pattern: %s", currItem.pattern);
359
+ /* compile our regex */
360
+ if (regcomp(&currItem.regexv, currItem.pattern, currItem.flag) != 0)
361
+ {
362
+ pool_error("add_to_patterns: invalid regex pattern: %s", currItem.pattern);
363
+ }
364
+ else if ((strcmp(type, "white_function_list") == 0 ||
365
+ strcmp(type, "black_function_list") == 0) &&
366
+ growFunctionPatternArray(currItem) < 0)
367
+ {
368
+ pool_error("add_to_patterns: unable to allocate new pattern");
369
+ return 0;
370
+ }
371
+ else if ((strcmp(type, "white_memqcache_table_list") == 0 ||
372
+ strcmp(type, "black_memqcache_table_list") == 0) &&
373
+ growMemqcacheTablePatternArray(currItem) < 0)
374
+ {
375
+ pool_error("add_to_patterns: unable to allocate new pattern");
376
+ return 0;
377
+ }
378
+
379
+ return 1;
380
+ }
381
+
382
+ /*
383
+ * Dynamically grow the regex pattern array
384
+ * The array start with PATTERN_ARR_SIZE storage place, if required
385
+ * it will grow of PATTERN_ARR_SIZE more each time.
386
+ */
387
+ int growFunctionPatternArray(RegPattern item)
388
+ {
389
+ void *_tmp = NULL;
390
+ if (pool_config->pattc == pool_config->current_pattern_size)
391
+ {
392
+ pool_config->current_pattern_size += PATTERN_ARR_SIZE;
393
+ _tmp = realloc(pool_config->lists_patterns,
394
+ (pool_config->current_pattern_size * sizeof(RegPattern)));
395
+ if (!_tmp)
396
+ {
397
+ return(-1);
398
+ }
399
+
400
+ pool_config->lists_patterns = (RegPattern*)_tmp;
401
+ }
402
+ pool_config->lists_patterns[pool_config->pattc] = item;
403
+ pool_config->pattc++;
404
+
405
+ return(pool_config->pattc);
406
+ }
407
+
408
+ int growMemqcacheTablePatternArray(RegPattern item)
409
+ {
410
+ void *_tmp = NULL;
411
+ if (pool_config->memqcache_table_pattc == pool_config->current_memqcache_table_pattern_size)
412
+ {
413
+ pool_config->current_memqcache_table_pattern_size += PATTERN_ARR_SIZE;
414
+ _tmp = realloc(pool_config->lists_memqcache_table_patterns,
415
+ (pool_config->current_memqcache_table_pattern_size * sizeof(RegPattern)));
416
+ if (!_tmp)
417
+ {
418
+ return(-1);
419
+ }
420
+
421
+ pool_config->lists_memqcache_table_patterns = (RegPattern*)_tmp;
422
+ }
423
+ pool_config->lists_memqcache_table_patterns[pool_config->memqcache_table_pattc] = item;
424
+ pool_config->memqcache_table_pattc++;
425
+
426
+ return(pool_config->memqcache_table_pattc);
427
+ }
428
+
429
+ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
430
+ {
431
+ FILE *fd;
432
+ int token;
433
+ char key[1024];
434
+ double total_weight;
435
+ int i;
436
+ bool log_destination_changed = false;
437
+ #ifdef USE_MEMCACHED
438
+ bool use_memcached = true;
439
+ #else
440
+ bool use_memcached = false;
441
+ #endif
442
+
443
+ #define PARSE_ERROR() pool_error("pool_config: parse error at line %d '%s'", Lineno, yytext)
444
+
445
+ /* open config file */
446
+ fd = fopen(confpath, "r");
447
+ if (!fd)
448
+ {
449
+ fprintf(stderr, "pool_config: could not open configuration file (%s)\n",
450
+ POOL_CONF_FILE_NAME);
451
+ fprintf(stderr, "pool_config: using default values...\n");
452
+ return 0;
453
+ }
454
+
455
+ yyin = fd;
456
+ Lineno = 1;
457
+
458
+ for(;;)
459
+ {
460
+ token = yylex();
461
+ if (token == 0)
462
+ {
463
+ break;
464
+ }
465
+ if (token == POOL_PARSE_ERROR)
466
+ {
467
+ PARSE_ERROR();
468
+ fclose(fd);
469
+ return(-1);
470
+ }
471
+ if (token == POOL_EOL)
472
+ continue;
473
+
474
+ if (token != POOL_KEY)
475
+ {
476
+ PARSE_ERROR();
477
+ fclose(fd);
478
+ return(-1);
479
+ }
480
+
481
+ strlcpy(key, yytext, sizeof(key));
482
+
483
+ pool_debug("key: %s", key);
484
+
485
+ token = yylex();
486
+
487
+ if (token == POOL_EQUALS)
488
+ token = yylex();
489
+
490
+ pool_debug("value: %s kind: %d", yytext, token);
491
+
492
+ if (!strcmp(key, "allow_inet_domain_socket") && CHECK_CONTEXT(INIT_CONFIG, context))
493
+ {
494
+ /* for backward compatibility */
495
+ int v = eval_logical(yytext);
496
+
497
+ if (v < 0)
498
+ {
499
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
500
+ fclose(fd);
501
+ return(-1);
502
+ }
503
+ if (v)
504
+ pool_config->listen_addresses = strdup("*");
505
+ else
506
+ pool_config->listen_addresses = strdup("");
507
+ }
508
+ else if (!strcmp(key, "listen_addresses") && CHECK_CONTEXT(INIT_CONFIG, context))
509
+ {
510
+ char *str;
511
+
512
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
513
+ {
514
+ PARSE_ERROR();
515
+ fclose(fd);
516
+ return(-1);
517
+ }
518
+ str = extract_string(yytext, token);
519
+ if (str == NULL)
520
+ {
521
+ fclose(fd);
522
+ return(-1);
523
+ }
524
+ pool_config->listen_addresses = str;
525
+ }
526
+
527
+ else if (!strcmp(key, "port") && CHECK_CONTEXT(INIT_CONFIG, context))
528
+ {
529
+ int v = atoi(yytext);
530
+
531
+ if (token != POOL_INTEGER || v < 1024)
532
+ {
533
+ pool_error("pool_config: %s must be 1024 or higher numeric value", key);
534
+ fclose(fd);
535
+ return(-1);
536
+ }
537
+ pool_config->port = v;
538
+ }
539
+ else if (!strcmp(key, "pcp_port") && CHECK_CONTEXT(INIT_CONFIG, context))
540
+ {
541
+ int v = atoi(yytext);
542
+
543
+ if (token != POOL_INTEGER || v < 1024)
544
+ {
545
+ pool_error("pool_config: %s must be 1024 or higher numeric value", key);
546
+ fclose(fd);
547
+ return(-1);
548
+ }
549
+ pool_config->pcp_port = v;
550
+ }
551
+ else if (!strcmp(key, "socket_dir") && CHECK_CONTEXT(INIT_CONFIG, context))
552
+ {
553
+ char *str;
554
+
555
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
556
+ {
557
+ PARSE_ERROR();
558
+ fclose(fd);
559
+ return(-1);
560
+ }
561
+ str = extract_string(yytext, token);
562
+ if (str == NULL)
563
+ {
564
+ fclose(fd);
565
+ return(-1);
566
+ }
567
+ pool_config->socket_dir = str;
568
+ }
569
+ else if (!strcmp(key, "pcp_socket_dir") && CHECK_CONTEXT(INIT_CONFIG, context))
570
+ {
571
+ char *str;
572
+
573
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
574
+ {
575
+ PARSE_ERROR();
576
+ fclose(fd);
577
+ return(-1);
578
+ }
579
+ str = extract_string(yytext, token);
580
+ if (str == NULL)
581
+ {
582
+ fclose(fd);
583
+ return(-1);
584
+ }
585
+ pool_config->pcp_socket_dir = str;
586
+ }
587
+ else if (!strcmp(key, "pcp_timeout") &&
588
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
589
+ {
590
+ int v = atoi(yytext);
591
+
592
+ if (token != POOL_INTEGER || v < 0)
593
+ {
594
+ pool_error("pool_config: %s must be equal or greater or equal to 0 numeric value", key);
595
+ fclose(fd);
596
+ return(-1);
597
+ }
598
+ pool_config->pcp_timeout = v;
599
+ }
600
+ else if (!strcmp(key, "num_init_children") && CHECK_CONTEXT(INIT_CONFIG, context))
601
+ {
602
+ int v = atoi(yytext);
603
+
604
+ if (token != POOL_INTEGER || v < 1)
605
+ {
606
+ pool_error("pool_config: %s must be higher than 1 numeric value", key);
607
+ fclose(fd);
608
+ return(-1);
609
+ }
610
+ pool_config->num_init_children = v;
611
+ }
612
+ else if (!strcmp(key, "child_life_time") &&
613
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
614
+ {
615
+ int v = atoi(yytext);
616
+
617
+ if (token != POOL_INTEGER || v < 0)
618
+ {
619
+ pool_error("pool_config: %s must be greater or equal to 0 numeric value", key);
620
+ fclose(fd);
621
+ return(-1);
622
+ }
623
+ pool_config->child_life_time = v;
624
+ }
625
+ else if (!strcmp(key, "client_idle_limit") &&
626
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
627
+ {
628
+ int v = atoi(yytext);
629
+
630
+ if (token != POOL_INTEGER || v < 0)
631
+ {
632
+ pool_error("pool_config: %s must be greater or equal to 0 numeric value", key);
633
+ fclose(fd);
634
+ return(-1);
635
+ }
636
+ pool_config->client_idle_limit = v;
637
+ }
638
+ else if (!strcmp(key, "connection_life_time") &&
639
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
640
+ {
641
+ int v = atoi(yytext);
642
+
643
+ if (token != POOL_INTEGER || v < 0)
644
+ {
645
+ pool_error("pool_config: %s must be greater or equal to 0 numeric value", key);
646
+ fclose(fd);
647
+ return(-1);
648
+ }
649
+ pool_config->connection_life_time = v;
650
+ }
651
+ else if (!strcmp(key, "child_max_connections") &&
652
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
653
+ {
654
+ int v = atoi(yytext);
655
+
656
+ if (token != POOL_INTEGER || v < 0)
657
+ {
658
+ pool_error("pool_config: %s must be greater or equal to 0 numeric value", key);
659
+ fclose(fd);
660
+ return(-1);
661
+ }
662
+ pool_config->child_max_connections = v;
663
+ }
664
+ else if (!strcmp(key, "authentication_timeout") &&
665
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
666
+ {
667
+ int v = atoi(yytext);
668
+
669
+ if (token != POOL_INTEGER || v < 0)
670
+ {
671
+ pool_error("pool_config: %s must be higher than 0 numeric value", key);
672
+ fclose(fd);
673
+ return(-1);
674
+ }
675
+ pool_config->authentication_timeout = v;
676
+ }
677
+ else if (!strcmp(key, "max_pool") && CHECK_CONTEXT(INIT_CONFIG, context))
678
+ {
679
+ int v = atoi(yytext);
680
+
681
+ if (token != POOL_INTEGER || v < 0)
682
+ {
683
+ pool_error("pool_config: %s must be greater or equal to 0 numeric value", key);
684
+ fclose(fd);
685
+ return(-1);
686
+ }
687
+ pool_config->max_pool = v;
688
+ }
689
+ else if (!strcmp(key, "logdir") && CHECK_CONTEXT(INIT_CONFIG, context))
690
+ {
691
+ char *str;
692
+
693
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
694
+ {
695
+ PARSE_ERROR();
696
+ fclose(fd);
697
+ return(-1);
698
+ }
699
+ str = extract_string(yytext, token);
700
+ if (str == NULL)
701
+ {
702
+ fclose(fd);
703
+ return(-1);
704
+ }
705
+ pool_config->logdir = str;
706
+ }
707
+ else if (!strcmp(key, "log_destination") &&
708
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
709
+ {
710
+ char *str;
711
+
712
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
713
+ {
714
+ PARSE_ERROR();
715
+ fclose(fd);
716
+ return(-1);
717
+ }
718
+ str = extract_string(yytext, token);
719
+ if (str == NULL)
720
+ {
721
+ fclose(fd);
722
+ return(-1);
723
+ }
724
+ log_destination_changed = pool_config->log_destination != str;
725
+ pool_config->log_destination = str;
726
+ }
727
+ else if (!strcmp(key, "syslog_facility") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
728
+ {
729
+ char *str;
730
+
731
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
732
+ {
733
+ PARSE_ERROR();
734
+ fclose(fd);
735
+ return(-1);
736
+ }
737
+ str = extract_string(yytext, token);
738
+ if (str == NULL)
739
+ {
740
+ fclose(fd);
741
+ return(-1);
742
+ }
743
+ pool_config->syslog_facility = set_syslog_facility(str);
744
+ }
745
+ else if (!strcmp(key, "syslog_ident") &&
746
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
747
+ {
748
+ char *str;
749
+
750
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
751
+ {
752
+ PARSE_ERROR();
753
+ fclose(fd);
754
+ return(-1);
755
+ }
756
+ str = extract_string(yytext, token);
757
+ if (str == NULL)
758
+ {
759
+ fclose(fd);
760
+ return(-1);
761
+ }
762
+ log_destination_changed = log_destination_changed || pool_config->syslog_ident != str;
763
+ pool_config->syslog_ident = str;
764
+ }
765
+ else if (!strcmp(key, "pid_file_name") && CHECK_CONTEXT(INIT_CONFIG, context))
766
+ {
767
+ char *str;
768
+
769
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
770
+ {
771
+ PARSE_ERROR();
772
+ fclose(fd);
773
+ return(-1);
774
+ }
775
+ str = extract_string(yytext, token);
776
+ if (str == NULL)
777
+ {
778
+ fclose(fd);
779
+ return(-1);
780
+ }
781
+ pool_config->pid_file_name = str;
782
+ }
783
+ else if (!strcmp(key, "log_connections") &&
784
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
785
+ {
786
+ int v = eval_logical(yytext);
787
+
788
+ if (v < 0)
789
+ {
790
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
791
+ fclose(fd);
792
+ return(-1);
793
+ }
794
+ pool_config->log_connections = v;
795
+ }
796
+ else if (!strcmp(key, "log_hostname") &&
797
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
798
+ {
799
+ int v = eval_logical(yytext);
800
+
801
+ if (v < 0)
802
+ {
803
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
804
+ fclose(fd);
805
+ return(-1);
806
+ }
807
+ pool_config->log_hostname = v;
808
+ }
809
+ else if (!strcmp(key, "enable_pool_hba") &&
810
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
811
+ {
812
+ int v = eval_logical(yytext);
813
+
814
+ if (v < 0)
815
+ {
816
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
817
+ fclose(fd);
818
+ return(-1);
819
+ }
820
+ pool_config->enable_pool_hba = v;
821
+ }
822
+ else if (!strcmp(key, "pool_passwd") && CHECK_CONTEXT(INIT_CONFIG, context))
823
+ {
824
+ char *str;
825
+
826
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
827
+ {
828
+ PARSE_ERROR();
829
+ fclose(fd);
830
+ return(-1);
831
+ }
832
+ str = extract_string(yytext, token);
833
+ if (str == NULL)
834
+ {
835
+ fclose(fd);
836
+ return(-1);
837
+ }
838
+ pool_config->pool_passwd = str;
839
+ }
840
+
841
+ else if (!strcmp(key, "presto_server") && CHECK_CONTEXT(INIT_CONFIG, context))
842
+ {
843
+ char *str;
844
+
845
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
846
+ {
847
+ PARSE_ERROR();
848
+ fclose(fd);
849
+ return(-1);
850
+ }
851
+ str = extract_string(yytext, token);
852
+ if (str == NULL)
853
+ {
854
+ fclose(fd);
855
+ return(-1);
856
+ }
857
+ pool_config->presto_server = str;
858
+ }
859
+ else if (!strcmp(key, "presto_catalog") && CHECK_CONTEXT(INIT_CONFIG, context))
860
+ {
861
+ char *str;
862
+
863
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
864
+ {
865
+ PARSE_ERROR();
866
+ fclose(fd);
867
+ return(-1);
868
+ }
869
+ str = extract_string(yytext, token);
870
+ if (str == NULL)
871
+ {
872
+ fclose(fd);
873
+ return(-1);
874
+ }
875
+ pool_config->presto_catalog = str;
876
+ }
877
+ else if (!strcmp(key, "presto_schema") && CHECK_CONTEXT(INIT_CONFIG, context))
878
+ {
879
+ char *str;
880
+
881
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
882
+ {
883
+ PARSE_ERROR();
884
+ fclose(fd);
885
+ return(-1);
886
+ }
887
+ str = extract_string(yytext, token);
888
+ if (str == NULL)
889
+ {
890
+ fclose(fd);
891
+ return(-1);
892
+ }
893
+ pool_config->presto_schema = str;
894
+ }
895
+ else if (!strcmp(key, "presto_external_auth_prog") && CHECK_CONTEXT(INIT_CONFIG, context))
896
+ {
897
+ char *str;
898
+
899
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
900
+ {
901
+ PARSE_ERROR();
902
+ fclose(fd);
903
+ return(-1);
904
+ }
905
+ str = extract_string(yytext, token);
906
+ if (str == NULL)
907
+ {
908
+ fclose(fd);
909
+ return(-1);
910
+ }
911
+ pool_config->presto_external_auth_prog = str;
912
+ }
913
+
914
+ else if (!strcmp(key, "backend_socket_dir") && CHECK_CONTEXT(INIT_CONFIG, context))
915
+ {
916
+ char *str;
917
+
918
+ pool_log("pool_config: backend_socket_dir is deprecated, please use backend_hostname");
919
+
920
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
921
+ {
922
+ PARSE_ERROR();
923
+ fclose(fd);
924
+ return(-1);
925
+ }
926
+ str = extract_string(yytext, token);
927
+ if (str == NULL)
928
+ {
929
+ fclose(fd);
930
+ return(-1);
931
+ }
932
+ pool_config->backend_socket_dir = str;
933
+ }
934
+ else if (!strcmp(key, "replication_mode") && CHECK_CONTEXT(INIT_CONFIG, context))
935
+ {
936
+ int v = eval_logical(yytext);
937
+
938
+ if (v < 0)
939
+ {
940
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
941
+ fclose(fd);
942
+ return(-1);
943
+ }
944
+ pool_config->replication_mode = v;
945
+
946
+ if (pool_config->master_slave_mode && pool_config->replication_mode)
947
+ {
948
+ pool_error("pool_config: replication_mode and master_slave_mode cannot be enabled at the same time");
949
+ fclose(fd);
950
+ return(-1);
951
+ }
952
+
953
+ }
954
+ else if (!strcmp(key, "load_balance_mode") && CHECK_CONTEXT(INIT_CONFIG, context))
955
+ {
956
+ int v = eval_logical(yytext);
957
+
958
+ if (v < 0)
959
+ {
960
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
961
+ fclose(fd);
962
+ return(-1);
963
+ }
964
+ pool_config->load_balance_mode = v;
965
+ }
966
+ else if (!strcmp(key, "replication_stop_on_mismatch") &&
967
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
968
+ {
969
+ int v = eval_logical(yytext);
970
+
971
+ if (v < 0)
972
+ {
973
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
974
+ fclose(fd);
975
+ return(-1);
976
+ }
977
+ pool_debug("replication_stop_on_mismatch: %d", v);
978
+ pool_config->replication_stop_on_mismatch = v;
979
+ }
980
+ else if (!strcmp(key, "failover_if_affected_tuples_mismatch") &&
981
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
982
+ {
983
+ int v = eval_logical(yytext);
984
+
985
+ if (v < 0)
986
+ {
987
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
988
+ fclose(fd);
989
+ return(-1);
990
+ }
991
+ pool_debug("failover_if_affected_tuples_mismatch: %d", v);
992
+ pool_config->failover_if_affected_tuples_mismatch = v;
993
+ }
994
+ else if (!strcmp(key, "replicate_select") &&
995
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
996
+ {
997
+ int v = eval_logical(yytext);
998
+
999
+ if (v < 0)
1000
+ {
1001
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
1002
+ fclose(fd);
1003
+ return(-1);
1004
+ }
1005
+ pool_debug("replicate_select: %d", v);
1006
+ pool_config->replicate_select = v;
1007
+ }
1008
+ else if (!strcmp(key, "reset_query_list") &&
1009
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1010
+ {
1011
+ char *str;
1012
+
1013
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1014
+ {
1015
+ PARSE_ERROR();
1016
+ fclose(fd);
1017
+ return(-1);
1018
+ }
1019
+ str = extract_string(yytext, token);
1020
+ if (str == NULL)
1021
+ {
1022
+ fclose(fd);
1023
+ return(-1);
1024
+ }
1025
+ pool_config->reset_query_list = extract_string_tokens(str, ";", &pool_config->num_reset_queries);
1026
+ if (pool_config->reset_query_list == NULL)
1027
+ {
1028
+ fclose(fd);
1029
+ return(-1);
1030
+ }
1031
+ }
1032
+
1033
+ else if (!strcmp(key, "white_function_list") &&
1034
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1035
+ {
1036
+ char *str;
1037
+
1038
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1039
+ {
1040
+ PARSE_ERROR();
1041
+ fclose(fd);
1042
+ return(-1);
1043
+ }
1044
+ str = extract_string(yytext, token);
1045
+ if (str == NULL)
1046
+ {
1047
+ fclose(fd);
1048
+ return(-1);
1049
+ }
1050
+ pool_config->white_function_list =
1051
+ extract_string_tokens(str, ",", &pool_config->num_white_function_list);
1052
+
1053
+ if (pool_config->white_function_list == NULL)
1054
+ {
1055
+ fclose(fd);
1056
+ return(-1);
1057
+ }
1058
+ for (i=0;i<pool_config->num_white_function_list;i++)
1059
+ {
1060
+ add_regex_pattern("white_function_list", pool_config->white_function_list[i]);
1061
+ }
1062
+ }
1063
+
1064
+ else if (!strcmp(key, "black_function_list") &&
1065
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1066
+ {
1067
+ char *str;
1068
+
1069
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1070
+ {
1071
+ PARSE_ERROR();
1072
+ fclose(fd);
1073
+ return(-1);
1074
+ }
1075
+ str = extract_string(yytext, token);
1076
+ if (str == NULL)
1077
+ {
1078
+ fclose(fd);
1079
+ return(-1);
1080
+ }
1081
+ pool_config->black_function_list =
1082
+ extract_string_tokens(str, ",", &pool_config->num_black_function_list);
1083
+
1084
+ if (pool_config->black_function_list == NULL)
1085
+ {
1086
+ fclose(fd);
1087
+ return(-1);
1088
+ }
1089
+ for (i=0;i<pool_config->num_black_function_list;i++)
1090
+ {
1091
+ add_regex_pattern("black_function_list", pool_config->black_function_list[i]);
1092
+ }
1093
+ }
1094
+
1095
+ else if (!strcmp(key, "print_timestamp") && CHECK_CONTEXT(INIT_CONFIG, context))
1096
+ {
1097
+ int v = eval_logical(yytext);
1098
+
1099
+ if (v < 0)
1100
+ {
1101
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
1102
+ fclose(fd);
1103
+ return(-1);
1104
+ }
1105
+ pool_config->print_timestamp = v;
1106
+ }
1107
+
1108
+ else if (!strcmp(key, "master_slave_mode") && CHECK_CONTEXT(INIT_CONFIG, context))
1109
+ {
1110
+ int v = eval_logical(yytext);
1111
+
1112
+ if (v < 0)
1113
+ {
1114
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
1115
+ fclose(fd);
1116
+ return(-1);
1117
+ }
1118
+ pool_config->master_slave_mode = v;
1119
+
1120
+ if (pool_config->master_slave_mode && pool_config->replication_mode)
1121
+ {
1122
+ pool_error("pool_config: replication_mode and master_slave_mode cannot be enabled at the same time");
1123
+ fclose(fd);
1124
+ return(-1);
1125
+ }
1126
+ }
1127
+
1128
+ else if (!strcmp(key, "master_slave_sub_mode") && CHECK_CONTEXT(INIT_CONFIG, context))
1129
+ {
1130
+ char *str;
1131
+
1132
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1133
+ {
1134
+ PARSE_ERROR();
1135
+ fclose(fd);
1136
+ return(-1);
1137
+ }
1138
+ str = extract_string(yytext, token);
1139
+ if (str == NULL)
1140
+ {
1141
+ fclose(fd);
1142
+ return(-1);
1143
+ }
1144
+
1145
+ if (strcmp(str, MODE_SLONY) && strcmp(str, MODE_STREAMREP))
1146
+ {
1147
+ pool_error("pool_config: %s must be either \"slony\" or \"stream\"", key);
1148
+ fclose(fd);
1149
+ return(-1);
1150
+ }
1151
+ pool_config->master_slave_sub_mode = str;
1152
+ }
1153
+
1154
+ else if (!strcmp(key, "delay_threshold") &&
1155
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1156
+ {
1157
+ long long int v = atol(yytext);
1158
+
1159
+ if (token != POOL_INTEGER || v < 0)
1160
+ {
1161
+ pool_error("pool_config: %s must be greater or equal to 0 numeric value", key);
1162
+ fclose(fd);
1163
+ return(-1);
1164
+ }
1165
+ pool_config->delay_threshold = v;
1166
+ }
1167
+
1168
+ else if (!strcmp(key, "log_standby_delay") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1169
+ {
1170
+ char *str;
1171
+
1172
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1173
+ {
1174
+ PARSE_ERROR();
1175
+ fclose(fd);
1176
+ return(-1);
1177
+ }
1178
+ str = extract_string(yytext, token);
1179
+ if (str == NULL)
1180
+ {
1181
+ fclose(fd);
1182
+ return(-1);
1183
+ }
1184
+
1185
+ if (strcmp(str, "always") && strcmp(str, "if_over_threshold") && strcmp(str, "none"))
1186
+ {
1187
+ pool_error("pool_config: invalid log_standby_delay %s", key);
1188
+ fclose(fd);
1189
+ return(-1);
1190
+ }
1191
+ pool_config->log_standby_delay = str;
1192
+ }
1193
+
1194
+ else if (!strcmp(key, "connection_cache") && CHECK_CONTEXT(INIT_CONFIG, context))
1195
+ {
1196
+ int v = eval_logical(yytext);
1197
+
1198
+ if (v < 0)
1199
+ {
1200
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
1201
+ fclose(fd);
1202
+ return(-1);
1203
+ }
1204
+ pool_config->connection_cache = v;
1205
+ }
1206
+
1207
+ else if (!strcmp(key, "health_check_timeout") &&
1208
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1209
+ {
1210
+ int v = atoi(yytext);
1211
+
1212
+ if (token != POOL_INTEGER || v < 0)
1213
+ {
1214
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
1215
+ fclose(fd);
1216
+ return(-1);
1217
+ }
1218
+ pool_config->health_check_timeout = v;
1219
+ }
1220
+
1221
+ else if (!strcmp(key, "health_check_period") &&
1222
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1223
+ {
1224
+ int v = atoi(yytext);
1225
+
1226
+ if (token != POOL_INTEGER || v < 0)
1227
+ {
1228
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
1229
+ fclose(fd);
1230
+ return(-1);
1231
+ }
1232
+ pool_config->health_check_period = v;
1233
+ }
1234
+
1235
+ else if (!strcmp(key, "health_check_user") &&
1236
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1237
+ {
1238
+ char *str;
1239
+
1240
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1241
+ {
1242
+ PARSE_ERROR();
1243
+ fclose(fd);
1244
+ return(-1);
1245
+ }
1246
+ str = extract_string(yytext, token);
1247
+ if (str == NULL)
1248
+ {
1249
+ fclose(fd);
1250
+ return(-1);
1251
+ }
1252
+ pool_config->health_check_user = str;
1253
+ }
1254
+
1255
+ else if (!strcmp(key, "health_check_password") &&
1256
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1257
+ {
1258
+ char *str;
1259
+
1260
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1261
+ {
1262
+ PARSE_ERROR();
1263
+ fclose(fd);
1264
+ return(-1);
1265
+ }
1266
+ str = extract_string(yytext, token);
1267
+ if (str == NULL)
1268
+ {
1269
+ fclose(fd);
1270
+ return(-1);
1271
+ }
1272
+ pool_config->health_check_password = str;
1273
+ }
1274
+
1275
+ else if (!strcmp(key, "health_check_max_retries") &&
1276
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1277
+ {
1278
+ int v = atoi(yytext);
1279
+
1280
+ if (token != POOL_INTEGER || v < 0)
1281
+ {
1282
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
1283
+ fclose(fd);
1284
+ return(-1);
1285
+ }
1286
+ pool_config->health_check_max_retries = v;
1287
+ }
1288
+
1289
+ else if (!strcmp(key, "health_check_retry_delay") &&
1290
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1291
+ {
1292
+ int v = atoi(yytext);
1293
+
1294
+ if (token != POOL_INTEGER || v < 0)
1295
+ {
1296
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
1297
+ fclose(fd);
1298
+ return(-1);
1299
+ }
1300
+ pool_config->health_check_retry_delay = v;
1301
+ }
1302
+
1303
+ else if (!strcmp(key, "sr_check_period") &&
1304
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1305
+ {
1306
+ int v = atoi(yytext);
1307
+
1308
+ if (token != POOL_INTEGER || v < 0)
1309
+ {
1310
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
1311
+ fclose(fd);
1312
+ return(-1);
1313
+ }
1314
+ pool_config->sr_check_period = v;
1315
+ }
1316
+
1317
+ else if (!strcmp(key, "sr_check_user") &&
1318
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1319
+ {
1320
+ char *str;
1321
+
1322
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1323
+ {
1324
+ PARSE_ERROR();
1325
+ fclose(fd);
1326
+ return(-1);
1327
+ }
1328
+ str = extract_string(yytext, token);
1329
+ if (str == NULL)
1330
+ {
1331
+ fclose(fd);
1332
+ return(-1);
1333
+ }
1334
+ pool_config->sr_check_user = str;
1335
+ }
1336
+
1337
+ else if (!strcmp(key, "sr_check_password") &&
1338
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1339
+ {
1340
+ char *str;
1341
+
1342
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1343
+ {
1344
+ PARSE_ERROR();
1345
+ fclose(fd);
1346
+ return(-1);
1347
+ }
1348
+ str = extract_string(yytext, token);
1349
+ if (str == NULL)
1350
+ {
1351
+ fclose(fd);
1352
+ return(-1);
1353
+ }
1354
+ pool_config->sr_check_password = str;
1355
+ }
1356
+
1357
+ else if (!strcmp(key, "failover_command") &&
1358
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1359
+ {
1360
+ char *str;
1361
+
1362
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1363
+ {
1364
+ PARSE_ERROR();
1365
+ fclose(fd);
1366
+ return(-1);
1367
+ }
1368
+ str = extract_string(yytext, token);
1369
+ if (str == NULL)
1370
+ {
1371
+ fclose(fd);
1372
+ return(-1);
1373
+ }
1374
+ pool_config->failover_command = str;
1375
+ }
1376
+
1377
+ else if (!strcmp(key, "follow_master_command") &&
1378
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1379
+ {
1380
+ char *str;
1381
+
1382
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1383
+ {
1384
+ PARSE_ERROR();
1385
+ fclose(fd);
1386
+ return(-1);
1387
+ }
1388
+ str = extract_string(yytext, token);
1389
+ if (str == NULL)
1390
+ {
1391
+ fclose(fd);
1392
+ return(-1);
1393
+ }
1394
+ pool_config->follow_master_command = str;
1395
+ }
1396
+
1397
+ else if (!strcmp(key, "failback_command") &&
1398
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1399
+ {
1400
+ char *str;
1401
+
1402
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1403
+ {
1404
+ PARSE_ERROR();
1405
+ fclose(fd);
1406
+ return(-1);
1407
+ }
1408
+ str = extract_string(yytext, token);
1409
+ if (str == NULL)
1410
+ {
1411
+ fclose(fd);
1412
+ return(-1);
1413
+ }
1414
+ pool_config->failback_command = str;
1415
+ }
1416
+
1417
+ else if (!strcmp(key, "fail_over_on_backend_error") &&
1418
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1419
+ {
1420
+ int v = eval_logical(yytext);
1421
+
1422
+ if (v < 0)
1423
+ {
1424
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
1425
+ fclose(fd);
1426
+ return(-1);
1427
+ }
1428
+ pool_config->fail_over_on_backend_error = v;
1429
+ }
1430
+
1431
+ else if (!strcmp(key, "recovery_user") &&
1432
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1433
+ {
1434
+ char *str;
1435
+
1436
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1437
+ {
1438
+ PARSE_ERROR();
1439
+ fclose(fd);
1440
+ return(-1);
1441
+ }
1442
+ str = extract_string(yytext, token);
1443
+ if (str == NULL)
1444
+ {
1445
+ fclose(fd);
1446
+ return(-1);
1447
+ }
1448
+ pool_config->recovery_user = str;
1449
+ }
1450
+
1451
+ else if (!strcmp(key, "recovery_password") &&
1452
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1453
+ {
1454
+ char *str;
1455
+
1456
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1457
+ {
1458
+ PARSE_ERROR();
1459
+ fclose(fd);
1460
+ return(-1);
1461
+ }
1462
+ str = extract_string(yytext, token);
1463
+ if (str == NULL)
1464
+ {
1465
+ fclose(fd);
1466
+ return(-1);
1467
+ }
1468
+ pool_config->recovery_password = str;
1469
+ }
1470
+
1471
+ else if (!strcmp(key, "recovery_1st_stage_command") &&
1472
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1473
+ {
1474
+ char *str;
1475
+
1476
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1477
+ {
1478
+ PARSE_ERROR();
1479
+ fclose(fd);
1480
+ return(-1);
1481
+ }
1482
+ str = extract_string(yytext, token);
1483
+ if (str == NULL)
1484
+ {
1485
+ fclose(fd);
1486
+ return(-1);
1487
+ }
1488
+ pool_config->recovery_1st_stage_command = str;
1489
+ }
1490
+
1491
+ else if (!strcmp(key, "recovery_2nd_stage_command") &&
1492
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1493
+ {
1494
+ char *str;
1495
+
1496
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1497
+ {
1498
+ PARSE_ERROR();
1499
+ fclose(fd);
1500
+ return(-1);
1501
+ }
1502
+ str = extract_string(yytext, token);
1503
+ if (str == NULL)
1504
+ {
1505
+ fclose(fd);
1506
+ return(-1);
1507
+ }
1508
+ pool_config->recovery_2nd_stage_command = str;
1509
+ }
1510
+
1511
+ else if (!strcmp(key, "recovery_timeout") &&
1512
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1513
+ {
1514
+ int v = atoi(yytext);
1515
+
1516
+ if (token != POOL_INTEGER || v < 0)
1517
+ {
1518
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
1519
+ fclose(fd);
1520
+ return(-1);
1521
+ }
1522
+ pool_config->recovery_timeout = v;
1523
+ }
1524
+
1525
+ else if (!strcmp(key, "search_primary_node_timeout") &&
1526
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1527
+ {
1528
+ int v = atoi(yytext);
1529
+
1530
+ if (token != POOL_INTEGER || v < 0)
1531
+ {
1532
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
1533
+ fclose(fd);
1534
+ return(-1);
1535
+ }
1536
+ pool_config->search_primary_node_timeout = v;
1537
+ }
1538
+
1539
+ else if (!strcmp(key, "client_idle_limit_in_recovery") &&
1540
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1541
+ {
1542
+ int v = atoi(yytext);
1543
+
1544
+ if (token != POOL_INTEGER || v < -1)
1545
+ {
1546
+ pool_error("pool_config: %s must be greater or equal to -1 numeric value", key);
1547
+ fclose(fd);
1548
+ return(-1);
1549
+ }
1550
+ pool_config->client_idle_limit_in_recovery = v;
1551
+ }
1552
+
1553
+ else if (!strcmp(key, "insert_lock") &&
1554
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1555
+ {
1556
+ int v = eval_logical(yytext);
1557
+
1558
+ if (v < 0)
1559
+ {
1560
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
1561
+ fclose(fd);
1562
+ return(-1);
1563
+ }
1564
+ pool_config->insert_lock = v;
1565
+ }
1566
+
1567
+ else if (!strcmp(key, "ignore_leading_white_space") &&
1568
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1569
+ {
1570
+ int v = eval_logical(yytext);
1571
+
1572
+ if (v < 0)
1573
+ {
1574
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
1575
+ fclose(fd);
1576
+ return(-1);
1577
+ }
1578
+ pool_config->ignore_leading_white_space = v;
1579
+ }
1580
+
1581
+ else if (!strcmp(key, "parallel_mode") && CHECK_CONTEXT(INIT_CONFIG, context))
1582
+ {
1583
+ int v = eval_logical(yytext);
1584
+
1585
+ if (v < 0)
1586
+ {
1587
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
1588
+ fclose(fd);
1589
+ return(-1);
1590
+ }
1591
+ pool_config->parallel_mode = v;
1592
+ }
1593
+
1594
+ else if (!strcmp(key, "enable_query_cache") && CHECK_CONTEXT(INIT_CONFIG, context))
1595
+ {
1596
+ int v = eval_logical(yytext);
1597
+
1598
+ if (v < 0)
1599
+ {
1600
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
1601
+ fclose(fd);
1602
+ return(-1);
1603
+ }
1604
+ pool_config->enable_query_cache = v;
1605
+ }
1606
+
1607
+ else if (!strcmp(key, "pgpool2_hostname") && CHECK_CONTEXT(INIT_CONFIG, context))
1608
+ {
1609
+ char *str;
1610
+
1611
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1612
+ {
1613
+ PARSE_ERROR();
1614
+ fclose(fd);
1615
+ return(-1);
1616
+ }
1617
+ str = extract_string(yytext, token);
1618
+ if (str == NULL)
1619
+ {
1620
+ fclose(fd);
1621
+ return(-1);
1622
+ }
1623
+ if(strlen(str))
1624
+ pool_config->pgpool2_hostname = str;
1625
+ }
1626
+
1627
+ else if (!strcmp(key, "system_db_hostname") && CHECK_CONTEXT(INIT_CONFIG, context))
1628
+ {
1629
+ char *str;
1630
+
1631
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1632
+ {
1633
+ PARSE_ERROR();
1634
+ fclose(fd);
1635
+ return(-1);
1636
+ }
1637
+ str = extract_string(yytext, token);
1638
+ if (str == NULL)
1639
+ {
1640
+ fclose(fd);
1641
+ return(-1);
1642
+ }
1643
+ pool_config->system_db_hostname = str;
1644
+ }
1645
+
1646
+ else if (!strcmp(key, "system_db_port") && CHECK_CONTEXT(INIT_CONFIG, context))
1647
+ {
1648
+ int v = atoi(yytext);
1649
+
1650
+ if (token != POOL_INTEGER || v < 0)
1651
+ {
1652
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
1653
+ fclose(fd);
1654
+ return(-1);
1655
+ }
1656
+ pool_config->system_db_port = v;
1657
+ }
1658
+
1659
+ else if (!strcmp(key, "system_db_dbname") && CHECK_CONTEXT(INIT_CONFIG, context))
1660
+ {
1661
+ char *str;
1662
+
1663
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1664
+ {
1665
+ PARSE_ERROR();
1666
+ fclose(fd);
1667
+ return(-1);
1668
+ }
1669
+ str = extract_string(yytext, token);
1670
+ if (str == NULL)
1671
+ {
1672
+ fclose(fd);
1673
+ return(-1);
1674
+ }
1675
+ pool_config->system_db_dbname = str;
1676
+ }
1677
+
1678
+ else if (!strcmp(key, "system_db_schema") && CHECK_CONTEXT(INIT_CONFIG, context))
1679
+ {
1680
+ char *str;
1681
+
1682
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1683
+ {
1684
+ PARSE_ERROR();
1685
+ fclose(fd);
1686
+ return(-1);
1687
+ }
1688
+ str = extract_string(yytext, token);
1689
+ if (str == NULL)
1690
+ {
1691
+ fclose(fd);
1692
+ return(-1);
1693
+ }
1694
+ pool_config->system_db_schema = str;
1695
+ }
1696
+
1697
+ else if (!strcmp(key, "system_db_user") && CHECK_CONTEXT(INIT_CONFIG, context))
1698
+ {
1699
+ char *str;
1700
+
1701
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1702
+ {
1703
+ PARSE_ERROR();
1704
+ fclose(fd);
1705
+ return(-1);
1706
+ }
1707
+ str = extract_string(yytext, token);
1708
+ if (str == NULL)
1709
+ {
1710
+ fclose(fd);
1711
+ return(-1);
1712
+ }
1713
+ pool_config->system_db_user = str;
1714
+ }
1715
+
1716
+ else if (!strcmp(key, "system_db_password") && CHECK_CONTEXT(INIT_CONFIG, context))
1717
+ {
1718
+ char *str;
1719
+
1720
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1721
+ {
1722
+ PARSE_ERROR();
1723
+ fclose(fd);
1724
+ return(-1);
1725
+ }
1726
+ str = extract_string(yytext, token);
1727
+ if (str == NULL)
1728
+ {
1729
+ fclose(fd);
1730
+ return(-1);
1731
+ }
1732
+ pool_config->system_db_password = str;
1733
+ }
1734
+
1735
+ else if (!strncmp(key, "backend_hostname", 16) &&
1736
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
1737
+ mypid == getpid()) /* this parameter must be modified by parent pid */
1738
+ {
1739
+ int slot;
1740
+ char *str;
1741
+
1742
+ slot = atoi(key + 16);
1743
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
1744
+ {
1745
+ pool_error("pool_config: backend number %s for backend_hostname out of range", key);
1746
+ fclose(fd);
1747
+ return(-1);
1748
+ }
1749
+
1750
+ str = extract_string(yytext, token);
1751
+ if (str == NULL)
1752
+ {
1753
+ fclose(fd);
1754
+ return(-1);
1755
+ }
1756
+ if (context == INIT_CONFIG ||
1757
+ (context == RELOAD_CONFIG && BACKEND_INFO(slot).backend_status == CON_UNUSED))
1758
+ strlcpy(BACKEND_INFO(slot).backend_hostname, str, MAX_DB_HOST_NAMELEN);
1759
+ }
1760
+
1761
+ else if (!strncmp(key, "backend_port", 12) &&
1762
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
1763
+ mypid == getpid()) /* this parameter must be modified by parent pid */
1764
+ {
1765
+ int slot;
1766
+
1767
+ slot = atoi(key + 12);
1768
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
1769
+ {
1770
+ pool_error("pool_config: host number %s for port number out of range", key);
1771
+ fclose(fd);
1772
+ return(-1);
1773
+ }
1774
+ pool_debug("pool_config: port slot number %d ", slot);
1775
+ if (context == INIT_CONFIG)
1776
+ {
1777
+ BACKEND_INFO(slot).backend_port = atoi(yytext);
1778
+ BACKEND_INFO(slot).backend_status = CON_CONNECT_WAIT;
1779
+ }
1780
+ else if (context == RELOAD_CONFIG && BACKEND_INFO(slot).backend_status == CON_UNUSED)
1781
+ {
1782
+ BACKEND_INFO(slot).backend_port = atoi(yytext);
1783
+ BACKEND_INFO(slot).backend_status = CON_DOWN;
1784
+ }
1785
+ }
1786
+
1787
+ else if (!strncmp(key, "backend_weight", 14) &&
1788
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
1789
+ mypid == getpid()) /* this parameter must be modified by parent pid */
1790
+ {
1791
+ int slot;
1792
+ double v;
1793
+ BACKEND_STATUS status;
1794
+
1795
+ slot = atoi(key + 14);
1796
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
1797
+ {
1798
+ pool_error("pool_config: weight number %s for port number out of range", key);
1799
+ fclose(fd);
1800
+ return(-1);
1801
+ }
1802
+
1803
+ v = atof(yytext);
1804
+
1805
+ if (v < 0.0)
1806
+ {
1807
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
1808
+ fclose(fd);
1809
+ return(-1);
1810
+ }
1811
+
1812
+ pool_debug("pool_config: weight slot number %d weight: %f", slot, v);
1813
+ status = BACKEND_INFO(slot).backend_status;
1814
+
1815
+ if (context == INIT_CONFIG || context == RELOAD_CONFIG)
1816
+ {
1817
+ double old_v = BACKEND_INFO(slot).unnormalized_weight;
1818
+ BACKEND_INFO(slot).unnormalized_weight = v;
1819
+
1820
+ /*
1821
+ * Log weight change event only when context is
1822
+ * reloading of pgpool.conf and weight is actually
1823
+ * changed
1824
+ */
1825
+ if (context == RELOAD_CONFIG && old_v != v)
1826
+ {
1827
+ pool_log("Backend weight for backend%d changed from %f to %f. This will take effect from next client session.", slot, old_v, v);
1828
+ }
1829
+ }
1830
+ }
1831
+ else if (!strncmp(key, "backend_data_directory", 22) &&
1832
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
1833
+ mypid == getpid()) /* this parameter must be modified by parent pid */
1834
+ {
1835
+ int slot;
1836
+ char *str;
1837
+ BACKEND_STATUS status;
1838
+
1839
+ slot = atoi(key + 22);
1840
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
1841
+ {
1842
+ pool_error("pool_config: backend number %s for backend_data_directory out of range", key);
1843
+ fclose(fd);
1844
+ return(-1);
1845
+ }
1846
+
1847
+ str = extract_string(yytext, token);
1848
+ if (str == NULL)
1849
+ {
1850
+ fclose(fd);
1851
+ return(-1);
1852
+ }
1853
+ status = BACKEND_INFO(slot).backend_status;
1854
+ if (context == INIT_CONFIG ||
1855
+ (context == RELOAD_CONFIG && (status == CON_UNUSED || status == CON_DOWN)))
1856
+ strlcpy(BACKEND_INFO(slot).backend_data_directory, str, MAX_PATH_LENGTH);
1857
+ }
1858
+ else if (!strncmp(key, "backend_flag", 12) &&
1859
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
1860
+ mypid == getpid()) /* this parameter must be modified by parent pid */
1861
+ {
1862
+ char *str;
1863
+ char **flags;
1864
+ int n;
1865
+ int i;
1866
+ int slot;
1867
+ unsigned short flag = 0;
1868
+ bool allow_to_failover_is_specified = 0;
1869
+ bool disallow_to_failover_is_specified = 0;
1870
+
1871
+ str = extract_string(yytext, token);
1872
+ if (str == NULL)
1873
+ {
1874
+ pool_error("pool_config: extract_string failed: %s", yytext);
1875
+ fclose(fd);
1876
+ return(-1);
1877
+ }
1878
+
1879
+ flags = extract_string_tokens(str, "|", &n);
1880
+ if (!flags || n < 0)
1881
+ {
1882
+ pool_debug("pool_config: unable to get backend flags");
1883
+ fclose(fd);
1884
+ return(-1);
1885
+ }
1886
+
1887
+ for (i=0;i<n;i++)
1888
+ {
1889
+ if (!strcmp(flags[i], "ALLOW_TO_FAILOVER"))
1890
+ {
1891
+ if (disallow_to_failover_is_specified)
1892
+ {
1893
+ pool_error("pool_config: cannot set ALLOW_TO_FAILOVER and DISALLOW_TO_FAILOVER at the same time");
1894
+ fclose(fd);
1895
+ return(-1);
1896
+ }
1897
+ flag &= ~POOL_FAILOVER;
1898
+ allow_to_failover_is_specified = true;
1899
+ pool_debug("pool_config: allow_to_failover on");
1900
+ }
1901
+
1902
+ else if (!strcmp(flags[i], "DISALLOW_TO_FAILOVER"))
1903
+ {
1904
+ if (allow_to_failover_is_specified)
1905
+ {
1906
+ pool_error("pool_config: cannot set ALLOW_TO_FAILOVER and DISALLOW_TO_FAILOVER at the same time");
1907
+ fclose(fd);
1908
+ return(-1);
1909
+ }
1910
+ flag |= POOL_FAILOVER;
1911
+ disallow_to_failover_is_specified = true;
1912
+ pool_debug("pool_config: disallow_to_failover on");
1913
+ }
1914
+
1915
+ else
1916
+ {
1917
+ pool_error("pool_config: invalid backend flag:%s", flags[i]);
1918
+ }
1919
+ }
1920
+
1921
+ slot = atoi(key + 12);
1922
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
1923
+ {
1924
+ pool_error("pool_config: slot number %s for flag out of range", key);
1925
+ fclose(fd);
1926
+ return(-1);
1927
+ }
1928
+
1929
+ BACKEND_INFO(slot).flag = flag;
1930
+
1931
+ pool_debug("pool_config: slot number %d flag: %04x", slot, flag);
1932
+ }
1933
+
1934
+ else if (!strcmp(key, "log_statement") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1935
+ {
1936
+ int v = eval_logical(yytext);
1937
+
1938
+ if (v < 0)
1939
+ {
1940
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
1941
+ return(-1);
1942
+ }
1943
+ pool_config->log_statement = v;
1944
+ }
1945
+ else if (!strcmp(key, "log_per_node_statement") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1946
+ {
1947
+ int v = eval_logical(yytext);
1948
+
1949
+ if (v < 0)
1950
+ {
1951
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
1952
+ return(-1);
1953
+ }
1954
+ pool_config->log_per_node_statement = v;
1955
+ }
1956
+
1957
+ else if (!strcmp(key, "lobj_lock_table") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
1958
+ {
1959
+ char *str;
1960
+
1961
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
1962
+ {
1963
+ PARSE_ERROR();
1964
+ fclose(fd);
1965
+ return(-1);
1966
+ }
1967
+ str = extract_string(yytext, token);
1968
+ if (str == NULL)
1969
+ {
1970
+ fclose(fd);
1971
+ return(-1);
1972
+ }
1973
+ pool_config->lobj_lock_table = str;
1974
+ }
1975
+ /*
1976
+ * add for watchdog
1977
+ */
1978
+ else if (!strncmp(key, "other_pgpool_hostname", 21) &&
1979
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
1980
+ mypid == getpid()) /* this parameter must be modified by parent pid */
1981
+ {
1982
+ int slot;
1983
+ char *str;
1984
+
1985
+ slot = atoi(key + 21) ;
1986
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
1987
+ {
1988
+ pool_error("pool_config: pgpool number %s for other_pgpool_hostname out of range", key);
1989
+ fclose(fd);
1990
+ return(-1);
1991
+ }
1992
+
1993
+ str = extract_string(yytext, token);
1994
+ if (str == NULL)
1995
+ {
1996
+ fclose(fd);
1997
+ return(-1);
1998
+ }
1999
+ if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
2000
+ strlcpy(WD_INFO(slot).hostname, str, WD_MAX_HOST_NAMELEN);
2001
+ }
2002
+
2003
+ else if (!strncmp(key, "other_pgpool_port", 17) &&
2004
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
2005
+ mypid == getpid()) /* this parameter must be modified by parent pid */
2006
+ {
2007
+ int slot;
2008
+
2009
+ slot = atoi(key + 17);
2010
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
2011
+ {
2012
+ pool_error("pool_config: pgpool number %s for other_pgpool_port out of range", key);
2013
+ fclose(fd);
2014
+ return(-1);
2015
+ }
2016
+
2017
+ if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
2018
+ WD_INFO(slot).pgpool_port = atoi(yytext);
2019
+ }
2020
+
2021
+ else if (!strncmp(key, "other_wd_port", 13) &&
2022
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
2023
+ mypid == getpid()) /* this parameter must be modified by parent pid */
2024
+ {
2025
+ int slot;
2026
+
2027
+ slot = atoi(key + 13);
2028
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
2029
+ {
2030
+ pool_error("pool_config: pgpool number %s for other_wd_port out of range", key);
2031
+ fclose(fd);
2032
+ return(-1);
2033
+ }
2034
+
2035
+ if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
2036
+ {
2037
+ WD_INFO(slot).wd_port = atoi(yytext);
2038
+ WD_INFO(slot).status = WD_INIT;
2039
+ pool_config->other_wd->num_wd = slot + 1;
2040
+ }
2041
+ }
2042
+ else if (!strcmp(key, "use_watchdog") && CHECK_CONTEXT(INIT_CONFIG, context))
2043
+ {
2044
+ int v = eval_logical(yytext);
2045
+
2046
+ if (v < 0)
2047
+ {
2048
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
2049
+ fclose(fd);
2050
+ return(-1);
2051
+ }
2052
+ pool_config->use_watchdog = v;
2053
+ }
2054
+
2055
+ else if (!strcmp(key, "clear_memqcache_on_escalation") && CHECK_CONTEXT(INIT_CONFIG, context))
2056
+ {
2057
+ int v = eval_logical(yytext);
2058
+
2059
+ if (v < 0)
2060
+ {
2061
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
2062
+ fclose(fd);
2063
+ return(-1);
2064
+ }
2065
+ pool_config->clear_memqcache_on_escalation = v;
2066
+ }
2067
+
2068
+ else if (!strcmp(key, "wd_escalation_command") &&
2069
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2070
+ {
2071
+ char *str;
2072
+
2073
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2074
+ {
2075
+ PARSE_ERROR();
2076
+ fclose(fd);
2077
+ return(-1);
2078
+ }
2079
+ str = extract_string(yytext, token);
2080
+ if (str == NULL)
2081
+ {
2082
+ fclose(fd);
2083
+ return(-1);
2084
+ }
2085
+ pool_config->wd_escalation_command = str;
2086
+ }
2087
+
2088
+ else if (!strcmp(key, "trusted_servers") && CHECK_CONTEXT(INIT_CONFIG, context))
2089
+ {
2090
+ char *str;
2091
+
2092
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2093
+ {
2094
+ PARSE_ERROR();
2095
+ fclose(fd);
2096
+ return(-1);
2097
+ }
2098
+ str = extract_string(yytext, token);
2099
+ if (str == NULL)
2100
+ {
2101
+ fclose(fd);
2102
+ return(-1);
2103
+ }
2104
+ if(strlen(str))
2105
+ pool_config->trusted_servers = str;
2106
+ }
2107
+ else if (!strcmp(key, "delegate_IP") && CHECK_CONTEXT(INIT_CONFIG, context))
2108
+ {
2109
+ char *str;
2110
+
2111
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2112
+ {
2113
+ PARSE_ERROR();
2114
+ fclose(fd);
2115
+ return(-1);
2116
+ }
2117
+ str = extract_string(yytext, token);
2118
+ if (str == NULL)
2119
+ {
2120
+ fclose(fd);
2121
+ return(-1);
2122
+ }
2123
+ if(strlen(str))
2124
+ pool_config->delegate_IP = str;
2125
+ }
2126
+ else if (!strcmp(key, "wd_hostname") && CHECK_CONTEXT(INIT_CONFIG, context))
2127
+ {
2128
+ char *str;
2129
+
2130
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2131
+ {
2132
+ PARSE_ERROR();
2133
+ fclose(fd);
2134
+ return(-1);
2135
+ }
2136
+ str = extract_string(yytext, token);
2137
+ if (str == NULL)
2138
+ {
2139
+ fclose(fd);
2140
+ return(-1);
2141
+ }
2142
+ if(strlen(str))
2143
+ pool_config->wd_hostname = str;
2144
+ }
2145
+ else if (!strcmp(key, "wd_port") && CHECK_CONTEXT(INIT_CONFIG, context))
2146
+ {
2147
+ int v = atoi(yytext);
2148
+
2149
+ if (token != POOL_INTEGER || v <= 0)
2150
+ {
2151
+ pool_error("pool_config: %s must be higher than 1 numeric value", key);
2152
+ fclose(fd);
2153
+ return(-1);
2154
+ }
2155
+ pool_config->wd_port = v;
2156
+ }
2157
+ else if (!strcmp(key, "wd_interval") && CHECK_CONTEXT(INIT_CONFIG, context))
2158
+ {
2159
+ int v = atoi(yytext);
2160
+
2161
+ if (token != POOL_INTEGER || v <= 0)
2162
+ {
2163
+ pool_error("pool_config: %s must be higher than 1 numeric value", key);
2164
+ fclose(fd);
2165
+ return(-1);
2166
+ }
2167
+ pool_config->wd_interval = v;
2168
+ }
2169
+ else if (!strcmp(key, "ping_path") && CHECK_CONTEXT(INIT_CONFIG, context))
2170
+ {
2171
+ char *str;
2172
+
2173
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2174
+ {
2175
+ PARSE_ERROR();
2176
+ fclose(fd);
2177
+ return(-1);
2178
+ }
2179
+ str = extract_string(yytext, token);
2180
+ if (str == NULL)
2181
+ {
2182
+ fclose(fd);
2183
+ return(-1);
2184
+ }
2185
+ if(strlen(str))
2186
+ pool_config->ping_path = str;
2187
+ }
2188
+ else if (!strcmp(key, "ifconfig_path") && CHECK_CONTEXT(INIT_CONFIG, context))
2189
+ {
2190
+ char *str;
2191
+
2192
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2193
+ {
2194
+ PARSE_ERROR();
2195
+ fclose(fd);
2196
+ return(-1);
2197
+ }
2198
+ str = extract_string(yytext, token);
2199
+ if (str == NULL)
2200
+ {
2201
+ fclose(fd);
2202
+ return(-1);
2203
+ }
2204
+ if(strlen(str))
2205
+ pool_config->ifconfig_path = str;
2206
+ }
2207
+ else if (!strcmp(key, "if_up_cmd") && CHECK_CONTEXT(INIT_CONFIG, context))
2208
+ {
2209
+ char *str;
2210
+
2211
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2212
+ {
2213
+ PARSE_ERROR();
2214
+ fclose(fd);
2215
+ return(-1);
2216
+ }
2217
+ str = extract_string(yytext, token);
2218
+ if (str == NULL)
2219
+ {
2220
+ fclose(fd);
2221
+ return(-1);
2222
+ }
2223
+ if(strlen(str))
2224
+ pool_config->if_up_cmd = str;
2225
+ }
2226
+ else if (!strcmp(key, "if_down_cmd") && CHECK_CONTEXT(INIT_CONFIG, context))
2227
+ {
2228
+ char *str;
2229
+
2230
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2231
+ {
2232
+ PARSE_ERROR();
2233
+ fclose(fd);
2234
+ return(-1);
2235
+ }
2236
+ str = extract_string(yytext, token);
2237
+ if (str == NULL)
2238
+ {
2239
+ fclose(fd);
2240
+ return(-1);
2241
+ }
2242
+ if(strlen(str))
2243
+ pool_config->if_down_cmd = str;
2244
+ }
2245
+ else if (!strcmp(key, "arping_path") && CHECK_CONTEXT(INIT_CONFIG, context))
2246
+ {
2247
+ char *str;
2248
+
2249
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2250
+ {
2251
+ PARSE_ERROR();
2252
+ fclose(fd);
2253
+ return(-1);
2254
+ }
2255
+ str = extract_string(yytext, token);
2256
+ if (str == NULL)
2257
+ {
2258
+ fclose(fd);
2259
+ return(-1);
2260
+ }
2261
+ if(strlen(str))
2262
+ pool_config->arping_path = str;
2263
+ }
2264
+ else if (!strcmp(key, "arping_cmd") && CHECK_CONTEXT(INIT_CONFIG, context))
2265
+ {
2266
+ char *str;
2267
+
2268
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2269
+ {
2270
+ PARSE_ERROR();
2271
+ fclose(fd);
2272
+ return(-1);
2273
+ }
2274
+ str = extract_string(yytext, token);
2275
+ if (str == NULL)
2276
+ {
2277
+ fclose(fd);
2278
+ return(-1);
2279
+ }
2280
+ if(strlen(str))
2281
+ pool_config->arping_cmd = str;
2282
+ }
2283
+ else if (!strcmp(key, "wd_life_point") && CHECK_CONTEXT(INIT_CONFIG, context))
2284
+ {
2285
+ int v = atoi(yytext);
2286
+
2287
+ if (token != POOL_INTEGER || v <= 0)
2288
+ {
2289
+ pool_error("pool_config: %s must be higher than 1 numeric value", key);
2290
+ fclose(fd);
2291
+ return(-1);
2292
+ }
2293
+ pool_config->wd_life_point = v;
2294
+ }
2295
+ else if (!strcmp(key, "wd_lifecheck_query") && CHECK_CONTEXT(INIT_CONFIG, context))
2296
+ {
2297
+ char *str;
2298
+
2299
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2300
+ {
2301
+ PARSE_ERROR();
2302
+ fclose(fd);
2303
+ return(-1);
2304
+ }
2305
+ str = extract_string(yytext, token);
2306
+ if (str == NULL)
2307
+ {
2308
+ fclose(fd);
2309
+ return(-1);
2310
+ }
2311
+ if(strlen(str))
2312
+ pool_config->wd_lifecheck_query = str;
2313
+ }
2314
+
2315
+ else if (!strcmp(key, "wd_lifecheck_dbname") &&
2316
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2317
+ {
2318
+ char *str;
2319
+
2320
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2321
+ {
2322
+ PARSE_ERROR();
2323
+ fclose(fd);
2324
+ return(-1);
2325
+ }
2326
+ str = extract_string(yytext, token);
2327
+ if (str == NULL)
2328
+ {
2329
+ fclose(fd);
2330
+ return(-1);
2331
+ }
2332
+ pool_config->wd_lifecheck_dbname = str;
2333
+ }
2334
+
2335
+ else if (!strcmp(key, "wd_lifecheck_user") &&
2336
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2337
+ {
2338
+ char *str;
2339
+
2340
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2341
+ {
2342
+ PARSE_ERROR();
2343
+ fclose(fd);
2344
+ return(-1);
2345
+ }
2346
+ str = extract_string(yytext, token);
2347
+ if (str == NULL)
2348
+ {
2349
+ fclose(fd);
2350
+ return(-1);
2351
+ }
2352
+ pool_config->wd_lifecheck_user = str;
2353
+ }
2354
+
2355
+ else if (!strcmp(key, "wd_lifecheck_password") &&
2356
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2357
+ {
2358
+ char *str;
2359
+
2360
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2361
+ {
2362
+ PARSE_ERROR();
2363
+ fclose(fd);
2364
+ return(-1);
2365
+ }
2366
+ str = extract_string(yytext, token);
2367
+ if (str == NULL)
2368
+ {
2369
+ fclose(fd);
2370
+ return(-1);
2371
+ }
2372
+ pool_config->wd_lifecheck_password = str;
2373
+ }
2374
+
2375
+ else if (!strcmp(key, "wd_lifecheck_method") && CHECK_CONTEXT(INIT_CONFIG, context))
2376
+ {
2377
+ char *str;
2378
+
2379
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2380
+ {
2381
+ PARSE_ERROR();
2382
+ fclose(fd);
2383
+ return(-1);
2384
+ }
2385
+ str = extract_string(yytext, token);
2386
+ if (str == NULL)
2387
+ {
2388
+ fclose(fd);
2389
+ return(-1);
2390
+ }
2391
+
2392
+ if (strcmp(str, MODE_HEARTBEAT) && strcmp(str, MODE_QUERY))
2393
+ {
2394
+ pool_error("pool_config: %s must be either \"heartbeat\" or \"query\"", key);
2395
+ fclose(fd);
2396
+ return(-1);
2397
+ }
2398
+ pool_config->wd_lifecheck_method = str;
2399
+ }
2400
+ else if (!strcmp(key, "wd_heartbeat_port") && CHECK_CONTEXT(INIT_CONFIG, context))
2401
+ {
2402
+ int v = atoi(yytext);
2403
+
2404
+ if (token != POOL_INTEGER || v <= 0)
2405
+ {
2406
+ pool_error("pool_config: %s must be higher than 1 numeric value", key);
2407
+ fclose(fd);
2408
+ return(-1);
2409
+ }
2410
+ pool_config->wd_heartbeat_port = v;
2411
+ }
2412
+ else if (!strcmp(key, "wd_heartbeat_keepalive") && CHECK_CONTEXT(INIT_CONFIG, context))
2413
+ {
2414
+ int v = atoi(yytext);
2415
+
2416
+ if (token != POOL_INTEGER || v <= 0)
2417
+ {
2418
+ pool_error("pool_config: %s must be higher than 1 numeric value", key);
2419
+ fclose(fd);
2420
+ return(-1);
2421
+ }
2422
+ pool_config->wd_heartbeat_keepalive = v;
2423
+ }
2424
+ else if (!strcmp(key, "wd_heartbeat_deadtime") && CHECK_CONTEXT(INIT_CONFIG, context))
2425
+ {
2426
+ int v = atoi(yytext);
2427
+
2428
+ if (token != POOL_INTEGER || v <= 0)
2429
+ {
2430
+ pool_error("pool_config: %s must be higher than 1 numeric value", key);
2431
+ fclose(fd);
2432
+ return(-1);
2433
+ }
2434
+ pool_config->wd_heartbeat_deadtime = v;
2435
+ }
2436
+ else if (!strcmp(key, "wd_authkey") &&
2437
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2438
+ {
2439
+ char *str;
2440
+
2441
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2442
+ {
2443
+ PARSE_ERROR();
2444
+ fclose(fd);
2445
+ return(-1);
2446
+ }
2447
+ str = extract_string(yytext, token);
2448
+ if (str == NULL)
2449
+ {
2450
+ fclose(fd);
2451
+ return(-1);
2452
+ }
2453
+ pool_config->wd_authkey = str;
2454
+ }
2455
+
2456
+ else if (!strncmp(key, "heartbeat_device", 16) &&
2457
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
2458
+ mypid == getpid()) /* this parameter must be modified by parent pid */
2459
+ {
2460
+ int slot;
2461
+ char *str;
2462
+
2463
+ slot = atoi(key + 16) ;
2464
+ if (slot < 0 || slot >= WD_MAX_IF_NUM)
2465
+ {
2466
+ pool_error("pool_config: pgpool number %s for heartbeat_device out of range", key);
2467
+ fclose(fd);
2468
+ return(-1);
2469
+ }
2470
+
2471
+ str = extract_string(yytext, token);
2472
+ if (str == NULL)
2473
+ {
2474
+ fclose(fd);
2475
+ return(-1);
2476
+ }
2477
+ if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
2478
+ strlcpy(WD_HB_IF(slot).if_name, str, WD_MAX_IF_NAME_LEN);
2479
+
2480
+ }
2481
+ /* this must be prior to hertbeat_destination */
2482
+ else if (!strncmp(key, "heartbeat_destination_port", 26) &&
2483
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
2484
+ mypid == getpid()) /* this parameter must be modified by parent pid */
2485
+ {
2486
+ int slot;
2487
+
2488
+ slot = atoi(key + 26) ;
2489
+ if (slot < 0 || slot >= WD_MAX_IF_NUM)
2490
+ {
2491
+ pool_error("pool_config: pgpool number %s for heartbeat_destination_port out of range", key);
2492
+ fclose(fd);
2493
+ return(-1);
2494
+ }
2495
+
2496
+ if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
2497
+ {
2498
+ WD_HB_IF(slot).dest_port = atoi(yytext);
2499
+ pool_config->num_hb_if = slot + 1;
2500
+ }
2501
+ }
2502
+ else if (!strncmp(key, "heartbeat_destination", 21) &&
2503
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
2504
+ mypid == getpid()) /* this parameter must be modified by parent pid */
2505
+ {
2506
+ int slot;
2507
+ char *str;
2508
+
2509
+ slot = atoi(key + 21) ;
2510
+ if (slot < 0 || slot >= WD_MAX_IF_NUM)
2511
+ {
2512
+ pool_error("pool_config: pgpool number %s for heartbeat_destination out of range", key);
2513
+ fclose(fd);
2514
+ return(-1);
2515
+ }
2516
+
2517
+ str = extract_string(yytext, token);
2518
+ if (str == NULL)
2519
+ {
2520
+ fclose(fd);
2521
+ return(-1);
2522
+ }
2523
+ if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
2524
+ strlcpy(WD_HB_IF(slot).addr, str, WD_MAX_HOST_NAMELEN);
2525
+ }
2526
+
2527
+ else if (!strcmp(key, "ssl") && CHECK_CONTEXT(INIT_CONFIG, context))
2528
+ {
2529
+ int v = eval_logical(yytext);
2530
+
2531
+ if (v < 0)
2532
+ {
2533
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
2534
+ return(-1);
2535
+ }
2536
+ pool_config->ssl = v;
2537
+ }
2538
+ else if (!strcmp(key, "ssl_cert") && CHECK_CONTEXT(INIT_CONFIG, context))
2539
+ {
2540
+ char *str;
2541
+
2542
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2543
+ {
2544
+ PARSE_ERROR();
2545
+ fclose(fd);
2546
+ return(-1);
2547
+ }
2548
+ str = extract_string(yytext, token);
2549
+ if (str == NULL)
2550
+ {
2551
+ fclose(fd);
2552
+ return(-1);
2553
+ }
2554
+ pool_config->ssl_cert = str;
2555
+ }
2556
+ else if (!strcmp(key, "ssl_key") && CHECK_CONTEXT(INIT_CONFIG, context))
2557
+ {
2558
+ char *str;
2559
+
2560
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2561
+ {
2562
+ PARSE_ERROR();
2563
+ fclose(fd);
2564
+ return(-1);
2565
+ }
2566
+ str = extract_string(yytext, token);
2567
+ if (str == NULL)
2568
+ {
2569
+ fclose(fd);
2570
+ return(-1);
2571
+ }
2572
+ pool_config->ssl_key = str;
2573
+ }
2574
+ else if (!strcmp(key, "ssl_ca_cert") &&
2575
+ CHECK_CONTEXT(INIT_CONFIG, context))
2576
+ {
2577
+ char *str;
2578
+
2579
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2580
+ {
2581
+ PARSE_ERROR();
2582
+ fclose(fd);
2583
+ return(-1);
2584
+ }
2585
+ str = extract_string(yytext, token);
2586
+ if (str == NULL)
2587
+ {
2588
+ fclose(fd);
2589
+ return(-1);
2590
+ }
2591
+ pool_config->ssl_ca_cert = str;
2592
+ }
2593
+ else if (!strcmp(key, "ssl_ca_cert_dir") &&
2594
+ CHECK_CONTEXT(INIT_CONFIG, context))
2595
+ {
2596
+ char *str;
2597
+
2598
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2599
+ {
2600
+ PARSE_ERROR();
2601
+ fclose(fd);
2602
+ return(-1);
2603
+ }
2604
+ str = extract_string(yytext, token);
2605
+ if (str == NULL)
2606
+ {
2607
+ fclose(fd);
2608
+ return(-1);
2609
+ }
2610
+ pool_config->ssl_ca_cert_dir = str;
2611
+ }
2612
+
2613
+ else if (!strcmp(key, "debug_level") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2614
+ {
2615
+ int v = atoi(yytext);
2616
+
2617
+ if (token != POOL_INTEGER || v < 0)
2618
+ {
2619
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
2620
+ fclose(fd);
2621
+ return(-1);
2622
+ }
2623
+ pool_config->debug_level = v;
2624
+ }
2625
+
2626
+ else if (!strcmp(key, "relcache_expire") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2627
+ {
2628
+ int v = atoi(yytext);
2629
+
2630
+ if (token != POOL_INTEGER || v < 0)
2631
+ {
2632
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
2633
+ fclose(fd);
2634
+ return(-1);
2635
+ }
2636
+ pool_config->relcache_expire = v;
2637
+ }
2638
+
2639
+ else if (!strcmp(key, "relcache_size") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2640
+ {
2641
+ int v = atoi(yytext);
2642
+
2643
+ if (token != POOL_INTEGER || v < 1)
2644
+ {
2645
+ pool_error("pool_config: %s must be equal or higher than 1 numeric value", key);
2646
+ fclose(fd);
2647
+ return(-1);
2648
+ }
2649
+ pool_config->relcache_size = v;
2650
+ }
2651
+
2652
+ else if (!strcmp(key, "check_temp_table") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2653
+ {
2654
+ int v = eval_logical(yytext);
2655
+
2656
+ if (v < 0)
2657
+ {
2658
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
2659
+ return(-1);
2660
+ }
2661
+ pool_config->check_temp_table = v;
2662
+ }
2663
+
2664
+ else if (!strcmp(key, "memory_cache_enabled") &&
2665
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2666
+ {
2667
+ int v = eval_logical(yytext);
2668
+
2669
+ if (v < 0)
2670
+ {
2671
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
2672
+ fclose(fd);
2673
+ return(-1);
2674
+ }
2675
+ pool_config->memory_cache_enabled = v;
2676
+ }
2677
+ else if (!strcmp(key, "memqcache_method") && CHECK_CONTEXT(INIT_CONFIG, context))
2678
+ {
2679
+ char *str;
2680
+
2681
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2682
+ {
2683
+ PARSE_ERROR();
2684
+ fclose(fd);
2685
+ return(-1);
2686
+ }
2687
+ str = extract_string(yytext, token);
2688
+ if (str == NULL)
2689
+ {
2690
+ fclose(fd);
2691
+ return(-1);
2692
+ }
2693
+
2694
+ if (!strcmp(str, "memcached") && !use_memcached)
2695
+ {
2696
+ pool_error("memqcached_method cannot be memcached because pgpool-II is not built with MEMCACHED enabled");
2697
+ fclose(fd);
2698
+ return -1;
2699
+ }
2700
+
2701
+ if (strcmp(str, "memcached") && strcmp(str, "shmem"))
2702
+ {
2703
+ pool_error("memqcached_method must be either shmem or memcached");
2704
+ fclose(fd);
2705
+ return -1;
2706
+ }
2707
+
2708
+ pool_config->memqcache_method = str;
2709
+ }
2710
+ else if (!strcmp(key, "memqcache_memcached_host") && CHECK_CONTEXT(INIT_CONFIG, context))
2711
+ {
2712
+ char *str;
2713
+
2714
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2715
+ {
2716
+ PARSE_ERROR();
2717
+ fclose(fd);
2718
+ return(-1);
2719
+ }
2720
+ str = extract_string(yytext, token);
2721
+ if (str == NULL)
2722
+ {
2723
+ fclose(fd);
2724
+ return(-1);
2725
+ }
2726
+ pool_config->memqcache_memcached_host = str;
2727
+ }
2728
+ else if (!strcmp(key, "memqcache_memcached_port") && CHECK_CONTEXT(INIT_CONFIG, context))
2729
+ {
2730
+ int v = atoi(yytext);
2731
+
2732
+ if (token != POOL_INTEGER || v < 0)
2733
+ {
2734
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
2735
+ fclose(fd);
2736
+ return(-1);
2737
+ }
2738
+ pool_config->memqcache_memcached_port = v;
2739
+ }
2740
+ else if (!strcmp(key, "memqcache_total_size") && CHECK_CONTEXT(INIT_CONFIG, context))
2741
+ {
2742
+ int v = atoi(yytext);
2743
+
2744
+ if (token != POOL_INTEGER || v < 0)
2745
+ {
2746
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
2747
+ fclose(fd);
2748
+ return(-1);
2749
+ }
2750
+ pool_config->memqcache_total_size = v;
2751
+ }
2752
+ else if (!strcmp(key, "memqcache_max_num_cache") && CHECK_CONTEXT(INIT_CONFIG, context))
2753
+ {
2754
+ int v = atoi(yytext);
2755
+
2756
+ if (token != POOL_INTEGER || v < 0)
2757
+ {
2758
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
2759
+ fclose(fd);
2760
+ return(-1);
2761
+ }
2762
+ pool_config->memqcache_max_num_cache = v;
2763
+ }
2764
+ else if (!strcmp(key, "memqcache_expire") && CHECK_CONTEXT(INIT_CONFIG, context))
2765
+ {
2766
+ int v = atoi(yytext);
2767
+
2768
+ if (token != POOL_INTEGER || v < 0)
2769
+ {
2770
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
2771
+ fclose(fd);
2772
+ return(-1);
2773
+ }
2774
+ pool_config->memqcache_expire = v;
2775
+ }
2776
+ else if (!strcmp(key, "memqcache_auto_cache_invalidation") && CHECK_CONTEXT(INIT_CONFIG, context))
2777
+ {
2778
+ int v = eval_logical(yytext);
2779
+
2780
+ if (v < 0)
2781
+ {
2782
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
2783
+ fclose(fd);
2784
+ return(-1);
2785
+ }
2786
+ pool_config->memqcache_auto_cache_invalidation = v;
2787
+ }
2788
+ else if (!strcmp(key, "memqcache_maxcache") && CHECK_CONTEXT(INIT_CONFIG, context))
2789
+ {
2790
+ int v = atoi(yytext);
2791
+
2792
+ if (token != POOL_INTEGER || v < 0)
2793
+ {
2794
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
2795
+ fclose(fd);
2796
+ return(-1);
2797
+ }
2798
+ pool_config->memqcache_maxcache = v;
2799
+ }
2800
+ else if (!strcmp(key, "memqcache_cache_block_size") && CHECK_CONTEXT(INIT_CONFIG, context))
2801
+ {
2802
+ int v = atoi(yytext);
2803
+
2804
+ if (token != POOL_INTEGER || v < 512)
2805
+ {
2806
+ pool_error("pool_config: %s must be equal or higher than 512 numeric value", key);
2807
+ fclose(fd);
2808
+ return(-1);
2809
+ }
2810
+ pool_config->memqcache_cache_block_size = v;
2811
+ }
2812
+ else if (!strcmp(key, "memqcache_oiddir") && CHECK_CONTEXT(INIT_CONFIG, context))
2813
+ {
2814
+ char *str;
2815
+
2816
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2817
+ {
2818
+ PARSE_ERROR();
2819
+ fclose(fd);
2820
+ return(-1);
2821
+ }
2822
+ str = extract_string(yytext, token);
2823
+ if (str == NULL)
2824
+ {
2825
+ fclose(fd);
2826
+ return(-1);
2827
+ }
2828
+ pool_config->memqcache_oiddir = str;
2829
+ }
2830
+ else if (!strcmp(key, "white_memqcache_table_list") &&
2831
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2832
+ {
2833
+ char *str;
2834
+
2835
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2836
+ {
2837
+ PARSE_ERROR();
2838
+ fclose(fd);
2839
+ return(-1);
2840
+ }
2841
+ str = extract_string(yytext, token);
2842
+ if (str == NULL)
2843
+ {
2844
+ fclose(fd);
2845
+ return(-1);
2846
+ }
2847
+ pool_config->white_memqcache_table_list =
2848
+ extract_string_tokens(str, ",", &pool_config->num_white_memqcache_table_list);
2849
+
2850
+ if (pool_config->white_memqcache_table_list == NULL)
2851
+ {
2852
+ fclose(fd);
2853
+ return(-1);
2854
+ }
2855
+ for (i=0;i<pool_config->num_white_memqcache_table_list;i++)
2856
+ {
2857
+ add_regex_pattern("white_memqcache_table_list", pool_config->white_memqcache_table_list[i]);
2858
+ }
2859
+ }
2860
+
2861
+ else if (!strcmp(key, "black_memqcache_table_list") &&
2862
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2863
+ {
2864
+ char *str;
2865
+
2866
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2867
+ {
2868
+ PARSE_ERROR();
2869
+ fclose(fd);
2870
+ return(-1);
2871
+ }
2872
+ str = extract_string(yytext, token);
2873
+ if (str == NULL)
2874
+ {
2875
+ fclose(fd);
2876
+ return(-1);
2877
+ }
2878
+ pool_config->black_memqcache_table_list =
2879
+ extract_string_tokens(str, ",", &pool_config->num_black_memqcache_table_list);
2880
+
2881
+ if (pool_config->black_memqcache_table_list == NULL)
2882
+ {
2883
+ fclose(fd);
2884
+ return(-1);
2885
+ }
2886
+ for (i=0;i<pool_config->num_black_memqcache_table_list;i++)
2887
+ {
2888
+ add_regex_pattern("black_memqcache_table_list", pool_config->black_memqcache_table_list[i]);
2889
+ }
2890
+ }
2891
+ }
2892
+
2893
+ fclose(fd);
2894
+
2895
+ if (log_destination_changed)
2896
+ {
2897
+ /* log_destination has changed, we need to open syslog or close it */
2898
+ if (!strcmp(pool_config->log_destination, "stderr"))
2899
+ {
2900
+ closelog();
2901
+ pool_config->logsyslog = 0;
2902
+ }
2903
+ else
2904
+ {
2905
+ openlog(pool_config->syslog_ident, LOG_PID|LOG_NDELAY|LOG_NOWAIT, pool_config->syslog_facility);
2906
+ pool_config->logsyslog = 1;
2907
+ }
2908
+ }
2909
+
2910
+ pool_config->backend_desc->num_backends = 0;
2911
+ total_weight = 0.0;
2912
+
2913
+ for (i=0;i<MAX_CONNECTION_SLOTS;i++)
2914
+ {
2915
+ /* port number == 0 indicates that this server is out of use */
2916
+ if (BACKEND_INFO(i).backend_port == 0)
2917
+ {
2918
+ clear_host_entry(i);
2919
+ }
2920
+
2921
+ else
2922
+ {
2923
+ total_weight += BACKEND_INFO(i).unnormalized_weight;
2924
+ pool_config->backend_desc->num_backends = i+1;
2925
+
2926
+ /* initialize backend_hostname with a default socket path if empty */
2927
+ if (*(BACKEND_INFO(i).backend_hostname) == '\0')
2928
+ {
2929
+ if (pool_config->backend_socket_dir == NULL)
2930
+ {
2931
+ pool_debug("pool_config: empty backend_hostname%d, use PostgreSQL's default unix socket path (%s)", i, DEFAULT_SOCKET_DIR);
2932
+ strlcpy(BACKEND_INFO(i).backend_hostname, DEFAULT_SOCKET_DIR, MAX_DB_HOST_NAMELEN);
2933
+ }
2934
+ else /* DEPRECATED. backward compatibility with older version. Use backend_socket_dir*/
2935
+ {
2936
+ pool_debug("pool_config: empty backend_hostname%d, use backend_socket_dir as unix socket path (%s)", i, pool_config->backend_socket_dir);
2937
+ strlcpy(BACKEND_INFO(i).backend_hostname, pool_config->backend_socket_dir, MAX_DB_HOST_NAMELEN);
2938
+ }
2939
+ }
2940
+ }
2941
+ }
2942
+
2943
+ pool_debug("num_backends: %d total_weight: %f",
2944
+ pool_config->backend_desc->num_backends, total_weight);
2945
+ /*
2946
+ * Normalize load balancing weights. What we are doing here is,
2947
+ * assign 0 to RAND_MAX to each backend's weight according to the
2948
+ * value weightN. For example, if two backends are assigned 1.0,
2949
+ * then each backend will get RAND_MAX/2 normalized weight.
2950
+ */
2951
+ for (i=0;i<MAX_CONNECTION_SLOTS;i++)
2952
+ {
2953
+ #ifdef DEBUG
2954
+ print_host_entry(i);
2955
+ #endif
2956
+
2957
+ if (BACKEND_INFO(i).backend_port != 0)
2958
+ {
2959
+ BACKEND_INFO(i).backend_weight =
2960
+ (RAND_MAX) * BACKEND_INFO(i).unnormalized_weight / total_weight;
2961
+ pool_debug("backend %d weight: %f", i, BACKEND_INFO(i).backend_weight);
2962
+ pool_debug("backend %d flag: %04x", i, BACKEND_INFO(i).flag);
2963
+ }
2964
+ }
2965
+
2966
+ if (pool_config->parallel_mode || pool_config->enable_query_cache)
2967
+ {
2968
+ #ifndef POOL_PRIVATE
2969
+ int dist_num;
2970
+ #endif
2971
+ SystemDBInfo *info;
2972
+
2973
+ system_db_info = malloc(sizeof(POOL_SYSTEMDB_CONNECTION_POOL));
2974
+ if (system_db_info == NULL)
2975
+ {
2976
+ pool_error("failed to allocate system_db_info");
2977
+ return -1;
2978
+ }
2979
+ memset(system_db_info, 0, sizeof(*system_db_info));
2980
+
2981
+ #ifndef POOL_PRIVATE
2982
+ system_db_info->system_db_status = pool_shared_memory_create(sizeof(BACKEND_STATUS));
2983
+ #else
2984
+ system_db_info->system_db_status = malloc(sizeof(BACKEND_STATUS));
2985
+ #endif
2986
+ if (system_db_info->system_db_status == NULL)
2987
+ {
2988
+ pool_error("failed to allocate system_db_info->system_db_status");
2989
+ return -1;
2990
+ }
2991
+
2992
+ *system_db_info->system_db_status = CON_CONNECT_WAIT; /* which is the same as SYSDB_STATUS = CON_CONNECT_WAIT */
2993
+
2994
+ info = malloc(sizeof(SystemDBInfo));
2995
+ if (info == NULL)
2996
+ {
2997
+ pool_error("failed to allocate info");
2998
+ return -1;
2999
+ }
3000
+
3001
+ system_db_info->info = info;
3002
+ info->hostname = pool_config->system_db_hostname;
3003
+ info->port = pool_config->system_db_port;
3004
+ info->user = pool_config->system_db_user;
3005
+ info->password = pool_config->system_db_password;
3006
+ info->database_name = pool_config->system_db_dbname;
3007
+ info->schema_name = pool_config->system_db_schema;
3008
+ info->dist_def_num = 0;
3009
+ info->dist_def_slot = NULL;
3010
+
3011
+ #ifndef POOL_PRIVATE
3012
+ if (pool_config->parallel_mode)
3013
+ {
3014
+
3015
+ dist_num = pool_memset_system_db_info(info);
3016
+ if(dist_num < 0)
3017
+ {
3018
+ pool_error("failed to get systemdb info");
3019
+ return(-1);
3020
+ }
3021
+ if (!pool_config->replication_mode && !pool_config->load_balance_mode)
3022
+ {
3023
+ pool_error("pool_config: parallel_mode requires replication_mode or load_balance_mode turned on");
3024
+ return(-1);
3025
+ }
3026
+ }
3027
+ if (pool_config->enable_query_cache)
3028
+ {
3029
+ info->query_cache_table_info.register_prepared_statement = NULL;
3030
+ if (! pool_query_cache_table_exists())
3031
+ {
3032
+ pool_error("failed to locate query_cache table. perhaps it's not defined?");
3033
+ return -1;
3034
+ }
3035
+ }
3036
+ SYSDB_STATUS = CON_UP;
3037
+ #endif
3038
+ }
3039
+
3040
+ if (strcmp(pool_config->recovery_1st_stage_command, "") ||
3041
+ strcmp(pool_config->recovery_2nd_stage_command, ""))
3042
+ {
3043
+ for (i=0;i<MAX_CONNECTION_SLOTS;i++)
3044
+ {
3045
+ if (pool_config->backend_desc->backend_info[i].backend_port != 0 &&
3046
+ !strcmp(pool_config->backend_desc->backend_info[i].backend_data_directory, ""))
3047
+ {
3048
+ pool_error("pool_config: recovery_1st_stage_command and recovery_2nd_stage_command requires backend_data_directory to be set");
3049
+ return -1;
3050
+ }
3051
+ }
3052
+ }
3053
+
3054
+ return 0;
3055
+ }
3056
+
3057
+ static char *extract_string(char *value, POOL_TOKEN token)
3058
+ {
3059
+ char *ret;
3060
+
3061
+ ret = strdup(value);
3062
+ if (!ret)
3063
+ {
3064
+ pool_error("extract_string: out of memory");
3065
+ return NULL;
3066
+ }
3067
+
3068
+ if (token == POOL_STRING)
3069
+ {
3070
+ ret[strlen(ret)-1] = '\0';
3071
+ return (ret+1);
3072
+ }
3073
+ return ret;
3074
+ }
3075
+
3076
+ /*
3077
+ * Try to interpret value as boolean value. Valid values are: true,
3078
+ * false, yes, no, on, off, 1, 0; as well as unique prefixes thereof.
3079
+ * If the string parses okay, return true, else false.
3080
+ * If okay and result is not NULL, return the value in *result.
3081
+ * This function copied from PostgreSQL source code.
3082
+ */
3083
+ static bool parse_bool_with_len(const char *value, size_t len, bool *result)
3084
+ {
3085
+ switch (*value)
3086
+ {
3087
+ case 't':
3088
+ case 'T':
3089
+ if (strncasecmp(value, "true", len) == 0)
3090
+ {
3091
+ if (result)
3092
+ *result = true;
3093
+ return true;
3094
+ }
3095
+ break;
3096
+ case 'f':
3097
+ case 'F':
3098
+ if (strncasecmp(value, "false", len) == 0)
3099
+ {
3100
+ if (result)
3101
+ *result = false;
3102
+ return true;
3103
+ }
3104
+ break;
3105
+ case 'y':
3106
+ case 'Y':
3107
+ if (strncasecmp(value, "yes", len) == 0)
3108
+ {
3109
+ if (result)
3110
+ *result = true;
3111
+ return true;
3112
+ }
3113
+ break;
3114
+ case 'n':
3115
+ case 'N':
3116
+ if (strncasecmp(value, "no", len) == 0)
3117
+ {
3118
+ if (result)
3119
+ *result = false;
3120
+ return true;
3121
+ }
3122
+ break;
3123
+ case 'o':
3124
+ case 'O':
3125
+ /* 'o' is not unique enough */
3126
+ if (strncasecmp(value, "on", (len > 2 ? len : 2)) == 0)
3127
+ {
3128
+ if (result)
3129
+ *result = true;
3130
+ return true;
3131
+ }
3132
+ else if (strncasecmp(value, "off", (len > 2 ? len : 2)) == 0)
3133
+ {
3134
+ if (result)
3135
+ *result = false;
3136
+ return true;
3137
+ }
3138
+ break;
3139
+ case '1':
3140
+ if (len == 1)
3141
+ {
3142
+ if (result)
3143
+ *result = true;
3144
+ return true;
3145
+ }
3146
+ break;
3147
+ case '0':
3148
+ if (len == 1)
3149
+ {
3150
+ if (result)
3151
+ *result = false;
3152
+ return true;
3153
+ }
3154
+ break;
3155
+ default:
3156
+ break;
3157
+ }
3158
+
3159
+ if (result)
3160
+ *result = false; /* suppress compiler warning */
3161
+ return false;
3162
+ }
3163
+
3164
+ int eval_logical(char *str)
3165
+ {
3166
+ bool result;
3167
+
3168
+ if (!parse_bool_with_len(str, strlen(str), &result))
3169
+ return -1;
3170
+
3171
+ return (result ? 1 : 0);
3172
+ }
3173
+
3174
+ /*
3175
+ * Extract tokens separated by delimi from str. Return value is an
3176
+ * array of pointers to malloced strings. number of tokens is set to
3177
+ * n; note that str will be destroyed by strtok().
3178
+ */
3179
+ #define MAXTOKENS 1024
3180
+ static char **extract_string_tokens(char *str, char *delimi, int *n)
3181
+ {
3182
+ char *token;
3183
+ static char **tokens;
3184
+
3185
+ *n = 0;
3186
+
3187
+ tokens = malloc(MAXTOKENS*sizeof(char *));
3188
+ if (tokens == NULL)
3189
+ {
3190
+ pool_error("extract_string_tokens: out of memory");
3191
+ return NULL;
3192
+ }
3193
+
3194
+ for (token = strtok(str, delimi); token != NULL && *n < MAXTOKENS; token = strtok(NULL, delimi))
3195
+ {
3196
+ tokens[*n] = strdup(token);
3197
+ if (tokens[*n] == NULL)
3198
+ {
3199
+ pool_error("extract_string_tokens: out of memory");
3200
+ return NULL;
3201
+ }
3202
+ pool_debug("extract_string_tokens: token: %s", tokens[*n]);
3203
+ (*n)++;
3204
+ }
3205
+ return tokens;
3206
+ }
3207
+
3208
+ static void clear_host_entry(int slot)
3209
+ {
3210
+ *pool_config->backend_desc->backend_info[slot].backend_hostname = '\0';
3211
+ pool_config->backend_desc->backend_info[slot].backend_port = 0;
3212
+ pool_config->backend_desc->backend_info[slot].backend_status = CON_UNUSED;
3213
+ pool_config->backend_desc->backend_info[slot].backend_weight = 0.0;
3214
+ }
3215
+
3216
+ #ifdef DEBUG
3217
+ static void print_host_entry(int slot)
3218
+ {
3219
+ pool_debug("slot: %d host: %s port: %d status: %d weight: %f",
3220
+ slot,
3221
+ pool_config->server_hostnames[slot],
3222
+ pool_config->server_ports[slot],
3223
+ pool_config->server_status[slot],
3224
+ pool_config->server_weights[slot]);
3225
+ }
3226
+ #endif
3227
+
3228
+ /* Use to set the syslog facility level if logsyslog is activated */
3229
+ int set_syslog_facility(char *value)
3230
+ {
3231
+ int facility = LOG_LOCAL0;
3232
+
3233
+ if (value == NULL)
3234
+ return facility;
3235
+
3236
+ if (strncmp(value, "LOCAL", 5) == 0 && strlen(value) == 6) {
3237
+ switch (value[5]) {
3238
+ case '0':
3239
+ facility = LOG_LOCAL0;
3240
+ break;
3241
+ case '1':
3242
+ facility = LOG_LOCAL1;
3243
+ break;
3244
+ case '2':
3245
+ facility = LOG_LOCAL2;
3246
+ break;
3247
+ case '3':
3248
+ facility = LOG_LOCAL3;
3249
+ break;
3250
+ case '4':
3251
+ facility = LOG_LOCAL4;
3252
+ break;
3253
+ case '5':
3254
+ facility = LOG_LOCAL5;
3255
+ break;
3256
+ case '6':
3257
+ facility = LOG_LOCAL6;
3258
+ break;
3259
+ case '7':
3260
+ facility = LOG_LOCAL7;
3261
+ break;
3262
+ }
3263
+ }
3264
+ return facility;
3265
+ }
3266
+
3267
+ /*
3268
+ * Translate binary form of backend flag to string.
3269
+ * The returned data is in static buffer, and it will be destroyed
3270
+ * at the next call to this function.
3271
+ */
3272
+ char *pool_flag_to_str(unsigned short flag)
3273
+ {
3274
+ static char buf[1024]; /* should be large enough */
3275
+
3276
+ if (POOL_ALLOW_TO_FAILOVER(flag))
3277
+ snprintf(buf, sizeof(buf), "ALLOW_TO_FAILOVER");
3278
+ else if (POOL_DISALLOW_TO_FAILOVER(flag))
3279
+ snprintf(buf, sizeof(buf), "DISALLOW_TO_FAILOVER");
3280
+ return buf;
3281
+ }