prestogres 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,5007 @@
1
+
2
+ #line 3 "../../pgpool2/pool_config.c"
3
+
4
+ #define YY_INT_ALIGNED short int
5
+
6
+ /* A lexical scanner generated by flex */
7
+
8
+ #define FLEX_SCANNER
9
+ #define YY_FLEX_MAJOR_VERSION 2
10
+ #define YY_FLEX_MINOR_VERSION 5
11
+ #define YY_FLEX_SUBMINOR_VERSION 35
12
+ #if YY_FLEX_SUBMINOR_VERSION > 0
13
+ #define FLEX_BETA
14
+ #endif
15
+
16
+ /* First, we deal with platform-specific or compiler-specific issues. */
17
+
18
+ /* begin standard C headers. */
19
+ #include <stdio.h>
20
+ #include <string.h>
21
+ #include <errno.h>
22
+ #include <stdlib.h>
23
+
24
+ /* end standard C headers. */
25
+
26
+ /* flex integer type definitions */
27
+
28
+ #ifndef FLEXINT_H
29
+ #define FLEXINT_H
30
+
31
+ /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
32
+
33
+ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
34
+
35
+ /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
36
+ * if you want the limit (max/min) macros for int types.
37
+ */
38
+ #ifndef __STDC_LIMIT_MACROS
39
+ #define __STDC_LIMIT_MACROS 1
40
+ #endif
41
+
42
+ #include <inttypes.h>
43
+ typedef int8_t flex_int8_t;
44
+ typedef uint8_t flex_uint8_t;
45
+ typedef int16_t flex_int16_t;
46
+ typedef uint16_t flex_uint16_t;
47
+ typedef int32_t flex_int32_t;
48
+ typedef uint32_t flex_uint32_t;
49
+ typedef uint64_t flex_uint64_t;
50
+ #else
51
+ typedef signed char flex_int8_t;
52
+ typedef short int flex_int16_t;
53
+ typedef int flex_int32_t;
54
+ typedef unsigned char flex_uint8_t;
55
+ typedef unsigned short int flex_uint16_t;
56
+ typedef unsigned int flex_uint32_t;
57
+ #endif /* ! C99 */
58
+
59
+ /* Limits of integral types. */
60
+ #ifndef INT8_MIN
61
+ #define INT8_MIN (-128)
62
+ #endif
63
+ #ifndef INT16_MIN
64
+ #define INT16_MIN (-32767-1)
65
+ #endif
66
+ #ifndef INT32_MIN
67
+ #define INT32_MIN (-2147483647-1)
68
+ #endif
69
+ #ifndef INT8_MAX
70
+ #define INT8_MAX (127)
71
+ #endif
72
+ #ifndef INT16_MAX
73
+ #define INT16_MAX (32767)
74
+ #endif
75
+ #ifndef INT32_MAX
76
+ #define INT32_MAX (2147483647)
77
+ #endif
78
+ #ifndef UINT8_MAX
79
+ #define UINT8_MAX (255U)
80
+ #endif
81
+ #ifndef UINT16_MAX
82
+ #define UINT16_MAX (65535U)
83
+ #endif
84
+ #ifndef UINT32_MAX
85
+ #define UINT32_MAX (4294967295U)
86
+ #endif
87
+
88
+ #endif /* ! FLEXINT_H */
89
+
90
+ #ifdef __cplusplus
91
+
92
+ /* The "const" storage-class-modifier is valid. */
93
+ #define YY_USE_CONST
94
+
95
+ #else /* ! __cplusplus */
96
+
97
+ /* C99 requires __STDC__ to be defined as 1. */
98
+ #if defined (__STDC__)
99
+
100
+ #define YY_USE_CONST
101
+
102
+ #endif /* defined (__STDC__) */
103
+ #endif /* ! __cplusplus */
104
+
105
+ #ifdef YY_USE_CONST
106
+ #define yyconst const
107
+ #else
108
+ #define yyconst
109
+ #endif
110
+
111
+ /* Returned upon end-of-file. */
112
+ #define YY_NULL 0
113
+
114
+ /* Promotes a possibly negative, possibly signed char to an unsigned
115
+ * integer for use as an array index. If the signed char is negative,
116
+ * we want to instead treat it as an 8-bit unsigned char, hence the
117
+ * double cast.
118
+ */
119
+ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
120
+
121
+ /* Enter a start condition. This macro really ought to take a parameter,
122
+ * but we do it the disgusting crufty way forced on us by the ()-less
123
+ * definition of BEGIN.
124
+ */
125
+ #define BEGIN (yy_start) = 1 + 2 *
126
+
127
+ /* Translate the current start state into a value that can be later handed
128
+ * to BEGIN to return to the state. The YYSTATE alias is for lex
129
+ * compatibility.
130
+ */
131
+ #define YY_START (((yy_start) - 1) / 2)
132
+ #define YYSTATE YY_START
133
+
134
+ /* Action number for EOF rule of a given start state. */
135
+ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
136
+
137
+ /* Special action meaning "start processing a new file". */
138
+ #define YY_NEW_FILE yyrestart(yyin )
139
+
140
+ #define YY_END_OF_BUFFER_CHAR 0
141
+
142
+ /* Size of default input buffer. */
143
+ #ifndef YY_BUF_SIZE
144
+ #define YY_BUF_SIZE 16384
145
+ #endif
146
+
147
+ /* The state buf must be large enough to hold one state per character in the main buffer.
148
+ */
149
+ #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
150
+
151
+ #ifndef YY_TYPEDEF_YY_BUFFER_STATE
152
+ #define YY_TYPEDEF_YY_BUFFER_STATE
153
+ typedef struct yy_buffer_state *YY_BUFFER_STATE;
154
+ #endif
155
+
156
+ #ifndef YY_TYPEDEF_YY_SIZE_T
157
+ #define YY_TYPEDEF_YY_SIZE_T
158
+ typedef size_t yy_size_t;
159
+ #endif
160
+
161
+ extern yy_size_t yyleng;
162
+
163
+ extern FILE *yyin, *yyout;
164
+
165
+ #define EOB_ACT_CONTINUE_SCAN 0
166
+ #define EOB_ACT_END_OF_FILE 1
167
+ #define EOB_ACT_LAST_MATCH 2
168
+
169
+ #define YY_LESS_LINENO(n)
170
+
171
+ /* Return all but the first "n" matched characters back to the input stream. */
172
+ #define yyless(n) \
173
+ do \
174
+ { \
175
+ /* Undo effects of setting up yytext. */ \
176
+ int yyless_macro_arg = (n); \
177
+ YY_LESS_LINENO(yyless_macro_arg);\
178
+ *yy_cp = (yy_hold_char); \
179
+ YY_RESTORE_YY_MORE_OFFSET \
180
+ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
181
+ YY_DO_BEFORE_ACTION; /* set up yytext again */ \
182
+ } \
183
+ while ( 0 )
184
+
185
+ #define unput(c) yyunput( c, (yytext_ptr) )
186
+
187
+ #ifndef YY_STRUCT_YY_BUFFER_STATE
188
+ #define YY_STRUCT_YY_BUFFER_STATE
189
+ struct yy_buffer_state
190
+ {
191
+ FILE *yy_input_file;
192
+
193
+ char *yy_ch_buf; /* input buffer */
194
+ char *yy_buf_pos; /* current position in input buffer */
195
+
196
+ /* Size of input buffer in bytes, not including room for EOB
197
+ * characters.
198
+ */
199
+ yy_size_t yy_buf_size;
200
+
201
+ /* Number of characters read into yy_ch_buf, not including EOB
202
+ * characters.
203
+ */
204
+ yy_size_t yy_n_chars;
205
+
206
+ /* Whether we "own" the buffer - i.e., we know we created it,
207
+ * and can realloc() it to grow it, and should free() it to
208
+ * delete it.
209
+ */
210
+ int yy_is_our_buffer;
211
+
212
+ /* Whether this is an "interactive" input source; if so, and
213
+ * if we're using stdio for input, then we want to use getc()
214
+ * instead of fread(), to make sure we stop fetching input after
215
+ * each newline.
216
+ */
217
+ int yy_is_interactive;
218
+
219
+ /* Whether we're considered to be at the beginning of a line.
220
+ * If so, '^' rules will be active on the next match, otherwise
221
+ * not.
222
+ */
223
+ int yy_at_bol;
224
+
225
+ int yy_bs_lineno; /**< The line count. */
226
+ int yy_bs_column; /**< The column count. */
227
+
228
+ /* Whether to try to fill the input buffer when we reach the
229
+ * end of it.
230
+ */
231
+ int yy_fill_buffer;
232
+
233
+ int yy_buffer_status;
234
+
235
+ #define YY_BUFFER_NEW 0
236
+ #define YY_BUFFER_NORMAL 1
237
+ /* When an EOF's been seen but there's still some text to process
238
+ * then we mark the buffer as YY_EOF_PENDING, to indicate that we
239
+ * shouldn't try reading from the input source any more. We might
240
+ * still have a bunch of tokens to match, though, because of
241
+ * possible backing-up.
242
+ *
243
+ * When we actually see the EOF, we change the status to "new"
244
+ * (via yyrestart()), so that the user can continue scanning by
245
+ * just pointing yyin at a new input file.
246
+ */
247
+ #define YY_BUFFER_EOF_PENDING 2
248
+
249
+ };
250
+ #endif /* !YY_STRUCT_YY_BUFFER_STATE */
251
+
252
+ /* Stack of input buffers. */
253
+ static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
254
+ static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
255
+ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
256
+
257
+ /* We provide macros for accessing buffer states in case in the
258
+ * future we want to put the buffer states in a more general
259
+ * "scanner state".
260
+ *
261
+ * Returns the top of the stack, or NULL.
262
+ */
263
+ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
264
+ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
265
+ : NULL)
266
+
267
+ /* Same as previous macro, but useful when we know that the buffer stack is not
268
+ * NULL or when we need an lvalue. For internal use only.
269
+ */
270
+ #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
271
+
272
+ /* yy_hold_char holds the character lost when yytext is formed. */
273
+ static char yy_hold_char;
274
+ static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */
275
+ yy_size_t yyleng;
276
+
277
+ /* Points to current character in buffer. */
278
+ static char *yy_c_buf_p = (char *) 0;
279
+ static int yy_init = 0; /* whether we need to initialize */
280
+ static int yy_start = 0; /* start state number */
281
+
282
+ /* Flag which is used to allow yywrap()'s to do buffer switches
283
+ * instead of setting up a fresh yyin. A bit of a hack ...
284
+ */
285
+ static int yy_did_buffer_switch_on_eof;
286
+
287
+ void yyrestart (FILE *input_file );
288
+ void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
289
+ YY_BUFFER_STATE yy_create_buffer (FILE *file,int size );
290
+ void yy_delete_buffer (YY_BUFFER_STATE b );
291
+ void yy_flush_buffer (YY_BUFFER_STATE b );
292
+ void yypush_buffer_state (YY_BUFFER_STATE new_buffer );
293
+ void yypop_buffer_state (void );
294
+
295
+ static void yyensure_buffer_stack (void );
296
+ static void yy_load_buffer_state (void );
297
+ static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
298
+
299
+ #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
300
+
301
+ YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
302
+ YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
303
+ YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len );
304
+
305
+ void *yyalloc (yy_size_t );
306
+ void *yyrealloc (void *,yy_size_t );
307
+ void yyfree (void * );
308
+
309
+ #define yy_new_buffer yy_create_buffer
310
+
311
+ #define yy_set_interactive(is_interactive) \
312
+ { \
313
+ if ( ! YY_CURRENT_BUFFER ){ \
314
+ yyensure_buffer_stack (); \
315
+ YY_CURRENT_BUFFER_LVALUE = \
316
+ yy_create_buffer(yyin,YY_BUF_SIZE ); \
317
+ } \
318
+ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
319
+ }
320
+
321
+ #define yy_set_bol(at_bol) \
322
+ { \
323
+ if ( ! YY_CURRENT_BUFFER ){\
324
+ yyensure_buffer_stack (); \
325
+ YY_CURRENT_BUFFER_LVALUE = \
326
+ yy_create_buffer(yyin,YY_BUF_SIZE ); \
327
+ } \
328
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
329
+ }
330
+
331
+ #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
332
+
333
+ /* Begin user sect3 */
334
+
335
+ #define yywrap(n) 1
336
+ #define YY_SKIP_YYWRAP
337
+
338
+ typedef unsigned char YY_CHAR;
339
+
340
+ FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
341
+
342
+ typedef int yy_state_type;
343
+
344
+ extern int yylineno;
345
+
346
+ int yylineno = 1;
347
+
348
+ extern char *yytext;
349
+ #define yytext_ptr yytext
350
+
351
+ static yy_state_type yy_get_previous_state (void );
352
+ static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
353
+ static int yy_get_next_buffer (void );
354
+ static void yy_fatal_error (yyconst char msg[] );
355
+
356
+ /* Done after the current pattern has been matched and before the
357
+ * corresponding action - sets up yytext.
358
+ */
359
+ #define YY_DO_BEFORE_ACTION \
360
+ (yytext_ptr) = yy_bp; \
361
+ yyleng = (yy_size_t) (yy_cp - yy_bp); \
362
+ (yy_hold_char) = *yy_cp; \
363
+ *yy_cp = '\0'; \
364
+ (yy_c_buf_p) = yy_cp;
365
+
366
+ #define YY_NUM_RULES 11
367
+ #define YY_END_OF_BUFFER 12
368
+ /* This struct is not used in this scanner,
369
+ but its presence is necessary. */
370
+ struct yy_trans_info
371
+ {
372
+ flex_int32_t yy_verify;
373
+ flex_int32_t yy_nxt;
374
+ };
375
+ static yyconst flex_int16_t yy_accept[38] =
376
+ { 0,
377
+ 0, 0, 12, 10, 2, 1, 10, 10, 10, 8,
378
+ 7, 7, 9, 4, 2, 0, 3, 0, 5, 0,
379
+ 8, 7, 7, 8, 0, 0, 6, 4, 4, 0,
380
+ 5, 0, 0, 8, 7, 6, 0
381
+ } ;
382
+
383
+ static yyconst flex_int32_t yy_ec[256] =
384
+ { 0,
385
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
386
+ 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
387
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
388
+ 1, 2, 1, 1, 4, 1, 1, 1, 5, 1,
389
+ 1, 1, 6, 1, 7, 8, 9, 10, 11, 11,
390
+ 11, 11, 11, 11, 11, 11, 11, 9, 1, 1,
391
+ 12, 1, 1, 1, 13, 13, 13, 13, 14, 13,
392
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
393
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
394
+ 1, 16, 1, 1, 17, 1, 13, 13, 13, 13,
395
+
396
+ 14, 13, 15, 15, 15, 15, 15, 15, 15, 15,
397
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 18,
398
+ 15, 15, 1, 1, 1, 1, 1, 15, 15, 15,
399
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
400
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
401
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
402
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
403
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
404
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
405
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
406
+
407
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
408
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
409
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
410
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
411
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
412
+ 15, 15, 15, 15, 15
413
+ } ;
414
+
415
+ static yyconst flex_int32_t yy_meta[19] =
416
+ { 0,
417
+ 1, 1, 2, 1, 1, 1, 3, 3, 3, 4,
418
+ 4, 1, 5, 4, 3, 1, 3, 3
419
+ } ;
420
+
421
+ static yyconst flex_int16_t yy_base[45] =
422
+ { 0,
423
+ 0, 0, 61, 86, 58, 86, 55, 14, 23, 43,
424
+ 10, 46, 86, 28, 47, 40, 86, 16, 86, 22,
425
+ 28, 0, 0, 0, 40, 0, 24, 45, 0, 24,
426
+ 39, 43, 12, 14, 0, 22, 86, 62, 67, 22,
427
+ 70, 75, 77, 80
428
+ } ;
429
+
430
+ static yyconst flex_int16_t yy_def[45] =
431
+ { 0,
432
+ 37, 1, 37, 37, 37, 37, 38, 39, 37, 40,
433
+ 9, 9, 37, 41, 37, 38, 37, 39, 37, 42,
434
+ 40, 11, 12, 21, 37, 43, 44, 41, 28, 39,
435
+ 39, 42, 37, 37, 43, 44, 0, 37, 37, 37,
436
+ 37, 37, 37, 37
437
+ } ;
438
+
439
+ static yyconst flex_int16_t yy_nxt[105] =
440
+ { 0,
441
+ 4, 5, 6, 7, 8, 9, 9, 10, 4, 11,
442
+ 12, 13, 14, 14, 14, 4, 14, 14, 19, 23,
443
+ 19, 34, 34, 34, 34, 24, 31, 26, 19, 20,
444
+ 21, 20, 22, 23, 27, 27, 27, 32, 36, 20,
445
+ 36, 25, 17, 19, 29, 33, 33, 31, 15, 34,
446
+ 34, 27, 27, 27, 20, 23, 25, 17, 32, 15,
447
+ 37, 29, 16, 16, 16, 16, 16, 18, 37, 18,
448
+ 18, 18, 28, 28, 28, 30, 37, 30, 30, 30,
449
+ 35, 35, 27, 27, 27, 3, 37, 37, 37, 37,
450
+ 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
451
+
452
+ 37, 37, 37, 37
453
+ } ;
454
+
455
+ static yyconst flex_int16_t yy_chk[105] =
456
+ { 0,
457
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
458
+ 1, 1, 1, 1, 1, 1, 1, 1, 8, 11,
459
+ 18, 33, 33, 34, 34, 40, 20, 11, 30, 8,
460
+ 9, 18, 9, 9, 14, 14, 14, 20, 36, 30,
461
+ 27, 21, 16, 31, 14, 25, 25, 32, 15, 25,
462
+ 25, 28, 28, 28, 31, 12, 10, 7, 32, 5,
463
+ 3, 28, 38, 38, 38, 38, 38, 39, 0, 39,
464
+ 39, 39, 41, 41, 41, 42, 0, 42, 42, 42,
465
+ 43, 43, 44, 44, 44, 37, 37, 37, 37, 37,
466
+ 37, 37, 37, 37, 37, 37, 37, 37, 37, 37,
467
+
468
+ 37, 37, 37, 37
469
+ } ;
470
+
471
+ static yy_state_type yy_last_accepting_state;
472
+ static char *yy_last_accepting_cpos;
473
+
474
+ extern int yy_flex_debug;
475
+ int yy_flex_debug = 0;
476
+
477
+ /* The intent behind this definition is that it'll catch
478
+ * any uses of REJECT which flex missed.
479
+ */
480
+ #define REJECT reject_used_but_not_detected
481
+ #define yymore() yymore_used_but_not_detected
482
+ #define YY_MORE_ADJ 0
483
+ #define YY_RESTORE_YY_MORE_OFFSET
484
+ char *yytext;
485
+ #line 1 "pool_config.l"
486
+ /* -*-pgsql-c-*- */
487
+ /*
488
+ *
489
+ * $Header$
490
+ *
491
+ * pgpool: a language independent connection pool server for PostgreSQL
492
+ * written by Tatsuo Ishii
493
+ *
494
+ * Copyright (c) 2003-2013 PgPool Global Development Group
495
+ *
496
+ * Permission to use, copy, modify, and distribute this software and
497
+ * its documentation for any purpose and without fee is hereby
498
+ * granted, provided that the above copyright notice appear in all
499
+ * copies and that both that copyright notice and this permission
500
+ * notice appear in supporting documentation, and that the name of the
501
+ * author not be used in advertising or publicity pertaining to
502
+ * distribution of the software without specific, written prior
503
+ * permission. The author makes no representations about the
504
+ * suitability of this software for any purpose. It is provided "as
505
+ * is" without express or implied warranty.
506
+ *
507
+ * pool_config.l: read configuration file
508
+ *
509
+ */
510
+ #line 27 "pool_config.l"
511
+
512
+ #include "pool.h"
513
+ #include "pool_config.h"
514
+
515
+ #include <stdio.h>
516
+ #include <stdlib.h>
517
+ #include <string.h>
518
+
519
+ #define CHECK_CONTEXT(mask, context) ((mask) & (context))
520
+
521
+ /* to shut off compiler warnings */
522
+ int yylex(void);
523
+
524
+ POOL_CONFIG *pool_config; /* configuration values */
525
+ POOL_SYSTEMDB_CONNECTION_POOL *system_db_info;
526
+ static unsigned Lineno;
527
+ static char *default_reset_query_list[] = {"ABORT", "DISCARD ALL"};
528
+ static char *default_black_function_list[] = {"nextval", "setval"};
529
+
530
+ typedef enum {
531
+ POOL_KEY = 1,
532
+ POOL_INTEGER,
533
+ POOL_REAL,
534
+ POOL_STRING,
535
+ POOL_UNQUOTED_STRING,
536
+ POOL_EQUALS,
537
+ POOL_EOL,
538
+ POOL_PARSE_ERROR
539
+ } POOL_TOKEN;
540
+
541
+ static char *extract_string(char *value, POOL_TOKEN token);
542
+ static char **extract_string_tokens(char *str, char *delim, int *n);
543
+ static void clear_host_entry(int slot);
544
+
545
+ #line 546 "../../pgpool2/pool_config.c"
546
+
547
+ #define INITIAL 0
548
+
549
+ #ifndef YY_NO_UNISTD_H
550
+ /* Special case for "unistd.h", since it is non-ANSI. We include it way
551
+ * down here because we want the user's section 1 to have been scanned first.
552
+ * The user has a chance to override it with an option.
553
+ */
554
+ #include <unistd.h>
555
+ #endif
556
+
557
+ #ifndef YY_EXTRA_TYPE
558
+ #define YY_EXTRA_TYPE void *
559
+ #endif
560
+
561
+ static int yy_init_globals (void );
562
+
563
+ /* Accessor methods to globals.
564
+ These are made visible to non-reentrant scanners for convenience. */
565
+
566
+ int yylex_destroy (void );
567
+
568
+ int yyget_debug (void );
569
+
570
+ void yyset_debug (int debug_flag );
571
+
572
+ YY_EXTRA_TYPE yyget_extra (void );
573
+
574
+ void yyset_extra (YY_EXTRA_TYPE user_defined );
575
+
576
+ FILE *yyget_in (void );
577
+
578
+ void yyset_in (FILE * in_str );
579
+
580
+ FILE *yyget_out (void );
581
+
582
+ void yyset_out (FILE * out_str );
583
+
584
+ yy_size_t yyget_leng (void );
585
+
586
+ char *yyget_text (void );
587
+
588
+ int yyget_lineno (void );
589
+
590
+ void yyset_lineno (int line_number );
591
+
592
+ /* Macros after this point can all be overridden by user definitions in
593
+ * section 1.
594
+ */
595
+
596
+ #ifndef YY_SKIP_YYWRAP
597
+ #ifdef __cplusplus
598
+ extern "C" int yywrap (void );
599
+ #else
600
+ extern int yywrap (void );
601
+ #endif
602
+ #endif
603
+
604
+ #ifndef yytext_ptr
605
+ static void yy_flex_strncpy (char *,yyconst char *,int );
606
+ #endif
607
+
608
+ #ifdef YY_NEED_STRLEN
609
+ static int yy_flex_strlen (yyconst char * );
610
+ #endif
611
+
612
+ #ifndef YY_NO_INPUT
613
+
614
+ #ifdef __cplusplus
615
+ static int yyinput (void );
616
+ #else
617
+ static int input (void );
618
+ #endif
619
+
620
+ #endif
621
+
622
+ /* Amount of stuff to slurp up with each read. */
623
+ #ifndef YY_READ_BUF_SIZE
624
+ #define YY_READ_BUF_SIZE 8192
625
+ #endif
626
+
627
+ /* Copy whatever the last rule matched to the standard output. */
628
+ #ifndef ECHO
629
+ /* This used to be an fputs(), but since the string might contain NUL's,
630
+ * we now use fwrite().
631
+ */
632
+ #define ECHO fwrite( yytext, yyleng, 1, yyout )
633
+ #endif
634
+
635
+ /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
636
+ * is returned in "result".
637
+ */
638
+ #ifndef YY_INPUT
639
+ #define YY_INPUT(buf,result,max_size) \
640
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
641
+ { \
642
+ int c = '*'; \
643
+ yy_size_t n; \
644
+ for ( n = 0; n < max_size && \
645
+ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
646
+ buf[n] = (char) c; \
647
+ if ( c == '\n' ) \
648
+ buf[n++] = (char) c; \
649
+ if ( c == EOF && ferror( yyin ) ) \
650
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
651
+ result = n; \
652
+ } \
653
+ else \
654
+ { \
655
+ errno=0; \
656
+ while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
657
+ { \
658
+ if( errno != EINTR) \
659
+ { \
660
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
661
+ break; \
662
+ } \
663
+ errno=0; \
664
+ clearerr(yyin); \
665
+ } \
666
+ }\
667
+ \
668
+
669
+ #endif
670
+
671
+ /* No semi-colon after return; correct usage is to write "yyterminate();" -
672
+ * we don't want an extra ';' after the "return" because that will cause
673
+ * some compilers to complain about unreachable statements.
674
+ */
675
+ #ifndef yyterminate
676
+ #define yyterminate() return YY_NULL
677
+ #endif
678
+
679
+ /* Number of entries by which start-condition stack grows. */
680
+ #ifndef YY_START_STACK_INCR
681
+ #define YY_START_STACK_INCR 25
682
+ #endif
683
+
684
+ /* Report a fatal error. */
685
+ #ifndef YY_FATAL_ERROR
686
+ #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
687
+ #endif
688
+
689
+ /* end tables serialization structures and prototypes */
690
+
691
+ /* Default declaration of generated scanner - a define so the user can
692
+ * easily add parameters.
693
+ */
694
+ #ifndef YY_DECL
695
+ #define YY_DECL_IS_OURS 1
696
+
697
+ extern int yylex (void);
698
+
699
+ #define YY_DECL int yylex (void)
700
+ #endif /* !YY_DECL */
701
+
702
+ /* Code executed at the beginning of each rule, after yytext and yyleng
703
+ * have been set up.
704
+ */
705
+ #ifndef YY_USER_ACTION
706
+ #define YY_USER_ACTION
707
+ #endif
708
+
709
+ /* Code executed at the end of each rule. */
710
+ #ifndef YY_BREAK
711
+ #define YY_BREAK break;
712
+ #endif
713
+
714
+ #define YY_RULE_SETUP \
715
+ YY_USER_ACTION
716
+
717
+ /** The main scanner function which does all the work.
718
+ */
719
+ YY_DECL
720
+ {
721
+ register yy_state_type yy_current_state;
722
+ register char *yy_cp, *yy_bp;
723
+ register int yy_act;
724
+
725
+ #line 85 "pool_config.l"
726
+
727
+
728
+ #line 729 "../../pgpool2/pool_config.c"
729
+
730
+ if ( !(yy_init) )
731
+ {
732
+ (yy_init) = 1;
733
+
734
+ #ifdef YY_USER_INIT
735
+ YY_USER_INIT;
736
+ #endif
737
+
738
+ if ( ! (yy_start) )
739
+ (yy_start) = 1; /* first start state */
740
+
741
+ if ( ! yyin )
742
+ yyin = stdin;
743
+
744
+ if ( ! yyout )
745
+ yyout = stdout;
746
+
747
+ if ( ! YY_CURRENT_BUFFER ) {
748
+ yyensure_buffer_stack ();
749
+ YY_CURRENT_BUFFER_LVALUE =
750
+ yy_create_buffer(yyin,YY_BUF_SIZE );
751
+ }
752
+
753
+ yy_load_buffer_state( );
754
+ }
755
+
756
+ while ( 1 ) /* loops until end-of-file is reached */
757
+ {
758
+ yy_cp = (yy_c_buf_p);
759
+
760
+ /* Support of yytext. */
761
+ *yy_cp = (yy_hold_char);
762
+
763
+ /* yy_bp points to the position in yy_ch_buf of the start of
764
+ * the current run.
765
+ */
766
+ yy_bp = yy_cp;
767
+
768
+ yy_current_state = (yy_start);
769
+ yy_match:
770
+ do
771
+ {
772
+ register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
773
+ if ( yy_accept[yy_current_state] )
774
+ {
775
+ (yy_last_accepting_state) = yy_current_state;
776
+ (yy_last_accepting_cpos) = yy_cp;
777
+ }
778
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
779
+ {
780
+ yy_current_state = (int) yy_def[yy_current_state];
781
+ if ( yy_current_state >= 38 )
782
+ yy_c = yy_meta[(unsigned int) yy_c];
783
+ }
784
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
785
+ ++yy_cp;
786
+ }
787
+ while ( yy_current_state != 37 );
788
+ yy_cp = (yy_last_accepting_cpos);
789
+ yy_current_state = (yy_last_accepting_state);
790
+
791
+ yy_find_action:
792
+ yy_act = yy_accept[yy_current_state];
793
+
794
+ YY_DO_BEFORE_ACTION;
795
+
796
+ do_action: /* This label is used only to access EOF actions. */
797
+
798
+ switch ( yy_act )
799
+ { /* beginning of action switch */
800
+ case 0: /* must back up */
801
+ /* undo the effects of YY_DO_BEFORE_ACTION */
802
+ *yy_cp = (yy_hold_char);
803
+ yy_cp = (yy_last_accepting_cpos);
804
+ yy_current_state = (yy_last_accepting_state);
805
+ goto yy_find_action;
806
+
807
+ case 1:
808
+ /* rule 1 can match eol */
809
+ YY_RULE_SETUP
810
+ #line 87 "pool_config.l"
811
+ Lineno++; return POOL_EOL;
812
+ YY_BREAK
813
+ case 2:
814
+ YY_RULE_SETUP
815
+ #line 88 "pool_config.l"
816
+ /* eat whitespace */
817
+ YY_BREAK
818
+ case 3:
819
+ *yy_cp = (yy_hold_char); /* undo effects of setting up yytext */
820
+ (yy_c_buf_p) = yy_cp -= 1;
821
+ YY_DO_BEFORE_ACTION; /* set up yytext again */
822
+ YY_RULE_SETUP
823
+ #line 89 "pool_config.l"
824
+ /* eat comment */
825
+ YY_BREAK
826
+ case 4:
827
+ YY_RULE_SETUP
828
+ #line 91 "pool_config.l"
829
+ return POOL_KEY;
830
+ YY_BREAK
831
+ case 5:
832
+ YY_RULE_SETUP
833
+ #line 92 "pool_config.l"
834
+ return POOL_STRING;
835
+ YY_BREAK
836
+ case 6:
837
+ YY_RULE_SETUP
838
+ #line 93 "pool_config.l"
839
+ return POOL_UNQUOTED_STRING;
840
+ YY_BREAK
841
+ case 7:
842
+ YY_RULE_SETUP
843
+ #line 94 "pool_config.l"
844
+ return POOL_INTEGER;
845
+ YY_BREAK
846
+ case 8:
847
+ YY_RULE_SETUP
848
+ #line 95 "pool_config.l"
849
+ return POOL_REAL;
850
+ YY_BREAK
851
+ case 9:
852
+ YY_RULE_SETUP
853
+ #line 96 "pool_config.l"
854
+ return POOL_EQUALS;
855
+ YY_BREAK
856
+ case 10:
857
+ YY_RULE_SETUP
858
+ #line 98 "pool_config.l"
859
+ return POOL_PARSE_ERROR;
860
+ YY_BREAK
861
+ case 11:
862
+ YY_RULE_SETUP
863
+ #line 100 "pool_config.l"
864
+ ECHO;
865
+ YY_BREAK
866
+ #line 867 "../../pgpool2/pool_config.c"
867
+ case YY_STATE_EOF(INITIAL):
868
+ yyterminate();
869
+
870
+ case YY_END_OF_BUFFER:
871
+ {
872
+ /* Amount of text matched not including the EOB char. */
873
+ int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
874
+
875
+ /* Undo the effects of YY_DO_BEFORE_ACTION. */
876
+ *yy_cp = (yy_hold_char);
877
+ YY_RESTORE_YY_MORE_OFFSET
878
+
879
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
880
+ {
881
+ /* We're scanning a new file or input source. It's
882
+ * possible that this happened because the user
883
+ * just pointed yyin at a new source and called
884
+ * yylex(). If so, then we have to assure
885
+ * consistency between YY_CURRENT_BUFFER and our
886
+ * globals. Here is the right place to do so, because
887
+ * this is the first action (other than possibly a
888
+ * back-up) that will match for the new input source.
889
+ */
890
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
891
+ YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
892
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
893
+ }
894
+
895
+ /* Note that here we test for yy_c_buf_p "<=" to the position
896
+ * of the first EOB in the buffer, since yy_c_buf_p will
897
+ * already have been incremented past the NUL character
898
+ * (since all states make transitions on EOB to the
899
+ * end-of-buffer state). Contrast this with the test
900
+ * in input().
901
+ */
902
+ if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
903
+ { /* This was really a NUL. */
904
+ yy_state_type yy_next_state;
905
+
906
+ (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
907
+
908
+ yy_current_state = yy_get_previous_state( );
909
+
910
+ /* Okay, we're now positioned to make the NUL
911
+ * transition. We couldn't have
912
+ * yy_get_previous_state() go ahead and do it
913
+ * for us because it doesn't know how to deal
914
+ * with the possibility of jamming (and we don't
915
+ * want to build jamming into it because then it
916
+ * will run more slowly).
917
+ */
918
+
919
+ yy_next_state = yy_try_NUL_trans( yy_current_state );
920
+
921
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
922
+
923
+ if ( yy_next_state )
924
+ {
925
+ /* Consume the NUL. */
926
+ yy_cp = ++(yy_c_buf_p);
927
+ yy_current_state = yy_next_state;
928
+ goto yy_match;
929
+ }
930
+
931
+ else
932
+ {
933
+ yy_cp = (yy_last_accepting_cpos);
934
+ yy_current_state = (yy_last_accepting_state);
935
+ goto yy_find_action;
936
+ }
937
+ }
938
+
939
+ else switch ( yy_get_next_buffer( ) )
940
+ {
941
+ case EOB_ACT_END_OF_FILE:
942
+ {
943
+ (yy_did_buffer_switch_on_eof) = 0;
944
+
945
+ if ( yywrap( ) )
946
+ {
947
+ /* Note: because we've taken care in
948
+ * yy_get_next_buffer() to have set up
949
+ * yytext, we can now set up
950
+ * yy_c_buf_p so that if some total
951
+ * hoser (like flex itself) wants to
952
+ * call the scanner after we return the
953
+ * YY_NULL, it'll still work - another
954
+ * YY_NULL will get returned.
955
+ */
956
+ (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
957
+
958
+ yy_act = YY_STATE_EOF(YY_START);
959
+ goto do_action;
960
+ }
961
+
962
+ else
963
+ {
964
+ if ( ! (yy_did_buffer_switch_on_eof) )
965
+ YY_NEW_FILE;
966
+ }
967
+ break;
968
+ }
969
+
970
+ case EOB_ACT_CONTINUE_SCAN:
971
+ (yy_c_buf_p) =
972
+ (yytext_ptr) + yy_amount_of_matched_text;
973
+
974
+ yy_current_state = yy_get_previous_state( );
975
+
976
+ yy_cp = (yy_c_buf_p);
977
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
978
+ goto yy_match;
979
+
980
+ case EOB_ACT_LAST_MATCH:
981
+ (yy_c_buf_p) =
982
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
983
+
984
+ yy_current_state = yy_get_previous_state( );
985
+
986
+ yy_cp = (yy_c_buf_p);
987
+ yy_bp = (yytext_ptr) + YY_MORE_ADJ;
988
+ goto yy_find_action;
989
+ }
990
+ break;
991
+ }
992
+
993
+ default:
994
+ YY_FATAL_ERROR(
995
+ "fatal flex scanner internal error--no action found" );
996
+ } /* end of action switch */
997
+ } /* end of scanning one token */
998
+ } /* end of yylex */
999
+
1000
+ /* yy_get_next_buffer - try to read in a new buffer
1001
+ *
1002
+ * Returns a code representing an action:
1003
+ * EOB_ACT_LAST_MATCH -
1004
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1005
+ * EOB_ACT_END_OF_FILE - end of file
1006
+ */
1007
+ static int yy_get_next_buffer (void)
1008
+ {
1009
+ register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1010
+ register char *source = (yytext_ptr);
1011
+ register int number_to_move, i;
1012
+ int ret_val;
1013
+
1014
+ if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1015
+ YY_FATAL_ERROR(
1016
+ "fatal flex scanner internal error--end of buffer missed" );
1017
+
1018
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1019
+ { /* Don't try to fill the buffer, so this is an EOF. */
1020
+ if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1021
+ {
1022
+ /* We matched a single character, the EOB, so
1023
+ * treat this as a final EOF.
1024
+ */
1025
+ return EOB_ACT_END_OF_FILE;
1026
+ }
1027
+
1028
+ else
1029
+ {
1030
+ /* We matched some text prior to the EOB, first
1031
+ * process it.
1032
+ */
1033
+ return EOB_ACT_LAST_MATCH;
1034
+ }
1035
+ }
1036
+
1037
+ /* Try to read more data. */
1038
+
1039
+ /* First move last chars to start of buffer. */
1040
+ number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1041
+
1042
+ for ( i = 0; i < number_to_move; ++i )
1043
+ *(dest++) = *(source++);
1044
+
1045
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1046
+ /* don't do the read, it's not guaranteed to return an EOF,
1047
+ * just force an EOF
1048
+ */
1049
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1050
+
1051
+ else
1052
+ {
1053
+ yy_size_t num_to_read =
1054
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1055
+
1056
+ while ( num_to_read <= 0 )
1057
+ { /* Not enough room in the buffer - grow it. */
1058
+
1059
+ /* just a shorter name for the current buffer */
1060
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1061
+
1062
+ int yy_c_buf_p_offset =
1063
+ (int) ((yy_c_buf_p) - b->yy_ch_buf);
1064
+
1065
+ if ( b->yy_is_our_buffer )
1066
+ {
1067
+ yy_size_t new_size = b->yy_buf_size * 2;
1068
+
1069
+ if ( new_size <= 0 )
1070
+ b->yy_buf_size += b->yy_buf_size / 8;
1071
+ else
1072
+ b->yy_buf_size *= 2;
1073
+
1074
+ b->yy_ch_buf = (char *)
1075
+ /* Include room in for 2 EOB chars. */
1076
+ yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1077
+ }
1078
+ else
1079
+ /* Can't grow it, we don't own it. */
1080
+ b->yy_ch_buf = 0;
1081
+
1082
+ if ( ! b->yy_ch_buf )
1083
+ YY_FATAL_ERROR(
1084
+ "fatal error - scanner input buffer overflow" );
1085
+
1086
+ (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1087
+
1088
+ num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1089
+ number_to_move - 1;
1090
+
1091
+ }
1092
+
1093
+ if ( num_to_read > YY_READ_BUF_SIZE )
1094
+ num_to_read = YY_READ_BUF_SIZE;
1095
+
1096
+ /* Read in more data. */
1097
+ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1098
+ (yy_n_chars), num_to_read );
1099
+
1100
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1101
+ }
1102
+
1103
+ if ( (yy_n_chars) == 0 )
1104
+ {
1105
+ if ( number_to_move == YY_MORE_ADJ )
1106
+ {
1107
+ ret_val = EOB_ACT_END_OF_FILE;
1108
+ yyrestart(yyin );
1109
+ }
1110
+
1111
+ else
1112
+ {
1113
+ ret_val = EOB_ACT_LAST_MATCH;
1114
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1115
+ YY_BUFFER_EOF_PENDING;
1116
+ }
1117
+ }
1118
+
1119
+ else
1120
+ ret_val = EOB_ACT_CONTINUE_SCAN;
1121
+
1122
+ if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1123
+ /* Extend the array by 50%, plus the number we really need. */
1124
+ yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1125
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
1126
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1127
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1128
+ }
1129
+
1130
+ (yy_n_chars) += number_to_move;
1131
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1132
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1133
+
1134
+ (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1135
+
1136
+ return ret_val;
1137
+ }
1138
+
1139
+ /* yy_get_previous_state - get the state just before the EOB char was reached */
1140
+
1141
+ static yy_state_type yy_get_previous_state (void)
1142
+ {
1143
+ register yy_state_type yy_current_state;
1144
+ register char *yy_cp;
1145
+
1146
+ yy_current_state = (yy_start);
1147
+
1148
+ for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1149
+ {
1150
+ register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1151
+ if ( yy_accept[yy_current_state] )
1152
+ {
1153
+ (yy_last_accepting_state) = yy_current_state;
1154
+ (yy_last_accepting_cpos) = yy_cp;
1155
+ }
1156
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1157
+ {
1158
+ yy_current_state = (int) yy_def[yy_current_state];
1159
+ if ( yy_current_state >= 38 )
1160
+ yy_c = yy_meta[(unsigned int) yy_c];
1161
+ }
1162
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1163
+ }
1164
+
1165
+ return yy_current_state;
1166
+ }
1167
+
1168
+ /* yy_try_NUL_trans - try to make a transition on the NUL character
1169
+ *
1170
+ * synopsis
1171
+ * next_state = yy_try_NUL_trans( current_state );
1172
+ */
1173
+ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1174
+ {
1175
+ register int yy_is_jam;
1176
+ register char *yy_cp = (yy_c_buf_p);
1177
+
1178
+ register YY_CHAR yy_c = 1;
1179
+ if ( yy_accept[yy_current_state] )
1180
+ {
1181
+ (yy_last_accepting_state) = yy_current_state;
1182
+ (yy_last_accepting_cpos) = yy_cp;
1183
+ }
1184
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1185
+ {
1186
+ yy_current_state = (int) yy_def[yy_current_state];
1187
+ if ( yy_current_state >= 38 )
1188
+ yy_c = yy_meta[(unsigned int) yy_c];
1189
+ }
1190
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1191
+ yy_is_jam = (yy_current_state == 37);
1192
+
1193
+ return yy_is_jam ? 0 : yy_current_state;
1194
+ }
1195
+
1196
+ #ifndef YY_NO_INPUT
1197
+ #ifdef __cplusplus
1198
+ static int yyinput (void)
1199
+ #else
1200
+ static int input (void)
1201
+ #endif
1202
+
1203
+ {
1204
+ int c;
1205
+
1206
+ *(yy_c_buf_p) = (yy_hold_char);
1207
+
1208
+ if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1209
+ {
1210
+ /* yy_c_buf_p now points to the character we want to return.
1211
+ * If this occurs *before* the EOB characters, then it's a
1212
+ * valid NUL; if not, then we've hit the end of the buffer.
1213
+ */
1214
+ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1215
+ /* This was really a NUL. */
1216
+ *(yy_c_buf_p) = '\0';
1217
+
1218
+ else
1219
+ { /* need more input */
1220
+ yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
1221
+ ++(yy_c_buf_p);
1222
+
1223
+ switch ( yy_get_next_buffer( ) )
1224
+ {
1225
+ case EOB_ACT_LAST_MATCH:
1226
+ /* This happens because yy_g_n_b()
1227
+ * sees that we've accumulated a
1228
+ * token and flags that we need to
1229
+ * try matching the token before
1230
+ * proceeding. But for input(),
1231
+ * there's no matching to consider.
1232
+ * So convert the EOB_ACT_LAST_MATCH
1233
+ * to EOB_ACT_END_OF_FILE.
1234
+ */
1235
+
1236
+ /* Reset buffer status. */
1237
+ yyrestart(yyin );
1238
+
1239
+ /*FALLTHROUGH*/
1240
+
1241
+ case EOB_ACT_END_OF_FILE:
1242
+ {
1243
+ if ( yywrap( ) )
1244
+ return 0;
1245
+
1246
+ if ( ! (yy_did_buffer_switch_on_eof) )
1247
+ YY_NEW_FILE;
1248
+ #ifdef __cplusplus
1249
+ return yyinput();
1250
+ #else
1251
+ return input();
1252
+ #endif
1253
+ }
1254
+
1255
+ case EOB_ACT_CONTINUE_SCAN:
1256
+ (yy_c_buf_p) = (yytext_ptr) + offset;
1257
+ break;
1258
+ }
1259
+ }
1260
+ }
1261
+
1262
+ c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1263
+ *(yy_c_buf_p) = '\0'; /* preserve yytext */
1264
+ (yy_hold_char) = *++(yy_c_buf_p);
1265
+
1266
+ return c;
1267
+ }
1268
+ #endif /* ifndef YY_NO_INPUT */
1269
+
1270
+ /** Immediately switch to a different input stream.
1271
+ * @param input_file A readable stream.
1272
+ *
1273
+ * @note This function does not reset the start condition to @c INITIAL .
1274
+ */
1275
+ void yyrestart (FILE * input_file )
1276
+ {
1277
+
1278
+ if ( ! YY_CURRENT_BUFFER ){
1279
+ yyensure_buffer_stack ();
1280
+ YY_CURRENT_BUFFER_LVALUE =
1281
+ yy_create_buffer(yyin,YY_BUF_SIZE );
1282
+ }
1283
+
1284
+ yy_init_buffer(YY_CURRENT_BUFFER,input_file );
1285
+ yy_load_buffer_state( );
1286
+ }
1287
+
1288
+ /** Switch to a different input buffer.
1289
+ * @param new_buffer The new input buffer.
1290
+ *
1291
+ */
1292
+ void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
1293
+ {
1294
+
1295
+ /* TODO. We should be able to replace this entire function body
1296
+ * with
1297
+ * yypop_buffer_state();
1298
+ * yypush_buffer_state(new_buffer);
1299
+ */
1300
+ yyensure_buffer_stack ();
1301
+ if ( YY_CURRENT_BUFFER == new_buffer )
1302
+ return;
1303
+
1304
+ if ( YY_CURRENT_BUFFER )
1305
+ {
1306
+ /* Flush out information for old buffer. */
1307
+ *(yy_c_buf_p) = (yy_hold_char);
1308
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1309
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1310
+ }
1311
+
1312
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
1313
+ yy_load_buffer_state( );
1314
+
1315
+ /* We don't actually know whether we did this switch during
1316
+ * EOF (yywrap()) processing, but the only time this flag
1317
+ * is looked at is after yywrap() is called, so it's safe
1318
+ * to go ahead and always set it.
1319
+ */
1320
+ (yy_did_buffer_switch_on_eof) = 1;
1321
+ }
1322
+
1323
+ static void yy_load_buffer_state (void)
1324
+ {
1325
+ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1326
+ (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1327
+ yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1328
+ (yy_hold_char) = *(yy_c_buf_p);
1329
+ }
1330
+
1331
+ /** Allocate and initialize an input buffer state.
1332
+ * @param file A readable stream.
1333
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1334
+ *
1335
+ * @return the allocated buffer state.
1336
+ */
1337
+ YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
1338
+ {
1339
+ YY_BUFFER_STATE b;
1340
+
1341
+ b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
1342
+ if ( ! b )
1343
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1344
+
1345
+ b->yy_buf_size = size;
1346
+
1347
+ /* yy_ch_buf has to be 2 characters longer than the size given because
1348
+ * we need to put in 2 end-of-buffer characters.
1349
+ */
1350
+ b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 );
1351
+ if ( ! b->yy_ch_buf )
1352
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1353
+
1354
+ b->yy_is_our_buffer = 1;
1355
+
1356
+ yy_init_buffer(b,file );
1357
+
1358
+ return b;
1359
+ }
1360
+
1361
+ /** Destroy the buffer.
1362
+ * @param b a buffer created with yy_create_buffer()
1363
+ *
1364
+ */
1365
+ void yy_delete_buffer (YY_BUFFER_STATE b )
1366
+ {
1367
+
1368
+ if ( ! b )
1369
+ return;
1370
+
1371
+ if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1372
+ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1373
+
1374
+ if ( b->yy_is_our_buffer )
1375
+ yyfree((void *) b->yy_ch_buf );
1376
+
1377
+ yyfree((void *) b );
1378
+ }
1379
+
1380
+ /* Initializes or reinitializes a buffer.
1381
+ * This function is sometimes called more than once on the same buffer,
1382
+ * such as during a yyrestart() or at EOF.
1383
+ */
1384
+ static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
1385
+
1386
+ {
1387
+ int oerrno = errno;
1388
+
1389
+ yy_flush_buffer(b );
1390
+
1391
+ b->yy_input_file = file;
1392
+ b->yy_fill_buffer = 1;
1393
+
1394
+ /* If b is the current buffer, then yy_init_buffer was _probably_
1395
+ * called from yyrestart() or through yy_get_next_buffer.
1396
+ * In that case, we don't want to reset the lineno or column.
1397
+ */
1398
+ if (b != YY_CURRENT_BUFFER){
1399
+ b->yy_bs_lineno = 1;
1400
+ b->yy_bs_column = 0;
1401
+ }
1402
+
1403
+ b->yy_is_interactive = 0;
1404
+
1405
+ errno = oerrno;
1406
+ }
1407
+
1408
+ /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1409
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1410
+ *
1411
+ */
1412
+ void yy_flush_buffer (YY_BUFFER_STATE b )
1413
+ {
1414
+ if ( ! b )
1415
+ return;
1416
+
1417
+ b->yy_n_chars = 0;
1418
+
1419
+ /* We always need two end-of-buffer characters. The first causes
1420
+ * a transition to the end-of-buffer state. The second causes
1421
+ * a jam in that state.
1422
+ */
1423
+ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1424
+ b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1425
+
1426
+ b->yy_buf_pos = &b->yy_ch_buf[0];
1427
+
1428
+ b->yy_at_bol = 1;
1429
+ b->yy_buffer_status = YY_BUFFER_NEW;
1430
+
1431
+ if ( b == YY_CURRENT_BUFFER )
1432
+ yy_load_buffer_state( );
1433
+ }
1434
+
1435
+ /** Pushes the new state onto the stack. The new state becomes
1436
+ * the current state. This function will allocate the stack
1437
+ * if necessary.
1438
+ * @param new_buffer The new state.
1439
+ *
1440
+ */
1441
+ void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
1442
+ {
1443
+ if (new_buffer == NULL)
1444
+ return;
1445
+
1446
+ yyensure_buffer_stack();
1447
+
1448
+ /* This block is copied from yy_switch_to_buffer. */
1449
+ if ( YY_CURRENT_BUFFER )
1450
+ {
1451
+ /* Flush out information for old buffer. */
1452
+ *(yy_c_buf_p) = (yy_hold_char);
1453
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1454
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1455
+ }
1456
+
1457
+ /* Only push if top exists. Otherwise, replace top. */
1458
+ if (YY_CURRENT_BUFFER)
1459
+ (yy_buffer_stack_top)++;
1460
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
1461
+
1462
+ /* copied from yy_switch_to_buffer. */
1463
+ yy_load_buffer_state( );
1464
+ (yy_did_buffer_switch_on_eof) = 1;
1465
+ }
1466
+
1467
+ /** Removes and deletes the top of the stack, if present.
1468
+ * The next element becomes the new top.
1469
+ *
1470
+ */
1471
+ void yypop_buffer_state (void)
1472
+ {
1473
+ if (!YY_CURRENT_BUFFER)
1474
+ return;
1475
+
1476
+ yy_delete_buffer(YY_CURRENT_BUFFER );
1477
+ YY_CURRENT_BUFFER_LVALUE = NULL;
1478
+ if ((yy_buffer_stack_top) > 0)
1479
+ --(yy_buffer_stack_top);
1480
+
1481
+ if (YY_CURRENT_BUFFER) {
1482
+ yy_load_buffer_state( );
1483
+ (yy_did_buffer_switch_on_eof) = 1;
1484
+ }
1485
+ }
1486
+
1487
+ /* Allocates the stack if it does not exist.
1488
+ * Guarantees space for at least one push.
1489
+ */
1490
+ static void yyensure_buffer_stack (void)
1491
+ {
1492
+ yy_size_t num_to_alloc;
1493
+
1494
+ if (!(yy_buffer_stack)) {
1495
+
1496
+ /* First allocation is just for 2 elements, since we don't know if this
1497
+ * scanner will even need a stack. We use 2 instead of 1 to avoid an
1498
+ * immediate realloc on the next call.
1499
+ */
1500
+ num_to_alloc = 1;
1501
+ (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
1502
+ (num_to_alloc * sizeof(struct yy_buffer_state*)
1503
+ );
1504
+ if ( ! (yy_buffer_stack) )
1505
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1506
+
1507
+ memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1508
+
1509
+ (yy_buffer_stack_max) = num_to_alloc;
1510
+ (yy_buffer_stack_top) = 0;
1511
+ return;
1512
+ }
1513
+
1514
+ if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1515
+
1516
+ /* Increase the buffer to prepare for a possible push. */
1517
+ int grow_size = 8 /* arbitrary grow size */;
1518
+
1519
+ num_to_alloc = (yy_buffer_stack_max) + grow_size;
1520
+ (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
1521
+ ((yy_buffer_stack),
1522
+ num_to_alloc * sizeof(struct yy_buffer_state*)
1523
+ );
1524
+ if ( ! (yy_buffer_stack) )
1525
+ YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1526
+
1527
+ /* zero only the new slots.*/
1528
+ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1529
+ (yy_buffer_stack_max) = num_to_alloc;
1530
+ }
1531
+ }
1532
+
1533
+ /** Setup the input buffer state to scan directly from a user-specified character buffer.
1534
+ * @param base the character buffer
1535
+ * @param size the size in bytes of the character buffer
1536
+ *
1537
+ * @return the newly allocated buffer state object.
1538
+ */
1539
+ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
1540
+ {
1541
+ YY_BUFFER_STATE b;
1542
+
1543
+ if ( size < 2 ||
1544
+ base[size-2] != YY_END_OF_BUFFER_CHAR ||
1545
+ base[size-1] != YY_END_OF_BUFFER_CHAR )
1546
+ /* They forgot to leave room for the EOB's. */
1547
+ return 0;
1548
+
1549
+ b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
1550
+ if ( ! b )
1551
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1552
+
1553
+ b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1554
+ b->yy_buf_pos = b->yy_ch_buf = base;
1555
+ b->yy_is_our_buffer = 0;
1556
+ b->yy_input_file = 0;
1557
+ b->yy_n_chars = b->yy_buf_size;
1558
+ b->yy_is_interactive = 0;
1559
+ b->yy_at_bol = 1;
1560
+ b->yy_fill_buffer = 0;
1561
+ b->yy_buffer_status = YY_BUFFER_NEW;
1562
+
1563
+ yy_switch_to_buffer(b );
1564
+
1565
+ return b;
1566
+ }
1567
+
1568
+ /** Setup the input buffer state to scan a string. The next call to yylex() will
1569
+ * scan from a @e copy of @a str.
1570
+ * @param yystr a NUL-terminated string to scan
1571
+ *
1572
+ * @return the newly allocated buffer state object.
1573
+ * @note If you want to scan bytes that may contain NUL values, then use
1574
+ * yy_scan_bytes() instead.
1575
+ */
1576
+ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
1577
+ {
1578
+
1579
+ return yy_scan_bytes(yystr,strlen(yystr) );
1580
+ }
1581
+
1582
+ /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
1583
+ * scan from a @e copy of @a bytes.
1584
+ * @param bytes the byte buffer to scan
1585
+ * @param len the number of bytes in the buffer pointed to by @a bytes.
1586
+ *
1587
+ * @return the newly allocated buffer state object.
1588
+ */
1589
+ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
1590
+ {
1591
+ YY_BUFFER_STATE b;
1592
+ char *buf;
1593
+ yy_size_t n, i;
1594
+
1595
+ /* Get memory for full buffer, including space for trailing EOB's. */
1596
+ n = _yybytes_len + 2;
1597
+ buf = (char *) yyalloc(n );
1598
+ if ( ! buf )
1599
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1600
+
1601
+ for ( i = 0; i < _yybytes_len; ++i )
1602
+ buf[i] = yybytes[i];
1603
+
1604
+ buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1605
+
1606
+ b = yy_scan_buffer(buf,n );
1607
+ if ( ! b )
1608
+ YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1609
+
1610
+ /* It's okay to grow etc. this buffer, and we should throw it
1611
+ * away when we're done.
1612
+ */
1613
+ b->yy_is_our_buffer = 1;
1614
+
1615
+ return b;
1616
+ }
1617
+
1618
+ #ifndef YY_EXIT_FAILURE
1619
+ #define YY_EXIT_FAILURE 2
1620
+ #endif
1621
+
1622
+ static void yy_fatal_error (yyconst char* msg )
1623
+ {
1624
+ (void) fprintf( stderr, "%s\n", msg );
1625
+ exit( YY_EXIT_FAILURE );
1626
+ }
1627
+
1628
+ /* Redefine yyless() so it works in section 3 code. */
1629
+
1630
+ #undef yyless
1631
+ #define yyless(n) \
1632
+ do \
1633
+ { \
1634
+ /* Undo effects of setting up yytext. */ \
1635
+ int yyless_macro_arg = (n); \
1636
+ YY_LESS_LINENO(yyless_macro_arg);\
1637
+ yytext[yyleng] = (yy_hold_char); \
1638
+ (yy_c_buf_p) = yytext + yyless_macro_arg; \
1639
+ (yy_hold_char) = *(yy_c_buf_p); \
1640
+ *(yy_c_buf_p) = '\0'; \
1641
+ yyleng = yyless_macro_arg; \
1642
+ } \
1643
+ while ( 0 )
1644
+
1645
+ /* Accessor methods (get/set functions) to struct members. */
1646
+
1647
+ /** Get the current line number.
1648
+ *
1649
+ */
1650
+ int yyget_lineno (void)
1651
+ {
1652
+
1653
+ return yylineno;
1654
+ }
1655
+
1656
+ /** Get the input stream.
1657
+ *
1658
+ */
1659
+ FILE *yyget_in (void)
1660
+ {
1661
+ return yyin;
1662
+ }
1663
+
1664
+ /** Get the output stream.
1665
+ *
1666
+ */
1667
+ FILE *yyget_out (void)
1668
+ {
1669
+ return yyout;
1670
+ }
1671
+
1672
+ /** Get the length of the current token.
1673
+ *
1674
+ */
1675
+ yy_size_t yyget_leng (void)
1676
+ {
1677
+ return yyleng;
1678
+ }
1679
+
1680
+ /** Get the current token.
1681
+ *
1682
+ */
1683
+
1684
+ char *yyget_text (void)
1685
+ {
1686
+ return yytext;
1687
+ }
1688
+
1689
+ /** Set the current line number.
1690
+ * @param line_number
1691
+ *
1692
+ */
1693
+ void yyset_lineno (int line_number )
1694
+ {
1695
+
1696
+ yylineno = line_number;
1697
+ }
1698
+
1699
+ /** Set the input stream. This does not discard the current
1700
+ * input buffer.
1701
+ * @param in_str A readable stream.
1702
+ *
1703
+ * @see yy_switch_to_buffer
1704
+ */
1705
+ void yyset_in (FILE * in_str )
1706
+ {
1707
+ yyin = in_str ;
1708
+ }
1709
+
1710
+ void yyset_out (FILE * out_str )
1711
+ {
1712
+ yyout = out_str ;
1713
+ }
1714
+
1715
+ int yyget_debug (void)
1716
+ {
1717
+ return yy_flex_debug;
1718
+ }
1719
+
1720
+ void yyset_debug (int bdebug )
1721
+ {
1722
+ yy_flex_debug = bdebug ;
1723
+ }
1724
+
1725
+ static int yy_init_globals (void)
1726
+ {
1727
+ /* Initialization is the same as for the non-reentrant scanner.
1728
+ * This function is called from yylex_destroy(), so don't allocate here.
1729
+ */
1730
+
1731
+ (yy_buffer_stack) = 0;
1732
+ (yy_buffer_stack_top) = 0;
1733
+ (yy_buffer_stack_max) = 0;
1734
+ (yy_c_buf_p) = (char *) 0;
1735
+ (yy_init) = 0;
1736
+ (yy_start) = 0;
1737
+
1738
+ /* Defined in main.c */
1739
+ #ifdef YY_STDINIT
1740
+ yyin = stdin;
1741
+ yyout = stdout;
1742
+ #else
1743
+ yyin = (FILE *) 0;
1744
+ yyout = (FILE *) 0;
1745
+ #endif
1746
+
1747
+ /* For future reference: Set errno on error, since we are called by
1748
+ * yylex_init()
1749
+ */
1750
+ return 0;
1751
+ }
1752
+
1753
+ /* yylex_destroy is for both reentrant and non-reentrant scanners. */
1754
+ int yylex_destroy (void)
1755
+ {
1756
+
1757
+ /* Pop the buffer stack, destroying each element. */
1758
+ while(YY_CURRENT_BUFFER){
1759
+ yy_delete_buffer(YY_CURRENT_BUFFER );
1760
+ YY_CURRENT_BUFFER_LVALUE = NULL;
1761
+ yypop_buffer_state();
1762
+ }
1763
+
1764
+ /* Destroy the stack itself. */
1765
+ yyfree((yy_buffer_stack) );
1766
+ (yy_buffer_stack) = NULL;
1767
+
1768
+ /* Reset the globals. This is important in a non-reentrant scanner so the next time
1769
+ * yylex() is called, initialization will occur. */
1770
+ yy_init_globals( );
1771
+
1772
+ return 0;
1773
+ }
1774
+
1775
+ /*
1776
+ * Internal utility routines.
1777
+ */
1778
+
1779
+ #ifndef yytext_ptr
1780
+ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1781
+ {
1782
+ register int i;
1783
+ for ( i = 0; i < n; ++i )
1784
+ s1[i] = s2[i];
1785
+ }
1786
+ #endif
1787
+
1788
+ #ifdef YY_NEED_STRLEN
1789
+ static int yy_flex_strlen (yyconst char * s )
1790
+ {
1791
+ register int n;
1792
+ for ( n = 0; s[n]; ++n )
1793
+ ;
1794
+
1795
+ return n;
1796
+ }
1797
+ #endif
1798
+
1799
+ void *yyalloc (yy_size_t size )
1800
+ {
1801
+ return (void *) malloc( size );
1802
+ }
1803
+
1804
+ void *yyrealloc (void * ptr, yy_size_t size )
1805
+ {
1806
+ /* The cast to (char *) in the following accommodates both
1807
+ * implementations that use char* generic pointers, and those
1808
+ * that use void* generic pointers. It works with the latter
1809
+ * because both ANSI C and C++ allow castless assignment from
1810
+ * any pointer type to void*, and deal with argument conversions
1811
+ * as though doing an assignment.
1812
+ */
1813
+ return (void *) realloc( (char *) ptr, size );
1814
+ }
1815
+
1816
+ void yyfree (void * ptr )
1817
+ {
1818
+ free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
1819
+ }
1820
+
1821
+ #define YYTABLES_NAME "yytables"
1822
+
1823
+ #line 100 "pool_config.l"
1824
+
1825
+
1826
+
1827
+ int pool_init_config(void)
1828
+ {
1829
+ int res;
1830
+ static char localhostname[256];
1831
+ int i;
1832
+
1833
+ pool_config = malloc(sizeof(POOL_CONFIG));
1834
+ if (pool_config == NULL)
1835
+ {
1836
+ pool_error("failed to allocate pool_config");
1837
+ return(-1);
1838
+ }
1839
+
1840
+ memset(pool_config, 0, sizeof(POOL_CONFIG));
1841
+
1842
+ #ifndef POOL_PRIVATE
1843
+ pool_config->backend_desc = pool_shared_memory_create(sizeof(BackendDesc));
1844
+ if (pool_config->backend_desc == NULL)
1845
+ {
1846
+ pool_error("failed to allocate pool_config->backend_desc");
1847
+ return -1;
1848
+ }
1849
+ #else
1850
+ pool_config->backend_desc = malloc(sizeof(BackendDesc));
1851
+ if (pool_config->backend_desc == NULL)
1852
+ {
1853
+ pool_error("failed to allocate pool_config->backend_desc");
1854
+ return -1;
1855
+ }
1856
+ #endif
1857
+
1858
+ /*
1859
+ * add for watchdog
1860
+ */
1861
+ pool_config->other_wd = malloc(sizeof(WdDesc));
1862
+ if (pool_config->other_wd == NULL)
1863
+ {
1864
+ pool_error("failed to allocate pool_config->cwother_wd");
1865
+ return -1;
1866
+ }
1867
+ memset(pool_config->other_wd, 0, sizeof(WdDesc));
1868
+
1869
+ /* set hardcoded default values */
1870
+ pool_config->listen_addresses = "localhost";
1871
+ pool_config->port = 9999;
1872
+ pool_config->pcp_port = 9898;
1873
+ pool_config->socket_dir = DEFAULT_SOCKET_DIR;
1874
+ pool_config->pcp_socket_dir = DEFAULT_SOCKET_DIR;
1875
+ pool_config->backend_socket_dir = NULL;
1876
+ pool_config->pcp_timeout = 10;
1877
+ pool_config->num_init_children = 32;
1878
+ pool_config->max_pool = 4;
1879
+ pool_config->child_life_time = 300;
1880
+ pool_config->client_idle_limit = 0;
1881
+ pool_config->connection_life_time = 0;
1882
+ pool_config->child_max_connections = 0;
1883
+ pool_config->authentication_timeout = 60;
1884
+ pool_config->logdir = DEFAULT_LOGDIR;
1885
+ pool_config->logsyslog = 0;
1886
+ pool_config->log_destination = "stderr";
1887
+ pool_config->syslog_facility = LOG_LOCAL0;
1888
+ pool_config->syslog_ident = "pgpool";
1889
+ pool_config->pid_file_name = DEFAULT_PID_FILE_NAME;
1890
+ pool_config->log_statement = 0;
1891
+ pool_config->log_per_node_statement = 0;
1892
+ pool_config->log_connections = 0;
1893
+ pool_config->log_hostname = 0;
1894
+ pool_config->enable_pool_hba = 0;
1895
+ pool_config->pool_passwd = "pool_passwd";
1896
+
1897
+ pool_config->presto_server = "";
1898
+ pool_config->presto_catalog = "";
1899
+ pool_config->presto_schema = "default";
1900
+ pool_config->presto_external_auth_prog = NULL;
1901
+
1902
+ pool_config->replication_mode = 0;
1903
+ pool_config->load_balance_mode = 0;
1904
+ pool_config->replication_stop_on_mismatch = 0;
1905
+ pool_config->failover_if_affected_tuples_mismatch = 0;
1906
+ pool_config->replicate_select = 0;
1907
+ pool_config->reset_query_list = default_reset_query_list;
1908
+ pool_config->num_reset_queries = sizeof(default_reset_query_list)/sizeof(char *);
1909
+ pool_config->white_function_list = NULL;
1910
+ pool_config->num_white_function_list = 0;
1911
+ pool_config->black_function_list = default_black_function_list;
1912
+ pool_config->num_black_function_list = sizeof(default_black_function_list)/sizeof(char *);
1913
+ pool_config->print_timestamp = 1;
1914
+ pool_config->master_slave_mode = 0;
1915
+ pool_config->master_slave_sub_mode = "slony";
1916
+ pool_config->delay_threshold = 0;
1917
+ pool_config->log_standby_delay = "none";
1918
+ pool_config->connection_cache = 1;
1919
+ pool_config->health_check_timeout = 20;
1920
+ pool_config->health_check_period = 0;
1921
+ pool_config->health_check_user = "nobody";
1922
+ pool_config->health_check_password = "";
1923
+ pool_config->health_check_max_retries = 0;
1924
+ pool_config->health_check_retry_delay = 1;
1925
+ pool_config->sr_check_period = 0;
1926
+ pool_config->sr_check_user = "nobody";
1927
+ pool_config->sr_check_password = "";
1928
+ pool_config->failover_command = "";
1929
+ pool_config->follow_master_command = "";
1930
+ pool_config->failback_command = "";
1931
+ pool_config->fail_over_on_backend_error = 1;
1932
+ pool_config->insert_lock = 1;
1933
+ pool_config->ignore_leading_white_space = 1;
1934
+ pool_config->parallel_mode = 0;
1935
+ pool_config->enable_query_cache = 0;
1936
+ pool_config->system_db_hostname = "localhost";
1937
+ pool_config->system_db_port = 5432;
1938
+ pool_config->system_db_dbname = "pgpool";
1939
+ pool_config->system_db_schema = "pgpool_catalog";
1940
+ pool_config->system_db_user = "pgpool";
1941
+ pool_config->system_db_password = "";
1942
+ pool_config->backend_desc->num_backends = 0;
1943
+ pool_config->recovery_user = "";
1944
+ pool_config->recovery_password = "";
1945
+ pool_config->recovery_1st_stage_command = "";
1946
+ pool_config->recovery_2nd_stage_command = "";
1947
+ pool_config->recovery_timeout = 90;
1948
+ pool_config->search_primary_node_timeout = 10;
1949
+ pool_config->client_idle_limit_in_recovery = 0;
1950
+ pool_config->lobj_lock_table = "";
1951
+ pool_config->ssl = 0;
1952
+ pool_config->ssl_cert = "";
1953
+ pool_config->ssl_key = "";
1954
+ pool_config->ssl_ca_cert = "";
1955
+ pool_config->ssl_ca_cert_dir = "";
1956
+ pool_config->debug_level = 0;
1957
+ pool_config->relcache_expire = 0;
1958
+ pool_config->relcache_size = 256;
1959
+ pool_config->check_temp_table = 1;
1960
+ pool_config->lists_patterns = NULL;
1961
+ pool_config->pattc = 0;
1962
+ pool_config->current_pattern_size = 0;
1963
+ /*
1964
+ * add for watchdog
1965
+ */
1966
+ pool_config->use_watchdog = 0;
1967
+ pool_config->wd_lifecheck_method = MODE_HEARTBEAT;
1968
+ pool_config->clear_memqcache_on_escalation = 1;
1969
+ pool_config->wd_escalation_command = "";
1970
+ pool_config->trusted_servers = "";
1971
+ pool_config->delegate_IP = "";
1972
+ res = gethostname(localhostname,sizeof(localhostname));
1973
+ if(res !=0 )
1974
+ {
1975
+ pool_debug("failed to get this hostname");
1976
+ }
1977
+ pool_config->wd_hostname = localhostname;
1978
+ pool_config->wd_port = 9000;
1979
+ pool_config->other_wd->num_wd = 0;
1980
+ pool_config->wd_interval = 10;
1981
+ pool_config->wd_authkey = "";
1982
+ pool_config->ping_path = "/bin";
1983
+ pool_config->ifconfig_path = "/sbin";
1984
+ pool_config->if_up_cmd = "ifconfig eth0:0 inet $_IP_$ netmask 255.255.255.0";
1985
+ pool_config->if_down_cmd = "ifconfig eth0:0 down";
1986
+ pool_config->arping_path = "/usr/sbin";
1987
+ pool_config->arping_cmd = "arping -U $_IP_$ -w 1";
1988
+ pool_config->wd_life_point = 3;
1989
+ pool_config->wd_lifecheck_query = "SELECT 1";
1990
+ pool_config->wd_lifecheck_dbname = "template1";
1991
+ pool_config->wd_lifecheck_user = "nobody";
1992
+ pool_config->wd_lifecheck_password = "";
1993
+ pool_config->wd_heartbeat_port = 9694;
1994
+ pool_config->wd_heartbeat_keepalive = 2;
1995
+ pool_config->wd_heartbeat_deadtime = 30;
1996
+ pool_config->num_hb_if = 0;
1997
+
1998
+ pool_config->memory_cache_enabled = 0;
1999
+ pool_config->memqcache_method = "shmem";
2000
+ pool_config->memqcache_memcached_host = "localhost";
2001
+ pool_config->memqcache_memcached_port = 11211;
2002
+ pool_config->memqcache_total_size = 67108864;
2003
+ pool_config->memqcache_max_num_cache = 1000000;
2004
+ pool_config->memqcache_expire = 0;
2005
+ pool_config->memqcache_auto_cache_invalidation = 1;
2006
+ pool_config->memqcache_maxcache = 409600;
2007
+ pool_config->memqcache_cache_block_size = 1048576;
2008
+ pool_config->memqcache_oiddir = "/var/log/pgpool/oiddir";
2009
+ pool_config->white_memqcache_table_list = NULL;
2010
+ pool_config->num_white_memqcache_table_list = 0;
2011
+ pool_config->black_memqcache_table_list = NULL;
2012
+ pool_config->num_black_memqcache_table_list = 0;
2013
+ pool_config->lists_memqcache_table_patterns = NULL;
2014
+ pool_config->memqcache_table_pattc = 0;
2015
+ pool_config->current_memqcache_table_pattern_size = 0;
2016
+
2017
+ res = gethostname(localhostname,sizeof(localhostname));
2018
+ if(res !=0 )
2019
+ {
2020
+ pool_debug("failed to get this hostname");
2021
+ }
2022
+ pool_config->pgpool2_hostname = localhostname;
2023
+
2024
+ for (i=0;i<MAX_CONNECTION_SLOTS;i++)
2025
+ {
2026
+ clear_host_entry(i);
2027
+ }
2028
+ return 0;
2029
+ }
2030
+
2031
+ /*
2032
+ * Add regex expression to patterns array
2033
+ * The supported type are: black_function_list and white_function_list
2034
+ * Return 0 on error, 1 on success
2035
+ */
2036
+ int add_regex_pattern(char *type, char *s)
2037
+ {
2038
+ int regex_flags = REG_NOSUB;
2039
+ RegPattern currItem;
2040
+ /* force case insensitive pattern matching */
2041
+ regex_flags |= REG_ICASE;
2042
+ /* Add extended regex search */
2043
+ regex_flags |= REG_EXTENDED;
2044
+ /* Fill the pattern type */
2045
+ if (strcmp(type, "black_function_list") == 0 ||
2046
+ strcmp(type, "black_memqcache_table_list") == 0)
2047
+ {
2048
+ currItem.type = BLACKLIST;
2049
+ }
2050
+ else if (strcmp(type, "white_function_list") == 0 ||
2051
+ strcmp(type, "white_memqcache_table_list") == 0)
2052
+ {
2053
+ currItem.type = WHITELIST;
2054
+ }
2055
+ else
2056
+ {
2057
+ pool_error("add_to_patterns: bad pattern type %s", type);
2058
+ return 0;
2059
+ }
2060
+ /* Fill the pattern flag */
2061
+ currItem.flag = regex_flags;
2062
+
2063
+ /* Fill pattern array */
2064
+ currItem.pattern = malloc(sizeof(char)*(strlen(s)+3));
2065
+ if (currItem.pattern == NULL)
2066
+ {
2067
+ pool_error("add_to_patterns: unable to allocate new pattern");
2068
+ return 0;
2069
+ }
2070
+ /* Force exact matching of function name with ^ and $ on the regex
2071
+ if required to prevent partial matching. It also allow backward
2072
+ compatibility.
2073
+ */
2074
+ if (strncmp(s, "^", 1) != 0) {
2075
+ strncpy(currItem.pattern, "^", 2);
2076
+ strncat(currItem.pattern, s, strlen(s) + 1);
2077
+ } else {
2078
+ strncpy(currItem.pattern, s, strlen(s) + 1);
2079
+ }
2080
+ if (s[strlen(s)-1] != '$') {
2081
+ strncat(currItem.pattern, "$", 2);
2082
+ }
2083
+ pool_debug("add_to_patterns: regex pattern: %s", currItem.pattern);
2084
+ /* compile our regex */
2085
+ if (regcomp(&currItem.regexv, currItem.pattern, currItem.flag) != 0)
2086
+ {
2087
+ pool_error("add_to_patterns: invalid regex pattern: %s", currItem.pattern);
2088
+ }
2089
+ else if ((strcmp(type, "white_function_list") == 0 ||
2090
+ strcmp(type, "black_function_list") == 0) &&
2091
+ growFunctionPatternArray(currItem) < 0)
2092
+ {
2093
+ pool_error("add_to_patterns: unable to allocate new pattern");
2094
+ return 0;
2095
+ }
2096
+ else if ((strcmp(type, "white_memqcache_table_list") == 0 ||
2097
+ strcmp(type, "black_memqcache_table_list") == 0) &&
2098
+ growMemqcacheTablePatternArray(currItem) < 0)
2099
+ {
2100
+ pool_error("add_to_patterns: unable to allocate new pattern");
2101
+ return 0;
2102
+ }
2103
+
2104
+ return 1;
2105
+ }
2106
+
2107
+ /*
2108
+ * Dynamically grow the regex pattern array
2109
+ * The array start with PATTERN_ARR_SIZE storage place, if required
2110
+ * it will grow of PATTERN_ARR_SIZE more each time.
2111
+ */
2112
+ int growFunctionPatternArray(RegPattern item)
2113
+ {
2114
+ void *_tmp = NULL;
2115
+ if (pool_config->pattc == pool_config->current_pattern_size)
2116
+ {
2117
+ pool_config->current_pattern_size += PATTERN_ARR_SIZE;
2118
+ _tmp = realloc(pool_config->lists_patterns,
2119
+ (pool_config->current_pattern_size * sizeof(RegPattern)));
2120
+ if (!_tmp)
2121
+ {
2122
+ return(-1);
2123
+ }
2124
+
2125
+ pool_config->lists_patterns = (RegPattern*)_tmp;
2126
+ }
2127
+ pool_config->lists_patterns[pool_config->pattc] = item;
2128
+ pool_config->pattc++;
2129
+
2130
+ return(pool_config->pattc);
2131
+ }
2132
+
2133
+ int growMemqcacheTablePatternArray(RegPattern item)
2134
+ {
2135
+ void *_tmp = NULL;
2136
+ if (pool_config->memqcache_table_pattc == pool_config->current_memqcache_table_pattern_size)
2137
+ {
2138
+ pool_config->current_memqcache_table_pattern_size += PATTERN_ARR_SIZE;
2139
+ _tmp = realloc(pool_config->lists_memqcache_table_patterns,
2140
+ (pool_config->current_memqcache_table_pattern_size * sizeof(RegPattern)));
2141
+ if (!_tmp)
2142
+ {
2143
+ return(-1);
2144
+ }
2145
+
2146
+ pool_config->lists_memqcache_table_patterns = (RegPattern*)_tmp;
2147
+ }
2148
+ pool_config->lists_memqcache_table_patterns[pool_config->memqcache_table_pattc] = item;
2149
+ pool_config->memqcache_table_pattc++;
2150
+
2151
+ return(pool_config->memqcache_table_pattc);
2152
+ }
2153
+
2154
+ int pool_get_config(char *confpath, POOL_CONFIG_CONTEXT context)
2155
+ {
2156
+ FILE *fd;
2157
+ int token;
2158
+ char key[1024];
2159
+ double total_weight;
2160
+ int i;
2161
+ bool log_destination_changed = false;
2162
+ #ifdef USE_MEMCACHED
2163
+ bool use_memcached = true;
2164
+ #else
2165
+ bool use_memcached = false;
2166
+ #endif
2167
+
2168
+ #define PARSE_ERROR() pool_error("pool_config: parse error at line %d '%s'", Lineno, yytext)
2169
+
2170
+ /* open config file */
2171
+ fd = fopen(confpath, "r");
2172
+ if (!fd)
2173
+ {
2174
+ fprintf(stderr, "pool_config: could not open configuration file (%s)\n",
2175
+ POOL_CONF_FILE_NAME);
2176
+ fprintf(stderr, "pool_config: using default values...\n");
2177
+ return 0;
2178
+ }
2179
+
2180
+ yyin = fd;
2181
+ Lineno = 1;
2182
+
2183
+ for(;;)
2184
+ {
2185
+ token = yylex();
2186
+ if (token == 0)
2187
+ {
2188
+ break;
2189
+ }
2190
+ if (token == POOL_PARSE_ERROR)
2191
+ {
2192
+ PARSE_ERROR();
2193
+ fclose(fd);
2194
+ return(-1);
2195
+ }
2196
+ if (token == POOL_EOL)
2197
+ continue;
2198
+
2199
+ if (token != POOL_KEY)
2200
+ {
2201
+ PARSE_ERROR();
2202
+ fclose(fd);
2203
+ return(-1);
2204
+ }
2205
+
2206
+ strlcpy(key, yytext, sizeof(key));
2207
+
2208
+ pool_debug("key: %s", key);
2209
+
2210
+ token = yylex();
2211
+
2212
+ if (token == POOL_EQUALS)
2213
+ token = yylex();
2214
+
2215
+ pool_debug("value: %s kind: %d", yytext, token);
2216
+
2217
+ if (!strcmp(key, "allow_inet_domain_socket") && CHECK_CONTEXT(INIT_CONFIG, context))
2218
+ {
2219
+ /* for backward compatibility */
2220
+ int v = eval_logical(yytext);
2221
+
2222
+ if (v < 0)
2223
+ {
2224
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
2225
+ fclose(fd);
2226
+ return(-1);
2227
+ }
2228
+ if (v)
2229
+ pool_config->listen_addresses = strdup("*");
2230
+ else
2231
+ pool_config->listen_addresses = strdup("");
2232
+ }
2233
+ else if (!strcmp(key, "listen_addresses") && CHECK_CONTEXT(INIT_CONFIG, context))
2234
+ {
2235
+ char *str;
2236
+
2237
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2238
+ {
2239
+ PARSE_ERROR();
2240
+ fclose(fd);
2241
+ return(-1);
2242
+ }
2243
+ str = extract_string(yytext, token);
2244
+ if (str == NULL)
2245
+ {
2246
+ fclose(fd);
2247
+ return(-1);
2248
+ }
2249
+ pool_config->listen_addresses = str;
2250
+ }
2251
+
2252
+ else if (!strcmp(key, "port") && CHECK_CONTEXT(INIT_CONFIG, context))
2253
+ {
2254
+ int v = atoi(yytext);
2255
+
2256
+ if (token != POOL_INTEGER || v < 1024)
2257
+ {
2258
+ pool_error("pool_config: %s must be 1024 or higher numeric value", key);
2259
+ fclose(fd);
2260
+ return(-1);
2261
+ }
2262
+ pool_config->port = v;
2263
+ }
2264
+ else if (!strcmp(key, "pcp_port") && CHECK_CONTEXT(INIT_CONFIG, context))
2265
+ {
2266
+ int v = atoi(yytext);
2267
+
2268
+ if (token != POOL_INTEGER || v < 1024)
2269
+ {
2270
+ pool_error("pool_config: %s must be 1024 or higher numeric value", key);
2271
+ fclose(fd);
2272
+ return(-1);
2273
+ }
2274
+ pool_config->pcp_port = v;
2275
+ }
2276
+ else if (!strcmp(key, "socket_dir") && CHECK_CONTEXT(INIT_CONFIG, context))
2277
+ {
2278
+ char *str;
2279
+
2280
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2281
+ {
2282
+ PARSE_ERROR();
2283
+ fclose(fd);
2284
+ return(-1);
2285
+ }
2286
+ str = extract_string(yytext, token);
2287
+ if (str == NULL)
2288
+ {
2289
+ fclose(fd);
2290
+ return(-1);
2291
+ }
2292
+ pool_config->socket_dir = str;
2293
+ }
2294
+ else if (!strcmp(key, "pcp_socket_dir") && CHECK_CONTEXT(INIT_CONFIG, context))
2295
+ {
2296
+ char *str;
2297
+
2298
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2299
+ {
2300
+ PARSE_ERROR();
2301
+ fclose(fd);
2302
+ return(-1);
2303
+ }
2304
+ str = extract_string(yytext, token);
2305
+ if (str == NULL)
2306
+ {
2307
+ fclose(fd);
2308
+ return(-1);
2309
+ }
2310
+ pool_config->pcp_socket_dir = str;
2311
+ }
2312
+ else if (!strcmp(key, "pcp_timeout") &&
2313
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2314
+ {
2315
+ int v = atoi(yytext);
2316
+
2317
+ if (token != POOL_INTEGER || v < 0)
2318
+ {
2319
+ pool_error("pool_config: %s must be equal or greater or equal to 0 numeric value", key);
2320
+ fclose(fd);
2321
+ return(-1);
2322
+ }
2323
+ pool_config->pcp_timeout = v;
2324
+ }
2325
+ else if (!strcmp(key, "num_init_children") && CHECK_CONTEXT(INIT_CONFIG, context))
2326
+ {
2327
+ int v = atoi(yytext);
2328
+
2329
+ if (token != POOL_INTEGER || v < 1)
2330
+ {
2331
+ pool_error("pool_config: %s must be higher than 1 numeric value", key);
2332
+ fclose(fd);
2333
+ return(-1);
2334
+ }
2335
+ pool_config->num_init_children = v;
2336
+ }
2337
+ else if (!strcmp(key, "child_life_time") &&
2338
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2339
+ {
2340
+ int v = atoi(yytext);
2341
+
2342
+ if (token != POOL_INTEGER || v < 0)
2343
+ {
2344
+ pool_error("pool_config: %s must be greater or equal to 0 numeric value", key);
2345
+ fclose(fd);
2346
+ return(-1);
2347
+ }
2348
+ pool_config->child_life_time = v;
2349
+ }
2350
+ else if (!strcmp(key, "client_idle_limit") &&
2351
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2352
+ {
2353
+ int v = atoi(yytext);
2354
+
2355
+ if (token != POOL_INTEGER || v < 0)
2356
+ {
2357
+ pool_error("pool_config: %s must be greater or equal to 0 numeric value", key);
2358
+ fclose(fd);
2359
+ return(-1);
2360
+ }
2361
+ pool_config->client_idle_limit = v;
2362
+ }
2363
+ else if (!strcmp(key, "connection_life_time") &&
2364
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2365
+ {
2366
+ int v = atoi(yytext);
2367
+
2368
+ if (token != POOL_INTEGER || v < 0)
2369
+ {
2370
+ pool_error("pool_config: %s must be greater or equal to 0 numeric value", key);
2371
+ fclose(fd);
2372
+ return(-1);
2373
+ }
2374
+ pool_config->connection_life_time = v;
2375
+ }
2376
+ else if (!strcmp(key, "child_max_connections") &&
2377
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2378
+ {
2379
+ int v = atoi(yytext);
2380
+
2381
+ if (token != POOL_INTEGER || v < 0)
2382
+ {
2383
+ pool_error("pool_config: %s must be greater or equal to 0 numeric value", key);
2384
+ fclose(fd);
2385
+ return(-1);
2386
+ }
2387
+ pool_config->child_max_connections = v;
2388
+ }
2389
+ else if (!strcmp(key, "authentication_timeout") &&
2390
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2391
+ {
2392
+ int v = atoi(yytext);
2393
+
2394
+ if (token != POOL_INTEGER || v < 0)
2395
+ {
2396
+ pool_error("pool_config: %s must be higher than 0 numeric value", key);
2397
+ fclose(fd);
2398
+ return(-1);
2399
+ }
2400
+ pool_config->authentication_timeout = v;
2401
+ }
2402
+ else if (!strcmp(key, "max_pool") && CHECK_CONTEXT(INIT_CONFIG, context))
2403
+ {
2404
+ int v = atoi(yytext);
2405
+
2406
+ if (token != POOL_INTEGER || v < 0)
2407
+ {
2408
+ pool_error("pool_config: %s must be greater or equal to 0 numeric value", key);
2409
+ fclose(fd);
2410
+ return(-1);
2411
+ }
2412
+ pool_config->max_pool = v;
2413
+ }
2414
+ else if (!strcmp(key, "logdir") && CHECK_CONTEXT(INIT_CONFIG, context))
2415
+ {
2416
+ char *str;
2417
+
2418
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2419
+ {
2420
+ PARSE_ERROR();
2421
+ fclose(fd);
2422
+ return(-1);
2423
+ }
2424
+ str = extract_string(yytext, token);
2425
+ if (str == NULL)
2426
+ {
2427
+ fclose(fd);
2428
+ return(-1);
2429
+ }
2430
+ pool_config->logdir = str;
2431
+ }
2432
+ else if (!strcmp(key, "log_destination") &&
2433
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2434
+ {
2435
+ char *str;
2436
+
2437
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2438
+ {
2439
+ PARSE_ERROR();
2440
+ fclose(fd);
2441
+ return(-1);
2442
+ }
2443
+ str = extract_string(yytext, token);
2444
+ if (str == NULL)
2445
+ {
2446
+ fclose(fd);
2447
+ return(-1);
2448
+ }
2449
+ log_destination_changed = pool_config->log_destination != str;
2450
+ pool_config->log_destination = str;
2451
+ }
2452
+ else if (!strcmp(key, "syslog_facility") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2453
+ {
2454
+ char *str;
2455
+
2456
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2457
+ {
2458
+ PARSE_ERROR();
2459
+ fclose(fd);
2460
+ return(-1);
2461
+ }
2462
+ str = extract_string(yytext, token);
2463
+ if (str == NULL)
2464
+ {
2465
+ fclose(fd);
2466
+ return(-1);
2467
+ }
2468
+ pool_config->syslog_facility = set_syslog_facility(str);
2469
+ }
2470
+ else if (!strcmp(key, "syslog_ident") &&
2471
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2472
+ {
2473
+ char *str;
2474
+
2475
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2476
+ {
2477
+ PARSE_ERROR();
2478
+ fclose(fd);
2479
+ return(-1);
2480
+ }
2481
+ str = extract_string(yytext, token);
2482
+ if (str == NULL)
2483
+ {
2484
+ fclose(fd);
2485
+ return(-1);
2486
+ }
2487
+ log_destination_changed = log_destination_changed || pool_config->syslog_ident != str;
2488
+ pool_config->syslog_ident = str;
2489
+ }
2490
+ else if (!strcmp(key, "pid_file_name") && CHECK_CONTEXT(INIT_CONFIG, context))
2491
+ {
2492
+ char *str;
2493
+
2494
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2495
+ {
2496
+ PARSE_ERROR();
2497
+ fclose(fd);
2498
+ return(-1);
2499
+ }
2500
+ str = extract_string(yytext, token);
2501
+ if (str == NULL)
2502
+ {
2503
+ fclose(fd);
2504
+ return(-1);
2505
+ }
2506
+ pool_config->pid_file_name = str;
2507
+ }
2508
+ else if (!strcmp(key, "log_connections") &&
2509
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2510
+ {
2511
+ int v = eval_logical(yytext);
2512
+
2513
+ if (v < 0)
2514
+ {
2515
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
2516
+ fclose(fd);
2517
+ return(-1);
2518
+ }
2519
+ pool_config->log_connections = v;
2520
+ }
2521
+ else if (!strcmp(key, "log_hostname") &&
2522
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2523
+ {
2524
+ int v = eval_logical(yytext);
2525
+
2526
+ if (v < 0)
2527
+ {
2528
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
2529
+ fclose(fd);
2530
+ return(-1);
2531
+ }
2532
+ pool_config->log_hostname = v;
2533
+ }
2534
+ else if (!strcmp(key, "enable_pool_hba") &&
2535
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2536
+ {
2537
+ int v = eval_logical(yytext);
2538
+
2539
+ if (v < 0)
2540
+ {
2541
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
2542
+ fclose(fd);
2543
+ return(-1);
2544
+ }
2545
+ pool_config->enable_pool_hba = v;
2546
+ }
2547
+ else if (!strcmp(key, "pool_passwd") && CHECK_CONTEXT(INIT_CONFIG, context))
2548
+ {
2549
+ char *str;
2550
+
2551
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2552
+ {
2553
+ PARSE_ERROR();
2554
+ fclose(fd);
2555
+ return(-1);
2556
+ }
2557
+ str = extract_string(yytext, token);
2558
+ if (str == NULL)
2559
+ {
2560
+ fclose(fd);
2561
+ return(-1);
2562
+ }
2563
+ pool_config->pool_passwd = str;
2564
+ }
2565
+
2566
+ else if (!strcmp(key, "presto_server") && CHECK_CONTEXT(INIT_CONFIG, context))
2567
+ {
2568
+ char *str;
2569
+
2570
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2571
+ {
2572
+ PARSE_ERROR();
2573
+ fclose(fd);
2574
+ return(-1);
2575
+ }
2576
+ str = extract_string(yytext, token);
2577
+ if (str == NULL)
2578
+ {
2579
+ fclose(fd);
2580
+ return(-1);
2581
+ }
2582
+ pool_config->presto_server = str;
2583
+ }
2584
+ else if (!strcmp(key, "presto_catalog") && CHECK_CONTEXT(INIT_CONFIG, context))
2585
+ {
2586
+ char *str;
2587
+
2588
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2589
+ {
2590
+ PARSE_ERROR();
2591
+ fclose(fd);
2592
+ return(-1);
2593
+ }
2594
+ str = extract_string(yytext, token);
2595
+ if (str == NULL)
2596
+ {
2597
+ fclose(fd);
2598
+ return(-1);
2599
+ }
2600
+ pool_config->presto_catalog = str;
2601
+ }
2602
+ else if (!strcmp(key, "presto_schema") && CHECK_CONTEXT(INIT_CONFIG, context))
2603
+ {
2604
+ char *str;
2605
+
2606
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2607
+ {
2608
+ PARSE_ERROR();
2609
+ fclose(fd);
2610
+ return(-1);
2611
+ }
2612
+ str = extract_string(yytext, token);
2613
+ if (str == NULL)
2614
+ {
2615
+ fclose(fd);
2616
+ return(-1);
2617
+ }
2618
+ pool_config->presto_schema = str;
2619
+ }
2620
+ else if (!strcmp(key, "presto_external_auth_prog") && CHECK_CONTEXT(INIT_CONFIG, context))
2621
+ {
2622
+ char *str;
2623
+
2624
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2625
+ {
2626
+ PARSE_ERROR();
2627
+ fclose(fd);
2628
+ return(-1);
2629
+ }
2630
+ str = extract_string(yytext, token);
2631
+ if (str == NULL)
2632
+ {
2633
+ fclose(fd);
2634
+ return(-1);
2635
+ }
2636
+ pool_config->presto_external_auth_prog = str;
2637
+ }
2638
+
2639
+ else if (!strcmp(key, "backend_socket_dir") && CHECK_CONTEXT(INIT_CONFIG, context))
2640
+ {
2641
+ char *str;
2642
+
2643
+ pool_log("pool_config: backend_socket_dir is deprecated, please use backend_hostname");
2644
+
2645
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2646
+ {
2647
+ PARSE_ERROR();
2648
+ fclose(fd);
2649
+ return(-1);
2650
+ }
2651
+ str = extract_string(yytext, token);
2652
+ if (str == NULL)
2653
+ {
2654
+ fclose(fd);
2655
+ return(-1);
2656
+ }
2657
+ pool_config->backend_socket_dir = str;
2658
+ }
2659
+ else if (!strcmp(key, "replication_mode") && CHECK_CONTEXT(INIT_CONFIG, context))
2660
+ {
2661
+ int v = eval_logical(yytext);
2662
+
2663
+ if (v < 0)
2664
+ {
2665
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
2666
+ fclose(fd);
2667
+ return(-1);
2668
+ }
2669
+ pool_config->replication_mode = v;
2670
+
2671
+ if (pool_config->master_slave_mode && pool_config->replication_mode)
2672
+ {
2673
+ pool_error("pool_config: replication_mode and master_slave_mode cannot be enabled at the same time");
2674
+ fclose(fd);
2675
+ return(-1);
2676
+ }
2677
+
2678
+ }
2679
+ else if (!strcmp(key, "load_balance_mode") && CHECK_CONTEXT(INIT_CONFIG, context))
2680
+ {
2681
+ int v = eval_logical(yytext);
2682
+
2683
+ if (v < 0)
2684
+ {
2685
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
2686
+ fclose(fd);
2687
+ return(-1);
2688
+ }
2689
+ pool_config->load_balance_mode = v;
2690
+ }
2691
+ else if (!strcmp(key, "replication_stop_on_mismatch") &&
2692
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2693
+ {
2694
+ int v = eval_logical(yytext);
2695
+
2696
+ if (v < 0)
2697
+ {
2698
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
2699
+ fclose(fd);
2700
+ return(-1);
2701
+ }
2702
+ pool_debug("replication_stop_on_mismatch: %d", v);
2703
+ pool_config->replication_stop_on_mismatch = v;
2704
+ }
2705
+ else if (!strcmp(key, "failover_if_affected_tuples_mismatch") &&
2706
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2707
+ {
2708
+ int v = eval_logical(yytext);
2709
+
2710
+ if (v < 0)
2711
+ {
2712
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
2713
+ fclose(fd);
2714
+ return(-1);
2715
+ }
2716
+ pool_debug("failover_if_affected_tuples_mismatch: %d", v);
2717
+ pool_config->failover_if_affected_tuples_mismatch = v;
2718
+ }
2719
+ else if (!strcmp(key, "replicate_select") &&
2720
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2721
+ {
2722
+ int v = eval_logical(yytext);
2723
+
2724
+ if (v < 0)
2725
+ {
2726
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
2727
+ fclose(fd);
2728
+ return(-1);
2729
+ }
2730
+ pool_debug("replicate_select: %d", v);
2731
+ pool_config->replicate_select = v;
2732
+ }
2733
+ else if (!strcmp(key, "reset_query_list") &&
2734
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2735
+ {
2736
+ char *str;
2737
+
2738
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2739
+ {
2740
+ PARSE_ERROR();
2741
+ fclose(fd);
2742
+ return(-1);
2743
+ }
2744
+ str = extract_string(yytext, token);
2745
+ if (str == NULL)
2746
+ {
2747
+ fclose(fd);
2748
+ return(-1);
2749
+ }
2750
+ pool_config->reset_query_list = extract_string_tokens(str, ";", &pool_config->num_reset_queries);
2751
+ if (pool_config->reset_query_list == NULL)
2752
+ {
2753
+ fclose(fd);
2754
+ return(-1);
2755
+ }
2756
+ }
2757
+
2758
+ else if (!strcmp(key, "white_function_list") &&
2759
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2760
+ {
2761
+ char *str;
2762
+
2763
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2764
+ {
2765
+ PARSE_ERROR();
2766
+ fclose(fd);
2767
+ return(-1);
2768
+ }
2769
+ str = extract_string(yytext, token);
2770
+ if (str == NULL)
2771
+ {
2772
+ fclose(fd);
2773
+ return(-1);
2774
+ }
2775
+ pool_config->white_function_list =
2776
+ extract_string_tokens(str, ",", &pool_config->num_white_function_list);
2777
+
2778
+ if (pool_config->white_function_list == NULL)
2779
+ {
2780
+ fclose(fd);
2781
+ return(-1);
2782
+ }
2783
+ for (i=0;i<pool_config->num_white_function_list;i++)
2784
+ {
2785
+ add_regex_pattern("white_function_list", pool_config->white_function_list[i]);
2786
+ }
2787
+ }
2788
+
2789
+ else if (!strcmp(key, "black_function_list") &&
2790
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2791
+ {
2792
+ char *str;
2793
+
2794
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2795
+ {
2796
+ PARSE_ERROR();
2797
+ fclose(fd);
2798
+ return(-1);
2799
+ }
2800
+ str = extract_string(yytext, token);
2801
+ if (str == NULL)
2802
+ {
2803
+ fclose(fd);
2804
+ return(-1);
2805
+ }
2806
+ pool_config->black_function_list =
2807
+ extract_string_tokens(str, ",", &pool_config->num_black_function_list);
2808
+
2809
+ if (pool_config->black_function_list == NULL)
2810
+ {
2811
+ fclose(fd);
2812
+ return(-1);
2813
+ }
2814
+ for (i=0;i<pool_config->num_black_function_list;i++)
2815
+ {
2816
+ add_regex_pattern("black_function_list", pool_config->black_function_list[i]);
2817
+ }
2818
+ }
2819
+
2820
+ else if (!strcmp(key, "print_timestamp") && CHECK_CONTEXT(INIT_CONFIG, context))
2821
+ {
2822
+ int v = eval_logical(yytext);
2823
+
2824
+ if (v < 0)
2825
+ {
2826
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
2827
+ fclose(fd);
2828
+ return(-1);
2829
+ }
2830
+ pool_config->print_timestamp = v;
2831
+ }
2832
+
2833
+ else if (!strcmp(key, "master_slave_mode") && CHECK_CONTEXT(INIT_CONFIG, context))
2834
+ {
2835
+ int v = eval_logical(yytext);
2836
+
2837
+ if (v < 0)
2838
+ {
2839
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
2840
+ fclose(fd);
2841
+ return(-1);
2842
+ }
2843
+ pool_config->master_slave_mode = v;
2844
+
2845
+ if (pool_config->master_slave_mode && pool_config->replication_mode)
2846
+ {
2847
+ pool_error("pool_config: replication_mode and master_slave_mode cannot be enabled at the same time");
2848
+ fclose(fd);
2849
+ return(-1);
2850
+ }
2851
+ }
2852
+
2853
+ else if (!strcmp(key, "master_slave_sub_mode") && CHECK_CONTEXT(INIT_CONFIG, context))
2854
+ {
2855
+ char *str;
2856
+
2857
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2858
+ {
2859
+ PARSE_ERROR();
2860
+ fclose(fd);
2861
+ return(-1);
2862
+ }
2863
+ str = extract_string(yytext, token);
2864
+ if (str == NULL)
2865
+ {
2866
+ fclose(fd);
2867
+ return(-1);
2868
+ }
2869
+
2870
+ if (strcmp(str, MODE_SLONY) && strcmp(str, MODE_STREAMREP))
2871
+ {
2872
+ pool_error("pool_config: %s must be either \"slony\" or \"stream\"", key);
2873
+ fclose(fd);
2874
+ return(-1);
2875
+ }
2876
+ pool_config->master_slave_sub_mode = str;
2877
+ }
2878
+
2879
+ else if (!strcmp(key, "delay_threshold") &&
2880
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2881
+ {
2882
+ long long int v = atol(yytext);
2883
+
2884
+ if (token != POOL_INTEGER || v < 0)
2885
+ {
2886
+ pool_error("pool_config: %s must be greater or equal to 0 numeric value", key);
2887
+ fclose(fd);
2888
+ return(-1);
2889
+ }
2890
+ pool_config->delay_threshold = v;
2891
+ }
2892
+
2893
+ else if (!strcmp(key, "log_standby_delay") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2894
+ {
2895
+ char *str;
2896
+
2897
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2898
+ {
2899
+ PARSE_ERROR();
2900
+ fclose(fd);
2901
+ return(-1);
2902
+ }
2903
+ str = extract_string(yytext, token);
2904
+ if (str == NULL)
2905
+ {
2906
+ fclose(fd);
2907
+ return(-1);
2908
+ }
2909
+
2910
+ if (strcmp(str, "always") && strcmp(str, "if_over_threshold") && strcmp(str, "none"))
2911
+ {
2912
+ pool_error("pool_config: invalid log_standby_delay %s", key);
2913
+ fclose(fd);
2914
+ return(-1);
2915
+ }
2916
+ pool_config->log_standby_delay = str;
2917
+ }
2918
+
2919
+ else if (!strcmp(key, "connection_cache") && CHECK_CONTEXT(INIT_CONFIG, context))
2920
+ {
2921
+ int v = eval_logical(yytext);
2922
+
2923
+ if (v < 0)
2924
+ {
2925
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
2926
+ fclose(fd);
2927
+ return(-1);
2928
+ }
2929
+ pool_config->connection_cache = v;
2930
+ }
2931
+
2932
+ else if (!strcmp(key, "health_check_timeout") &&
2933
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2934
+ {
2935
+ int v = atoi(yytext);
2936
+
2937
+ if (token != POOL_INTEGER || v < 0)
2938
+ {
2939
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
2940
+ fclose(fd);
2941
+ return(-1);
2942
+ }
2943
+ pool_config->health_check_timeout = v;
2944
+ }
2945
+
2946
+ else if (!strcmp(key, "health_check_period") &&
2947
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2948
+ {
2949
+ int v = atoi(yytext);
2950
+
2951
+ if (token != POOL_INTEGER || v < 0)
2952
+ {
2953
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
2954
+ fclose(fd);
2955
+ return(-1);
2956
+ }
2957
+ pool_config->health_check_period = v;
2958
+ }
2959
+
2960
+ else if (!strcmp(key, "health_check_user") &&
2961
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2962
+ {
2963
+ char *str;
2964
+
2965
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2966
+ {
2967
+ PARSE_ERROR();
2968
+ fclose(fd);
2969
+ return(-1);
2970
+ }
2971
+ str = extract_string(yytext, token);
2972
+ if (str == NULL)
2973
+ {
2974
+ fclose(fd);
2975
+ return(-1);
2976
+ }
2977
+ pool_config->health_check_user = str;
2978
+ }
2979
+
2980
+ else if (!strcmp(key, "health_check_password") &&
2981
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
2982
+ {
2983
+ char *str;
2984
+
2985
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
2986
+ {
2987
+ PARSE_ERROR();
2988
+ fclose(fd);
2989
+ return(-1);
2990
+ }
2991
+ str = extract_string(yytext, token);
2992
+ if (str == NULL)
2993
+ {
2994
+ fclose(fd);
2995
+ return(-1);
2996
+ }
2997
+ pool_config->health_check_password = str;
2998
+ }
2999
+
3000
+ else if (!strcmp(key, "health_check_max_retries") &&
3001
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
3002
+ {
3003
+ int v = atoi(yytext);
3004
+
3005
+ if (token != POOL_INTEGER || v < 0)
3006
+ {
3007
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
3008
+ fclose(fd);
3009
+ return(-1);
3010
+ }
3011
+ pool_config->health_check_max_retries = v;
3012
+ }
3013
+
3014
+ else if (!strcmp(key, "health_check_retry_delay") &&
3015
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
3016
+ {
3017
+ int v = atoi(yytext);
3018
+
3019
+ if (token != POOL_INTEGER || v < 0)
3020
+ {
3021
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
3022
+ fclose(fd);
3023
+ return(-1);
3024
+ }
3025
+ pool_config->health_check_retry_delay = v;
3026
+ }
3027
+
3028
+ else if (!strcmp(key, "sr_check_period") &&
3029
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
3030
+ {
3031
+ int v = atoi(yytext);
3032
+
3033
+ if (token != POOL_INTEGER || v < 0)
3034
+ {
3035
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
3036
+ fclose(fd);
3037
+ return(-1);
3038
+ }
3039
+ pool_config->sr_check_period = v;
3040
+ }
3041
+
3042
+ else if (!strcmp(key, "sr_check_user") &&
3043
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
3044
+ {
3045
+ char *str;
3046
+
3047
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3048
+ {
3049
+ PARSE_ERROR();
3050
+ fclose(fd);
3051
+ return(-1);
3052
+ }
3053
+ str = extract_string(yytext, token);
3054
+ if (str == NULL)
3055
+ {
3056
+ fclose(fd);
3057
+ return(-1);
3058
+ }
3059
+ pool_config->sr_check_user = str;
3060
+ }
3061
+
3062
+ else if (!strcmp(key, "sr_check_password") &&
3063
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
3064
+ {
3065
+ char *str;
3066
+
3067
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3068
+ {
3069
+ PARSE_ERROR();
3070
+ fclose(fd);
3071
+ return(-1);
3072
+ }
3073
+ str = extract_string(yytext, token);
3074
+ if (str == NULL)
3075
+ {
3076
+ fclose(fd);
3077
+ return(-1);
3078
+ }
3079
+ pool_config->sr_check_password = str;
3080
+ }
3081
+
3082
+ else if (!strcmp(key, "failover_command") &&
3083
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
3084
+ {
3085
+ char *str;
3086
+
3087
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3088
+ {
3089
+ PARSE_ERROR();
3090
+ fclose(fd);
3091
+ return(-1);
3092
+ }
3093
+ str = extract_string(yytext, token);
3094
+ if (str == NULL)
3095
+ {
3096
+ fclose(fd);
3097
+ return(-1);
3098
+ }
3099
+ pool_config->failover_command = str;
3100
+ }
3101
+
3102
+ else if (!strcmp(key, "follow_master_command") &&
3103
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
3104
+ {
3105
+ char *str;
3106
+
3107
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3108
+ {
3109
+ PARSE_ERROR();
3110
+ fclose(fd);
3111
+ return(-1);
3112
+ }
3113
+ str = extract_string(yytext, token);
3114
+ if (str == NULL)
3115
+ {
3116
+ fclose(fd);
3117
+ return(-1);
3118
+ }
3119
+ pool_config->follow_master_command = str;
3120
+ }
3121
+
3122
+ else if (!strcmp(key, "failback_command") &&
3123
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
3124
+ {
3125
+ char *str;
3126
+
3127
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3128
+ {
3129
+ PARSE_ERROR();
3130
+ fclose(fd);
3131
+ return(-1);
3132
+ }
3133
+ str = extract_string(yytext, token);
3134
+ if (str == NULL)
3135
+ {
3136
+ fclose(fd);
3137
+ return(-1);
3138
+ }
3139
+ pool_config->failback_command = str;
3140
+ }
3141
+
3142
+ else if (!strcmp(key, "fail_over_on_backend_error") &&
3143
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
3144
+ {
3145
+ int v = eval_logical(yytext);
3146
+
3147
+ if (v < 0)
3148
+ {
3149
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
3150
+ fclose(fd);
3151
+ return(-1);
3152
+ }
3153
+ pool_config->fail_over_on_backend_error = v;
3154
+ }
3155
+
3156
+ else if (!strcmp(key, "recovery_user") &&
3157
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
3158
+ {
3159
+ char *str;
3160
+
3161
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3162
+ {
3163
+ PARSE_ERROR();
3164
+ fclose(fd);
3165
+ return(-1);
3166
+ }
3167
+ str = extract_string(yytext, token);
3168
+ if (str == NULL)
3169
+ {
3170
+ fclose(fd);
3171
+ return(-1);
3172
+ }
3173
+ pool_config->recovery_user = str;
3174
+ }
3175
+
3176
+ else if (!strcmp(key, "recovery_password") &&
3177
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
3178
+ {
3179
+ char *str;
3180
+
3181
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3182
+ {
3183
+ PARSE_ERROR();
3184
+ fclose(fd);
3185
+ return(-1);
3186
+ }
3187
+ str = extract_string(yytext, token);
3188
+ if (str == NULL)
3189
+ {
3190
+ fclose(fd);
3191
+ return(-1);
3192
+ }
3193
+ pool_config->recovery_password = str;
3194
+ }
3195
+
3196
+ else if (!strcmp(key, "recovery_1st_stage_command") &&
3197
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
3198
+ {
3199
+ char *str;
3200
+
3201
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3202
+ {
3203
+ PARSE_ERROR();
3204
+ fclose(fd);
3205
+ return(-1);
3206
+ }
3207
+ str = extract_string(yytext, token);
3208
+ if (str == NULL)
3209
+ {
3210
+ fclose(fd);
3211
+ return(-1);
3212
+ }
3213
+ pool_config->recovery_1st_stage_command = str;
3214
+ }
3215
+
3216
+ else if (!strcmp(key, "recovery_2nd_stage_command") &&
3217
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
3218
+ {
3219
+ char *str;
3220
+
3221
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3222
+ {
3223
+ PARSE_ERROR();
3224
+ fclose(fd);
3225
+ return(-1);
3226
+ }
3227
+ str = extract_string(yytext, token);
3228
+ if (str == NULL)
3229
+ {
3230
+ fclose(fd);
3231
+ return(-1);
3232
+ }
3233
+ pool_config->recovery_2nd_stage_command = str;
3234
+ }
3235
+
3236
+ else if (!strcmp(key, "recovery_timeout") &&
3237
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
3238
+ {
3239
+ int v = atoi(yytext);
3240
+
3241
+ if (token != POOL_INTEGER || v < 0)
3242
+ {
3243
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
3244
+ fclose(fd);
3245
+ return(-1);
3246
+ }
3247
+ pool_config->recovery_timeout = v;
3248
+ }
3249
+
3250
+ else if (!strcmp(key, "search_primary_node_timeout") &&
3251
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
3252
+ {
3253
+ int v = atoi(yytext);
3254
+
3255
+ if (token != POOL_INTEGER || v < 0)
3256
+ {
3257
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
3258
+ fclose(fd);
3259
+ return(-1);
3260
+ }
3261
+ pool_config->search_primary_node_timeout = v;
3262
+ }
3263
+
3264
+ else if (!strcmp(key, "client_idle_limit_in_recovery") &&
3265
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
3266
+ {
3267
+ int v = atoi(yytext);
3268
+
3269
+ if (token != POOL_INTEGER || v < -1)
3270
+ {
3271
+ pool_error("pool_config: %s must be greater or equal to -1 numeric value", key);
3272
+ fclose(fd);
3273
+ return(-1);
3274
+ }
3275
+ pool_config->client_idle_limit_in_recovery = v;
3276
+ }
3277
+
3278
+ else if (!strcmp(key, "insert_lock") &&
3279
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
3280
+ {
3281
+ int v = eval_logical(yytext);
3282
+
3283
+ if (v < 0)
3284
+ {
3285
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
3286
+ fclose(fd);
3287
+ return(-1);
3288
+ }
3289
+ pool_config->insert_lock = v;
3290
+ }
3291
+
3292
+ else if (!strcmp(key, "ignore_leading_white_space") &&
3293
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
3294
+ {
3295
+ int v = eval_logical(yytext);
3296
+
3297
+ if (v < 0)
3298
+ {
3299
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
3300
+ fclose(fd);
3301
+ return(-1);
3302
+ }
3303
+ pool_config->ignore_leading_white_space = v;
3304
+ }
3305
+
3306
+ else if (!strcmp(key, "parallel_mode") && CHECK_CONTEXT(INIT_CONFIG, context))
3307
+ {
3308
+ int v = eval_logical(yytext);
3309
+
3310
+ if (v < 0)
3311
+ {
3312
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
3313
+ fclose(fd);
3314
+ return(-1);
3315
+ }
3316
+ pool_config->parallel_mode = v;
3317
+ }
3318
+
3319
+ else if (!strcmp(key, "enable_query_cache") && CHECK_CONTEXT(INIT_CONFIG, context))
3320
+ {
3321
+ int v = eval_logical(yytext);
3322
+
3323
+ if (v < 0)
3324
+ {
3325
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
3326
+ fclose(fd);
3327
+ return(-1);
3328
+ }
3329
+ pool_config->enable_query_cache = v;
3330
+ }
3331
+
3332
+ else if (!strcmp(key, "pgpool2_hostname") && CHECK_CONTEXT(INIT_CONFIG, context))
3333
+ {
3334
+ char *str;
3335
+
3336
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3337
+ {
3338
+ PARSE_ERROR();
3339
+ fclose(fd);
3340
+ return(-1);
3341
+ }
3342
+ str = extract_string(yytext, token);
3343
+ if (str == NULL)
3344
+ {
3345
+ fclose(fd);
3346
+ return(-1);
3347
+ }
3348
+ if(strlen(str))
3349
+ pool_config->pgpool2_hostname = str;
3350
+ }
3351
+
3352
+ else if (!strcmp(key, "system_db_hostname") && CHECK_CONTEXT(INIT_CONFIG, context))
3353
+ {
3354
+ char *str;
3355
+
3356
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3357
+ {
3358
+ PARSE_ERROR();
3359
+ fclose(fd);
3360
+ return(-1);
3361
+ }
3362
+ str = extract_string(yytext, token);
3363
+ if (str == NULL)
3364
+ {
3365
+ fclose(fd);
3366
+ return(-1);
3367
+ }
3368
+ pool_config->system_db_hostname = str;
3369
+ }
3370
+
3371
+ else if (!strcmp(key, "system_db_port") && CHECK_CONTEXT(INIT_CONFIG, context))
3372
+ {
3373
+ int v = atoi(yytext);
3374
+
3375
+ if (token != POOL_INTEGER || v < 0)
3376
+ {
3377
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
3378
+ fclose(fd);
3379
+ return(-1);
3380
+ }
3381
+ pool_config->system_db_port = v;
3382
+ }
3383
+
3384
+ else if (!strcmp(key, "system_db_dbname") && CHECK_CONTEXT(INIT_CONFIG, context))
3385
+ {
3386
+ char *str;
3387
+
3388
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3389
+ {
3390
+ PARSE_ERROR();
3391
+ fclose(fd);
3392
+ return(-1);
3393
+ }
3394
+ str = extract_string(yytext, token);
3395
+ if (str == NULL)
3396
+ {
3397
+ fclose(fd);
3398
+ return(-1);
3399
+ }
3400
+ pool_config->system_db_dbname = str;
3401
+ }
3402
+
3403
+ else if (!strcmp(key, "system_db_schema") && CHECK_CONTEXT(INIT_CONFIG, context))
3404
+ {
3405
+ char *str;
3406
+
3407
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3408
+ {
3409
+ PARSE_ERROR();
3410
+ fclose(fd);
3411
+ return(-1);
3412
+ }
3413
+ str = extract_string(yytext, token);
3414
+ if (str == NULL)
3415
+ {
3416
+ fclose(fd);
3417
+ return(-1);
3418
+ }
3419
+ pool_config->system_db_schema = str;
3420
+ }
3421
+
3422
+ else if (!strcmp(key, "system_db_user") && CHECK_CONTEXT(INIT_CONFIG, context))
3423
+ {
3424
+ char *str;
3425
+
3426
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3427
+ {
3428
+ PARSE_ERROR();
3429
+ fclose(fd);
3430
+ return(-1);
3431
+ }
3432
+ str = extract_string(yytext, token);
3433
+ if (str == NULL)
3434
+ {
3435
+ fclose(fd);
3436
+ return(-1);
3437
+ }
3438
+ pool_config->system_db_user = str;
3439
+ }
3440
+
3441
+ else if (!strcmp(key, "system_db_password") && CHECK_CONTEXT(INIT_CONFIG, context))
3442
+ {
3443
+ char *str;
3444
+
3445
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3446
+ {
3447
+ PARSE_ERROR();
3448
+ fclose(fd);
3449
+ return(-1);
3450
+ }
3451
+ str = extract_string(yytext, token);
3452
+ if (str == NULL)
3453
+ {
3454
+ fclose(fd);
3455
+ return(-1);
3456
+ }
3457
+ pool_config->system_db_password = str;
3458
+ }
3459
+
3460
+ else if (!strncmp(key, "backend_hostname", 16) &&
3461
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
3462
+ mypid == getpid()) /* this parameter must be modified by parent pid */
3463
+ {
3464
+ int slot;
3465
+ char *str;
3466
+
3467
+ slot = atoi(key + 16);
3468
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
3469
+ {
3470
+ pool_error("pool_config: backend number %s for backend_hostname out of range", key);
3471
+ fclose(fd);
3472
+ return(-1);
3473
+ }
3474
+
3475
+ str = extract_string(yytext, token);
3476
+ if (str == NULL)
3477
+ {
3478
+ fclose(fd);
3479
+ return(-1);
3480
+ }
3481
+ if (context == INIT_CONFIG ||
3482
+ (context == RELOAD_CONFIG && BACKEND_INFO(slot).backend_status == CON_UNUSED))
3483
+ strlcpy(BACKEND_INFO(slot).backend_hostname, str, MAX_DB_HOST_NAMELEN);
3484
+ }
3485
+
3486
+ else if (!strncmp(key, "backend_port", 12) &&
3487
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
3488
+ mypid == getpid()) /* this parameter must be modified by parent pid */
3489
+ {
3490
+ int slot;
3491
+
3492
+ slot = atoi(key + 12);
3493
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
3494
+ {
3495
+ pool_error("pool_config: host number %s for port number out of range", key);
3496
+ fclose(fd);
3497
+ return(-1);
3498
+ }
3499
+ pool_debug("pool_config: port slot number %d ", slot);
3500
+ if (context == INIT_CONFIG)
3501
+ {
3502
+ BACKEND_INFO(slot).backend_port = atoi(yytext);
3503
+ BACKEND_INFO(slot).backend_status = CON_CONNECT_WAIT;
3504
+ }
3505
+ else if (context == RELOAD_CONFIG && BACKEND_INFO(slot).backend_status == CON_UNUSED)
3506
+ {
3507
+ BACKEND_INFO(slot).backend_port = atoi(yytext);
3508
+ BACKEND_INFO(slot).backend_status = CON_DOWN;
3509
+ }
3510
+ }
3511
+
3512
+ else if (!strncmp(key, "backend_weight", 14) &&
3513
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
3514
+ mypid == getpid()) /* this parameter must be modified by parent pid */
3515
+ {
3516
+ int slot;
3517
+ double v;
3518
+ BACKEND_STATUS status;
3519
+
3520
+ slot = atoi(key + 14);
3521
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
3522
+ {
3523
+ pool_error("pool_config: weight number %s for port number out of range", key);
3524
+ fclose(fd);
3525
+ return(-1);
3526
+ }
3527
+
3528
+ v = atof(yytext);
3529
+
3530
+ if (v < 0.0)
3531
+ {
3532
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
3533
+ fclose(fd);
3534
+ return(-1);
3535
+ }
3536
+
3537
+ pool_debug("pool_config: weight slot number %d weight: %f", slot, v);
3538
+ status = BACKEND_INFO(slot).backend_status;
3539
+
3540
+ if (context == INIT_CONFIG || context == RELOAD_CONFIG)
3541
+ {
3542
+ double old_v = BACKEND_INFO(slot).unnormalized_weight;
3543
+ BACKEND_INFO(slot).unnormalized_weight = v;
3544
+
3545
+ /*
3546
+ * Log weight change event only when context is
3547
+ * reloading of pgpool.conf and weight is actually
3548
+ * changed
3549
+ */
3550
+ if (context == RELOAD_CONFIG && old_v != v)
3551
+ {
3552
+ pool_log("Backend weight for backend%d changed from %f to %f. This will take effect from next client session.", slot, old_v, v);
3553
+ }
3554
+ }
3555
+ }
3556
+ else if (!strncmp(key, "backend_data_directory", 22) &&
3557
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
3558
+ mypid == getpid()) /* this parameter must be modified by parent pid */
3559
+ {
3560
+ int slot;
3561
+ char *str;
3562
+ BACKEND_STATUS status;
3563
+
3564
+ slot = atoi(key + 22);
3565
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
3566
+ {
3567
+ pool_error("pool_config: backend number %s for backend_data_directory out of range", key);
3568
+ fclose(fd);
3569
+ return(-1);
3570
+ }
3571
+
3572
+ str = extract_string(yytext, token);
3573
+ if (str == NULL)
3574
+ {
3575
+ fclose(fd);
3576
+ return(-1);
3577
+ }
3578
+ status = BACKEND_INFO(slot).backend_status;
3579
+ if (context == INIT_CONFIG ||
3580
+ (context == RELOAD_CONFIG && (status == CON_UNUSED || status == CON_DOWN)))
3581
+ strlcpy(BACKEND_INFO(slot).backend_data_directory, str, MAX_PATH_LENGTH);
3582
+ }
3583
+ else if (!strncmp(key, "backend_flag", 12) &&
3584
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
3585
+ mypid == getpid()) /* this parameter must be modified by parent pid */
3586
+ {
3587
+ char *str;
3588
+ char **flags;
3589
+ int n;
3590
+ int i;
3591
+ int slot;
3592
+ unsigned short flag = 0;
3593
+ bool allow_to_failover_is_specified = 0;
3594
+ bool disallow_to_failover_is_specified = 0;
3595
+
3596
+ str = extract_string(yytext, token);
3597
+ if (str == NULL)
3598
+ {
3599
+ pool_error("pool_config: extract_string failed: %s", yytext);
3600
+ fclose(fd);
3601
+ return(-1);
3602
+ }
3603
+
3604
+ flags = extract_string_tokens(str, "|", &n);
3605
+ if (!flags || n < 0)
3606
+ {
3607
+ pool_debug("pool_config: unable to get backend flags");
3608
+ fclose(fd);
3609
+ return(-1);
3610
+ }
3611
+
3612
+ for (i=0;i<n;i++)
3613
+ {
3614
+ if (!strcmp(flags[i], "ALLOW_TO_FAILOVER"))
3615
+ {
3616
+ if (disallow_to_failover_is_specified)
3617
+ {
3618
+ pool_error("pool_config: cannot set ALLOW_TO_FAILOVER and DISALLOW_TO_FAILOVER at the same time");
3619
+ fclose(fd);
3620
+ return(-1);
3621
+ }
3622
+ flag &= ~POOL_FAILOVER;
3623
+ allow_to_failover_is_specified = true;
3624
+ pool_debug("pool_config: allow_to_failover on");
3625
+ }
3626
+
3627
+ else if (!strcmp(flags[i], "DISALLOW_TO_FAILOVER"))
3628
+ {
3629
+ if (allow_to_failover_is_specified)
3630
+ {
3631
+ pool_error("pool_config: cannot set ALLOW_TO_FAILOVER and DISALLOW_TO_FAILOVER at the same time");
3632
+ fclose(fd);
3633
+ return(-1);
3634
+ }
3635
+ flag |= POOL_FAILOVER;
3636
+ disallow_to_failover_is_specified = true;
3637
+ pool_debug("pool_config: disallow_to_failover on");
3638
+ }
3639
+
3640
+ else
3641
+ {
3642
+ pool_error("pool_config: invalid backend flag:%s", flags[i]);
3643
+ }
3644
+ }
3645
+
3646
+ slot = atoi(key + 12);
3647
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
3648
+ {
3649
+ pool_error("pool_config: slot number %s for flag out of range", key);
3650
+ fclose(fd);
3651
+ return(-1);
3652
+ }
3653
+
3654
+ BACKEND_INFO(slot).flag = flag;
3655
+
3656
+ pool_debug("pool_config: slot number %d flag: %04x", slot, flag);
3657
+ }
3658
+
3659
+ else if (!strcmp(key, "log_statement") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
3660
+ {
3661
+ int v = eval_logical(yytext);
3662
+
3663
+ if (v < 0)
3664
+ {
3665
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
3666
+ return(-1);
3667
+ }
3668
+ pool_config->log_statement = v;
3669
+ }
3670
+ else if (!strcmp(key, "log_per_node_statement") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
3671
+ {
3672
+ int v = eval_logical(yytext);
3673
+
3674
+ if (v < 0)
3675
+ {
3676
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
3677
+ return(-1);
3678
+ }
3679
+ pool_config->log_per_node_statement = v;
3680
+ }
3681
+
3682
+ else if (!strcmp(key, "lobj_lock_table") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
3683
+ {
3684
+ char *str;
3685
+
3686
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3687
+ {
3688
+ PARSE_ERROR();
3689
+ fclose(fd);
3690
+ return(-1);
3691
+ }
3692
+ str = extract_string(yytext, token);
3693
+ if (str == NULL)
3694
+ {
3695
+ fclose(fd);
3696
+ return(-1);
3697
+ }
3698
+ pool_config->lobj_lock_table = str;
3699
+ }
3700
+ /*
3701
+ * add for watchdog
3702
+ */
3703
+ else if (!strncmp(key, "other_pgpool_hostname", 21) &&
3704
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
3705
+ mypid == getpid()) /* this parameter must be modified by parent pid */
3706
+ {
3707
+ int slot;
3708
+ char *str;
3709
+
3710
+ slot = atoi(key + 21) ;
3711
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
3712
+ {
3713
+ pool_error("pool_config: pgpool number %s for other_pgpool_hostname out of range", key);
3714
+ fclose(fd);
3715
+ return(-1);
3716
+ }
3717
+
3718
+ str = extract_string(yytext, token);
3719
+ if (str == NULL)
3720
+ {
3721
+ fclose(fd);
3722
+ return(-1);
3723
+ }
3724
+ if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
3725
+ strlcpy(WD_INFO(slot).hostname, str, WD_MAX_HOST_NAMELEN);
3726
+ }
3727
+
3728
+ else if (!strncmp(key, "other_pgpool_port", 17) &&
3729
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
3730
+ mypid == getpid()) /* this parameter must be modified by parent pid */
3731
+ {
3732
+ int slot;
3733
+
3734
+ slot = atoi(key + 17);
3735
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
3736
+ {
3737
+ pool_error("pool_config: pgpool number %s for other_pgpool_port out of range", key);
3738
+ fclose(fd);
3739
+ return(-1);
3740
+ }
3741
+
3742
+ if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
3743
+ WD_INFO(slot).pgpool_port = atoi(yytext);
3744
+ }
3745
+
3746
+ else if (!strncmp(key, "other_wd_port", 13) &&
3747
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
3748
+ mypid == getpid()) /* this parameter must be modified by parent pid */
3749
+ {
3750
+ int slot;
3751
+
3752
+ slot = atoi(key + 13);
3753
+ if (slot < 0 || slot >= MAX_CONNECTION_SLOTS)
3754
+ {
3755
+ pool_error("pool_config: pgpool number %s for other_wd_port out of range", key);
3756
+ fclose(fd);
3757
+ return(-1);
3758
+ }
3759
+
3760
+ if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
3761
+ {
3762
+ WD_INFO(slot).wd_port = atoi(yytext);
3763
+ WD_INFO(slot).status = WD_INIT;
3764
+ pool_config->other_wd->num_wd = slot + 1;
3765
+ }
3766
+ }
3767
+ else if (!strcmp(key, "use_watchdog") && CHECK_CONTEXT(INIT_CONFIG, context))
3768
+ {
3769
+ int v = eval_logical(yytext);
3770
+
3771
+ if (v < 0)
3772
+ {
3773
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
3774
+ fclose(fd);
3775
+ return(-1);
3776
+ }
3777
+ pool_config->use_watchdog = v;
3778
+ }
3779
+
3780
+ else if (!strcmp(key, "clear_memqcache_on_escalation") && CHECK_CONTEXT(INIT_CONFIG, context))
3781
+ {
3782
+ int v = eval_logical(yytext);
3783
+
3784
+ if (v < 0)
3785
+ {
3786
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
3787
+ fclose(fd);
3788
+ return(-1);
3789
+ }
3790
+ pool_config->clear_memqcache_on_escalation = v;
3791
+ }
3792
+
3793
+ else if (!strcmp(key, "wd_escalation_command") &&
3794
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
3795
+ {
3796
+ char *str;
3797
+
3798
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3799
+ {
3800
+ PARSE_ERROR();
3801
+ fclose(fd);
3802
+ return(-1);
3803
+ }
3804
+ str = extract_string(yytext, token);
3805
+ if (str == NULL)
3806
+ {
3807
+ fclose(fd);
3808
+ return(-1);
3809
+ }
3810
+ pool_config->wd_escalation_command = str;
3811
+ }
3812
+
3813
+ else if (!strcmp(key, "trusted_servers") && CHECK_CONTEXT(INIT_CONFIG, context))
3814
+ {
3815
+ char *str;
3816
+
3817
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3818
+ {
3819
+ PARSE_ERROR();
3820
+ fclose(fd);
3821
+ return(-1);
3822
+ }
3823
+ str = extract_string(yytext, token);
3824
+ if (str == NULL)
3825
+ {
3826
+ fclose(fd);
3827
+ return(-1);
3828
+ }
3829
+ if(strlen(str))
3830
+ pool_config->trusted_servers = str;
3831
+ }
3832
+ else if (!strcmp(key, "delegate_IP") && CHECK_CONTEXT(INIT_CONFIG, context))
3833
+ {
3834
+ char *str;
3835
+
3836
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3837
+ {
3838
+ PARSE_ERROR();
3839
+ fclose(fd);
3840
+ return(-1);
3841
+ }
3842
+ str = extract_string(yytext, token);
3843
+ if (str == NULL)
3844
+ {
3845
+ fclose(fd);
3846
+ return(-1);
3847
+ }
3848
+ if(strlen(str))
3849
+ pool_config->delegate_IP = str;
3850
+ }
3851
+ else if (!strcmp(key, "wd_hostname") && CHECK_CONTEXT(INIT_CONFIG, context))
3852
+ {
3853
+ char *str;
3854
+
3855
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3856
+ {
3857
+ PARSE_ERROR();
3858
+ fclose(fd);
3859
+ return(-1);
3860
+ }
3861
+ str = extract_string(yytext, token);
3862
+ if (str == NULL)
3863
+ {
3864
+ fclose(fd);
3865
+ return(-1);
3866
+ }
3867
+ if(strlen(str))
3868
+ pool_config->wd_hostname = str;
3869
+ }
3870
+ else if (!strcmp(key, "wd_port") && CHECK_CONTEXT(INIT_CONFIG, context))
3871
+ {
3872
+ int v = atoi(yytext);
3873
+
3874
+ if (token != POOL_INTEGER || v <= 0)
3875
+ {
3876
+ pool_error("pool_config: %s must be higher than 1 numeric value", key);
3877
+ fclose(fd);
3878
+ return(-1);
3879
+ }
3880
+ pool_config->wd_port = v;
3881
+ }
3882
+ else if (!strcmp(key, "wd_interval") && CHECK_CONTEXT(INIT_CONFIG, context))
3883
+ {
3884
+ int v = atoi(yytext);
3885
+
3886
+ if (token != POOL_INTEGER || v <= 0)
3887
+ {
3888
+ pool_error("pool_config: %s must be higher than 1 numeric value", key);
3889
+ fclose(fd);
3890
+ return(-1);
3891
+ }
3892
+ pool_config->wd_interval = v;
3893
+ }
3894
+ else if (!strcmp(key, "ping_path") && CHECK_CONTEXT(INIT_CONFIG, context))
3895
+ {
3896
+ char *str;
3897
+
3898
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3899
+ {
3900
+ PARSE_ERROR();
3901
+ fclose(fd);
3902
+ return(-1);
3903
+ }
3904
+ str = extract_string(yytext, token);
3905
+ if (str == NULL)
3906
+ {
3907
+ fclose(fd);
3908
+ return(-1);
3909
+ }
3910
+ if(strlen(str))
3911
+ pool_config->ping_path = str;
3912
+ }
3913
+ else if (!strcmp(key, "ifconfig_path") && CHECK_CONTEXT(INIT_CONFIG, context))
3914
+ {
3915
+ char *str;
3916
+
3917
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3918
+ {
3919
+ PARSE_ERROR();
3920
+ fclose(fd);
3921
+ return(-1);
3922
+ }
3923
+ str = extract_string(yytext, token);
3924
+ if (str == NULL)
3925
+ {
3926
+ fclose(fd);
3927
+ return(-1);
3928
+ }
3929
+ if(strlen(str))
3930
+ pool_config->ifconfig_path = str;
3931
+ }
3932
+ else if (!strcmp(key, "if_up_cmd") && CHECK_CONTEXT(INIT_CONFIG, context))
3933
+ {
3934
+ char *str;
3935
+
3936
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3937
+ {
3938
+ PARSE_ERROR();
3939
+ fclose(fd);
3940
+ return(-1);
3941
+ }
3942
+ str = extract_string(yytext, token);
3943
+ if (str == NULL)
3944
+ {
3945
+ fclose(fd);
3946
+ return(-1);
3947
+ }
3948
+ if(strlen(str))
3949
+ pool_config->if_up_cmd = str;
3950
+ }
3951
+ else if (!strcmp(key, "if_down_cmd") && CHECK_CONTEXT(INIT_CONFIG, context))
3952
+ {
3953
+ char *str;
3954
+
3955
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3956
+ {
3957
+ PARSE_ERROR();
3958
+ fclose(fd);
3959
+ return(-1);
3960
+ }
3961
+ str = extract_string(yytext, token);
3962
+ if (str == NULL)
3963
+ {
3964
+ fclose(fd);
3965
+ return(-1);
3966
+ }
3967
+ if(strlen(str))
3968
+ pool_config->if_down_cmd = str;
3969
+ }
3970
+ else if (!strcmp(key, "arping_path") && CHECK_CONTEXT(INIT_CONFIG, context))
3971
+ {
3972
+ char *str;
3973
+
3974
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3975
+ {
3976
+ PARSE_ERROR();
3977
+ fclose(fd);
3978
+ return(-1);
3979
+ }
3980
+ str = extract_string(yytext, token);
3981
+ if (str == NULL)
3982
+ {
3983
+ fclose(fd);
3984
+ return(-1);
3985
+ }
3986
+ if(strlen(str))
3987
+ pool_config->arping_path = str;
3988
+ }
3989
+ else if (!strcmp(key, "arping_cmd") && CHECK_CONTEXT(INIT_CONFIG, context))
3990
+ {
3991
+ char *str;
3992
+
3993
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
3994
+ {
3995
+ PARSE_ERROR();
3996
+ fclose(fd);
3997
+ return(-1);
3998
+ }
3999
+ str = extract_string(yytext, token);
4000
+ if (str == NULL)
4001
+ {
4002
+ fclose(fd);
4003
+ return(-1);
4004
+ }
4005
+ if(strlen(str))
4006
+ pool_config->arping_cmd = str;
4007
+ }
4008
+ else if (!strcmp(key, "wd_life_point") && CHECK_CONTEXT(INIT_CONFIG, context))
4009
+ {
4010
+ int v = atoi(yytext);
4011
+
4012
+ if (token != POOL_INTEGER || v <= 0)
4013
+ {
4014
+ pool_error("pool_config: %s must be higher than 1 numeric value", key);
4015
+ fclose(fd);
4016
+ return(-1);
4017
+ }
4018
+ pool_config->wd_life_point = v;
4019
+ }
4020
+ else if (!strcmp(key, "wd_lifecheck_query") && CHECK_CONTEXT(INIT_CONFIG, context))
4021
+ {
4022
+ char *str;
4023
+
4024
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
4025
+ {
4026
+ PARSE_ERROR();
4027
+ fclose(fd);
4028
+ return(-1);
4029
+ }
4030
+ str = extract_string(yytext, token);
4031
+ if (str == NULL)
4032
+ {
4033
+ fclose(fd);
4034
+ return(-1);
4035
+ }
4036
+ if(strlen(str))
4037
+ pool_config->wd_lifecheck_query = str;
4038
+ }
4039
+
4040
+ else if (!strcmp(key, "wd_lifecheck_dbname") &&
4041
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
4042
+ {
4043
+ char *str;
4044
+
4045
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
4046
+ {
4047
+ PARSE_ERROR();
4048
+ fclose(fd);
4049
+ return(-1);
4050
+ }
4051
+ str = extract_string(yytext, token);
4052
+ if (str == NULL)
4053
+ {
4054
+ fclose(fd);
4055
+ return(-1);
4056
+ }
4057
+ pool_config->wd_lifecheck_dbname = str;
4058
+ }
4059
+
4060
+ else if (!strcmp(key, "wd_lifecheck_user") &&
4061
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
4062
+ {
4063
+ char *str;
4064
+
4065
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
4066
+ {
4067
+ PARSE_ERROR();
4068
+ fclose(fd);
4069
+ return(-1);
4070
+ }
4071
+ str = extract_string(yytext, token);
4072
+ if (str == NULL)
4073
+ {
4074
+ fclose(fd);
4075
+ return(-1);
4076
+ }
4077
+ pool_config->wd_lifecheck_user = str;
4078
+ }
4079
+
4080
+ else if (!strcmp(key, "wd_lifecheck_password") &&
4081
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
4082
+ {
4083
+ char *str;
4084
+
4085
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
4086
+ {
4087
+ PARSE_ERROR();
4088
+ fclose(fd);
4089
+ return(-1);
4090
+ }
4091
+ str = extract_string(yytext, token);
4092
+ if (str == NULL)
4093
+ {
4094
+ fclose(fd);
4095
+ return(-1);
4096
+ }
4097
+ pool_config->wd_lifecheck_password = str;
4098
+ }
4099
+
4100
+ else if (!strcmp(key, "wd_lifecheck_method") && CHECK_CONTEXT(INIT_CONFIG, context))
4101
+ {
4102
+ char *str;
4103
+
4104
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
4105
+ {
4106
+ PARSE_ERROR();
4107
+ fclose(fd);
4108
+ return(-1);
4109
+ }
4110
+ str = extract_string(yytext, token);
4111
+ if (str == NULL)
4112
+ {
4113
+ fclose(fd);
4114
+ return(-1);
4115
+ }
4116
+
4117
+ if (strcmp(str, MODE_HEARTBEAT) && strcmp(str, MODE_QUERY))
4118
+ {
4119
+ pool_error("pool_config: %s must be either \"heartbeat\" or \"query\"", key);
4120
+ fclose(fd);
4121
+ return(-1);
4122
+ }
4123
+ pool_config->wd_lifecheck_method = str;
4124
+ }
4125
+ else if (!strcmp(key, "wd_heartbeat_port") && CHECK_CONTEXT(INIT_CONFIG, context))
4126
+ {
4127
+ int v = atoi(yytext);
4128
+
4129
+ if (token != POOL_INTEGER || v <= 0)
4130
+ {
4131
+ pool_error("pool_config: %s must be higher than 1 numeric value", key);
4132
+ fclose(fd);
4133
+ return(-1);
4134
+ }
4135
+ pool_config->wd_heartbeat_port = v;
4136
+ }
4137
+ else if (!strcmp(key, "wd_heartbeat_keepalive") && CHECK_CONTEXT(INIT_CONFIG, context))
4138
+ {
4139
+ int v = atoi(yytext);
4140
+
4141
+ if (token != POOL_INTEGER || v <= 0)
4142
+ {
4143
+ pool_error("pool_config: %s must be higher than 1 numeric value", key);
4144
+ fclose(fd);
4145
+ return(-1);
4146
+ }
4147
+ pool_config->wd_heartbeat_keepalive = v;
4148
+ }
4149
+ else if (!strcmp(key, "wd_heartbeat_deadtime") && CHECK_CONTEXT(INIT_CONFIG, context))
4150
+ {
4151
+ int v = atoi(yytext);
4152
+
4153
+ if (token != POOL_INTEGER || v <= 0)
4154
+ {
4155
+ pool_error("pool_config: %s must be higher than 1 numeric value", key);
4156
+ fclose(fd);
4157
+ return(-1);
4158
+ }
4159
+ pool_config->wd_heartbeat_deadtime = v;
4160
+ }
4161
+ else if (!strcmp(key, "wd_authkey") &&
4162
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
4163
+ {
4164
+ char *str;
4165
+
4166
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
4167
+ {
4168
+ PARSE_ERROR();
4169
+ fclose(fd);
4170
+ return(-1);
4171
+ }
4172
+ str = extract_string(yytext, token);
4173
+ if (str == NULL)
4174
+ {
4175
+ fclose(fd);
4176
+ return(-1);
4177
+ }
4178
+ pool_config->wd_authkey = str;
4179
+ }
4180
+
4181
+ else if (!strncmp(key, "heartbeat_device", 16) &&
4182
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
4183
+ mypid == getpid()) /* this parameter must be modified by parent pid */
4184
+ {
4185
+ int slot;
4186
+ char *str;
4187
+
4188
+ slot = atoi(key + 16) ;
4189
+ if (slot < 0 || slot >= WD_MAX_IF_NUM)
4190
+ {
4191
+ pool_error("pool_config: pgpool number %s for heartbeat_device out of range", key);
4192
+ fclose(fd);
4193
+ return(-1);
4194
+ }
4195
+
4196
+ str = extract_string(yytext, token);
4197
+ if (str == NULL)
4198
+ {
4199
+ fclose(fd);
4200
+ return(-1);
4201
+ }
4202
+ if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
4203
+ strlcpy(WD_HB_IF(slot).if_name, str, WD_MAX_IF_NAME_LEN);
4204
+
4205
+ }
4206
+ /* this must be prior to hertbeat_destination */
4207
+ else if (!strncmp(key, "heartbeat_destination_port", 26) &&
4208
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
4209
+ mypid == getpid()) /* this parameter must be modified by parent pid */
4210
+ {
4211
+ int slot;
4212
+
4213
+ slot = atoi(key + 26) ;
4214
+ if (slot < 0 || slot >= WD_MAX_IF_NUM)
4215
+ {
4216
+ pool_error("pool_config: pgpool number %s for heartbeat_destination_port out of range", key);
4217
+ fclose(fd);
4218
+ return(-1);
4219
+ }
4220
+
4221
+ if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
4222
+ {
4223
+ WD_HB_IF(slot).dest_port = atoi(yytext);
4224
+ pool_config->num_hb_if = slot + 1;
4225
+ }
4226
+ }
4227
+ else if (!strncmp(key, "heartbeat_destination", 21) &&
4228
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context) &&
4229
+ mypid == getpid()) /* this parameter must be modified by parent pid */
4230
+ {
4231
+ int slot;
4232
+ char *str;
4233
+
4234
+ slot = atoi(key + 21) ;
4235
+ if (slot < 0 || slot >= WD_MAX_IF_NUM)
4236
+ {
4237
+ pool_error("pool_config: pgpool number %s for heartbeat_destination out of range", key);
4238
+ fclose(fd);
4239
+ return(-1);
4240
+ }
4241
+
4242
+ str = extract_string(yytext, token);
4243
+ if (str == NULL)
4244
+ {
4245
+ fclose(fd);
4246
+ return(-1);
4247
+ }
4248
+ if (context == INIT_CONFIG || (context == RELOAD_CONFIG ))
4249
+ strlcpy(WD_HB_IF(slot).addr, str, WD_MAX_HOST_NAMELEN);
4250
+ }
4251
+
4252
+ else if (!strcmp(key, "ssl") && CHECK_CONTEXT(INIT_CONFIG, context))
4253
+ {
4254
+ int v = eval_logical(yytext);
4255
+
4256
+ if (v < 0)
4257
+ {
4258
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
4259
+ return(-1);
4260
+ }
4261
+ pool_config->ssl = v;
4262
+ }
4263
+ else if (!strcmp(key, "ssl_cert") && CHECK_CONTEXT(INIT_CONFIG, context))
4264
+ {
4265
+ char *str;
4266
+
4267
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
4268
+ {
4269
+ PARSE_ERROR();
4270
+ fclose(fd);
4271
+ return(-1);
4272
+ }
4273
+ str = extract_string(yytext, token);
4274
+ if (str == NULL)
4275
+ {
4276
+ fclose(fd);
4277
+ return(-1);
4278
+ }
4279
+ pool_config->ssl_cert = str;
4280
+ }
4281
+ else if (!strcmp(key, "ssl_key") && CHECK_CONTEXT(INIT_CONFIG, context))
4282
+ {
4283
+ char *str;
4284
+
4285
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
4286
+ {
4287
+ PARSE_ERROR();
4288
+ fclose(fd);
4289
+ return(-1);
4290
+ }
4291
+ str = extract_string(yytext, token);
4292
+ if (str == NULL)
4293
+ {
4294
+ fclose(fd);
4295
+ return(-1);
4296
+ }
4297
+ pool_config->ssl_key = str;
4298
+ }
4299
+ else if (!strcmp(key, "ssl_ca_cert") &&
4300
+ CHECK_CONTEXT(INIT_CONFIG, context))
4301
+ {
4302
+ char *str;
4303
+
4304
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
4305
+ {
4306
+ PARSE_ERROR();
4307
+ fclose(fd);
4308
+ return(-1);
4309
+ }
4310
+ str = extract_string(yytext, token);
4311
+ if (str == NULL)
4312
+ {
4313
+ fclose(fd);
4314
+ return(-1);
4315
+ }
4316
+ pool_config->ssl_ca_cert = str;
4317
+ }
4318
+ else if (!strcmp(key, "ssl_ca_cert_dir") &&
4319
+ CHECK_CONTEXT(INIT_CONFIG, context))
4320
+ {
4321
+ char *str;
4322
+
4323
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
4324
+ {
4325
+ PARSE_ERROR();
4326
+ fclose(fd);
4327
+ return(-1);
4328
+ }
4329
+ str = extract_string(yytext, token);
4330
+ if (str == NULL)
4331
+ {
4332
+ fclose(fd);
4333
+ return(-1);
4334
+ }
4335
+ pool_config->ssl_ca_cert_dir = str;
4336
+ }
4337
+
4338
+ else if (!strcmp(key, "debug_level") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
4339
+ {
4340
+ int v = atoi(yytext);
4341
+
4342
+ if (token != POOL_INTEGER || v < 0)
4343
+ {
4344
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
4345
+ fclose(fd);
4346
+ return(-1);
4347
+ }
4348
+ pool_config->debug_level = v;
4349
+ }
4350
+
4351
+ else if (!strcmp(key, "relcache_expire") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
4352
+ {
4353
+ int v = atoi(yytext);
4354
+
4355
+ if (token != POOL_INTEGER || v < 0)
4356
+ {
4357
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
4358
+ fclose(fd);
4359
+ return(-1);
4360
+ }
4361
+ pool_config->relcache_expire = v;
4362
+ }
4363
+
4364
+ else if (!strcmp(key, "relcache_size") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
4365
+ {
4366
+ int v = atoi(yytext);
4367
+
4368
+ if (token != POOL_INTEGER || v < 1)
4369
+ {
4370
+ pool_error("pool_config: %s must be equal or higher than 1 numeric value", key);
4371
+ fclose(fd);
4372
+ return(-1);
4373
+ }
4374
+ pool_config->relcache_size = v;
4375
+ }
4376
+
4377
+ else if (!strcmp(key, "check_temp_table") && CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
4378
+ {
4379
+ int v = eval_logical(yytext);
4380
+
4381
+ if (v < 0)
4382
+ {
4383
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
4384
+ return(-1);
4385
+ }
4386
+ pool_config->check_temp_table = v;
4387
+ }
4388
+
4389
+ else if (!strcmp(key, "memory_cache_enabled") &&
4390
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
4391
+ {
4392
+ int v = eval_logical(yytext);
4393
+
4394
+ if (v < 0)
4395
+ {
4396
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
4397
+ fclose(fd);
4398
+ return(-1);
4399
+ }
4400
+ pool_config->memory_cache_enabled = v;
4401
+ }
4402
+ else if (!strcmp(key, "memqcache_method") && CHECK_CONTEXT(INIT_CONFIG, context))
4403
+ {
4404
+ char *str;
4405
+
4406
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
4407
+ {
4408
+ PARSE_ERROR();
4409
+ fclose(fd);
4410
+ return(-1);
4411
+ }
4412
+ str = extract_string(yytext, token);
4413
+ if (str == NULL)
4414
+ {
4415
+ fclose(fd);
4416
+ return(-1);
4417
+ }
4418
+
4419
+ if (!strcmp(str, "memcached") && !use_memcached)
4420
+ {
4421
+ pool_error("memqcached_method cannot be memcached because pgpool-II is not built with MEMCACHED enabled");
4422
+ fclose(fd);
4423
+ return -1;
4424
+ }
4425
+
4426
+ if (strcmp(str, "memcached") && strcmp(str, "shmem"))
4427
+ {
4428
+ pool_error("memqcached_method must be either shmem or memcached");
4429
+ fclose(fd);
4430
+ return -1;
4431
+ }
4432
+
4433
+ pool_config->memqcache_method = str;
4434
+ }
4435
+ else if (!strcmp(key, "memqcache_memcached_host") && CHECK_CONTEXT(INIT_CONFIG, context))
4436
+ {
4437
+ char *str;
4438
+
4439
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
4440
+ {
4441
+ PARSE_ERROR();
4442
+ fclose(fd);
4443
+ return(-1);
4444
+ }
4445
+ str = extract_string(yytext, token);
4446
+ if (str == NULL)
4447
+ {
4448
+ fclose(fd);
4449
+ return(-1);
4450
+ }
4451
+ pool_config->memqcache_memcached_host = str;
4452
+ }
4453
+ else if (!strcmp(key, "memqcache_memcached_port") && CHECK_CONTEXT(INIT_CONFIG, context))
4454
+ {
4455
+ int v = atoi(yytext);
4456
+
4457
+ if (token != POOL_INTEGER || v < 0)
4458
+ {
4459
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
4460
+ fclose(fd);
4461
+ return(-1);
4462
+ }
4463
+ pool_config->memqcache_memcached_port = v;
4464
+ }
4465
+ else if (!strcmp(key, "memqcache_total_size") && CHECK_CONTEXT(INIT_CONFIG, context))
4466
+ {
4467
+ int v = atoi(yytext);
4468
+
4469
+ if (token != POOL_INTEGER || v < 0)
4470
+ {
4471
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
4472
+ fclose(fd);
4473
+ return(-1);
4474
+ }
4475
+ pool_config->memqcache_total_size = v;
4476
+ }
4477
+ else if (!strcmp(key, "memqcache_max_num_cache") && CHECK_CONTEXT(INIT_CONFIG, context))
4478
+ {
4479
+ int v = atoi(yytext);
4480
+
4481
+ if (token != POOL_INTEGER || v < 0)
4482
+ {
4483
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
4484
+ fclose(fd);
4485
+ return(-1);
4486
+ }
4487
+ pool_config->memqcache_max_num_cache = v;
4488
+ }
4489
+ else if (!strcmp(key, "memqcache_expire") && CHECK_CONTEXT(INIT_CONFIG, context))
4490
+ {
4491
+ int v = atoi(yytext);
4492
+
4493
+ if (token != POOL_INTEGER || v < 0)
4494
+ {
4495
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
4496
+ fclose(fd);
4497
+ return(-1);
4498
+ }
4499
+ pool_config->memqcache_expire = v;
4500
+ }
4501
+ else if (!strcmp(key, "memqcache_auto_cache_invalidation") && CHECK_CONTEXT(INIT_CONFIG, context))
4502
+ {
4503
+ int v = eval_logical(yytext);
4504
+
4505
+ if (v < 0)
4506
+ {
4507
+ pool_error("pool_config: invalid value %s for %s", yytext, key);
4508
+ fclose(fd);
4509
+ return(-1);
4510
+ }
4511
+ pool_config->memqcache_auto_cache_invalidation = v;
4512
+ }
4513
+ else if (!strcmp(key, "memqcache_maxcache") && CHECK_CONTEXT(INIT_CONFIG, context))
4514
+ {
4515
+ int v = atoi(yytext);
4516
+
4517
+ if (token != POOL_INTEGER || v < 0)
4518
+ {
4519
+ pool_error("pool_config: %s must be equal or higher than 0 numeric value", key);
4520
+ fclose(fd);
4521
+ return(-1);
4522
+ }
4523
+ pool_config->memqcache_maxcache = v;
4524
+ }
4525
+ else if (!strcmp(key, "memqcache_cache_block_size") && CHECK_CONTEXT(INIT_CONFIG, context))
4526
+ {
4527
+ int v = atoi(yytext);
4528
+
4529
+ if (token != POOL_INTEGER || v < 512)
4530
+ {
4531
+ pool_error("pool_config: %s must be equal or higher than 512 numeric value", key);
4532
+ fclose(fd);
4533
+ return(-1);
4534
+ }
4535
+ pool_config->memqcache_cache_block_size = v;
4536
+ }
4537
+ else if (!strcmp(key, "memqcache_oiddir") && CHECK_CONTEXT(INIT_CONFIG, context))
4538
+ {
4539
+ char *str;
4540
+
4541
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
4542
+ {
4543
+ PARSE_ERROR();
4544
+ fclose(fd);
4545
+ return(-1);
4546
+ }
4547
+ str = extract_string(yytext, token);
4548
+ if (str == NULL)
4549
+ {
4550
+ fclose(fd);
4551
+ return(-1);
4552
+ }
4553
+ pool_config->memqcache_oiddir = str;
4554
+ }
4555
+ else if (!strcmp(key, "white_memqcache_table_list") &&
4556
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
4557
+ {
4558
+ char *str;
4559
+
4560
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
4561
+ {
4562
+ PARSE_ERROR();
4563
+ fclose(fd);
4564
+ return(-1);
4565
+ }
4566
+ str = extract_string(yytext, token);
4567
+ if (str == NULL)
4568
+ {
4569
+ fclose(fd);
4570
+ return(-1);
4571
+ }
4572
+ pool_config->white_memqcache_table_list =
4573
+ extract_string_tokens(str, ",", &pool_config->num_white_memqcache_table_list);
4574
+
4575
+ if (pool_config->white_memqcache_table_list == NULL)
4576
+ {
4577
+ fclose(fd);
4578
+ return(-1);
4579
+ }
4580
+ for (i=0;i<pool_config->num_white_memqcache_table_list;i++)
4581
+ {
4582
+ add_regex_pattern("white_memqcache_table_list", pool_config->white_memqcache_table_list[i]);
4583
+ }
4584
+ }
4585
+
4586
+ else if (!strcmp(key, "black_memqcache_table_list") &&
4587
+ CHECK_CONTEXT(INIT_CONFIG|RELOAD_CONFIG, context))
4588
+ {
4589
+ char *str;
4590
+
4591
+ if (token != POOL_STRING && token != POOL_UNQUOTED_STRING && token != POOL_KEY)
4592
+ {
4593
+ PARSE_ERROR();
4594
+ fclose(fd);
4595
+ return(-1);
4596
+ }
4597
+ str = extract_string(yytext, token);
4598
+ if (str == NULL)
4599
+ {
4600
+ fclose(fd);
4601
+ return(-1);
4602
+ }
4603
+ pool_config->black_memqcache_table_list =
4604
+ extract_string_tokens(str, ",", &pool_config->num_black_memqcache_table_list);
4605
+
4606
+ if (pool_config->black_memqcache_table_list == NULL)
4607
+ {
4608
+ fclose(fd);
4609
+ return(-1);
4610
+ }
4611
+ for (i=0;i<pool_config->num_black_memqcache_table_list;i++)
4612
+ {
4613
+ add_regex_pattern("black_memqcache_table_list", pool_config->black_memqcache_table_list[i]);
4614
+ }
4615
+ }
4616
+ }
4617
+
4618
+ fclose(fd);
4619
+
4620
+ if (log_destination_changed)
4621
+ {
4622
+ /* log_destination has changed, we need to open syslog or close it */
4623
+ if (!strcmp(pool_config->log_destination, "stderr"))
4624
+ {
4625
+ closelog();
4626
+ pool_config->logsyslog = 0;
4627
+ }
4628
+ else
4629
+ {
4630
+ openlog(pool_config->syslog_ident, LOG_PID|LOG_NDELAY|LOG_NOWAIT, pool_config->syslog_facility);
4631
+ pool_config->logsyslog = 1;
4632
+ }
4633
+ }
4634
+
4635
+ pool_config->backend_desc->num_backends = 0;
4636
+ total_weight = 0.0;
4637
+
4638
+ for (i=0;i<MAX_CONNECTION_SLOTS;i++)
4639
+ {
4640
+ /* port number == 0 indicates that this server is out of use */
4641
+ if (BACKEND_INFO(i).backend_port == 0)
4642
+ {
4643
+ clear_host_entry(i);
4644
+ }
4645
+
4646
+ else
4647
+ {
4648
+ total_weight += BACKEND_INFO(i).unnormalized_weight;
4649
+ pool_config->backend_desc->num_backends = i+1;
4650
+
4651
+ /* initialize backend_hostname with a default socket path if empty */
4652
+ if (*(BACKEND_INFO(i).backend_hostname) == '\0')
4653
+ {
4654
+ if (pool_config->backend_socket_dir == NULL)
4655
+ {
4656
+ pool_debug("pool_config: empty backend_hostname%d, use PostgreSQL's default unix socket path (%s)", i, DEFAULT_SOCKET_DIR);
4657
+ strlcpy(BACKEND_INFO(i).backend_hostname, DEFAULT_SOCKET_DIR, MAX_DB_HOST_NAMELEN);
4658
+ }
4659
+ else /* DEPRECATED. backward compatibility with older version. Use backend_socket_dir*/
4660
+ {
4661
+ pool_debug("pool_config: empty backend_hostname%d, use backend_socket_dir as unix socket path (%s)", i, pool_config->backend_socket_dir);
4662
+ strlcpy(BACKEND_INFO(i).backend_hostname, pool_config->backend_socket_dir, MAX_DB_HOST_NAMELEN);
4663
+ }
4664
+ }
4665
+ }
4666
+ }
4667
+
4668
+ pool_debug("num_backends: %d total_weight: %f",
4669
+ pool_config->backend_desc->num_backends, total_weight);
4670
+ /*
4671
+ * Normalize load balancing weights. What we are doing here is,
4672
+ * assign 0 to RAND_MAX to each backend's weight according to the
4673
+ * value weightN. For example, if two backends are assigned 1.0,
4674
+ * then each backend will get RAND_MAX/2 normalized weight.
4675
+ */
4676
+ for (i=0;i<MAX_CONNECTION_SLOTS;i++)
4677
+ {
4678
+ #ifdef DEBUG
4679
+ print_host_entry(i);
4680
+ #endif
4681
+
4682
+ if (BACKEND_INFO(i).backend_port != 0)
4683
+ {
4684
+ BACKEND_INFO(i).backend_weight =
4685
+ (RAND_MAX) * BACKEND_INFO(i).unnormalized_weight / total_weight;
4686
+ pool_debug("backend %d weight: %f", i, BACKEND_INFO(i).backend_weight);
4687
+ pool_debug("backend %d flag: %04x", i, BACKEND_INFO(i).flag);
4688
+ }
4689
+ }
4690
+
4691
+ if (pool_config->parallel_mode || pool_config->enable_query_cache)
4692
+ {
4693
+ #ifndef POOL_PRIVATE
4694
+ int dist_num;
4695
+ #endif
4696
+ SystemDBInfo *info;
4697
+
4698
+ system_db_info = malloc(sizeof(POOL_SYSTEMDB_CONNECTION_POOL));
4699
+ if (system_db_info == NULL)
4700
+ {
4701
+ pool_error("failed to allocate system_db_info");
4702
+ return -1;
4703
+ }
4704
+ memset(system_db_info, 0, sizeof(*system_db_info));
4705
+
4706
+ #ifndef POOL_PRIVATE
4707
+ system_db_info->system_db_status = pool_shared_memory_create(sizeof(BACKEND_STATUS));
4708
+ #else
4709
+ system_db_info->system_db_status = malloc(sizeof(BACKEND_STATUS));
4710
+ #endif
4711
+ if (system_db_info->system_db_status == NULL)
4712
+ {
4713
+ pool_error("failed to allocate system_db_info->system_db_status");
4714
+ return -1;
4715
+ }
4716
+
4717
+ *system_db_info->system_db_status = CON_CONNECT_WAIT; /* which is the same as SYSDB_STATUS = CON_CONNECT_WAIT */
4718
+
4719
+ info = malloc(sizeof(SystemDBInfo));
4720
+ if (info == NULL)
4721
+ {
4722
+ pool_error("failed to allocate info");
4723
+ return -1;
4724
+ }
4725
+
4726
+ system_db_info->info = info;
4727
+ info->hostname = pool_config->system_db_hostname;
4728
+ info->port = pool_config->system_db_port;
4729
+ info->user = pool_config->system_db_user;
4730
+ info->password = pool_config->system_db_password;
4731
+ info->database_name = pool_config->system_db_dbname;
4732
+ info->schema_name = pool_config->system_db_schema;
4733
+ info->dist_def_num = 0;
4734
+ info->dist_def_slot = NULL;
4735
+
4736
+ #ifndef POOL_PRIVATE
4737
+ if (pool_config->parallel_mode)
4738
+ {
4739
+
4740
+ dist_num = pool_memset_system_db_info(info);
4741
+ if(dist_num < 0)
4742
+ {
4743
+ pool_error("failed to get systemdb info");
4744
+ return(-1);
4745
+ }
4746
+ if (!pool_config->replication_mode && !pool_config->load_balance_mode)
4747
+ {
4748
+ pool_error("pool_config: parallel_mode requires replication_mode or load_balance_mode turned on");
4749
+ return(-1);
4750
+ }
4751
+ }
4752
+ if (pool_config->enable_query_cache)
4753
+ {
4754
+ info->query_cache_table_info.register_prepared_statement = NULL;
4755
+ if (! pool_query_cache_table_exists())
4756
+ {
4757
+ pool_error("failed to locate query_cache table. perhaps it's not defined?");
4758
+ return -1;
4759
+ }
4760
+ }
4761
+ SYSDB_STATUS = CON_UP;
4762
+ #endif
4763
+ }
4764
+
4765
+ if (strcmp(pool_config->recovery_1st_stage_command, "") ||
4766
+ strcmp(pool_config->recovery_2nd_stage_command, ""))
4767
+ {
4768
+ for (i=0;i<MAX_CONNECTION_SLOTS;i++)
4769
+ {
4770
+ if (pool_config->backend_desc->backend_info[i].backend_port != 0 &&
4771
+ !strcmp(pool_config->backend_desc->backend_info[i].backend_data_directory, ""))
4772
+ {
4773
+ pool_error("pool_config: recovery_1st_stage_command and recovery_2nd_stage_command requires backend_data_directory to be set");
4774
+ return -1;
4775
+ }
4776
+ }
4777
+ }
4778
+
4779
+ return 0;
4780
+ }
4781
+
4782
+ static char *extract_string(char *value, POOL_TOKEN token)
4783
+ {
4784
+ char *ret;
4785
+
4786
+ ret = strdup(value);
4787
+ if (!ret)
4788
+ {
4789
+ pool_error("extract_string: out of memory");
4790
+ return NULL;
4791
+ }
4792
+
4793
+ if (token == POOL_STRING)
4794
+ {
4795
+ ret[strlen(ret)-1] = '\0';
4796
+ return (ret+1);
4797
+ }
4798
+ return ret;
4799
+ }
4800
+
4801
+ /*
4802
+ * Try to interpret value as boolean value. Valid values are: true,
4803
+ * false, yes, no, on, off, 1, 0; as well as unique prefixes thereof.
4804
+ * If the string parses okay, return true, else false.
4805
+ * If okay and result is not NULL, return the value in *result.
4806
+ * This function copied from PostgreSQL source code.
4807
+ */
4808
+ static bool parse_bool_with_len(const char *value, size_t len, bool *result)
4809
+ {
4810
+ switch (*value)
4811
+ {
4812
+ case 't':
4813
+ case 'T':
4814
+ if (strncasecmp(value, "true", len) == 0)
4815
+ {
4816
+ if (result)
4817
+ *result = true;
4818
+ return true;
4819
+ }
4820
+ break;
4821
+ case 'f':
4822
+ case 'F':
4823
+ if (strncasecmp(value, "false", len) == 0)
4824
+ {
4825
+ if (result)
4826
+ *result = false;
4827
+ return true;
4828
+ }
4829
+ break;
4830
+ case 'y':
4831
+ case 'Y':
4832
+ if (strncasecmp(value, "yes", len) == 0)
4833
+ {
4834
+ if (result)
4835
+ *result = true;
4836
+ return true;
4837
+ }
4838
+ break;
4839
+ case 'n':
4840
+ case 'N':
4841
+ if (strncasecmp(value, "no", len) == 0)
4842
+ {
4843
+ if (result)
4844
+ *result = false;
4845
+ return true;
4846
+ }
4847
+ break;
4848
+ case 'o':
4849
+ case 'O':
4850
+ /* 'o' is not unique enough */
4851
+ if (strncasecmp(value, "on", (len > 2 ? len : 2)) == 0)
4852
+ {
4853
+ if (result)
4854
+ *result = true;
4855
+ return true;
4856
+ }
4857
+ else if (strncasecmp(value, "off", (len > 2 ? len : 2)) == 0)
4858
+ {
4859
+ if (result)
4860
+ *result = false;
4861
+ return true;
4862
+ }
4863
+ break;
4864
+ case '1':
4865
+ if (len == 1)
4866
+ {
4867
+ if (result)
4868
+ *result = true;
4869
+ return true;
4870
+ }
4871
+ break;
4872
+ case '0':
4873
+ if (len == 1)
4874
+ {
4875
+ if (result)
4876
+ *result = false;
4877
+ return true;
4878
+ }
4879
+ break;
4880
+ default:
4881
+ break;
4882
+ }
4883
+
4884
+ if (result)
4885
+ *result = false; /* suppress compiler warning */
4886
+ return false;
4887
+ }
4888
+
4889
+ int eval_logical(char *str)
4890
+ {
4891
+ bool result;
4892
+
4893
+ if (!parse_bool_with_len(str, strlen(str), &result))
4894
+ return -1;
4895
+
4896
+ return (result ? 1 : 0);
4897
+ }
4898
+
4899
+ /*
4900
+ * Extract tokens separated by delimi from str. Return value is an
4901
+ * array of pointers to malloced strings. number of tokens is set to
4902
+ * n; note that str will be destroyed by strtok().
4903
+ */
4904
+ #define MAXTOKENS 1024
4905
+ static char **extract_string_tokens(char *str, char *delimi, int *n)
4906
+ {
4907
+ char *token;
4908
+ static char **tokens;
4909
+
4910
+ *n = 0;
4911
+
4912
+ tokens = malloc(MAXTOKENS*sizeof(char *));
4913
+ if (tokens == NULL)
4914
+ {
4915
+ pool_error("extract_string_tokens: out of memory");
4916
+ return NULL;
4917
+ }
4918
+
4919
+ for (token = strtok(str, delimi); token != NULL && *n < MAXTOKENS; token = strtok(NULL, delimi))
4920
+ {
4921
+ tokens[*n] = strdup(token);
4922
+ if (tokens[*n] == NULL)
4923
+ {
4924
+ pool_error("extract_string_tokens: out of memory");
4925
+ return NULL;
4926
+ }
4927
+ pool_debug("extract_string_tokens: token: %s", tokens[*n]);
4928
+ (*n)++;
4929
+ }
4930
+ return tokens;
4931
+ }
4932
+
4933
+ static void clear_host_entry(int slot)
4934
+ {
4935
+ *pool_config->backend_desc->backend_info[slot].backend_hostname = '\0';
4936
+ pool_config->backend_desc->backend_info[slot].backend_port = 0;
4937
+ pool_config->backend_desc->backend_info[slot].backend_status = CON_UNUSED;
4938
+ pool_config->backend_desc->backend_info[slot].backend_weight = 0.0;
4939
+ }
4940
+
4941
+ #ifdef DEBUG
4942
+ static void print_host_entry(int slot)
4943
+ {
4944
+ pool_debug("slot: %d host: %s port: %d status: %d weight: %f",
4945
+ slot,
4946
+ pool_config->server_hostnames[slot],
4947
+ pool_config->server_ports[slot],
4948
+ pool_config->server_status[slot],
4949
+ pool_config->server_weights[slot]);
4950
+ }
4951
+ #endif
4952
+
4953
+ /* Use to set the syslog facility level if logsyslog is activated */
4954
+ int set_syslog_facility(char *value)
4955
+ {
4956
+ int facility = LOG_LOCAL0;
4957
+
4958
+ if (value == NULL)
4959
+ return facility;
4960
+
4961
+ if (strncmp(value, "LOCAL", 5) == 0 && strlen(value) == 6) {
4962
+ switch (value[5]) {
4963
+ case '0':
4964
+ facility = LOG_LOCAL0;
4965
+ break;
4966
+ case '1':
4967
+ facility = LOG_LOCAL1;
4968
+ break;
4969
+ case '2':
4970
+ facility = LOG_LOCAL2;
4971
+ break;
4972
+ case '3':
4973
+ facility = LOG_LOCAL3;
4974
+ break;
4975
+ case '4':
4976
+ facility = LOG_LOCAL4;
4977
+ break;
4978
+ case '5':
4979
+ facility = LOG_LOCAL5;
4980
+ break;
4981
+ case '6':
4982
+ facility = LOG_LOCAL6;
4983
+ break;
4984
+ case '7':
4985
+ facility = LOG_LOCAL7;
4986
+ break;
4987
+ }
4988
+ }
4989
+ return facility;
4990
+ }
4991
+
4992
+ /*
4993
+ * Translate binary form of backend flag to string.
4994
+ * The returned data is in static buffer, and it will be destroyed
4995
+ * at the next call to this function.
4996
+ */
4997
+ char *pool_flag_to_str(unsigned short flag)
4998
+ {
4999
+ static char buf[1024]; /* should be large enough */
5000
+
5001
+ if (POOL_ALLOW_TO_FAILOVER(flag))
5002
+ snprintf(buf, sizeof(buf), "ALLOW_TO_FAILOVER");
5003
+ else if (POOL_DISALLOW_TO_FAILOVER(flag))
5004
+ snprintf(buf, sizeof(buf), "DISALLOW_TO_FAILOVER");
5005
+ return buf;
5006
+ }
5007
+