prestogres 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (393) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +20 -0
  4. data/LICENSE +202 -0
  5. data/NOTICE +22 -0
  6. data/README.md +217 -0
  7. data/Rakefile +13 -0
  8. data/VERSION +1 -0
  9. data/bin/prestogres +254 -0
  10. data/config/pcp.conf.sample +28 -0
  11. data/config/pgpool.conf +678 -0
  12. data/config/pool_hba.conf +84 -0
  13. data/config/pool_passwd +0 -0
  14. data/config/postgresql.conf +2 -0
  15. data/ext/.gitignore +6 -0
  16. data/ext/depend +26 -0
  17. data/ext/extconf.rb +4 -0
  18. data/ext/prestogres_config.c +12 -0
  19. data/pgpool2/.gitignore +36 -0
  20. data/pgpool2/AUTHORS +4 -0
  21. data/pgpool2/COPYING +12 -0
  22. data/pgpool2/ChangeLog +1 -0
  23. data/pgpool2/INSTALL +1 -0
  24. data/pgpool2/Makefile.am +159 -0
  25. data/pgpool2/Makefile.in +1187 -0
  26. data/pgpool2/NEWS +4960 -0
  27. data/pgpool2/README +1 -0
  28. data/pgpool2/README.euc_jp +1 -0
  29. data/pgpool2/README.online-recovery +62 -0
  30. data/pgpool2/TODO +103 -0
  31. data/pgpool2/ac_func_accept_argtypes.m4 +85 -0
  32. data/pgpool2/aclocal.m4 +1088 -0
  33. data/pgpool2/c-compiler.m4 +134 -0
  34. data/pgpool2/c-library.m4 +325 -0
  35. data/pgpool2/child.c +2097 -0
  36. data/pgpool2/config.guess +1532 -0
  37. data/pgpool2/config.h.in +332 -0
  38. data/pgpool2/config.sub +1640 -0
  39. data/pgpool2/configure +15752 -0
  40. data/pgpool2/configure.in +392 -0
  41. data/pgpool2/depcomp +522 -0
  42. data/pgpool2/doc/basebackup.sh +17 -0
  43. data/pgpool2/doc/pgpool-de.html +4220 -0
  44. data/pgpool2/doc/pgpool-en.html +5738 -0
  45. data/pgpool2/doc/pgpool-fr.html +4118 -0
  46. data/pgpool2/doc/pgpool-ja.css +198 -0
  47. data/pgpool2/doc/pgpool-ja.html +11279 -0
  48. data/pgpool2/doc/pgpool-zh_cn.html +4445 -0
  49. data/pgpool2/doc/pgpool.css +280 -0
  50. data/pgpool2/doc/pgpool_remote_start +13 -0
  51. data/pgpool2/doc/recovery.conf.sample +117 -0
  52. data/pgpool2/doc/tutorial-en.html +707 -0
  53. data/pgpool2/doc/tutorial-ja.html +422 -0
  54. data/pgpool2/doc/tutorial-memqcache-en.html +325 -0
  55. data/pgpool2/doc/tutorial-memqcache-ja.html +370 -0
  56. data/pgpool2/doc/tutorial-memqcache-zh_cn.html +322 -0
  57. data/pgpool2/doc/tutorial-watchdog-en.html +306 -0
  58. data/pgpool2/doc/tutorial-watchdog-ja.html +343 -0
  59. data/pgpool2/doc/tutorial-watchdog-zh_cn.html +301 -0
  60. data/pgpool2/doc/tutorial-zh_cn.html +537 -0
  61. data/pgpool2/doc/watchdog.png +0 -0
  62. data/pgpool2/doc/wd-en.html +236 -0
  63. data/pgpool2/doc/wd-en.jpg +0 -0
  64. data/pgpool2/doc/wd-ja.html +219 -0
  65. data/pgpool2/doc/wd-ja.jpg +0 -0
  66. data/pgpool2/doc/wd-zh_cn.html +201 -0
  67. data/pgpool2/doc/where_to_send_queries.odg +0 -0
  68. data/pgpool2/doc/where_to_send_queries.pdf +0 -0
  69. data/pgpool2/general.m4 +166 -0
  70. data/pgpool2/getopt_long.c +200 -0
  71. data/pgpool2/getopt_long.h +44 -0
  72. data/pgpool2/install-sh +251 -0
  73. data/pgpool2/ltmain.sh +8406 -0
  74. data/pgpool2/m4/libtool.m4 +7360 -0
  75. data/pgpool2/m4/ltoptions.m4 +368 -0
  76. data/pgpool2/m4/ltsugar.m4 +123 -0
  77. data/pgpool2/m4/ltversion.m4 +23 -0
  78. data/pgpool2/m4/lt~obsolete.m4 +92 -0
  79. data/pgpool2/main.c +2971 -0
  80. data/pgpool2/md5.c +444 -0
  81. data/pgpool2/md5.h +28 -0
  82. data/pgpool2/missing +360 -0
  83. data/pgpool2/mkinstalldirs +40 -0
  84. data/pgpool2/parser/Makefile.am +50 -0
  85. data/pgpool2/parser/Makefile.in +559 -0
  86. data/pgpool2/parser/copyfuncs.c +3310 -0
  87. data/pgpool2/parser/gram.c +39100 -0
  88. data/pgpool2/parser/gram.h +940 -0
  89. data/pgpool2/parser/gram.y +13408 -0
  90. data/pgpool2/parser/gramparse.h +74 -0
  91. data/pgpool2/parser/keywords.c +32 -0
  92. data/pgpool2/parser/keywords.h +39 -0
  93. data/pgpool2/parser/kwlist.h +425 -0
  94. data/pgpool2/parser/kwlookup.c +88 -0
  95. data/pgpool2/parser/list.c +1156 -0
  96. data/pgpool2/parser/makefuncs.c +518 -0
  97. data/pgpool2/parser/makefuncs.h +83 -0
  98. data/pgpool2/parser/memnodes.h +79 -0
  99. data/pgpool2/parser/nodes.c +29 -0
  100. data/pgpool2/parser/nodes.h +609 -0
  101. data/pgpool2/parser/outfuncs.c +5790 -0
  102. data/pgpool2/parser/parsenodes.h +2615 -0
  103. data/pgpool2/parser/parser.c +262 -0
  104. data/pgpool2/parser/parser.h +46 -0
  105. data/pgpool2/parser/pg_class.h +158 -0
  106. data/pgpool2/parser/pg_config_manual.h +273 -0
  107. data/pgpool2/parser/pg_list.h +352 -0
  108. data/pgpool2/parser/pg_trigger.h +147 -0
  109. data/pgpool2/parser/pg_wchar.h +492 -0
  110. data/pgpool2/parser/pool_memory.c +342 -0
  111. data/pgpool2/parser/pool_memory.h +77 -0
  112. data/pgpool2/parser/pool_parser.h +222 -0
  113. data/pgpool2/parser/pool_string.c +121 -0
  114. data/pgpool2/parser/pool_string.h +37 -0
  115. data/pgpool2/parser/primnodes.h +1280 -0
  116. data/pgpool2/parser/scan.c +4094 -0
  117. data/pgpool2/parser/scan.l +1451 -0
  118. data/pgpool2/parser/scanner.h +120 -0
  119. data/pgpool2/parser/scansup.c +221 -0
  120. data/pgpool2/parser/scansup.h +28 -0
  121. data/pgpool2/parser/snprintf.c +1102 -0
  122. data/pgpool2/parser/stringinfo.c +294 -0
  123. data/pgpool2/parser/stringinfo.h +178 -0
  124. data/pgpool2/parser/value.c +78 -0
  125. data/pgpool2/parser/value.h +62 -0
  126. data/pgpool2/parser/wchar.c +2048 -0
  127. data/pgpool2/pcp.conf.sample +28 -0
  128. data/pgpool2/pcp/Makefile.am +40 -0
  129. data/pgpool2/pcp/Makefile.in +771 -0
  130. data/pgpool2/pcp/libpcp_ext.h +250 -0
  131. data/pgpool2/pcp/md5.c +444 -0
  132. data/pgpool2/pcp/md5.h +28 -0
  133. data/pgpool2/pcp/pcp.c +1652 -0
  134. data/pgpool2/pcp/pcp.h +61 -0
  135. data/pgpool2/pcp/pcp_attach_node.c +172 -0
  136. data/pgpool2/pcp/pcp_detach_node.c +185 -0
  137. data/pgpool2/pcp/pcp_error.c +87 -0
  138. data/pgpool2/pcp/pcp_node_count.c +160 -0
  139. data/pgpool2/pcp/pcp_node_info.c +198 -0
  140. data/pgpool2/pcp/pcp_pool_status.c +166 -0
  141. data/pgpool2/pcp/pcp_proc_count.c +166 -0
  142. data/pgpool2/pcp/pcp_proc_info.c +261 -0
  143. data/pgpool2/pcp/pcp_promote_node.c +185 -0
  144. data/pgpool2/pcp/pcp_recovery_node.c +172 -0
  145. data/pgpool2/pcp/pcp_stop_pgpool.c +179 -0
  146. data/pgpool2/pcp/pcp_stream.c +385 -0
  147. data/pgpool2/pcp/pcp_stream.h +52 -0
  148. data/pgpool2/pcp/pcp_systemdb_info.c +194 -0
  149. data/pgpool2/pcp/pcp_watchdog_info.c +211 -0
  150. data/pgpool2/pcp_child.c +1493 -0
  151. data/pgpool2/pg_md5.c +305 -0
  152. data/pgpool2/pgpool.8.in +121 -0
  153. data/pgpool2/pgpool.conf +553 -0
  154. data/pgpool2/pgpool.conf.sample +666 -0
  155. data/pgpool2/pgpool.conf.sample-master-slave +665 -0
  156. data/pgpool2/pgpool.conf.sample-replication +664 -0
  157. data/pgpool2/pgpool.conf.sample-stream +664 -0
  158. data/pgpool2/pgpool.spec +264 -0
  159. data/pgpool2/pgpool_adm/TODO +7 -0
  160. data/pgpool2/pgpool_adm/pgpool_adm--1.0.sql +85 -0
  161. data/pgpool2/pgpool_adm/pgpool_adm.c +558 -0
  162. data/pgpool2/pgpool_adm/pgpool_adm.control +5 -0
  163. data/pgpool2/pgpool_adm/pgpool_adm.h +46 -0
  164. data/pgpool2/pgpool_adm/pgpool_adm.sql.in +85 -0
  165. data/pgpool2/pool.h +655 -0
  166. data/pgpool2/pool_auth.c +1390 -0
  167. data/pgpool2/pool_config.c +5007 -0
  168. data/pgpool2/pool_config.h +284 -0
  169. data/pgpool2/pool_config.l +3281 -0
  170. data/pgpool2/pool_config_md5.c +29 -0
  171. data/pgpool2/pool_connection_pool.c +812 -0
  172. data/pgpool2/pool_error.c +242 -0
  173. data/pgpool2/pool_globals.c +27 -0
  174. data/pgpool2/pool_hba.c +1723 -0
  175. data/pgpool2/pool_hba.conf.sample +67 -0
  176. data/pgpool2/pool_ip.c +567 -0
  177. data/pgpool2/pool_ip.h +65 -0
  178. data/pgpool2/pool_ipc.h +38 -0
  179. data/pgpool2/pool_lobj.c +242 -0
  180. data/pgpool2/pool_lobj.h +32 -0
  181. data/pgpool2/pool_memqcache.c +3818 -0
  182. data/pgpool2/pool_memqcache.h +268 -0
  183. data/pgpool2/pool_params.c +163 -0
  184. data/pgpool2/pool_passwd.c +249 -0
  185. data/pgpool2/pool_passwd.h +41 -0
  186. data/pgpool2/pool_path.c +193 -0
  187. data/pgpool2/pool_path.h +81 -0
  188. data/pgpool2/pool_process_context.c +247 -0
  189. data/pgpool2/pool_process_context.h +62 -0
  190. data/pgpool2/pool_process_query.c +5001 -0
  191. data/pgpool2/pool_process_reporting.c +1671 -0
  192. data/pgpool2/pool_process_reporting.h +44 -0
  193. data/pgpool2/pool_proto2.c +671 -0
  194. data/pgpool2/pool_proto_modules.c +3524 -0
  195. data/pgpool2/pool_proto_modules.h +185 -0
  196. data/pgpool2/pool_query_cache.c +1020 -0
  197. data/pgpool2/pool_query_context.c +1871 -0
  198. data/pgpool2/pool_query_context.h +105 -0
  199. data/pgpool2/pool_relcache.c +284 -0
  200. data/pgpool2/pool_relcache.h +78 -0
  201. data/pgpool2/pool_rewrite_outfuncs.c +9060 -0
  202. data/pgpool2/pool_rewrite_query.c +715 -0
  203. data/pgpool2/pool_rewrite_query.h +192 -0
  204. data/pgpool2/pool_select_walker.c +1150 -0
  205. data/pgpool2/pool_select_walker.h +68 -0
  206. data/pgpool2/pool_sema.c +161 -0
  207. data/pgpool2/pool_session_context.c +952 -0
  208. data/pgpool2/pool_session_context.h +203 -0
  209. data/pgpool2/pool_shmem.c +185 -0
  210. data/pgpool2/pool_signal.c +158 -0
  211. data/pgpool2/pool_signal.h +61 -0
  212. data/pgpool2/pool_ssl.c +339 -0
  213. data/pgpool2/pool_stream.c +962 -0
  214. data/pgpool2/pool_stream.h +61 -0
  215. data/pgpool2/pool_system.c +659 -0
  216. data/pgpool2/pool_timestamp.c +1215 -0
  217. data/pgpool2/pool_timestamp.h +38 -0
  218. data/pgpool2/pool_type.h +171 -0
  219. data/pgpool2/pool_worker_child.c +384 -0
  220. data/pgpool2/ps_status.c +404 -0
  221. data/pgpool2/recovery.c +435 -0
  222. data/pgpool2/redhat/pgpool.conf.sample.patch +52 -0
  223. data/pgpool2/redhat/pgpool.init +201 -0
  224. data/pgpool2/redhat/pgpool.sysconfig +7 -0
  225. data/pgpool2/redhat/rpm_installer/basebackup-replication.sh +53 -0
  226. data/pgpool2/redhat/rpm_installer/basebackup-stream.sh +55 -0
  227. data/pgpool2/redhat/rpm_installer/config_for_script +17 -0
  228. data/pgpool2/redhat/rpm_installer/failover.sh +64 -0
  229. data/pgpool2/redhat/rpm_installer/getsources.sh +141 -0
  230. data/pgpool2/redhat/rpm_installer/install.sh +1363 -0
  231. data/pgpool2/redhat/rpm_installer/pgpool_recovery_pitr +47 -0
  232. data/pgpool2/redhat/rpm_installer/pgpool_remote_start +15 -0
  233. data/pgpool2/redhat/rpm_installer/recovery.conf +4 -0
  234. data/pgpool2/redhat/rpm_installer/uninstall.sh +57 -0
  235. data/pgpool2/sample/dist_def_pgbench.sql +73 -0
  236. data/pgpool2/sample/pgpool.pam +3 -0
  237. data/pgpool2/sample/pgpool_recovery +20 -0
  238. data/pgpool2/sample/pgpool_recovery_pitr +19 -0
  239. data/pgpool2/sample/pgpool_remote_start +13 -0
  240. data/pgpool2/sample/replicate_def_pgbench.sql +18 -0
  241. data/pgpool2/sql/insert_lock.sql +15 -0
  242. data/pgpool2/sql/pgpool-recovery/pgpool-recovery.c +280 -0
  243. data/pgpool2/sql/pgpool-recovery/pgpool-recovery.sql.in +19 -0
  244. data/pgpool2/sql/pgpool-recovery/pgpool_recovery--1.0.sql +24 -0
  245. data/pgpool2/sql/pgpool-recovery/pgpool_recovery.control +5 -0
  246. data/pgpool2/sql/pgpool-recovery/uninstall_pgpool-recovery.sql +3 -0
  247. data/pgpool2/sql/pgpool-regclass/pgpool-regclass.c +206 -0
  248. data/pgpool2/sql/pgpool-regclass/pgpool-regclass.sql.in +4 -0
  249. data/pgpool2/sql/pgpool-regclass/pgpool_regclass--1.0.sql +7 -0
  250. data/pgpool2/sql/pgpool-regclass/pgpool_regclass.control +5 -0
  251. data/pgpool2/sql/pgpool-regclass/uninstall_pgpool-regclass.sql +1 -0
  252. data/pgpool2/sql/system_db.sql +38 -0
  253. data/pgpool2/strlcpy.c +85 -0
  254. data/pgpool2/test/C/test_extended.c +98 -0
  255. data/pgpool2/test/jdbc/.cvsignore +2 -0
  256. data/pgpool2/test/jdbc/AutoCommitTest.java +45 -0
  257. data/pgpool2/test/jdbc/BatchTest.java +55 -0
  258. data/pgpool2/test/jdbc/ColumnTest.java +60 -0
  259. data/pgpool2/test/jdbc/CreateTempTableTest.java +48 -0
  260. data/pgpool2/test/jdbc/InsertTest.java +34 -0
  261. data/pgpool2/test/jdbc/LockTest.java +36 -0
  262. data/pgpool2/test/jdbc/PgpoolTest.java +75 -0
  263. data/pgpool2/test/jdbc/README.euc_jp +73 -0
  264. data/pgpool2/test/jdbc/RunTest.java +83 -0
  265. data/pgpool2/test/jdbc/SelectTest.java +37 -0
  266. data/pgpool2/test/jdbc/UpdateTest.java +32 -0
  267. data/pgpool2/test/jdbc/expected/CreateTempTable +1 -0
  268. data/pgpool2/test/jdbc/expected/autocommit +10 -0
  269. data/pgpool2/test/jdbc/expected/batch +1 -0
  270. data/pgpool2/test/jdbc/expected/column +100 -0
  271. data/pgpool2/test/jdbc/expected/insert +1 -0
  272. data/pgpool2/test/jdbc/expected/lock +100 -0
  273. data/pgpool2/test/jdbc/expected/select +2 -0
  274. data/pgpool2/test/jdbc/expected/update +1 -0
  275. data/pgpool2/test/jdbc/pgpool.properties +7 -0
  276. data/pgpool2/test/jdbc/prepare.sql +54 -0
  277. data/pgpool2/test/jdbc/run.sh +6 -0
  278. data/pgpool2/test/parser/.cvsignore +6 -0
  279. data/pgpool2/test/parser/README +32 -0
  280. data/pgpool2/test/parser/expected/copy.out +17 -0
  281. data/pgpool2/test/parser/expected/create.out +64 -0
  282. data/pgpool2/test/parser/expected/cursor.out +37 -0
  283. data/pgpool2/test/parser/expected/delete.out +10 -0
  284. data/pgpool2/test/parser/expected/drop.out +12 -0
  285. data/pgpool2/test/parser/expected/insert.out +13 -0
  286. data/pgpool2/test/parser/expected/misc.out +28 -0
  287. data/pgpool2/test/parser/expected/prepare.out +4 -0
  288. data/pgpool2/test/parser/expected/privileges.out +31 -0
  289. data/pgpool2/test/parser/expected/scanner.out +30 -0
  290. data/pgpool2/test/parser/expected/select.out +89 -0
  291. data/pgpool2/test/parser/expected/transaction.out +38 -0
  292. data/pgpool2/test/parser/expected/update.out +11 -0
  293. data/pgpool2/test/parser/expected/v84.out +37 -0
  294. data/pgpool2/test/parser/expected/v90.out +25 -0
  295. data/pgpool2/test/parser/expected/var.out +22 -0
  296. data/pgpool2/test/parser/input/alter.sql +2 -0
  297. data/pgpool2/test/parser/input/copy.sql +17 -0
  298. data/pgpool2/test/parser/input/create.sql +64 -0
  299. data/pgpool2/test/parser/input/cursor.sql +37 -0
  300. data/pgpool2/test/parser/input/delete.sql +10 -0
  301. data/pgpool2/test/parser/input/drop.sql +12 -0
  302. data/pgpool2/test/parser/input/insert.sql +13 -0
  303. data/pgpool2/test/parser/input/misc.sql +28 -0
  304. data/pgpool2/test/parser/input/prepare.sql +4 -0
  305. data/pgpool2/test/parser/input/privileges.sql +31 -0
  306. data/pgpool2/test/parser/input/scanner.sql +34 -0
  307. data/pgpool2/test/parser/input/select.sql +89 -0
  308. data/pgpool2/test/parser/input/transaction.sql +38 -0
  309. data/pgpool2/test/parser/input/update.sql +11 -0
  310. data/pgpool2/test/parser/input/v84.sql +37 -0
  311. data/pgpool2/test/parser/input/v90.sql +38 -0
  312. data/pgpool2/test/parser/input/var.sql +22 -0
  313. data/pgpool2/test/parser/main.c +96 -0
  314. data/pgpool2/test/parser/parse_schedule +16 -0
  315. data/pgpool2/test/parser/pool.h +13 -0
  316. data/pgpool2/test/parser/run-test +62 -0
  317. data/pgpool2/test/pdo-test/README.euc_jp +58 -0
  318. data/pgpool2/test/pdo-test/SQLlist/test1.sql +3 -0
  319. data/pgpool2/test/pdo-test/SQLlist/test2.sql +3 -0
  320. data/pgpool2/test/pdo-test/collections.inc +11 -0
  321. data/pgpool2/test/pdo-test/def.inc +7 -0
  322. data/pgpool2/test/pdo-test/log.txt +0 -0
  323. data/pgpool2/test/pdo-test/mod/database.inc +36 -0
  324. data/pgpool2/test/pdo-test/mod/def.inc +0 -0
  325. data/pgpool2/test/pdo-test/mod/errorhandler.inc +27 -0
  326. data/pgpool2/test/pdo-test/pdotest.php +11 -0
  327. data/pgpool2/test/pdo-test/regsql.inc +56 -0
  328. data/pgpool2/test/pgpool_setup +898 -0
  329. data/pgpool2/test/regression/README +39 -0
  330. data/pgpool2/test/regression/clean.sh +21 -0
  331. data/pgpool2/test/regression/libs.sh +16 -0
  332. data/pgpool2/test/regression/regress.sh +166 -0
  333. data/pgpool2/test/regression/tests/001.load_balance/test.sh +128 -0
  334. data/pgpool2/test/regression/tests/002.native_replication/PgTester.java +47 -0
  335. data/pgpool2/test/regression/tests/002.native_replication/create.sql +6 -0
  336. data/pgpool2/test/regression/tests/002.native_replication/test.sh +71 -0
  337. data/pgpool2/test/regression/tests/003.failover/expected.r +6 -0
  338. data/pgpool2/test/regression/tests/003.failover/expected.s +6 -0
  339. data/pgpool2/test/regression/tests/003.failover/test.sh +45 -0
  340. data/pgpool2/test/regression/tests/004.watchdog/master.conf +12 -0
  341. data/pgpool2/test/regression/tests/004.watchdog/standby.conf +19 -0
  342. data/pgpool2/test/regression/tests/004.watchdog/test.sh +52 -0
  343. data/pgpool2/test/regression/tests/050.bug58/test.sh +50 -0
  344. data/pgpool2/test/regression/tests/051.bug60/bug.sql +12 -0
  345. data/pgpool2/test/regression/tests/051.bug60/database-clean.sql +6 -0
  346. data/pgpool2/test/regression/tests/051.bug60/database-setup.sql +28 -0
  347. data/pgpool2/test/regression/tests/051.bug60/test.sh +79 -0
  348. data/pgpool2/test/regression/tests/052.do_query/test.sh +44 -0
  349. data/pgpool2/test/regression/tests/053.insert_lock_hangs/test.sh +81 -0
  350. data/pgpool2/test/regression/tests/054.postgres_fdw/test.sh +67 -0
  351. data/pgpool2/test/regression/tests/055.backend_all_down/test.sh +52 -0
  352. data/pgpool2/test/regression/tests/056.bug63/jdbctest2.java +66 -0
  353. data/pgpool2/test/regression/tests/056.bug63/test.sh +47 -0
  354. data/pgpool2/test/regression/tests/057.bug61/test.sh +40 -0
  355. data/pgpool2/test/regression/tests/058.bug68/jdbctest3.java +45 -0
  356. data/pgpool2/test/regression/tests/058.bug68/test.sh +47 -0
  357. data/pgpool2/test/timestamp/expected/insert.out +16 -0
  358. data/pgpool2/test/timestamp/expected/misc.out +3 -0
  359. data/pgpool2/test/timestamp/expected/update.out +6 -0
  360. data/pgpool2/test/timestamp/input/insert.sql +16 -0
  361. data/pgpool2/test/timestamp/input/misc.sql +3 -0
  362. data/pgpool2/test/timestamp/input/update.sql +6 -0
  363. data/pgpool2/test/timestamp/main.c +129 -0
  364. data/pgpool2/test/timestamp/parse_schedule +3 -0
  365. data/pgpool2/test/timestamp/run-test +69 -0
  366. data/pgpool2/version.h +1 -0
  367. data/pgpool2/watchdog/Makefile.am +17 -0
  368. data/pgpool2/watchdog/Makefile.in +505 -0
  369. data/pgpool2/watchdog/test/stab.c +266 -0
  370. data/pgpool2/watchdog/test/test.c +85 -0
  371. data/pgpool2/watchdog/test/wd_child_t.c +87 -0
  372. data/pgpool2/watchdog/test/wd_lifecheck_t.c +87 -0
  373. data/pgpool2/watchdog/test/wd_packet_t.c +87 -0
  374. data/pgpool2/watchdog/test/wd_ping_t.c +20 -0
  375. data/pgpool2/watchdog/watchdog.c +408 -0
  376. data/pgpool2/watchdog/watchdog.h +209 -0
  377. data/pgpool2/watchdog/wd_child.c +444 -0
  378. data/pgpool2/watchdog/wd_ext.h +123 -0
  379. data/pgpool2/watchdog/wd_heartbeat.c +577 -0
  380. data/pgpool2/watchdog/wd_if.c +216 -0
  381. data/pgpool2/watchdog/wd_init.c +126 -0
  382. data/pgpool2/watchdog/wd_interlock.c +347 -0
  383. data/pgpool2/watchdog/wd_lifecheck.c +512 -0
  384. data/pgpool2/watchdog/wd_list.c +429 -0
  385. data/pgpool2/watchdog/wd_packet.c +1159 -0
  386. data/pgpool2/watchdog/wd_ping.c +330 -0
  387. data/pgpool2/ylwrap +223 -0
  388. data/pgsql/presto_client.py +346 -0
  389. data/pgsql/prestogres.py +156 -0
  390. data/pgsql/setup_functions.sql +21 -0
  391. data/pgsql/setup_language.sql +3 -0
  392. data/prestogres.gemspec +23 -0
  393. metadata +496 -0
