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,121 @@
1
+ /* -*-pgsql-c-*- */
2
+ /*
3
+ * $Header$
4
+ *
5
+ * Copyright (c) 2006-2008, pgpool Global Development Group
6
+ *
7
+ * Permission to use, copy, modify, and distribute this software and
8
+ * its documentation for any purpose and without fee is hereby
9
+ * granted, provided that the above copyright notice appear in all
10
+ * copies and that both that copyright notice and this permission
11
+ * notice appear in supporting documentation, and that the name of the
12
+ * author not be used in advertising or publicity pertaining to
13
+ * distribution of the software without specific, written prior
14
+ * permission. The author makes no representations about the
15
+ * suitability of this software for any purpose. It is provided "as
16
+ * is" without express or implied warranty.
17
+ */
18
+ #include "pool.h"
19
+ #include "pool_parser.h"
20
+
21
+ #include <errno.h>
22
+ #include <string.h>
23
+ #include <stdlib.h>
24
+
25
+ #include "pool_memory.h"
26
+ #include "pool_string.h"
27
+ #include "value.h"
28
+
29
+ /* String Library */
30
+ String *init_string(char *str)
31
+ {
32
+ String *string = palloc(sizeof(String));
33
+ int size;
34
+
35
+ if (string == NULL)
36
+ {
37
+ pool_error("init_string: palloc failed: %s", strerror(errno));
38
+ child_exit(1);
39
+ }
40
+
41
+ size = (strlen(str) + 1) / STRING_SIZE + 1;
42
+ string->size = size;
43
+ string->data = palloc(STRING_SIZE * size);
44
+ if (string->data == NULL)
45
+ {
46
+ pool_error("init_string: palloc failed: %s", strerror(errno));
47
+ pfree(string);
48
+ child_exit(1);
49
+ }
50
+
51
+ memset(string->data, 0, STRING_SIZE * size);
52
+
53
+ if (str == NULL)
54
+ {
55
+ string->len = 0;
56
+ }
57
+ else
58
+ {
59
+ string->len = strlen(str);
60
+ memcpy(string->data, str, string->len);
61
+ }
62
+
63
+ return string;
64
+ }
65
+
66
+ void string_append_string(String *string, String *data)
67
+ {
68
+ string_append_char(string, data->data);
69
+ }
70
+
71
+ void string_append_char(String *string, char *append_data)
72
+ {
73
+ int len = strlen(append_data);
74
+
75
+ if (string->len + len + 1 > string->size * STRING_SIZE)
76
+ {
77
+ int size, old_size;
78
+ size = (string->len + len + 1) / STRING_SIZE + 1;
79
+ old_size = string->size;
80
+ string->size = size;
81
+ string->data = repalloc(string->data, string->size * STRING_SIZE);
82
+ if (string->data == NULL)
83
+ {
84
+ pool_error("string_append_char: realloc failed: %s", strerror(errno));
85
+ child_exit(1);
86
+ }
87
+ memset(string->data + (old_size * STRING_SIZE),
88
+ 0, STRING_SIZE * (string->size - old_size));
89
+ }
90
+ memcpy(string->data + string->len, append_data, len);
91
+ string->len += len;
92
+ }
93
+
94
+ void free_string(String *string)
95
+ {
96
+ pfree(string->data);
97
+ pfree(string);
98
+ }
99
+
100
+ String *copy_string(String *string)
101
+ {
102
+ String *copy = palloc(sizeof(String));
103
+
104
+ if (copy == NULL)
105
+ {
106
+ pool_error("copy_string: palloc failed: %s", strerror(errno));
107
+ child_exit(1);
108
+ }
109
+ copy->size = string->size;
110
+ copy->len = string->len;
111
+ copy->data = palloc(string->size * STRING_SIZE);
112
+ if (copy->data == NULL)
113
+ {
114
+ pool_error("copy_string: palloc failed: %s", strerror(errno));
115
+ pfree(copy);
116
+ child_exit(1);
117
+ }
118
+ memcpy(copy->data, string->data, string->size * STRING_SIZE);
119
+
120
+ return copy;
121
+ }
@@ -0,0 +1,37 @@
1
+ /* -*-pgsql-c-*- */
2
+ /*
3
+ * $Header$
4
+ *
5
+ * Copyright (c) 2006-2008, pgpool Global Development Group
6
+ *
7
+ * Permission to use, copy, modify, and distribute this software and
8
+ * its documentation for any purpose and without fee is hereby
9
+ * granted, provided that the above copyright notice appear in all
10
+ * copies and that both that copyright notice and this permission
11
+ * notice appear in supporting documentation, and that the name of the
12
+ * author not be used in advertising or publicity pertaining to
13
+ * distribution of the software without specific, written prior
14
+ * permission. The author makes no representations about the
15
+ * suitability of this software for any purpose. It is provided "as
16
+ * is" without express or implied warranty.
17
+ */
18
+
19
+ #ifndef POOL_STRING_H
20
+ #define POOL_STRING_H
21
+
22
+ #define STRING_SIZE 128
23
+
24
+ typedef struct
25
+ {
26
+ int size;
27
+ int len;
28
+ char *data;
29
+ } String;
30
+
31
+ extern String *init_string(char *str);
32
+ extern void string_append_string(String *string, String *append_data);
33
+ extern void string_append_char(String *string, char *append_data);
34
+ extern void free_string(String *string);
35
+ extern String *copy_string(String *string);
36
+
37
+ #endif /* POOL_STRING_H */
@@ -0,0 +1,1280 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * primnodes.h
4
+ * Definitions for "primitive" node types, those that are used in more
5
+ * than one of the parse/plan/execute stages of the query pipeline.
6
+ * Currently, these are mostly nodes for executable expressions
7
+ * and join trees.
8
+ *
9
+ *
10
+ * Portions Copyright (c) 2003-2013, PgPool Global Development Group
11
+ * Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
12
+ * Portions Copyright (c) 1994, Regents of the University of California
13
+ *
14
+ * src/include/nodes/primnodes.h
15
+ *
16
+ *-------------------------------------------------------------------------
17
+ */
18
+ #ifndef PRIMNODES_H
19
+ #define PRIMNODES_H
20
+
21
+ #include "pg_list.h"
22
+
23
+
24
+ /* ----------------------------------------------------------------
25
+ * node definitions
26
+ * ----------------------------------------------------------------
27
+ */
28
+
29
+ /*
30
+ * Alias -
31
+ * specifies an alias for a range variable; the alias might also
32
+ * specify renaming of columns within the table.
33
+ *
34
+ * Note: colnames is a list of Value nodes (always strings). In Alias structs
35
+ * associated with RTEs, there may be entries corresponding to dropped
36
+ * columns; these are normally empty strings (""). See parsenodes.h for info.
37
+ */
38
+ typedef struct Alias
39
+ {
40
+ NodeTag type;
41
+ char *aliasname; /* aliased rel name (never qualified) */
42
+ List *colnames; /* optional list of column aliases */
43
+ } Alias;
44
+
45
+ typedef enum InhOption
46
+ {
47
+ INH_NO, /* Do NOT scan child tables */
48
+ INH_YES, /* DO scan child tables */
49
+ INH_DEFAULT /* Use current SQL_inheritance option */
50
+ } InhOption;
51
+
52
+ /* What to do at commit time for temporary relations */
53
+ typedef enum OnCommitAction
54
+ {
55
+ ONCOMMIT_NOOP, /* No ON COMMIT clause (do nothing) */
56
+ ONCOMMIT_PRESERVE_ROWS, /* ON COMMIT PRESERVE ROWS (do nothing) */
57
+ ONCOMMIT_DELETE_ROWS, /* ON COMMIT DELETE ROWS */
58
+ ONCOMMIT_DROP /* ON COMMIT DROP */
59
+ } OnCommitAction;
60
+
61
+ /*
62
+ * RangeVar - range variable, used in FROM clauses
63
+ *
64
+ * Also used to represent table names in utility statements; there, the alias
65
+ * field is not used, and inhOpt shows whether to apply the operation
66
+ * recursively to child tables. In some contexts it is also useful to carry
67
+ * a TEMP table indication here.
68
+ */
69
+ typedef struct RangeVar
70
+ {
71
+ NodeTag type;
72
+ char *catalogname; /* the catalog (database) name, or NULL */
73
+ char *schemaname; /* the schema name, or NULL */
74
+ char *relname; /* the relation/sequence name */
75
+ InhOption inhOpt; /* expand rel by inheritance? recursively act
76
+ * on children? */
77
+ char relpersistence; /* see RELPERSISTENCE_* in pg_class.h */
78
+ Alias *alias; /* table alias & optional column aliases */
79
+ int location; /* token location, or -1 if unknown */
80
+ } RangeVar;
81
+
82
+ /*
83
+ * IntoClause - target information for SELECT INTO and CREATE TABLE AS
84
+ */
85
+ typedef struct IntoClause
86
+ {
87
+ NodeTag type;
88
+
89
+ RangeVar *rel; /* target relation name */
90
+ List *colNames; /* column names to assign, or NIL */
91
+ List *options; /* options from WITH clause */
92
+ OnCommitAction onCommit; /* what do we do at COMMIT? */
93
+ char *tableSpaceName; /* table space to use, or NULL */
94
+ bool skipData; /* true for WITH NO DATA */
95
+ } IntoClause;
96
+
97
+
98
+ /* ----------------------------------------------------------------
99
+ * node types for executable expressions
100
+ * ----------------------------------------------------------------
101
+ */
102
+
103
+ /*
104
+ * Expr - generic superclass for executable-expression nodes
105
+ *
106
+ * All node types that are used in executable expression trees should derive
107
+ * from Expr (that is, have Expr as their first field). Since Expr only
108
+ * contains NodeTag, this is a formality, but it is an easy form of
109
+ * documentation. See also the ExprState node types in execnodes.h.
110
+ */
111
+ typedef struct Expr
112
+ {
113
+ NodeTag type;
114
+ } Expr;
115
+
116
+ /*
117
+ * Var - expression node representing a variable (ie, a table column)
118
+ *
119
+ * Note: during parsing/planning, varnoold/varoattno are always just copies
120
+ * of varno/varattno. At the tail end of planning, Var nodes appearing in
121
+ * upper-level plan nodes are reassigned to point to the outputs of their
122
+ * subplans; for example, in a join node varno becomes INNER_VAR or OUTER_VAR
123
+ * and varattno becomes the index of the proper element of that subplan's
124
+ * target list. But varnoold/varoattno continue to hold the original values.
125
+ * The code doesn't really need varnoold/varoattno, but they are very useful
126
+ * for debugging and interpreting completed plans, so we keep them around.
127
+ */
128
+ #define INNER_VAR 65000 /* reference to inner subplan */
129
+ #define OUTER_VAR 65001 /* reference to outer subplan */
130
+ #define INDEX_VAR 65002 /* reference to index column */
131
+
132
+ #define IS_SPECIAL_VARNO(varno) ((varno) >= INNER_VAR)
133
+
134
+ /* Symbols for the indexes of the special RTE entries in rules */
135
+ #define PRS2_OLD_VARNO 1
136
+ #define PRS2_NEW_VARNO 2
137
+
138
+ typedef struct Var
139
+ {
140
+ Expr xpr;
141
+ Index varno; /* index of this var's relation in the range
142
+ * table, or INNER_VAR/OUTER_VAR/INDEX_VAR */
143
+ AttrNumber varattno; /* attribute number of this var, or zero for
144
+ * all */
145
+ Oid vartype; /* pg_type OID for the type of this var */
146
+ int32 vartypmod; /* pg_attribute typmod value */
147
+ Oid varcollid; /* OID of collation, or InvalidOid if none */
148
+ Index varlevelsup; /* for subquery variables referencing outer
149
+ * relations; 0 in a normal var, >0 means N
150
+ * levels up */
151
+ Index varnoold; /* original value of varno, for debugging */
152
+ AttrNumber varoattno; /* original value of varattno */
153
+ int location; /* token location, or -1 if unknown */
154
+ } Var;
155
+
156
+ /*
157
+ * Const
158
+ */
159
+ typedef struct Const
160
+ {
161
+ Expr xpr;
162
+ Oid consttype; /* pg_type OID of the constant's datatype */
163
+ int32 consttypmod; /* typmod value, if any */
164
+ Oid constcollid; /* OID of collation, or InvalidOid if none */
165
+ int constlen; /* typlen of the constant's datatype */
166
+ Datum constvalue; /* the constant's value */
167
+ bool constisnull; /* whether the constant is null (if true,
168
+ * constvalue is undefined) */
169
+ bool constbyval; /* whether this datatype is passed by value.
170
+ * If true, then all the information is stored
171
+ * in the Datum. If false, then the Datum
172
+ * contains a pointer to the information. */
173
+ int location; /* token location, or -1 if unknown */
174
+ } Const;
175
+
176
+ /* ----------------
177
+ * Param
178
+ * paramkind - specifies the kind of parameter. The possible values
179
+ * for this field are:
180
+ *
181
+ * PARAM_EXTERN: The parameter value is supplied from outside the plan.
182
+ * Such parameters are numbered from 1 to n.
183
+ *
184
+ * PARAM_EXEC: The parameter is an internal executor parameter, used
185
+ * for passing values into and out of sub-queries or from
186
+ * nestloop joins to their inner scans.
187
+ * For historical reasons, such parameters are numbered from 0.
188
+ * These numbers are independent of PARAM_EXTERN numbers.
189
+ *
190
+ * PARAM_SUBLINK: The parameter represents an output column of a SubLink
191
+ * node's sub-select. The column number is contained in the
192
+ * `paramid' field. (This type of Param is converted to
193
+ * PARAM_EXEC during planning.)
194
+ *
195
+ * Note: currently, paramtypmod is valid for PARAM_SUBLINK Params, and for
196
+ * PARAM_EXEC Params generated from them; it is always -1 for PARAM_EXTERN
197
+ * params, since the APIs that supply values for such parameters don't carry
198
+ * any typmod info.
199
+ * ----------------
200
+ */
201
+ typedef enum ParamKind
202
+ {
203
+ PARAM_EXTERN,
204
+ PARAM_EXEC,
205
+ PARAM_SUBLINK
206
+ } ParamKind;
207
+
208
+ typedef struct Param
209
+ {
210
+ Expr xpr;
211
+ ParamKind paramkind; /* kind of parameter. See above */
212
+ int paramid; /* numeric ID for parameter */
213
+ Oid paramtype; /* pg_type OID of parameter's datatype */
214
+ int32 paramtypmod; /* typmod value, if known */
215
+ Oid paramcollid; /* OID of collation, or InvalidOid if none */
216
+ int location; /* token location, or -1 if unknown */
217
+ } Param;
218
+
219
+ /*
220
+ * Aggref
221
+ *
222
+ * The aggregate's args list is a targetlist, ie, a list of TargetEntry nodes
223
+ * (before Postgres 9.0 it was just bare expressions). The non-resjunk TLEs
224
+ * represent the aggregate's regular arguments (if any) and resjunk TLEs can
225
+ * be added at the end to represent ORDER BY expressions that are not also
226
+ * arguments. As in a top-level Query, the TLEs can be marked with
227
+ * ressortgroupref indexes to let them be referenced by SortGroupClause
228
+ * entries in the aggorder and/or aggdistinct lists. This represents ORDER BY
229
+ * and DISTINCT operations to be applied to the aggregate input rows before
230
+ * they are passed to the transition function. The grammar only allows a
231
+ * simple "DISTINCT" specifier for the arguments, but we use the full
232
+ * query-level representation to allow more code sharing.
233
+ */
234
+ typedef struct Aggref
235
+ {
236
+ Expr xpr;
237
+ Oid aggfnoid; /* pg_proc Oid of the aggregate */
238
+ Oid aggtype; /* type Oid of result of the aggregate */
239
+ Oid aggcollid; /* OID of collation of result */
240
+ Oid inputcollid; /* OID of collation that function should use */
241
+ List *args; /* arguments and sort expressions */
242
+ List *aggorder; /* ORDER BY (list of SortGroupClause) */
243
+ List *aggdistinct; /* DISTINCT (list of SortGroupClause) */
244
+ bool aggstar; /* TRUE if argument list was really '*' */
245
+ Index agglevelsup; /* > 0 if agg belongs to outer query */
246
+ int location; /* token location, or -1 if unknown */
247
+ } Aggref;
248
+
249
+ /*
250
+ * WindowFunc
251
+ */
252
+ typedef struct WindowFunc
253
+ {
254
+ Expr xpr;
255
+ Oid winfnoid; /* pg_proc Oid of the function */
256
+ Oid wintype; /* type Oid of result of the window function */
257
+ Oid wincollid; /* OID of collation of result */
258
+ Oid inputcollid; /* OID of collation that function should use */
259
+ List *args; /* arguments to the window function */
260
+ Index winref; /* index of associated WindowClause */
261
+ bool winstar; /* TRUE if argument list was really '*' */
262
+ bool winagg; /* is function a simple aggregate? */
263
+ int location; /* token location, or -1 if unknown */
264
+ } WindowFunc;
265
+
266
+ /* ----------------
267
+ * ArrayRef: describes an array subscripting operation
268
+ *
269
+ * An ArrayRef can describe fetching a single element from an array,
270
+ * fetching a subarray (array slice), storing a single element into
271
+ * an array, or storing a slice. The "store" cases work with an
272
+ * initial array value and a source value that is inserted into the
273
+ * appropriate part of the array; the result of the operation is an
274
+ * entire new modified array value.
275
+ *
276
+ * If reflowerindexpr = NIL, then we are fetching or storing a single array
277
+ * element at the subscripts given by refupperindexpr. Otherwise we are
278
+ * fetching or storing an array slice, that is a rectangular subarray
279
+ * with lower and upper bounds given by the index expressions.
280
+ * reflowerindexpr must be the same length as refupperindexpr when it
281
+ * is not NIL.
282
+ *
283
+ * Note: the result datatype is the element type when fetching a single
284
+ * element; but it is the array type when doing subarray fetch or either
285
+ * type of store.
286
+ * ----------------
287
+ */
288
+ typedef struct ArrayRef
289
+ {
290
+ Expr xpr;
291
+ Oid refarraytype; /* type of the array proper */
292
+ Oid refelemtype; /* type of the array elements */
293
+ int32 reftypmod; /* typmod of the array (and elements too) */
294
+ Oid refcollid; /* OID of collation, or InvalidOid if none */
295
+ List *refupperindexpr;/* expressions that evaluate to upper array
296
+ * indexes */
297
+ List *reflowerindexpr;/* expressions that evaluate to lower array
298
+ * indexes */
299
+ Expr *refexpr; /* the expression that evaluates to an array
300
+ * value */
301
+ Expr *refassgnexpr; /* expression for the source value, or NULL if
302
+ * fetch */
303
+ } ArrayRef;
304
+
305
+ /*
306
+ * CoercionContext - distinguishes the allowed set of type casts
307
+ *
308
+ * NB: ordering of the alternatives is significant; later (larger) values
309
+ * allow more casts than earlier ones.
310
+ */
311
+ typedef enum CoercionContext
312
+ {
313
+ COERCION_IMPLICIT, /* coercion in context of expression */
314
+ COERCION_ASSIGNMENT, /* coercion in context of assignment */
315
+ COERCION_EXPLICIT /* explicit cast operation */
316
+ } CoercionContext;
317
+
318
+ /*
319
+ * CoercionForm - information showing how to display a function-call node
320
+ *
321
+ * NB: equal() ignores CoercionForm fields, therefore this *must* not carry
322
+ * any semantically significant information. We need that behavior so that
323
+ * the planner will consider equivalent implicit and explicit casts to be
324
+ * equivalent. In cases where those actually behave differently, the coercion
325
+ * function's arguments will be different.
326
+ */
327
+ typedef enum CoercionForm
328
+ {
329
+ COERCE_EXPLICIT_CALL, /* display as a function call */
330
+ COERCE_EXPLICIT_CAST, /* display as an explicit cast */
331
+ COERCE_IMPLICIT_CAST, /* implicit cast, so hide it */
332
+ COERCE_DONTCARE /* special case for planner */
333
+ } CoercionForm;
334
+
335
+ /*
336
+ * FuncExpr - expression node for a function call
337
+ */
338
+ typedef struct FuncExpr
339
+ {
340
+ Expr xpr;
341
+ Oid funcid; /* PG_PROC OID of the function */
342
+ Oid funcresulttype; /* PG_TYPE OID of result value */
343
+ bool funcretset; /* true if function returns set */
344
+ CoercionForm funcformat; /* how to display this function call */
345
+ Oid funccollid; /* OID of collation of result */
346
+ Oid inputcollid; /* OID of collation that function should use */
347
+ List *args; /* arguments to the function */
348
+ int location; /* token location, or -1 if unknown */
349
+ } FuncExpr;
350
+
351
+ /*
352
+ * NamedArgExpr - a named argument of a function
353
+ *
354
+ * This node type can only appear in the args list of a FuncCall or FuncExpr
355
+ * node. We support pure positional call notation (no named arguments),
356
+ * named notation (all arguments are named), and mixed notation (unnamed
357
+ * arguments followed by named ones).
358
+ *
359
+ * Parse analysis sets argnumber to the positional index of the argument,
360
+ * but doesn't rearrange the argument list.
361
+ *
362
+ * The planner will convert argument lists to pure positional notation
363
+ * during expression preprocessing, so execution never sees a NamedArgExpr.
364
+ */
365
+ typedef struct NamedArgExpr
366
+ {
367
+ Expr xpr;
368
+ Expr *arg; /* the argument expression */
369
+ char *name; /* the name */
370
+ int argnumber; /* argument's number in positional notation */
371
+ int location; /* argument name location, or -1 if unknown */
372
+ } NamedArgExpr;
373
+
374
+ /*
375
+ * OpExpr - expression node for an operator invocation
376
+ *
377
+ * Semantically, this is essentially the same as a function call.
378
+ *
379
+ * Note that opfuncid is not necessarily filled in immediately on creation
380
+ * of the node. The planner makes sure it is valid before passing the node
381
+ * tree to the executor, but during parsing/planning opfuncid can be 0.
382
+ */
383
+ typedef struct OpExpr
384
+ {
385
+ Expr xpr;
386
+ Oid opno; /* PG_OPERATOR OID of the operator */
387
+ Oid opfuncid; /* PG_PROC OID of underlying function */
388
+ Oid opresulttype; /* PG_TYPE OID of result value */
389
+ bool opretset; /* true if operator returns set */
390
+ Oid opcollid; /* OID of collation of result */
391
+ Oid inputcollid; /* OID of collation that operator should use */
392
+ List *args; /* arguments to the operator (1 or 2) */
393
+ int location; /* token location, or -1 if unknown */
394
+ } OpExpr;
395
+
396
+ /*
397
+ * DistinctExpr - expression node for "x IS DISTINCT FROM y"
398
+ *
399
+ * Except for the nodetag, this is represented identically to an OpExpr
400
+ * referencing the "=" operator for x and y.
401
+ * We use "=", not the more obvious "<>", because more datatypes have "="
402
+ * than "<>". This means the executor must invert the operator result.
403
+ * Note that the operator function won't be called at all if either input
404
+ * is NULL, since then the result can be determined directly.
405
+ */
406
+ typedef OpExpr DistinctExpr;
407
+
408
+ /*
409
+ * NullIfExpr - a NULLIF expression
410
+ *
411
+ * Like DistinctExpr, this is represented the same as an OpExpr referencing
412
+ * the "=" operator for x and y.
413
+ */
414
+ typedef OpExpr NullIfExpr;
415
+
416
+ /*
417
+ * ScalarArrayOpExpr - expression node for "scalar op ANY/ALL (array)"
418
+ *
419
+ * The operator must yield boolean. It is applied to the left operand
420
+ * and each element of the righthand array, and the results are combined
421
+ * with OR or AND (for ANY or ALL respectively). The node representation
422
+ * is almost the same as for the underlying operator, but we need a useOr
423
+ * flag to remember whether it's ANY or ALL, and we don't have to store
424
+ * the result type (or the collation) because it must be boolean.
425
+ */
426
+ typedef struct ScalarArrayOpExpr
427
+ {
428
+ Expr xpr;
429
+ Oid opno; /* PG_OPERATOR OID of the operator */
430
+ Oid opfuncid; /* PG_PROC OID of underlying function */
431
+ bool useOr; /* true for ANY, false for ALL */
432
+ Oid inputcollid; /* OID of collation that operator should use */
433
+ List *args; /* the scalar and array operands */
434
+ int location; /* token location, or -1 if unknown */
435
+ } ScalarArrayOpExpr;
436
+
437
+ /*
438
+ * BoolExpr - expression node for the basic Boolean operators AND, OR, NOT
439
+ *
440
+ * Notice the arguments are given as a List. For NOT, of course the list
441
+ * must always have exactly one element. For AND and OR, the executor can
442
+ * handle any number of arguments. The parser generally treats AND and OR
443
+ * as binary and so it typically only produces two-element lists, but the
444
+ * optimizer will flatten trees of AND and OR nodes to produce longer lists
445
+ * when possible. There are also a few special cases where more arguments
446
+ * can appear before optimization.
447
+ */
448
+ typedef enum BoolExprType
449
+ {
450
+ AND_EXPR, OR_EXPR, NOT_EXPR
451
+ } BoolExprType;
452
+
453
+ typedef struct BoolExpr
454
+ {
455
+ Expr xpr;
456
+ BoolExprType boolop;
457
+ List *args; /* arguments to this expression */
458
+ int location; /* token location, or -1 if unknown */
459
+ } BoolExpr;
460
+
461
+ /*
462
+ * SubLink
463
+ *
464
+ * A SubLink represents a subselect appearing in an expression, and in some
465
+ * cases also the combining operator(s) just above it. The subLinkType
466
+ * indicates the form of the expression represented:
467
+ * EXISTS_SUBLINK EXISTS(SELECT ...)
468
+ * ALL_SUBLINK (lefthand) op ALL (SELECT ...)
469
+ * ANY_SUBLINK (lefthand) op ANY (SELECT ...)
470
+ * ROWCOMPARE_SUBLINK (lefthand) op (SELECT ...)
471
+ * EXPR_SUBLINK (SELECT with single targetlist item ...)
472
+ * ARRAY_SUBLINK ARRAY(SELECT with single targetlist item ...)
473
+ * CTE_SUBLINK WITH query (never actually part of an expression)
474
+ * For ALL, ANY, and ROWCOMPARE, the lefthand is a list of expressions of the
475
+ * same length as the subselect's targetlist. ROWCOMPARE will *always* have
476
+ * a list with more than one entry; if the subselect has just one target
477
+ * then the parser will create an EXPR_SUBLINK instead (and any operator
478
+ * above the subselect will be represented separately). Note that both
479
+ * ROWCOMPARE and EXPR require the subselect to deliver only one row.
480
+ * ALL, ANY, and ROWCOMPARE require the combining operators to deliver boolean
481
+ * results. ALL and ANY combine the per-row results using AND and OR
482
+ * semantics respectively.
483
+ * ARRAY requires just one target column, and creates an array of the target
484
+ * column's type using any number of rows resulting from the subselect.
485
+ *
486
+ * SubLink is classed as an Expr node, but it is not actually executable;
487
+ * it must be replaced in the expression tree by a SubPlan node during
488
+ * planning.
489
+ *
490
+ * NOTE: in the raw output of gram.y, testexpr contains just the raw form
491
+ * of the lefthand expression (if any), and operName is the String name of
492
+ * the combining operator. Also, subselect is a raw parsetree. During parse
493
+ * analysis, the parser transforms testexpr into a complete boolean expression
494
+ * that compares the lefthand value(s) to PARAM_SUBLINK nodes representing the
495
+ * output columns of the subselect. And subselect is transformed to a Query.
496
+ * This is the representation seen in saved rules and in the rewriter.
497
+ *
498
+ * In EXISTS, EXPR, and ARRAY SubLinks, testexpr and operName are unused and
499
+ * are always null.
500
+ *
501
+ * The CTE_SUBLINK case never occurs in actual SubLink nodes, but it is used
502
+ * in SubPlans generated for WITH subqueries.
503
+ */
504
+ typedef enum SubLinkType
505
+ {
506
+ EXISTS_SUBLINK,
507
+ ALL_SUBLINK,
508
+ ANY_SUBLINK,
509
+ ROWCOMPARE_SUBLINK,
510
+ EXPR_SUBLINK,
511
+ ARRAY_SUBLINK,
512
+ CTE_SUBLINK /* for SubPlans only */
513
+ } SubLinkType;
514
+
515
+
516
+ typedef struct SubLink
517
+ {
518
+ Expr xpr;
519
+ SubLinkType subLinkType; /* see above */
520
+ Node *testexpr; /* outer-query test for ALL/ANY/ROWCOMPARE */
521
+ List *operName; /* originally specified operator name */
522
+ Node *subselect; /* subselect as Query* or parsetree */
523
+ int location; /* token location, or -1 if unknown */
524
+ } SubLink;
525
+
526
+ /*
527
+ * SubPlan - executable expression node for a subplan (sub-SELECT)
528
+ *
529
+ * The planner replaces SubLink nodes in expression trees with SubPlan
530
+ * nodes after it has finished planning the subquery. SubPlan references
531
+ * a sub-plantree stored in the subplans list of the toplevel PlannedStmt.
532
+ * (We avoid a direct link to make it easier to copy expression trees
533
+ * without causing multiple processing of the subplan.)
534
+ *
535
+ * In an ordinary subplan, testexpr points to an executable expression
536
+ * (OpExpr, an AND/OR tree of OpExprs, or RowCompareExpr) for the combining
537
+ * operator(s); the left-hand arguments are the original lefthand expressions,
538
+ * and the right-hand arguments are PARAM_EXEC Param nodes representing the
539
+ * outputs of the sub-select. (NOTE: runtime coercion functions may be
540
+ * inserted as well.) This is just the same expression tree as testexpr in
541
+ * the original SubLink node, but the PARAM_SUBLINK nodes are replaced by
542
+ * suitably numbered PARAM_EXEC nodes.
543
+ *
544
+ * If the sub-select becomes an initplan rather than a subplan, the executable
545
+ * expression is part of the outer plan's expression tree (and the SubPlan
546
+ * node itself is not, but rather is found in the outer plan's initPlan
547
+ * list). In this case testexpr is NULL to avoid duplication.
548
+ *
549
+ * The planner also derives lists of the values that need to be passed into
550
+ * and out of the subplan. Input values are represented as a list "args" of
551
+ * expressions to be evaluated in the outer-query context (currently these
552
+ * args are always just Vars, but in principle they could be any expression).
553
+ * The values are assigned to the global PARAM_EXEC params indexed by parParam
554
+ * (the parParam and args lists must have the same ordering). setParam is a
555
+ * list of the PARAM_EXEC params that are computed by the sub-select, if it
556
+ * is an initplan; they are listed in order by sub-select output column
557
+ * position. (parParam and setParam are integer Lists, not Bitmapsets,
558
+ * because their ordering is significant.)
559
+ *
560
+ * Also, the planner computes startup and per-call costs for use of the
561
+ * SubPlan. Note that these include the cost of the subquery proper,
562
+ * evaluation of the testexpr if any, and any hashtable management overhead.
563
+ */
564
+ typedef struct SubPlan
565
+ {
566
+ Expr xpr;
567
+ /* Fields copied from original SubLink: */
568
+ SubLinkType subLinkType; /* see above */
569
+ /* The combining operators, transformed to an executable expression: */
570
+ Node *testexpr; /* OpExpr or RowCompareExpr expression tree */
571
+ List *paramIds; /* IDs of Params embedded in the above */
572
+ /* Identification of the Plan tree to use: */
573
+ int plan_id; /* Index (from 1) in PlannedStmt.subplans */
574
+ /* Identification of the SubPlan for EXPLAIN and debugging purposes: */
575
+ char *plan_name; /* A name assigned during planning */
576
+ /* Extra data useful for determining subplan's output type: */
577
+ Oid firstColType; /* Type of first column of subplan result */
578
+ int32 firstColTypmod; /* Typmod of first column of subplan result */
579
+ Oid firstColCollation; /* Collation of first column of
580
+ * subplan result */
581
+ /* Information about execution strategy: */
582
+ bool useHashTable; /* TRUE to store subselect output in a hash
583
+ * table (implies we are doing "IN") */
584
+ bool unknownEqFalse; /* TRUE if it's okay to return FALSE when the
585
+ * spec result is UNKNOWN; this allows much
586
+ * simpler handling of null values */
587
+ /* Information for passing params into and out of the subselect: */
588
+ /* setParam and parParam are lists of integers (param IDs) */
589
+ List *setParam; /* initplan subqueries have to set these
590
+ * Params for parent plan */
591
+ List *parParam; /* indices of input Params from parent plan */
592
+ List *args; /* exprs to pass as parParam values */
593
+ /* Estimated execution costs: */
594
+ Cost startup_cost; /* one-time setup cost */
595
+ Cost per_call_cost; /* cost for each subplan evaluation */
596
+ } SubPlan;
597
+
598
+ /*
599
+ * AlternativeSubPlan - expression node for a choice among SubPlans
600
+ *
601
+ * The subplans are given as a List so that the node definition need not
602
+ * change if there's ever more than two alternatives. For the moment,
603
+ * though, there are always exactly two; and the first one is the fast-start
604
+ * plan.
605
+ */
606
+ typedef struct AlternativeSubPlan
607
+ {
608
+ Expr xpr;
609
+ List *subplans; /* SubPlan(s) with equivalent results */
610
+ } AlternativeSubPlan;
611
+
612
+ /* ----------------
613
+ * FieldSelect
614
+ *
615
+ * FieldSelect represents the operation of extracting one field from a tuple
616
+ * value. At runtime, the input expression is expected to yield a rowtype
617
+ * Datum. The specified field number is extracted and returned as a Datum.
618
+ * ----------------
619
+ */
620
+
621
+ typedef struct FieldSelect
622
+ {
623
+ Expr xpr;
624
+ Expr *arg; /* input expression */
625
+ AttrNumber fieldnum; /* attribute number of field to extract */
626
+ Oid resulttype; /* type of the field (result type of this
627
+ * node) */
628
+ int32 resulttypmod; /* output typmod (usually -1) */
629
+ Oid resultcollid; /* OID of collation of the field */
630
+ } FieldSelect;
631
+
632
+ /* ----------------
633
+ * FieldStore
634
+ *
635
+ * FieldStore represents the operation of modifying one field in a tuple
636
+ * value, yielding a new tuple value (the input is not touched!). Like
637
+ * the assign case of ArrayRef, this is used to implement UPDATE of a
638
+ * portion of a column.
639
+ *
640
+ * A single FieldStore can actually represent updates of several different
641
+ * fields. The parser only generates FieldStores with single-element lists,
642
+ * but the planner will collapse multiple updates of the same base column
643
+ * into one FieldStore.
644
+ * ----------------
645
+ */
646
+
647
+ typedef struct FieldStore
648
+ {
649
+ Expr xpr;
650
+ Expr *arg; /* input tuple value */
651
+ List *newvals; /* new value(s) for field(s) */
652
+ List *fieldnums; /* integer list of field attnums */
653
+ Oid resulttype; /* type of result (same as type of arg) */
654
+ /* Like RowExpr, we deliberately omit a typmod and collation here */
655
+ } FieldStore;
656
+
657
+ /* ----------------
658
+ * RelabelType
659
+ *
660
+ * RelabelType represents a "dummy" type coercion between two binary-
661
+ * compatible datatypes, such as reinterpreting the result of an OID
662
+ * expression as an int4. It is a no-op at runtime; we only need it
663
+ * to provide a place to store the correct type to be attributed to
664
+ * the expression result during type resolution. (We can't get away
665
+ * with just overwriting the type field of the input expression node,
666
+ * so we need a separate node to show the coercion's result type.)
667
+ * ----------------
668
+ */
669
+
670
+ typedef struct RelabelType
671
+ {
672
+ Expr xpr;
673
+ Expr *arg; /* input expression */
674
+ Oid resulttype; /* output type of coercion expression */
675
+ int32 resulttypmod; /* output typmod (usually -1) */
676
+ Oid resultcollid; /* OID of collation, or InvalidOid if none */
677
+ CoercionForm relabelformat; /* how to display this node */
678
+ int location; /* token location, or -1 if unknown */
679
+ } RelabelType;
680
+
681
+ /* ----------------
682
+ * CoerceViaIO
683
+ *
684
+ * CoerceViaIO represents a type coercion between two types whose textual
685
+ * representations are compatible, implemented by invoking the source type's
686
+ * typoutput function then the destination type's typinput function.
687
+ * ----------------
688
+ */
689
+
690
+ typedef struct CoerceViaIO
691
+ {
692
+ Expr xpr;
693
+ Expr *arg; /* input expression */
694
+ Oid resulttype; /* output type of coercion */
695
+ /* output typmod is not stored, but is presumed -1 */
696
+ Oid resultcollid; /* OID of collation, or InvalidOid if none */
697
+ CoercionForm coerceformat; /* how to display this node */
698
+ int location; /* token location, or -1 if unknown */
699
+ } CoerceViaIO;
700
+
701
+ /* ----------------
702
+ * ArrayCoerceExpr
703
+ *
704
+ * ArrayCoerceExpr represents a type coercion from one array type to another,
705
+ * which is implemented by applying the indicated element-type coercion
706
+ * function to each element of the source array. If elemfuncid is InvalidOid
707
+ * then the element types are binary-compatible, but the coercion still
708
+ * requires some effort (we have to fix the element type ID stored in the
709
+ * array header).
710
+ * ----------------
711
+ */
712
+
713
+ typedef struct ArrayCoerceExpr
714
+ {
715
+ Expr xpr;
716
+ Expr *arg; /* input expression (yields an array) */
717
+ Oid elemfuncid; /* OID of element coercion function, or 0 */
718
+ Oid resulttype; /* output type of coercion (an array type) */
719
+ int32 resulttypmod; /* output typmod (also element typmod) */
720
+ Oid resultcollid; /* OID of collation, or InvalidOid if none */
721
+ bool isExplicit; /* conversion semantics flag to pass to func */
722
+ CoercionForm coerceformat; /* how to display this node */
723
+ int location; /* token location, or -1 if unknown */
724
+ } ArrayCoerceExpr;
725
+
726
+ /* ----------------
727
+ * ConvertRowtypeExpr
728
+ *
729
+ * ConvertRowtypeExpr represents a type coercion from one composite type
730
+ * to another, where the source type is guaranteed to contain all the columns
731
+ * needed for the destination type plus possibly others; the columns need not
732
+ * be in the same positions, but are matched up by name. This is primarily
733
+ * used to convert a whole-row value of an inheritance child table into a
734
+ * valid whole-row value of its parent table's rowtype.
735
+ * ----------------
736
+ */
737
+
738
+ typedef struct ConvertRowtypeExpr
739
+ {
740
+ Expr xpr;
741
+ Expr *arg; /* input expression */
742
+ Oid resulttype; /* output type (always a composite type) */
743
+ /* Like RowExpr, we deliberately omit a typmod and collation here */
744
+ CoercionForm convertformat; /* how to display this node */
745
+ int location; /* token location, or -1 if unknown */
746
+ } ConvertRowtypeExpr;
747
+
748
+ /*----------
749
+ * CollateExpr - COLLATE
750
+ *
751
+ * The planner replaces CollateExpr with RelabelType during expression
752
+ * preprocessing, so execution never sees a CollateExpr.
753
+ *----------
754
+ */
755
+ typedef struct CollateExpr
756
+ {
757
+ Expr xpr;
758
+ Expr *arg; /* input expression */
759
+ Oid collOid; /* collation's OID */
760
+ int location; /* token location, or -1 if unknown */
761
+ } CollateExpr;
762
+
763
+ /*----------
764
+ * CaseExpr - a CASE expression
765
+ *
766
+ * We support two distinct forms of CASE expression:
767
+ * CASE WHEN boolexpr THEN expr [ WHEN boolexpr THEN expr ... ]
768
+ * CASE testexpr WHEN compexpr THEN expr [ WHEN compexpr THEN expr ... ]
769
+ * These are distinguishable by the "arg" field being NULL in the first case
770
+ * and the testexpr in the second case.
771
+ *
772
+ * In the raw grammar output for the second form, the condition expressions
773
+ * of the WHEN clauses are just the comparison values. Parse analysis
774
+ * converts these to valid boolean expressions of the form
775
+ * CaseTestExpr '=' compexpr
776
+ * where the CaseTestExpr node is a placeholder that emits the correct
777
+ * value at runtime. This structure is used so that the testexpr need be
778
+ * evaluated only once. Note that after parse analysis, the condition
779
+ * expressions always yield boolean.
780
+ *
781
+ * Note: we can test whether a CaseExpr has been through parse analysis
782
+ * yet by checking whether casetype is InvalidOid or not.
783
+ *----------
784
+ */
785
+ typedef struct CaseExpr
786
+ {
787
+ Expr xpr;
788
+ Oid casetype; /* type of expression result */
789
+ Oid casecollid; /* OID of collation, or InvalidOid if none */
790
+ Expr *arg; /* implicit equality comparison argument */
791
+ List *args; /* the arguments (list of WHEN clauses) */
792
+ Expr *defresult; /* the default result (ELSE clause) */
793
+ int location; /* token location, or -1 if unknown */
794
+ } CaseExpr;
795
+
796
+ /*
797
+ * CaseWhen - one arm of a CASE expression
798
+ */
799
+ typedef struct CaseWhen
800
+ {
801
+ Expr xpr;
802
+ Expr *expr; /* condition expression */
803
+ Expr *result; /* substitution result */
804
+ int location; /* token location, or -1 if unknown */
805
+ } CaseWhen;
806
+
807
+ /*
808
+ * Placeholder node for the test value to be processed by a CASE expression.
809
+ * This is effectively like a Param, but can be implemented more simply
810
+ * since we need only one replacement value at a time.
811
+ *
812
+ * We also use this in nested UPDATE expressions.
813
+ * See transformAssignmentIndirection().
814
+ */
815
+ typedef struct CaseTestExpr
816
+ {
817
+ Expr xpr;
818
+ Oid typeId; /* type for substituted value */
819
+ int32 typeMod; /* typemod for substituted value */
820
+ Oid collation; /* collation for the substituted value */
821
+ } CaseTestExpr;
822
+
823
+ /*
824
+ * ArrayExpr - an ARRAY[] expression
825
+ *
826
+ * Note: if multidims is false, the constituent expressions all yield the
827
+ * scalar type identified by element_typeid. If multidims is true, the
828
+ * constituent expressions all yield arrays of element_typeid (ie, the same
829
+ * type as array_typeid); at runtime we must check for compatible subscripts.
830
+ */
831
+ typedef struct ArrayExpr
832
+ {
833
+ Expr xpr;
834
+ Oid array_typeid; /* type of expression result */
835
+ Oid array_collid; /* OID of collation, or InvalidOid if none */
836
+ Oid element_typeid; /* common type of array elements */
837
+ List *elements; /* the array elements or sub-arrays */
838
+ bool multidims; /* true if elements are sub-arrays */
839
+ int location; /* token location, or -1 if unknown */
840
+ } ArrayExpr;
841
+
842
+ /*
843
+ * RowExpr - a ROW() expression
844
+ *
845
+ * Note: the list of fields must have a one-for-one correspondence with
846
+ * physical fields of the associated rowtype, although it is okay for it
847
+ * to be shorter than the rowtype. That is, the N'th list element must
848
+ * match up with the N'th physical field. When the N'th physical field
849
+ * is a dropped column (attisdropped) then the N'th list element can just
850
+ * be a NULL constant. (This case can only occur for named composite types,
851
+ * not RECORD types, since those are built from the RowExpr itself rather
852
+ * than vice versa.) It is important not to assume that length(args) is
853
+ * the same as the number of columns logically present in the rowtype.
854
+ *
855
+ * colnames provides field names in cases where the names can't easily be
856
+ * obtained otherwise. Names *must* be provided if row_typeid is RECORDOID.
857
+ * If row_typeid identifies a known composite type, colnames can be NIL to
858
+ * indicate the type's cataloged field names apply. Note that colnames can
859
+ * be non-NIL even for a composite type, and typically is when the RowExpr
860
+ * was created by expanding a whole-row Var. This is so that we can retain
861
+ * the column alias names of the RTE that the Var referenced (which would
862
+ * otherwise be very difficult to extract from the parsetree). Like the
863
+ * args list, colnames is one-for-one with physical fields of the rowtype.
864
+ */
865
+ typedef struct RowExpr
866
+ {
867
+ Expr xpr;
868
+ List *args; /* the fields */
869
+ Oid row_typeid; /* RECORDOID or a composite type's ID */
870
+
871
+ /*
872
+ * Note: we deliberately do NOT store a typmod. Although a typmod will be
873
+ * associated with specific RECORD types at runtime, it will differ for
874
+ * different backends, and so cannot safely be stored in stored
875
+ * parsetrees. We must assume typmod -1 for a RowExpr node.
876
+ *
877
+ * We don't need to store a collation either. The result type is
878
+ * necessarily composite, and composite types never have a collation.
879
+ */
880
+ CoercionForm row_format; /* how to display this node */
881
+ List *colnames; /* list of String, or NIL */
882
+ int location; /* token location, or -1 if unknown */
883
+ } RowExpr;
884
+
885
+ /*
886
+ * RowCompareExpr - row-wise comparison, such as (a, b) <= (1, 2)
887
+ *
888
+ * We support row comparison for any operator that can be determined to
889
+ * act like =, <>, <, <=, >, or >= (we determine this by looking for the
890
+ * operator in btree opfamilies). Note that the same operator name might
891
+ * map to a different operator for each pair of row elements, since the
892
+ * element datatypes can vary.
893
+ *
894
+ * A RowCompareExpr node is only generated for the < <= > >= cases;
895
+ * the = and <> cases are translated to simple AND or OR combinations
896
+ * of the pairwise comparisons. However, we include = and <> in the
897
+ * RowCompareType enum for the convenience of parser logic.
898
+ */
899
+ typedef enum RowCompareType
900
+ {
901
+ /* Values of this enum are chosen to match btree strategy numbers */
902
+ ROWCOMPARE_LT = 1, /* BTLessStrategyNumber */
903
+ ROWCOMPARE_LE = 2, /* BTLessEqualStrategyNumber */
904
+ ROWCOMPARE_EQ = 3, /* BTEqualStrategyNumber */
905
+ ROWCOMPARE_GE = 4, /* BTGreaterEqualStrategyNumber */
906
+ ROWCOMPARE_GT = 5, /* BTGreaterStrategyNumber */
907
+ ROWCOMPARE_NE = 6 /* no such btree strategy */
908
+ } RowCompareType;
909
+
910
+ typedef struct RowCompareExpr
911
+ {
912
+ Expr xpr;
913
+ RowCompareType rctype; /* LT LE GE or GT, never EQ or NE */
914
+ List *opnos; /* OID list of pairwise comparison ops */
915
+ List *opfamilies; /* OID list of containing operator families */
916
+ List *inputcollids; /* OID list of collations for comparisons */
917
+ List *largs; /* the left-hand input arguments */
918
+ List *rargs; /* the right-hand input arguments */
919
+ } RowCompareExpr;
920
+
921
+ /*
922
+ * CoalesceExpr - a COALESCE expression
923
+ */
924
+ typedef struct CoalesceExpr
925
+ {
926
+ Expr xpr;
927
+ Oid coalescetype; /* type of expression result */
928
+ Oid coalescecollid; /* OID of collation, or InvalidOid if none */
929
+ List *args; /* the arguments */
930
+ int location; /* token location, or -1 if unknown */
931
+ } CoalesceExpr;
932
+
933
+ /*
934
+ * MinMaxExpr - a GREATEST or LEAST function
935
+ */
936
+ typedef enum MinMaxOp
937
+ {
938
+ IS_GREATEST,
939
+ IS_LEAST
940
+ } MinMaxOp;
941
+
942
+ typedef struct MinMaxExpr
943
+ {
944
+ Expr xpr;
945
+ Oid minmaxtype; /* common type of arguments and result */
946
+ Oid minmaxcollid; /* OID of collation of result */
947
+ Oid inputcollid; /* OID of collation that function should use */
948
+ MinMaxOp op; /* function to execute */
949
+ List *args; /* the arguments */
950
+ int location; /* token location, or -1 if unknown */
951
+ } MinMaxExpr;
952
+
953
+ /*
954
+ * XmlExpr - various SQL/XML functions requiring special grammar productions
955
+ *
956
+ * 'name' carries the "NAME foo" argument (already XML-escaped).
957
+ * 'named_args' and 'arg_names' represent an xml_attribute list.
958
+ * 'args' carries all other arguments.
959
+ *
960
+ * Note: result type/typmod/collation are not stored, but can be deduced
961
+ * from the XmlExprOp. The type/typmod fields are just used for display
962
+ * purposes, and are NOT necessarily the true result type of the node.
963
+ * (We also use type == InvalidOid to mark a not-yet-parse-analyzed XmlExpr.)
964
+ */
965
+ typedef enum XmlExprOp
966
+ {
967
+ IS_XMLCONCAT, /* XMLCONCAT(args) */
968
+ IS_XMLELEMENT, /* XMLELEMENT(name, xml_attributes, args) */
969
+ IS_XMLFOREST, /* XMLFOREST(xml_attributes) */
970
+ IS_XMLPARSE, /* XMLPARSE(text, is_doc, preserve_ws) */
971
+ IS_XMLPI, /* XMLPI(name [, args]) */
972
+ IS_XMLROOT, /* XMLROOT(xml, version, standalone) */
973
+ IS_XMLSERIALIZE, /* XMLSERIALIZE(is_document, xmlval) */
974
+ IS_DOCUMENT /* xmlval IS DOCUMENT */
975
+ } XmlExprOp;
976
+
977
+ typedef enum
978
+ {
979
+ XMLOPTION_DOCUMENT,
980
+ XMLOPTION_CONTENT
981
+ } XmlOptionType;
982
+
983
+ typedef struct XmlExpr
984
+ {
985
+ Expr xpr;
986
+ XmlExprOp op; /* xml function ID */
987
+ char *name; /* name in xml(NAME foo ...) syntaxes */
988
+ List *named_args; /* non-XML expressions for xml_attributes */
989
+ List *arg_names; /* parallel list of Value strings */
990
+ List *args; /* list of expressions */
991
+ XmlOptionType xmloption; /* DOCUMENT or CONTENT */
992
+ Oid type; /* target type/typmod for XMLSERIALIZE */
993
+ int32 typmod;
994
+ int location; /* token location, or -1 if unknown */
995
+ } XmlExpr;
996
+
997
+ /* ----------------
998
+ * NullTest
999
+ *
1000
+ * NullTest represents the operation of testing a value for NULLness.
1001
+ * The appropriate test is performed and returned as a boolean Datum.
1002
+ *
1003
+ * NOTE: the semantics of this for rowtype inputs are noticeably different
1004
+ * from the scalar case. We provide an "argisrow" flag to reflect that.
1005
+ * ----------------
1006
+ */
1007
+
1008
+ typedef enum NullTestType
1009
+ {
1010
+ IS_NULL, IS_NOT_NULL
1011
+ } NullTestType;
1012
+
1013
+ typedef struct NullTest
1014
+ {
1015
+ Expr xpr;
1016
+ Expr *arg; /* input expression */
1017
+ NullTestType nulltesttype; /* IS NULL, IS NOT NULL */
1018
+ bool argisrow; /* T if input is of a composite type */
1019
+ } NullTest;
1020
+
1021
+ /*
1022
+ * BooleanTest
1023
+ *
1024
+ * BooleanTest represents the operation of determining whether a boolean
1025
+ * is TRUE, FALSE, or UNKNOWN (ie, NULL). All six meaningful combinations
1026
+ * are supported. Note that a NULL input does *not* cause a NULL result.
1027
+ * The appropriate test is performed and returned as a boolean Datum.
1028
+ */
1029
+
1030
+ typedef enum BoolTestType
1031
+ {
1032
+ IS_TRUE, IS_NOT_TRUE, IS_FALSE, IS_NOT_FALSE, IS_UNKNOWN, IS_NOT_UNKNOWN
1033
+ } BoolTestType;
1034
+
1035
+ typedef struct BooleanTest
1036
+ {
1037
+ Expr xpr;
1038
+ Expr *arg; /* input expression */
1039
+ BoolTestType booltesttype; /* test type */
1040
+ } BooleanTest;
1041
+
1042
+ /*
1043
+ * CoerceToDomain
1044
+ *
1045
+ * CoerceToDomain represents the operation of coercing a value to a domain
1046
+ * type. At runtime (and not before) the precise set of constraints to be
1047
+ * checked will be determined. If the value passes, it is returned as the
1048
+ * result; if not, an error is raised. Note that this is equivalent to
1049
+ * RelabelType in the scenario where no constraints are applied.
1050
+ */
1051
+ typedef struct CoerceToDomain
1052
+ {
1053
+ Expr xpr;
1054
+ Expr *arg; /* input expression */
1055
+ Oid resulttype; /* domain type ID (result type) */
1056
+ int32 resulttypmod; /* output typmod (currently always -1) */
1057
+ Oid resultcollid; /* OID of collation, or InvalidOid if none */
1058
+ CoercionForm coercionformat; /* how to display this node */
1059
+ int location; /* token location, or -1 if unknown */
1060
+ } CoerceToDomain;
1061
+
1062
+ /*
1063
+ * Placeholder node for the value to be processed by a domain's check
1064
+ * constraint. This is effectively like a Param, but can be implemented more
1065
+ * simply since we need only one replacement value at a time.
1066
+ *
1067
+ * Note: the typeId/typeMod/collation will be set from the domain's base type,
1068
+ * not the domain itself. This is because we shouldn't consider the value
1069
+ * to be a member of the domain if we haven't yet checked its constraints.
1070
+ */
1071
+ typedef struct CoerceToDomainValue
1072
+ {
1073
+ Expr xpr;
1074
+ Oid typeId; /* type for substituted value */
1075
+ int32 typeMod; /* typemod for substituted value */
1076
+ Oid collation; /* collation for the substituted value */
1077
+ int location; /* token location, or -1 if unknown */
1078
+ } CoerceToDomainValue;
1079
+
1080
+ /*
1081
+ * Placeholder node for a DEFAULT marker in an INSERT or UPDATE command.
1082
+ *
1083
+ * This is not an executable expression: it must be replaced by the actual
1084
+ * column default expression during rewriting. But it is convenient to
1085
+ * treat it as an expression node during parsing and rewriting.
1086
+ */
1087
+ typedef struct SetToDefault
1088
+ {
1089
+ Expr xpr;
1090
+ Oid typeId; /* type for substituted value */
1091
+ int32 typeMod; /* typemod for substituted value */
1092
+ Oid collation; /* collation for the substituted value */
1093
+ int location; /* token location, or -1 if unknown */
1094
+ } SetToDefault;
1095
+
1096
+ /*
1097
+ * Node representing [WHERE] CURRENT OF cursor_name
1098
+ *
1099
+ * CURRENT OF is a bit like a Var, in that it carries the rangetable index
1100
+ * of the target relation being constrained; this aids placing the expression
1101
+ * correctly during planning. We can assume however that its "levelsup" is
1102
+ * always zero, due to the syntactic constraints on where it can appear.
1103
+ *
1104
+ * The referenced cursor can be represented either as a hardwired string
1105
+ * or as a reference to a run-time parameter of type REFCURSOR. The latter
1106
+ * case is for the convenience of plpgsql.
1107
+ */
1108
+ typedef struct CurrentOfExpr
1109
+ {
1110
+ Expr xpr;
1111
+ Index cvarno; /* RT index of target relation */
1112
+ char *cursor_name; /* name of referenced cursor, or NULL */
1113
+ int cursor_param; /* refcursor parameter number, or 0 */
1114
+ } CurrentOfExpr;
1115
+
1116
+ /*--------------------
1117
+ * TargetEntry -
1118
+ * a target entry (used in query target lists)
1119
+ *
1120
+ * Strictly speaking, a TargetEntry isn't an expression node (since it can't
1121
+ * be evaluated by ExecEvalExpr). But we treat it as one anyway, since in
1122
+ * very many places it's convenient to process a whole query targetlist as a
1123
+ * single expression tree.
1124
+ *
1125
+ * In a SELECT's targetlist, resno should always be equal to the item's
1126
+ * ordinal position (counting from 1). However, in an INSERT or UPDATE
1127
+ * targetlist, resno represents the attribute number of the destination
1128
+ * column for the item; so there may be missing or out-of-order resnos.
1129
+ * It is even legal to have duplicated resnos; consider
1130
+ * UPDATE table SET arraycol[1] = ..., arraycol[2] = ..., ...
1131
+ * The two meanings come together in the executor, because the planner
1132
+ * transforms INSERT/UPDATE tlists into a normalized form with exactly
1133
+ * one entry for each column of the destination table. Before that's
1134
+ * happened, however, it is risky to assume that resno == position.
1135
+ * Generally get_tle_by_resno() should be used rather than list_nth()
1136
+ * to fetch tlist entries by resno, and only in SELECT should you assume
1137
+ * that resno is a unique identifier.
1138
+ *
1139
+ * resname is required to represent the correct column name in non-resjunk
1140
+ * entries of top-level SELECT targetlists, since it will be used as the
1141
+ * column title sent to the frontend. In most other contexts it is only
1142
+ * a debugging aid, and may be wrong or even NULL. (In particular, it may
1143
+ * be wrong in a tlist from a stored rule, if the referenced column has been
1144
+ * renamed by ALTER TABLE since the rule was made. Also, the planner tends
1145
+ * to store NULL rather than look up a valid name for tlist entries in
1146
+ * non-toplevel plan nodes.) In resjunk entries, resname should be either
1147
+ * a specific system-generated name (such as "ctid") or NULL; anything else
1148
+ * risks confusing ExecGetJunkAttribute!
1149
+ *
1150
+ * ressortgroupref is used in the representation of ORDER BY, GROUP BY, and
1151
+ * DISTINCT items. Targetlist entries with ressortgroupref=0 are not
1152
+ * sort/group items. If ressortgroupref>0, then this item is an ORDER BY,
1153
+ * GROUP BY, and/or DISTINCT target value. No two entries in a targetlist
1154
+ * may have the same nonzero ressortgroupref --- but there is no particular
1155
+ * meaning to the nonzero values, except as tags. (For example, one must
1156
+ * not assume that lower ressortgroupref means a more significant sort key.)
1157
+ * The order of the associated SortGroupClause lists determine the semantics.
1158
+ *
1159
+ * resorigtbl/resorigcol identify the source of the column, if it is a
1160
+ * simple reference to a column of a base table (or view). If it is not
1161
+ * a simple reference, these fields are zeroes.
1162
+ *
1163
+ * If resjunk is true then the column is a working column (such as a sort key)
1164
+ * that should be removed from the final output of the query. Resjunk columns
1165
+ * must have resnos that cannot duplicate any regular column's resno. Also
1166
+ * note that there are places that assume resjunk columns come after non-junk
1167
+ * columns.
1168
+ *--------------------
1169
+ */
1170
+ typedef struct TargetEntry
1171
+ {
1172
+ Expr xpr;
1173
+ Expr *expr; /* expression to evaluate */
1174
+ AttrNumber resno; /* attribute number (see notes above) */
1175
+ char *resname; /* name of the column (could be NULL) */
1176
+ Index ressortgroupref;/* nonzero if referenced by a sort/group
1177
+ * clause */
1178
+ Oid resorigtbl; /* OID of column's source table */
1179
+ AttrNumber resorigcol; /* column's number in source table */
1180
+ bool resjunk; /* set to true to eliminate the attribute from
1181
+ * final target list */
1182
+ } TargetEntry;
1183
+
1184
+
1185
+ /* ----------------------------------------------------------------
1186
+ * node types for join trees
1187
+ *
1188
+ * The leaves of a join tree structure are RangeTblRef nodes. Above
1189
+ * these, JoinExpr nodes can appear to denote a specific kind of join
1190
+ * or qualified join. Also, FromExpr nodes can appear to denote an
1191
+ * ordinary cross-product join ("FROM foo, bar, baz WHERE ...").
1192
+ * FromExpr is like a JoinExpr of jointype JOIN_INNER, except that it
1193
+ * may have any number of child nodes, not just two.
1194
+ *
1195
+ * NOTE: the top level of a Query's jointree is always a FromExpr.
1196
+ * Even if the jointree contains no rels, there will be a FromExpr.
1197
+ *
1198
+ * NOTE: the qualification expressions present in JoinExpr nodes are
1199
+ * *in addition to* the query's main WHERE clause, which appears as the
1200
+ * qual of the top-level FromExpr. The reason for associating quals with
1201
+ * specific nodes in the jointree is that the position of a qual is critical
1202
+ * when outer joins are present. (If we enforce a qual too soon or too late,
1203
+ * that may cause the outer join to produce the wrong set of NULL-extended
1204
+ * rows.) If all joins are inner joins then all the qual positions are
1205
+ * semantically interchangeable.
1206
+ *
1207
+ * NOTE: in the raw output of gram.y, a join tree contains RangeVar,
1208
+ * RangeSubselect, and RangeFunction nodes, which are all replaced by
1209
+ * RangeTblRef nodes during the parse analysis phase. Also, the top-level
1210
+ * FromExpr is added during parse analysis; the grammar regards FROM and
1211
+ * WHERE as separate.
1212
+ * ----------------------------------------------------------------
1213
+ */
1214
+
1215
+ /*
1216
+ * RangeTblRef - reference to an entry in the query's rangetable
1217
+ *
1218
+ * We could use direct pointers to the RT entries and skip having these
1219
+ * nodes, but multiple pointers to the same node in a querytree cause
1220
+ * lots of headaches, so it seems better to store an index into the RT.
1221
+ */
1222
+ typedef struct RangeTblRef
1223
+ {
1224
+ NodeTag type;
1225
+ int rtindex;
1226
+ } RangeTblRef;
1227
+
1228
+ /*----------
1229
+ * JoinExpr - for SQL JOIN expressions
1230
+ *
1231
+ * isNatural, usingClause, and quals are interdependent. The user can write
1232
+ * only one of NATURAL, USING(), or ON() (this is enforced by the grammar).
1233
+ * If he writes NATURAL then parse analysis generates the equivalent USING()
1234
+ * list, and from that fills in "quals" with the right equality comparisons.
1235
+ * If he writes USING() then "quals" is filled with equality comparisons.
1236
+ * If he writes ON() then only "quals" is set. Note that NATURAL/USING
1237
+ * are not equivalent to ON() since they also affect the output column list.
1238
+ *
1239
+ * alias is an Alias node representing the AS alias-clause attached to the
1240
+ * join expression, or NULL if no clause. NB: presence or absence of the
1241
+ * alias has a critical impact on semantics, because a join with an alias
1242
+ * restricts visibility of the tables/columns inside it.
1243
+ *
1244
+ * During parse analysis, an RTE is created for the Join, and its index
1245
+ * is filled into rtindex. This RTE is present mainly so that Vars can
1246
+ * be created that refer to the outputs of the join. The planner sometimes
1247
+ * generates JoinExprs internally; these can have rtindex = 0 if there are
1248
+ * no join alias variables referencing such joins.
1249
+ *----------
1250
+ */
1251
+ typedef struct JoinExpr
1252
+ {
1253
+ NodeTag type;
1254
+ JoinType jointype; /* type of join */
1255
+ bool isNatural; /* Natural join? Will need to shape table */
1256
+ Node *larg; /* left subtree */
1257
+ Node *rarg; /* right subtree */
1258
+ List *usingClause; /* USING clause, if any (list of String) */
1259
+ Node *quals; /* qualifiers on join, if any */
1260
+ Alias *alias; /* user-written alias clause, if any */
1261
+ int rtindex; /* RT index assigned for join, or 0 */
1262
+ } JoinExpr;
1263
+
1264
+ /*----------
1265
+ * FromExpr - represents a FROM ... WHERE ... construct
1266
+ *
1267
+ * This is both more flexible than a JoinExpr (it can have any number of
1268
+ * children, including zero) and less so --- we don't need to deal with
1269
+ * aliases and so on. The output column set is implicitly just the union
1270
+ * of the outputs of the children.
1271
+ *----------
1272
+ */
1273
+ typedef struct FromExpr
1274
+ {
1275
+ NodeTag type;
1276
+ List *fromlist; /* List of join subtrees */
1277
+ Node *quals; /* qualifiers on join, if any */
1278
+ } FromExpr;
1279
+
1280
+ #endif /* PRIMNODES_H */