@@ -0,0 +1,147 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * pg_trigger.h
4
+ * definition of the system "trigger" relation (pg_trigger)
5
+ * along with the relation's initial contents.
6
+ *
7
+ *
8
+ * Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
9
+ * Portions Copyright (c) 1994, Regents of the University of California
10
+ *
11
+ * src/include/catalog/pg_trigger.h
12
+ *
13
+ * NOTES
14
+ * the genbki.pl script reads this file and generates .bki
15
+ * information from the DATA() statements.
16
+ *
17
+ *-------------------------------------------------------------------------
18
+ */
19
+ #ifndef PG_TRIGGER_H
20
+ #define PG_TRIGGER_H
21
+
22
+ #if 0
23
+ #include "catalog/genbki.h"
24
+
25
+ /* ----------------
26
+ * pg_trigger definition. cpp turns this into
27
+ * typedef struct FormData_pg_trigger
28
+ *
29
+ * Note: when tgconstraint is nonzero, tgconstrrelid, tgconstrindid,
30
+ * tgdeferrable, and tginitdeferred are largely redundant with the referenced
31
+ * pg_constraint entry. However, it is possible for a non-deferrable trigger
32
+ * to be associated with a deferrable constraint.
33
+ * ----------------
34
+ */
35
+ #define TriggerRelationId 2620
36
+
37
+ CATALOG(pg_trigger,2620)
38
+ {
39
+ Oid tgrelid; /* relation trigger is attached to */
40
+ NameData tgname; /* trigger's name */
41
+ Oid tgfoid; /* OID of function to be called */
42
+ int2 tgtype; /* BEFORE/AFTER/INSTEAD, UPDATE/DELETE/INSERT,
43
+ * ROW/STATEMENT; see below */
44
+ char tgenabled; /* trigger's firing configuration WRT
45
+ * session_replication_role */
46
+ bool tgisinternal; /* trigger is system-generated */
47
+ Oid tgconstrrelid; /* constraint's FROM table, if any */
48
+ Oid tgconstrindid; /* constraint's supporting index, if any */
49
+ Oid tgconstraint; /* associated pg_constraint entry, if any */
50
+ bool tgdeferrable; /* constraint trigger is deferrable */
51
+ bool tginitdeferred; /* constraint trigger is deferred initially */
52
+ int2 tgnargs; /* # of extra arguments in tgargs */
53
+
54
+ /*
55
+ * Variable-length fields start here, but we allow direct access to
56
+ * tgattr. Note: tgattr and tgargs must not be null.
57
+ */
58
+ int2vector tgattr; /* column numbers, if trigger is on columns */
59
+
60
+ #ifdef CATALOG_VARLEN
61
+ bytea tgargs; /* first\000second\000tgnargs\000 */
62
+ pg_node_tree tgqual; /* WHEN expression, or NULL if none */
63
+ #endif
64
+ } FormData_pg_trigger;
65
+
66
+ /* ----------------
67
+ * Form_pg_trigger corresponds to a pointer to a tuple with
68
+ * the format of pg_trigger relation.
69
+ * ----------------
70
+ */
71
+ typedef FormData_pg_trigger *Form_pg_trigger;
72
+ #endif
73
+
74
+ /* ----------------
75
+ * compiler constants for pg_trigger
76
+ * ----------------
77
+ */
78
+ #define Natts_pg_trigger 15
79
+ #define Anum_pg_trigger_tgrelid 1
80
+ #define Anum_pg_trigger_tgname 2
81
+ #define Anum_pg_trigger_tgfoid 3
82
+ #define Anum_pg_trigger_tgtype 4
83
+ #define Anum_pg_trigger_tgenabled 5
84
+ #define Anum_pg_trigger_tgisinternal 6
85
+ #define Anum_pg_trigger_tgconstrrelid 7
86
+ #define Anum_pg_trigger_tgconstrindid 8
87
+ #define Anum_pg_trigger_tgconstraint 9
88
+ #define Anum_pg_trigger_tgdeferrable 10
89
+ #define Anum_pg_trigger_tginitdeferred 11
90
+ #define Anum_pg_trigger_tgnargs 12
91
+ #define Anum_pg_trigger_tgattr 13
92
+ #define Anum_pg_trigger_tgargs 14
93
+ #define Anum_pg_trigger_tgqual 15
94
+
95
+ /* Bits within tgtype */
96
+ #define TRIGGER_TYPE_ROW (1 << 0)
97
+ #define TRIGGER_TYPE_BEFORE (1 << 1)
98
+ #define TRIGGER_TYPE_INSERT (1 << 2)
99
+ #define TRIGGER_TYPE_DELETE (1 << 3)
100
+ #define TRIGGER_TYPE_UPDATE (1 << 4)
101
+ #define TRIGGER_TYPE_TRUNCATE (1 << 5)
102
+ #define TRIGGER_TYPE_INSTEAD (1 << 6)
103
+
104
+ #define TRIGGER_TYPE_LEVEL_MASK (TRIGGER_TYPE_ROW)
105
+ #define TRIGGER_TYPE_STATEMENT 0
106
+
107
+ /* Note bits within TRIGGER_TYPE_TIMING_MASK aren't adjacent */
108
+ #define TRIGGER_TYPE_TIMING_MASK \
109
+ (TRIGGER_TYPE_BEFORE | TRIGGER_TYPE_INSTEAD)
110
+ #define TRIGGER_TYPE_AFTER 0
111
+
112
+ #define TRIGGER_TYPE_EVENT_MASK \
113
+ (TRIGGER_TYPE_INSERT | TRIGGER_TYPE_DELETE | TRIGGER_TYPE_UPDATE | TRIGGER_TYPE_TRUNCATE)
114
+
115
+ /* Macros for manipulating tgtype */
116
+ #define TRIGGER_CLEAR_TYPE(type) ((type) = 0)
117
+
118
+ #define TRIGGER_SETT_ROW(type) ((type) |= TRIGGER_TYPE_ROW)
119
+ #define TRIGGER_SETT_STATEMENT(type) ((type) |= TRIGGER_TYPE_STATEMENT)
120
+ #define TRIGGER_SETT_BEFORE(type) ((type) |= TRIGGER_TYPE_BEFORE)
121
+ #define TRIGGER_SETT_AFTER(type) ((type) |= TRIGGER_TYPE_AFTER)
122
+ #define TRIGGER_SETT_INSTEAD(type) ((type) |= TRIGGER_TYPE_INSTEAD)
123
+ #define TRIGGER_SETT_INSERT(type) ((type) |= TRIGGER_TYPE_INSERT)
124
+ #define TRIGGER_SETT_DELETE(type) ((type) |= TRIGGER_TYPE_DELETE)
125
+ #define TRIGGER_SETT_UPDATE(type) ((type) |= TRIGGER_TYPE_UPDATE)
126
+ #define TRIGGER_SETT_TRUNCATE(type) ((type) |= TRIGGER_TYPE_TRUNCATE)
127
+
128
+ #define TRIGGER_FOR_ROW(type) ((type) & TRIGGER_TYPE_ROW)
129
+ #define TRIGGER_FOR_BEFORE(type) (((type) & TRIGGER_TYPE_TIMING_MASK) == TRIGGER_TYPE_BEFORE)
130
+ #define TRIGGER_FOR_AFTER(type) (((type) & TRIGGER_TYPE_TIMING_MASK) == TRIGGER_TYPE_AFTER)
131
+ #define TRIGGER_FOR_INSTEAD(type) (((type) & TRIGGER_TYPE_TIMING_MASK) == TRIGGER_TYPE_INSTEAD)
132
+ #define TRIGGER_FOR_INSERT(type) ((type) & TRIGGER_TYPE_INSERT)
133
+ #define TRIGGER_FOR_DELETE(type) ((type) & TRIGGER_TYPE_DELETE)
134
+ #define TRIGGER_FOR_UPDATE(type) ((type) & TRIGGER_TYPE_UPDATE)
135
+ #define TRIGGER_FOR_TRUNCATE(type) ((type) & TRIGGER_TYPE_TRUNCATE)
136
+
137
+ /*
138
+ * Efficient macro for checking if tgtype matches a particular level
139
+ * (TRIGGER_TYPE_ROW or TRIGGER_TYPE_STATEMENT), timing (TRIGGER_TYPE_BEFORE,
140
+ * TRIGGER_TYPE_AFTER or TRIGGER_TYPE_INSTEAD), and event (TRIGGER_TYPE_INSERT,
141
+ * TRIGGER_TYPE_DELETE, TRIGGER_TYPE_UPDATE, or TRIGGER_TYPE_TRUNCATE). Note
142
+ * that a tgtype can match more than one event, but only one level or timing.
143
+ */
144
+ #define TRIGGER_TYPE_MATCHES(type, level, timing, event) \
145
+ (((type) & (TRIGGER_TYPE_LEVEL_MASK | TRIGGER_TYPE_TIMING_MASK | (event))) == ((level) | (timing) | (event)))
146
+
147
+ #endif /* PG_TRIGGER_H */
@@ -0,0 +1,492 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * pg_wchar.h
4
+ * multibyte-character support
5
+ *
6
+ * Portions Copyright (c) 2003-2013, PgPool Global Development Group
7
+ * Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
8
+ * Portions Copyright (c) 1994, Regents of the University of California
9
+ *
10
+ * src/include/mb/pg_wchar.h
11
+ *
12
+ * NOTES
13
+ * This is used both by the backend and by libpq, but should not be
14
+ * included by libpq client programs. In particular, a libpq client
15
+ * should not assume that the encoding IDs used by the version of libpq
16
+ * it's linked to match up with the IDs declared here.
17
+ *
18
+ *-------------------------------------------------------------------------
19
+ */
20
+ #ifndef PG_WCHAR_H
21
+ #define PG_WCHAR_H
22
+
23
+ /*
24
+ * The pg_wchar type
25
+ */
26
+ typedef unsigned int pg_wchar;
27
+
28
+ /*
29
+ * various definitions for EUC
30
+ */
31
+ #define SS2 0x8e /* single shift 2 (JIS0201) */
32
+ #define SS3 0x8f /* single shift 3 (JIS0212) */
33
+
34
+ /*
35
+ * SJIS validation macros
36
+ */
37
+ #define ISSJISHEAD(c) (((c) >= 0x81 && (c) <= 0x9f) || ((c) >= 0xe0 && (c) <= 0xfc))
38
+ #define ISSJISTAIL(c) (((c) >= 0x40 && (c) <= 0x7e) || ((c) >= 0x80 && (c) <= 0xfc))
39
+
40
+ /*
41
+ * Leading byte types or leading prefix byte for MULE internal code.
42
+ * See http://www.xemacs.org for more details. (there is a doc titled
43
+ * "XEmacs Internals Manual", "MULE Character Sets and Encodings"
44
+ * section.)
45
+ */
46
+ /*
47
+ * Is a leading byte for "official" single byte encodings?
48
+ */
49
+ #define IS_LC1(c) ((unsigned char)(c) >= 0x81 && (unsigned char)(c) <= 0x8d)
50
+ /*
51
+ * Is a prefix byte for "private" single byte encodings?
52
+ */
53
+ #define LCPRV1_A 0x9a
54
+ #define LCPRV1_B 0x9b
55
+ #define IS_LCPRV1(c) ((unsigned char)(c) == LCPRV1_A || (unsigned char)(c) == LCPRV1_B)
56
+ #define IS_LCPRV1_A_RANGE(c) \
57
+ ((unsigned char)(c) >= 0xa0 && (unsigned char)(c) <= 0xdf)
58
+ #define IS_LCPRV1_B_RANGE(c) \
59
+ ((unsigned char)(c) >= 0xe0 && (unsigned char)(c) <= 0xef)
60
+ /*
61
+ * Is a leading byte for "official" multibyte encodings?
62
+ */
63
+ #define IS_LC2(c) ((unsigned char)(c) >= 0x90 && (unsigned char)(c) <= 0x99)
64
+ /*
65
+ * Is a prefix byte for "private" multibyte encodings?
66
+ */
67
+ #define LCPRV2_A 0x9c
68
+ #define LCPRV2_B 0x9d
69
+ #define IS_LCPRV2(c) ((unsigned char)(c) == LCPRV2_A || (unsigned char)(c) == LCPRV2_B)
70
+ #define IS_LCPRV2_A_RANGE(c) \
71
+ ((unsigned char)(c) >= 0xf0 && (unsigned char)(c) <= 0xf4)
72
+ #define IS_LCPRV2_B_RANGE(c) \
73
+ ((unsigned char)(c) >= 0xf5 && (unsigned char)(c) <= 0xfe)
74
+
75
+ /*----------------------------------------------------
76
+ * leading characters
77
+ *----------------------------------------------------
78
+ */
79
+
80
+ /*
81
+ * Official single byte encodings (0x81-0x8e)
82
+ */
83
+ #define LC_ISO8859_1 0x81 /* ISO8859 Latin 1 */
84
+ #define LC_ISO8859_2 0x82 /* ISO8859 Latin 2 */
85
+ #define LC_ISO8859_3 0x83 /* ISO8859 Latin 3 */
86
+ #define LC_ISO8859_4 0x84 /* ISO8859 Latin 4 */
87
+ #define LC_TIS620 0x85 /* Thai (not supported yet) */
88
+ #define LC_ISO8859_7 0x86 /* Greek (not supported yet) */
89
+ #define LC_ISO8859_6 0x87 /* Arabic (not supported yet) */
90
+ #define LC_ISO8859_8 0x88 /* Hebrew (not supported yet) */
91
+ #define LC_JISX0201K 0x89 /* Japanese 1 byte kana */
92
+ #define LC_JISX0201R 0x8a /* Japanese 1 byte Roman */
93
+ /* Note that 0x8b seems to be unused as of Emacs 20.7.
94
+ * However, there might be a chance that 0x8b could be used
95
+ * in later version of Emacs.
96
+ */
97
+ #define LC_KOI8_R 0x8b /* Cyrillic KOI8-R */
98
+ #define LC_KOI8_U 0x8b /* Cyrillic KOI8-U */
99
+ #define LC_ISO8859_5 0x8c /* ISO8859 Cyrillic */
100
+ #define LC_ISO8859_9 0x8d /* ISO8859 Latin 5 (not supported yet) */
101
+ /* #define FREE 0x8e free (unused) */
102
+
103
+ /*
104
+ * Unused
105
+ */
106
+ #define CONTROL_1 0x8f /* control characters (unused) */
107
+
108
+ /*
109
+ * Official multibyte byte encodings (0x90-0x99)
110
+ * 0x9a-0x9d are free. 0x9e and 0x9f are reserved.
111
+ */
112
+ #define LC_JISX0208_1978 0x90 /* Japanese Kanji, old JIS (not supported) */
113
+ /* #define FREE 0x90 free (unused) */
114
+ #define LC_GB2312_80 0x91 /* Chinese */
115
+ #define LC_JISX0208 0x92 /* Japanese Kanji (JIS X 0208) */
116
+ #define LC_KS5601 0x93 /* Korean */
117
+ #define LC_JISX0212 0x94 /* Japanese Kanji (JIS X 0212) */
118
+ #define LC_CNS11643_1 0x95 /* CNS 11643-1992 Plane 1 */
119
+ #define LC_CNS11643_2 0x96 /* CNS 11643-1992 Plane 2 */
120
+ /* #define FREE 0x97 free (unused) */
121
+ #define LC_BIG5_1 0x98 /* Plane 1 Chinese traditional (not supported) */
122
+ #define LC_BIG5_2 0x99 /* Plane 1 Chinese traditional (not supported) */
123
+
124
+ /*
125
+ * Private single byte encodings (0xa0-0xef)
126
+ */
127
+ #define LC_SISHENG 0xa0/* Chinese SiSheng characters for
128
+ * PinYin/ZhuYin (not supported) */
129
+ #define LC_IPA 0xa1/* IPA (International Phonetic Association)
130
+ * (not supported) */
131
+ #define LC_VISCII_LOWER 0xa2/* Vietnamese VISCII1.1 lower-case (not
132
+ * supported) */
133
+ #define LC_VISCII_UPPER 0xa3/* Vietnamese VISCII1.1 upper-case (not
134
+ * supported) */
135
+ #define LC_ARABIC_DIGIT 0xa4 /* Arabic digit (not supported) */
136
+ #define LC_ARABIC_1_COLUMN 0xa5 /* Arabic 1-column (not supported) */
137
+ #define LC_ASCII_RIGHT_TO_LEFT 0xa6 /* ASCII (left half of ISO8859-1) with
138
+ * right-to-left direction (not
139
+ * supported) */
140
+ #define LC_LAO 0xa7/* Lao characters (ISO10646 0E80..0EDF) (not
141
+ * supported) */
142
+ #define LC_ARABIC_2_COLUMN 0xa8 /* Arabic 1-column (not supported) */
143
+
144
+ /*
145
+ * Private multibyte encodings (0xf0-0xff)
146
+ */
147
+ #define LC_INDIAN_1_COLUMN 0xf0/* Indian charset for 1-column width glypps
148
+ * (not supported) */
149
+ #define LC_TIBETAN_1_COLUMN 0xf1 /* Tibetan 1 column glyph (not supported) */
150
+ #define LC_ETHIOPIC 0xf5 /* Ethiopic characters (not supported) */
151
+ #define LC_CNS11643_3 0xf6 /* CNS 11643-1992 Plane 3 */
152
+ #define LC_CNS11643_4 0xf7 /* CNS 11643-1992 Plane 4 */
153
+ #define LC_CNS11643_5 0xf8 /* CNS 11643-1992 Plane 5 */
154
+ #define LC_CNS11643_6 0xf9 /* CNS 11643-1992 Plane 6 */
155
+ #define LC_CNS11643_7 0xfa /* CNS 11643-1992 Plane 7 */
156
+ #define LC_INDIAN_2_COLUMN 0xfb/* Indian charset for 2-column width glypps
157
+ * (not supported) */
158
+ #define LC_TIBETAN 0xfc /* Tibetan (not supported) */
159
+ /* #define FREE 0xfd free (unused) */
160
+ /* #define FREE 0xfe free (unused) */
161
+ /* #define FREE 0xff free (unused) */
162
+
163
+ /*
164
+ * PostgreSQL encoding identifiers
165
+ *
166
+ * WARNING: the order of this enum must be same as order of entries
167
+ * in the pg_enc2name_tbl[] array (in mb/encnames.c), and
168
+ * in the pg_wchar_table[] array (in mb/wchar.c)!
169
+ *
170
+ * If you add some encoding don't forget to check
171
+ * PG_ENCODING_BE_LAST macro.
172
+ *
173
+ * PG_SQL_ASCII is default encoding and must be = 0.
174
+ *
175
+ * XXX We must avoid renumbering any backend encoding until libpq's major
176
+ * version number is increased beyond 5; it turns out that the backend
177
+ * encoding IDs are effectively part of libpq's ABI as far as 8.2 initdb and
178
+ * psql are concerned.
179
+ */
180
+ typedef enum pg_enc
181
+ {
182
+ PG_SQL_ASCII = 0, /* SQL/ASCII */
183
+ PG_EUC_JP, /* EUC for Japanese */
184
+ PG_EUC_CN, /* EUC for Chinese */
185
+ PG_EUC_KR, /* EUC for Korean */
186
+ PG_EUC_TW, /* EUC for Taiwan */
187
+ PG_EUC_JIS_2004, /* EUC-JIS-2004 */
188
+ PG_UTF8, /* Unicode UTF8 */
189
+ PG_MULE_INTERNAL, /* Mule internal code */
190
+ PG_LATIN1, /* ISO-8859-1 Latin 1 */
191
+ PG_LATIN2, /* ISO-8859-2 Latin 2 */
192
+ PG_LATIN3, /* ISO-8859-3 Latin 3 */
193
+ PG_LATIN4, /* ISO-8859-4 Latin 4 */
194
+ PG_LATIN5, /* ISO-8859-9 Latin 5 */
195
+ PG_LATIN6, /* ISO-8859-10 Latin6 */
196
+ PG_LATIN7, /* ISO-8859-13 Latin7 */
197
+ PG_LATIN8, /* ISO-8859-14 Latin8 */
198
+ PG_LATIN9, /* ISO-8859-15 Latin9 */
199
+ PG_LATIN10, /* ISO-8859-16 Latin10 */
200
+ PG_WIN1256, /* windows-1256 */
201
+ PG_WIN1258, /* Windows-1258 */
202
+ PG_WIN866, /* (MS-DOS CP866) */
203
+ PG_WIN874, /* windows-874 */
204
+ PG_KOI8R, /* KOI8-R */
205
+ PG_WIN1251, /* windows-1251 */
206
+ PG_WIN1252, /* windows-1252 */
207
+ PG_ISO_8859_5, /* ISO-8859-5 */
208
+ PG_ISO_8859_6, /* ISO-8859-6 */
209
+ PG_ISO_8859_7, /* ISO-8859-7 */
210
+ PG_ISO_8859_8, /* ISO-8859-8 */
211
+ PG_WIN1250, /* windows-1250 */
212
+ PG_WIN1253, /* windows-1253 */
213
+ PG_WIN1254, /* windows-1254 */
214
+ PG_WIN1255, /* windows-1255 */
215
+ PG_WIN1257, /* windows-1257 */
216
+ PG_KOI8U, /* KOI8-U */
217
+ /* PG_ENCODING_BE_LAST points to the above entry */
218
+
219
+ /* followings are for client encoding only */
220
+ PG_SJIS, /* Shift JIS (Winindows-932) */
221
+ PG_BIG5, /* Big5 (Windows-950) */
222
+ PG_GBK, /* GBK (Windows-936) */
223
+ PG_UHC, /* UHC (Windows-949) */
224
+ PG_GB18030, /* GB18030 */
225
+ PG_JOHAB, /* EUC for Korean JOHAB */
226
+ PG_SHIFT_JIS_2004, /* Shift-JIS-2004 */
227
+ _PG_LAST_ENCODING_ /* mark only */
228
+
229
+ } pg_enc;
230
+
231
+ #define PG_ENCODING_BE_LAST PG_KOI8U
232
+
233
+ /*
234
+ * Please use these tests before access to pg_encconv_tbl[]
235
+ * or to other places...
236
+ */
237
+ #define PG_VALID_BE_ENCODING(_enc) \
238
+ ((_enc) >= 0 && (_enc) <= PG_ENCODING_BE_LAST)
239
+
240
+ #define PG_ENCODING_IS_CLIENT_ONLY(_enc) \
241
+ ((_enc) > PG_ENCODING_BE_LAST && (_enc) < _PG_LAST_ENCODING_)
242
+
243
+ #define PG_VALID_ENCODING(_enc) \
244
+ ((_enc) >= 0 && (_enc) < _PG_LAST_ENCODING_)
245
+
246
+ /* On FE are possible all encodings */
247
+ #define PG_VALID_FE_ENCODING(_enc) PG_VALID_ENCODING(_enc)
248
+
249
+ /*
250
+ * Encoding names with all aliases
251
+ */
252
+ typedef struct pg_encname
253
+ {
254
+ char *name;
255
+ pg_enc encoding;
256
+ } pg_encname;
257
+
258
+ extern pg_encname pg_encname_tbl[];
259
+ extern unsigned int pg_encname_tbl_sz;
260
+
261
+ /*
262
+ * Careful:
263
+ *
264
+ * if (PG_VALID_ENCODING(encoding))
265
+ * pg_enc2name_tbl[ encoding ];
266
+ */
267
+ typedef struct pg_enc2name
268
+ {
269
+ char *name;
270
+ pg_enc encoding;
271
+ #ifdef WIN32
272
+ unsigned codepage; /* codepage for WIN32 */
273
+ #endif
274
+ } pg_enc2name;
275
+
276
+ extern pg_enc2name pg_enc2name_tbl[];
277
+
278
+ /*
279
+ * Encoding names for gettext
280
+ */
281
+ typedef struct pg_enc2gettext
282
+ {
283
+ pg_enc encoding;
284
+ const char *name;
285
+ } pg_enc2gettext;
286
+
287
+ extern pg_enc2gettext pg_enc2gettext_tbl[];
288
+
289
+ /*
290
+ * pg_wchar stuff
291
+ */
292
+ typedef int (*mb2wchar_with_len_converter) (const unsigned char *from,
293
+ pg_wchar *to,
294
+ int len);
295
+
296
+ typedef int (*wchar2mb_with_len_converter) (const pg_wchar *from,
297
+ unsigned char *to,
298
+ int len);
299
+
300
+ typedef int (*mblen_converter) (const unsigned char *mbstr);
301
+
302
+ typedef int (*mbdisplaylen_converter) (const unsigned char *mbstr);
303
+
304
+ typedef bool (*mbcharacter_incrementer) (unsigned char *mbstr, int len);
305
+
306
+ typedef int (*mbverifier) (const unsigned char *mbstr, int len);
307
+
308
+ typedef struct
309
+ {
310
+ mb2wchar_with_len_converter mb2wchar_with_len; /* convert a multibyte
311
+ * string to a wchar */
312
+ wchar2mb_with_len_converter wchar2mb_with_len; /* convert a wchar
313
+ * string to a multibyte */
314
+ mblen_converter mblen; /* get byte length of a char */
315
+ mbdisplaylen_converter dsplen; /* get display width of a char */
316
+ mbverifier mbverify; /* verify multibyte sequence */
317
+ int maxmblen; /* max bytes for a char in this encoding */
318
+ } pg_wchar_tbl;
319
+
320
+ extern pg_wchar_tbl pg_wchar_table[];
321
+
322
+ /*
323
+ * UTF-8 to local code conversion map
324
+ * Note that we limit the max length of UTF-8 to 4 bytes,
325
+ * which is UCS-4 00010000-001FFFFF range.
326
+ */
327
+ typedef struct
328
+ {
329
+ uint32 utf; /* UTF-8 */
330
+ uint32 code; /* local code */
331
+ } pg_utf_to_local;
332
+
333
+ /*
334
+ * local code to UTF-8 conversion map
335
+ */
336
+ typedef struct
337
+ {
338
+ uint32 code; /* local code */
339
+ uint32 utf; /* UTF-8 */
340
+ } pg_local_to_utf;
341
+
342
+ /*
343
+ * UTF-8 to local code conversion map(combined characters)
344
+ */
345
+ typedef struct
346
+ {
347
+ uint32 utf1; /* UTF-8 code 1 */
348
+ uint32 utf2; /* UTF-8 code 2 */
349
+ uint32 code; /* local code */
350
+ } pg_utf_to_local_combined;
351
+
352
+ /*
353
+ * local code to UTF-8 conversion map(combined characters)
354
+ */
355
+ typedef struct
356
+ {
357
+ uint32 code; /* local code */
358
+ uint32 utf1; /* UTF-8 code 1 */
359
+ uint32 utf2; /* UTF-8 code 2 */
360
+ } pg_local_to_utf_combined;
361
+
362
+ /*
363
+ * Support macro for encoding conversion functions to validate their
364
+ * arguments. (This could be made more compact if we included fmgr.h
365
+ * here, but we don't want to do that because this header file is also
366
+ * used by frontends.)
367
+ */
368
+ #define CHECK_ENCODING_CONVERSION_ARGS(srcencoding,destencoding) \
369
+ check_encoding_conversion_args(PG_GETARG_INT32(0), \
370
+ PG_GETARG_INT32(1), \
371
+ PG_GETARG_INT32(4), \
372
+ (srcencoding), \
373
+ (destencoding))
374
+
375
+
376
+ /*
377
+ * These functions are considered part of libpq's exported API and
378
+ * are also declared in libpq-fe.h.
379
+ */
380
+ extern int pg_char_to_encoding(const char *name);
381
+ extern const char *pg_encoding_to_char(int encoding);
382
+ extern int pg_valid_server_encoding_id(int encoding);
383
+
384
+ /*
385
+ * Remaining functions are not considered part of libpq's API, though many
386
+ * of them do exist inside libpq.
387
+ */
388
+ extern pg_encname *pg_char_to_encname_struct(const char *name);
389
+
390
+ extern int pg_mb2wchar(const char *from, pg_wchar *to);
391
+ extern int pg_mb2wchar_with_len(const char *from, pg_wchar *to, int len);
392
+ extern int pg_encoding_mb2wchar_with_len(int encoding,
393
+ const char *from, pg_wchar *to, int len);
394
+ extern int pg_wchar2mb(const pg_wchar *from, char *to);
395
+ extern int pg_wchar2mb_with_len(const pg_wchar *from, char *to, int len);
396
+ extern int pg_encoding_wchar2mb_with_len(int encoding,
397
+ const pg_wchar *from, char *to, int len);
398
+ extern int pg_char_and_wchar_strcmp(const char *s1, const pg_wchar *s2);
399
+ extern int pg_wchar_strncmp(const pg_wchar *s1, const pg_wchar *s2, size_t n);
400
+ extern int pg_char_and_wchar_strncmp(const char *s1, const pg_wchar *s2, size_t n);
401
+ extern size_t pg_wchar_strlen(const pg_wchar *wstr);
402
+ extern int pg_mblen(const char *mbstr);
403
+ extern int pg_dsplen(const char *mbstr);
404
+ extern int pg_encoding_mblen(int encoding, const char *mbstr);
405
+ extern int pg_encoding_dsplen(int encoding, const char *mbstr);
406
+ extern int pg_encoding_verifymb(int encoding, const char *mbstr, int len);
407
+ extern int pg_mule_mblen(const unsigned char *mbstr);
408
+ extern int pg_mic_mblen(const unsigned char *mbstr);
409
+ extern int pg_mbstrlen(const char *mbstr);
410
+ extern int pg_mbstrlen_with_len(const char *mbstr, int len);
411
+ extern int pg_mbcliplen(const char *mbstr, int len, int limit);
412
+ extern int pg_encoding_mbcliplen(int encoding, const char *mbstr,
413
+ int len, int limit);
414
+ extern int pg_mbcharcliplen(const char *mbstr, int len, int imit);
415
+ extern int pg_encoding_max_length(int encoding);
416
+ extern int pg_database_encoding_max_length(void);
417
+ extern mbcharacter_incrementer pg_database_encoding_character_incrementer(void);
418
+
419
+ extern int PrepareClientEncoding(int encoding);
420
+ extern int SetClientEncoding(int encoding);
421
+ extern void InitializeClientEncoding(void);
422
+ extern int pg_get_client_encoding(void);
423
+ extern const char *pg_get_client_encoding_name(void);
424
+
425
+ extern void SetDatabaseEncoding(int encoding);
426
+ extern int GetDatabaseEncoding(void);
427
+ extern const char *GetDatabaseEncodingName(void);
428
+ extern int GetPlatformEncoding(void);
429
+ extern void pg_bind_textdomain_codeset(const char *domainname);
430
+
431
+ extern int pg_valid_client_encoding(const char *name);
432
+ extern int pg_valid_server_encoding(const char *name);
433
+
434
+ extern unsigned char *unicode_to_utf8(pg_wchar c, unsigned char *utf8string);
435
+ extern pg_wchar utf8_to_unicode(const unsigned char *c);
436
+ extern int pg_utf_mblen(const unsigned char *);
437
+ extern unsigned char *pg_do_encoding_conversion(unsigned char *src, int len,
438
+ int src_encoding,
439
+ int dest_encoding);
440
+
441
+ extern char *pg_client_to_server(const char *s, int len);
442
+ extern char *pg_server_to_client(const char *s, int len);
443
+ extern char *pg_any_to_server(const char *s, int len, int encoding);
444
+ extern char *pg_server_to_any(const char *s, int len, int encoding);
445
+
446
+ extern unsigned short BIG5toCNS(unsigned short big5, unsigned char *lc);
447
+ extern unsigned short CNStoBIG5(unsigned short cns, unsigned char lc);
448
+
449
+ extern void LocalToUtf(const unsigned char *iso, unsigned char *utf,
450
+ const pg_local_to_utf *map, const pg_local_to_utf_combined *cmap,
451
+ int size1, int size2, int encoding, int len);
452
+
453
+ extern void UtfToLocal(const unsigned char *utf, unsigned char *iso,
454
+ const pg_utf_to_local *map, const pg_utf_to_local_combined *cmap,
455
+ int size1, int size2, int encoding, int len);
456
+
457
+ extern bool pg_verifymbstr(const char *mbstr, int len, bool noError);
458
+ extern bool pg_verify_mbstr(int encoding, const char *mbstr, int len,
459
+ bool noError);
460
+ extern int pg_verify_mbstr_len(int encoding, const char *mbstr, int len,
461
+ bool noError);
462
+
463
+ extern void check_encoding_conversion_args(int src_encoding,
464
+ int dest_encoding,
465
+ int len,
466
+ int expected_src_encoding,
467
+ int expected_dest_encoding);
468
+
469
+ extern void report_invalid_encoding(int encoding, const char *mbstr, int len);
470
+ extern void report_untranslatable_char(int src_encoding, int dest_encoding,
471
+ const char *mbstr, int len);
472
+
473
+ extern void pg_ascii2mic(const unsigned char *l, unsigned char *p, int len);
474
+ extern void pg_mic2ascii(const unsigned char *mic, unsigned char *p, int len);
475
+ extern void latin2mic(const unsigned char *l, unsigned char *p, int len,
476
+ int lc, int encoding);
477
+ extern void mic2latin(const unsigned char *mic, unsigned char *p, int len,
478
+ int lc, int encoding);
479
+ extern void latin2mic_with_table(const unsigned char *l, unsigned char *p,
480
+ int len, int lc, int encoding,
481
+ const unsigned char *tab);
482
+ extern void mic2latin_with_table(const unsigned char *mic, unsigned char *p,
483
+ int len, int lc, int encoding,
484
+ const unsigned char *tab);
485
+
486
+ extern bool pg_utf8_islegal(const unsigned char *source, int length);
487
+
488
+ #ifdef WIN32
489
+ extern WCHAR *pgwin32_toUTF16(const char *str, int len, int *utf16len);
490
+ #endif
491
+
492
+ #endif /* PG_WCHAR_H */