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,2615 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * parsenodes.h
4
+ * definitions for parse tree nodes
5
+ *
6
+ * Many of the node types used in parsetrees include a "location" field.
7
+ * This is a byte (not character) offset in the original source text, to be
8
+ * used for positioning an error cursor when there is an error related to
9
+ * the node. Access to the original source text is needed to make use of
10
+ * the location.
11
+ *
12
+ *
13
+ * Portions Copyright (c) 2003-2013, PgPool Global Development Group
14
+ * Portions Copyright (c) 1996-2012, PostgreSQL Global Development Group
15
+ * Portions Copyright (c) 1994, Regents of the University of California
16
+ *
17
+ * src/include/nodes/parsenodes.h
18
+ *
19
+ *-------------------------------------------------------------------------
20
+ */
21
+ #ifndef PARSENODES_H
22
+ #define PARSENODES_H
23
+
24
+ #include "../pool_type.h"
25
+ #include "primnodes.h"
26
+ #include "value.h"
27
+
28
+ /* include/nodes/bitmapset.h start */
29
+ typedef uint32 bitmapword; /* must be an unsigned type */
30
+
31
+ typedef struct Bitmapset
32
+ {
33
+ int nwords; /* number of words in array */
34
+ bitmapword words[1]; /* really [nwords] */
35
+ } Bitmapset; /* VARIABLE LENGTH STRUCT */
36
+
37
+ extern Bitmapset *bms_copy(const Bitmapset *a);
38
+ /* include/nodes/bitmapset.h end */
39
+
40
+
41
+ /* Possible sources of a Query */
42
+ typedef enum QuerySource
43
+ {
44
+ QSRC_ORIGINAL, /* original parsetree (explicit query) */
45
+ QSRC_PARSER, /* added by parse analysis (now unused) */
46
+ QSRC_INSTEAD_RULE, /* added by unconditional INSTEAD rule */
47
+ QSRC_QUAL_INSTEAD_RULE, /* added by conditional INSTEAD rule */
48
+ QSRC_NON_INSTEAD_RULE /* added by non-INSTEAD rule */
49
+ } QuerySource;
50
+
51
+ /* Sort ordering options for ORDER BY and CREATE INDEX */
52
+ typedef enum SortByDir
53
+ {
54
+ SORTBY_DEFAULT,
55
+ SORTBY_ASC,
56
+ SORTBY_DESC,
57
+ SORTBY_USING /* not allowed in CREATE INDEX ... */
58
+ } SortByDir;
59
+
60
+ typedef enum SortByNulls
61
+ {
62
+ SORTBY_NULLS_DEFAULT,
63
+ SORTBY_NULLS_FIRST,
64
+ SORTBY_NULLS_LAST
65
+ } SortByNulls;
66
+
67
+ /*
68
+ * Grantable rights are encoded so that we can OR them together in a bitmask.
69
+ * The present representation of AclItem limits us to 16 distinct rights,
70
+ * even though AclMode is defined as uint32. See utils/acl.h.
71
+ *
72
+ * Caution: changing these codes breaks stored ACLs, hence forces initdb.
73
+ */
74
+ typedef uint32 AclMode; /* a bitmask of privilege bits */
75
+
76
+ #define ACL_INSERT (1<<0) /* for relations */
77
+ #define ACL_SELECT (1<<1)
78
+ #define ACL_UPDATE (1<<2)
79
+ #define ACL_DELETE (1<<3)
80
+ #define ACL_TRUNCATE (1<<4)
81
+ #define ACL_REFERENCES (1<<5)
82
+ #define ACL_TRIGGER (1<<6)
83
+ #define ACL_EXECUTE (1<<7) /* for functions */
84
+ #define ACL_USAGE (1<<8) /* for languages, namespaces, FDWs, and
85
+ * servers */
86
+ #define ACL_CREATE (1<<9) /* for namespaces and databases */
87
+ #define ACL_CREATE_TEMP (1<<10) /* for databases */
88
+ #define ACL_CONNECT (1<<11) /* for databases */
89
+ #define N_ACL_RIGHTS 12 /* 1 plus the last 1<<x */
90
+ #define ACL_NO_RIGHTS 0
91
+ /* Currently, SELECT ... FOR UPDATE/FOR SHARE requires UPDATE privileges */
92
+ #define ACL_SELECT_FOR_UPDATE ACL_UPDATE
93
+
94
+
95
+ /*****************************************************************************
96
+ * Query Tree
97
+ *****************************************************************************/
98
+
99
+ /*
100
+ * Query -
101
+ * Parse analysis turns all statements into a Query tree
102
+ * for further processing by the rewriter and planner.
103
+ *
104
+ * Utility statements (i.e. non-optimizable statements) have the
105
+ * utilityStmt field set, and the Query itself is mostly dummy.
106
+ * DECLARE CURSOR is a special case: it is represented like a SELECT,
107
+ * but the original DeclareCursorStmt is stored in utilityStmt.
108
+ *
109
+ * Planning converts a Query tree into a Plan tree headed by a PlannedStmt
110
+ * node --- the Query structure is not used by the executor.
111
+ */
112
+ typedef struct Query
113
+ {
114
+ NodeTag type;
115
+
116
+ CmdType commandType; /* select|insert|update|delete|utility */
117
+
118
+ QuerySource querySource; /* where did I come from? */
119
+
120
+ uint32 queryId; /* query identifier (can be set by plugins) */
121
+
122
+ bool canSetTag; /* do I set the command result tag? */
123
+
124
+ Node *utilityStmt; /* non-null if this is DECLARE CURSOR or a
125
+ * non-optimizable statement */
126
+
127
+ int resultRelation; /* rtable index of target relation for
128
+ * INSERT/UPDATE/DELETE; 0 for SELECT */
129
+
130
+ bool hasAggs; /* has aggregates in tlist or havingQual */
131
+ bool hasWindowFuncs; /* has window functions in tlist */
132
+ bool hasSubLinks; /* has subquery SubLink */
133
+ bool hasDistinctOn; /* distinctClause is from DISTINCT ON */
134
+ bool hasRecursive; /* WITH RECURSIVE was specified */
135
+ bool hasModifyingCTE; /* has INSERT/UPDATE/DELETE in WITH */
136
+ bool hasForUpdate; /* FOR UPDATE or FOR SHARE was specified */
137
+
138
+ List *cteList; /* WITH list (of CommonTableExpr's) */
139
+
140
+ List *rtable; /* list of range table entries */
141
+ FromExpr *jointree; /* table join tree (FROM and WHERE clauses) */
142
+
143
+ List *targetList; /* target list (of TargetEntry) */
144
+
145
+ List *returningList; /* return-values list (of TargetEntry) */
146
+
147
+ List *groupClause; /* a list of SortGroupClause's */
148
+
149
+ Node *havingQual; /* qualifications applied to groups */
150
+
151
+ List *windowClause; /* a list of WindowClause's */
152
+
153
+ List *distinctClause; /* a list of SortGroupClause's */
154
+
155
+ List *sortClause; /* a list of SortGroupClause's */
156
+
157
+ Node *limitOffset; /* # of result tuples to skip (int8 expr) */
158
+ Node *limitCount; /* # of result tuples to return (int8 expr) */
159
+
160
+ List *rowMarks; /* a list of RowMarkClause's */
161
+
162
+ Node *setOperations; /* set-operation tree if this is top level of
163
+ * a UNION/INTERSECT/EXCEPT query */
164
+
165
+ List *constraintDeps; /* a list of pg_constraint OIDs that the query
166
+ * depends on to be semantically valid */
167
+ } Query;
168
+
169
+
170
+ /****************************************************************************
171
+ * Supporting data structures for Parse Trees
172
+ *
173
+ * Most of these node types appear in raw parsetrees output by the grammar,
174
+ * and get transformed to something else by the analyzer. A few of them
175
+ * are used as-is in transformed querytrees.
176
+ ****************************************************************************/
177
+
178
+ /*
179
+ * TypeName - specifies a type in definitions
180
+ *
181
+ * For TypeName structures generated internally, it is often easier to
182
+ * specify the type by OID than by name. If "names" is NIL then the
183
+ * actual type OID is given by typeOid, otherwise typeOid is unused.
184
+ * Similarly, if "typmods" is NIL then the actual typmod is expected to
185
+ * be prespecified in typemod, otherwise typemod is unused.
186
+ *
187
+ * If pct_type is TRUE, then names is actually a field name and we look up
188
+ * the type of that field. Otherwise (the normal case), names is a type
189
+ * name possibly qualified with schema and database name.
190
+ */
191
+ typedef struct TypeName
192
+ {
193
+ NodeTag type;
194
+ List *names; /* qualified name (list of Value strings) */
195
+ Oid typeOid; /* type identified by OID */
196
+ bool setof; /* is a set? */
197
+ bool pct_type; /* %TYPE specified? */
198
+ List *typmods; /* type modifier expression(s) */
199
+ int32 typemod; /* prespecified type modifier */
200
+ List *arrayBounds; /* array bounds */
201
+ int location; /* token location, or -1 if unknown */
202
+ } TypeName;
203
+
204
+ /*
205
+ * ColumnRef - specifies a reference to a column, or possibly a whole tuple
206
+ *
207
+ * The "fields" list must be nonempty. It can contain string Value nodes
208
+ * (representing names) and A_Star nodes (representing occurrence of a '*').
209
+ * Currently, A_Star must appear only as the last list element --- the grammar
210
+ * is responsible for enforcing this!
211
+ *
212
+ * Note: any array subscripting or selection of fields from composite columns
213
+ * is represented by an A_Indirection node above the ColumnRef. However,
214
+ * for simplicity in the normal case, initial field selection from a table
215
+ * name is represented within ColumnRef and not by adding A_Indirection.
216
+ */
217
+ typedef struct ColumnRef
218
+ {
219
+ NodeTag type;
220
+ List *fields; /* field names (Value strings) or A_Star */
221
+ int location; /* token location, or -1 if unknown */
222
+ } ColumnRef;
223
+
224
+ /*
225
+ * ParamRef - specifies a $n parameter reference
226
+ */
227
+ typedef struct ParamRef
228
+ {
229
+ NodeTag type;
230
+ int number; /* the number of the parameter */
231
+ int location; /* token location, or -1 if unknown */
232
+ } ParamRef;
233
+
234
+ /*
235
+ * A_Expr - infix, prefix, and postfix expressions
236
+ */
237
+ typedef enum A_Expr_Kind
238
+ {
239
+ AEXPR_OP, /* normal operator */
240
+ AEXPR_AND, /* booleans - name field is unused */
241
+ AEXPR_OR,
242
+ AEXPR_NOT,
243
+ AEXPR_OP_ANY, /* scalar op ANY (array) */
244
+ AEXPR_OP_ALL, /* scalar op ALL (array) */
245
+ AEXPR_DISTINCT, /* IS DISTINCT FROM - name must be "=" */
246
+ AEXPR_NULLIF, /* NULLIF - name must be "=" */
247
+ AEXPR_OF, /* IS [NOT] OF - name must be "=" or "<>" */
248
+ AEXPR_IN /* [NOT] IN - name must be "=" or "<>" */
249
+ } A_Expr_Kind;
250
+
251
+ typedef struct A_Expr
252
+ {
253
+ NodeTag type;
254
+ A_Expr_Kind kind; /* see above */
255
+ List *name; /* possibly-qualified name of operator */
256
+ Node *lexpr; /* left argument, or NULL if none */
257
+ Node *rexpr; /* right argument, or NULL if none */
258
+ int location; /* token location, or -1 if unknown */
259
+ } A_Expr;
260
+
261
+ /*
262
+ * A_Const - a literal constant
263
+ */
264
+ typedef struct A_Const
265
+ {
266
+ NodeTag type;
267
+ Value val; /* value (includes type info, see value.h) */
268
+ int location; /* token location, or -1 if unknown */
269
+ } A_Const;
270
+
271
+ /*
272
+ * TypeCast - a CAST expression
273
+ */
274
+ typedef struct TypeCast
275
+ {
276
+ NodeTag type;
277
+ Node *arg; /* the expression being casted */
278
+ TypeName *typeName; /* the target type */
279
+ int location; /* token location, or -1 if unknown */
280
+ } TypeCast;
281
+
282
+ /*
283
+ * CollateClause - a COLLATE expression
284
+ */
285
+ typedef struct CollateClause
286
+ {
287
+ NodeTag type;
288
+ Node *arg; /* input expression */
289
+ List *collname; /* possibly-qualified collation name */
290
+ int location; /* token location, or -1 if unknown */
291
+ } CollateClause;
292
+
293
+ /*
294
+ * FuncCall - a function or aggregate invocation
295
+ *
296
+ * agg_order (if not NIL) indicates we saw 'foo(... ORDER BY ...)'.
297
+ * agg_star indicates we saw a 'foo(*)' construct, while agg_distinct
298
+ * indicates we saw 'foo(DISTINCT ...)'. In any of these cases, the
299
+ * construct *must* be an aggregate call. Otherwise, it might be either an
300
+ * aggregate or some other kind of function. However, if OVER is present
301
+ * it had better be an aggregate or window function.
302
+ */
303
+ typedef struct FuncCall
304
+ {
305
+ NodeTag type;
306
+ List *funcname; /* qualified name of function */
307
+ List *args; /* the arguments (list of exprs) */
308
+ List *agg_order; /* ORDER BY (list of SortBy) */
309
+ bool agg_star; /* argument was really '*' */
310
+ bool agg_distinct; /* arguments were labeled DISTINCT */
311
+ bool func_variadic; /* last argument was labeled VARIADIC */
312
+ struct WindowDef *over; /* OVER clause, if any */
313
+ int location; /* token location, or -1 if unknown */
314
+ } FuncCall;
315
+
316
+ /*
317
+ * A_Star - '*' representing all columns of a table or compound field
318
+ *
319
+ * This can appear within ColumnRef.fields, A_Indirection.indirection, and
320
+ * ResTarget.indirection lists.
321
+ */
322
+ typedef struct A_Star
323
+ {
324
+ NodeTag type;
325
+ } A_Star;
326
+
327
+ /*
328
+ * A_Indices - array subscript or slice bounds ([lidx:uidx] or [uidx])
329
+ */
330
+ typedef struct A_Indices
331
+ {
332
+ NodeTag type;
333
+ Node *lidx; /* NULL if it's a single subscript */
334
+ Node *uidx;
335
+ } A_Indices;
336
+
337
+ /*
338
+ * A_Indirection - select a field and/or array element from an expression
339
+ *
340
+ * The indirection list can contain A_Indices nodes (representing
341
+ * subscripting), string Value nodes (representing field selection --- the
342
+ * string value is the name of the field to select), and A_Star nodes
343
+ * (representing selection of all fields of a composite type).
344
+ * For example, a complex selection operation like
345
+ * (foo).field1[42][7].field2
346
+ * would be represented with a single A_Indirection node having a 4-element
347
+ * indirection list.
348
+ *
349
+ * Currently, A_Star must appear only as the last list element --- the grammar
350
+ * is responsible for enforcing this!
351
+ */
352
+ typedef struct A_Indirection
353
+ {
354
+ NodeTag type;
355
+ Node *arg; /* the thing being selected from */
356
+ List *indirection; /* subscripts and/or field names and/or * */
357
+ } A_Indirection;
358
+
359
+ /*
360
+ * A_ArrayExpr - an ARRAY[] construct
361
+ */
362
+ typedef struct A_ArrayExpr
363
+ {
364
+ NodeTag type;
365
+ List *elements; /* array element expressions */
366
+ int location; /* token location, or -1 if unknown */
367
+ } A_ArrayExpr;
368
+
369
+ /*
370
+ * ResTarget -
371
+ * result target (used in target list of pre-transformed parse trees)
372
+ *
373
+ * In a SELECT target list, 'name' is the column label from an
374
+ * 'AS ColumnLabel' clause, or NULL if there was none, and 'val' is the
375
+ * value expression itself. The 'indirection' field is not used.
376
+ *
377
+ * INSERT uses ResTarget in its target-column-names list. Here, 'name' is
378
+ * the name of the destination column, 'indirection' stores any subscripts
379
+ * attached to the destination, and 'val' is not used.
380
+ *
381
+ * In an UPDATE target list, 'name' is the name of the destination column,
382
+ * 'indirection' stores any subscripts attached to the destination, and
383
+ * 'val' is the expression to assign.
384
+ *
385
+ * See A_Indirection for more info about what can appear in 'indirection'.
386
+ */
387
+ typedef struct ResTarget
388
+ {
389
+ NodeTag type;
390
+ char *name; /* column name or NULL */
391
+ List *indirection; /* subscripts, field names, and '*', or NIL */
392
+ Node *val; /* the value expression to compute or assign */
393
+ int location; /* token location, or -1 if unknown */
394
+ } ResTarget;
395
+
396
+ /*
397
+ * SortBy - for ORDER BY clause
398
+ */
399
+ typedef struct SortBy
400
+ {
401
+ NodeTag type;
402
+ Node *node; /* expression to sort on */
403
+ SortByDir sortby_dir; /* ASC/DESC/USING/default */
404
+ SortByNulls sortby_nulls; /* NULLS FIRST/LAST */
405
+ List *useOp; /* name of op to use, if SORTBY_USING */
406
+ int location; /* operator location, or -1 if none/unknown */
407
+ } SortBy;
408
+
409
+ /*
410
+ * WindowDef - raw representation of WINDOW and OVER clauses
411
+ *
412
+ * For entries in a WINDOW list, "name" is the window name being defined.
413
+ * For OVER clauses, we use "name" for the "OVER window" syntax, or "refname"
414
+ * for the "OVER (window)" syntax, which is subtly different --- the latter
415
+ * implies overriding the window frame clause.
416
+ */
417
+ typedef struct WindowDef
418
+ {
419
+ NodeTag type;
420
+ char *name; /* window's own name */
421
+ char *refname; /* referenced window name, if any */
422
+ List *partitionClause; /* PARTITION BY expression list */
423
+ List *orderClause; /* ORDER BY (list of SortBy) */
424
+ int frameOptions; /* frame_clause options, see below */
425
+ Node *startOffset; /* expression for starting bound, if any */
426
+ Node *endOffset; /* expression for ending bound, if any */
427
+ int location; /* parse location, or -1 if none/unknown */
428
+ } WindowDef;
429
+
430
+ /*
431
+ * frameOptions is an OR of these bits. The NONDEFAULT and BETWEEN bits are
432
+ * used so that ruleutils.c can tell which properties were specified and
433
+ * which were defaulted; the correct behavioral bits must be set either way.
434
+ * The START_foo and END_foo options must come in pairs of adjacent bits for
435
+ * the convenience of gram.y, even though some of them are useless/invalid.
436
+ * We will need more bits (and fields) to cover the full SQL:2008 option set.
437
+ */
438
+ #define FRAMEOPTION_NONDEFAULT 0x00001 /* any specified? */
439
+ #define FRAMEOPTION_RANGE 0x00002 /* RANGE behavior */
440
+ #define FRAMEOPTION_ROWS 0x00004 /* ROWS behavior */
441
+ #define FRAMEOPTION_BETWEEN 0x00008 /* BETWEEN given? */
442
+ #define FRAMEOPTION_START_UNBOUNDED_PRECEDING 0x00010 /* start is U. P. */
443
+ #define FRAMEOPTION_END_UNBOUNDED_PRECEDING 0x00020 /* (disallowed) */
444
+ #define FRAMEOPTION_START_UNBOUNDED_FOLLOWING 0x00040 /* (disallowed) */
445
+ #define FRAMEOPTION_END_UNBOUNDED_FOLLOWING 0x00080 /* end is U. F. */
446
+ #define FRAMEOPTION_START_CURRENT_ROW 0x00100 /* start is C. R. */
447
+ #define FRAMEOPTION_END_CURRENT_ROW 0x00200 /* end is C. R. */
448
+ #define FRAMEOPTION_START_VALUE_PRECEDING 0x00400 /* start is V. P. */
449
+ #define FRAMEOPTION_END_VALUE_PRECEDING 0x00800 /* end is V. P. */
450
+ #define FRAMEOPTION_START_VALUE_FOLLOWING 0x01000 /* start is V. F. */
451
+ #define FRAMEOPTION_END_VALUE_FOLLOWING 0x02000 /* end is V. F. */
452
+
453
+ #define FRAMEOPTION_START_VALUE \
454
+ (FRAMEOPTION_START_VALUE_PRECEDING | FRAMEOPTION_START_VALUE_FOLLOWING)
455
+ #define FRAMEOPTION_END_VALUE \
456
+ (FRAMEOPTION_END_VALUE_PRECEDING | FRAMEOPTION_END_VALUE_FOLLOWING)
457
+
458
+ #define FRAMEOPTION_DEFAULTS \
459
+ (FRAMEOPTION_RANGE | FRAMEOPTION_START_UNBOUNDED_PRECEDING | \
460
+ FRAMEOPTION_END_CURRENT_ROW)
461
+
462
+ /*
463
+ * RangeSubselect - subquery appearing in a FROM clause
464
+ */
465
+ typedef struct RangeSubselect
466
+ {
467
+ NodeTag type;
468
+ Node *subquery; /* the untransformed sub-select clause */
469
+ Alias *alias; /* table alias & optional column aliases */
470
+ } RangeSubselect;
471
+
472
+ /*
473
+ * RangeFunction - function call appearing in a FROM clause
474
+ */
475
+ typedef struct RangeFunction
476
+ {
477
+ NodeTag type;
478
+ Node *funccallnode; /* untransformed function call tree */
479
+ Alias *alias; /* table alias & optional column aliases */
480
+ List *coldeflist; /* list of ColumnDef nodes to describe result
481
+ * of function returning RECORD */
482
+ } RangeFunction;
483
+
484
+ /*
485
+ * ColumnDef - column definition (used in various creates)
486
+ *
487
+ * If the column has a default value, we may have the value expression
488
+ * in either "raw" form (an untransformed parse tree) or "cooked" form
489
+ * (a post-parse-analysis, executable expression tree), depending on
490
+ * how this ColumnDef node was created (by parsing, or by inheritance
491
+ * from an existing relation). We should never have both in the same node!
492
+ *
493
+ * Similarly, we may have a COLLATE specification in either raw form
494
+ * (represented as a CollateClause with arg==NULL) or cooked form
495
+ * (the collation's OID).
496
+ *
497
+ * The constraints list may contain a CONSTR_DEFAULT item in a raw
498
+ * parsetree produced by gram.y, but transformCreateStmt will remove
499
+ * the item and set raw_default instead. CONSTR_DEFAULT items
500
+ * should not appear in any subsequent processing.
501
+ */
502
+ typedef struct ColumnDef
503
+ {
504
+ NodeTag type;
505
+ char *colname; /* name of column */
506
+ TypeName *typeName; /* type of column */
507
+ int inhcount; /* number of times column is inherited */
508
+ bool is_local; /* column has local (non-inherited) def'n */
509
+ bool is_not_null; /* NOT NULL constraint specified? */
510
+ bool is_from_type; /* column definition came from table type */
511
+ char storage; /* attstorage setting, or 0 for default */
512
+ Node *raw_default; /* default value (untransformed parse tree) */
513
+ Node *cooked_default; /* default value (transformed expr tree) */
514
+ CollateClause *collClause; /* untransformed COLLATE spec, if any */
515
+ Oid collOid; /* collation OID (InvalidOid if not set) */
516
+ List *constraints; /* other constraints on column */
517
+ List *fdwoptions; /* per-column FDW options */
518
+ } ColumnDef;
519
+
520
+ /*
521
+ * TableLikeClause - CREATE TABLE ( ... LIKE ... ) clause
522
+ */
523
+ typedef struct TableLikeClause
524
+ {
525
+ NodeTag type;
526
+ RangeVar *relation;
527
+ bits32 options; /* OR of TableLikeOption flags */
528
+ } TableLikeClause;
529
+
530
+ typedef enum TableLikeOption
531
+ {
532
+ CREATE_TABLE_LIKE_DEFAULTS = 1 << 0,
533
+ CREATE_TABLE_LIKE_CONSTRAINTS = 1 << 1,
534
+ CREATE_TABLE_LIKE_INDEXES = 1 << 2,
535
+ CREATE_TABLE_LIKE_STORAGE = 1 << 3,
536
+ CREATE_TABLE_LIKE_COMMENTS = 1 << 4,
537
+ CREATE_TABLE_LIKE_ALL = 0x7FFFFFFF
538
+ } TableLikeOption;
539
+
540
+ /*
541
+ * IndexElem - index parameters (used in CREATE INDEX)
542
+ *
543
+ * For a plain index attribute, 'name' is the name of the table column to
544
+ * index, and 'expr' is NULL. For an index expression, 'name' is NULL and
545
+ * 'expr' is the expression tree.
546
+ */
547
+ typedef struct IndexElem
548
+ {
549
+ NodeTag type;
550
+ char *name; /* name of attribute to index, or NULL */
551
+ Node *expr; /* expression to index, or NULL */
552
+ char *indexcolname; /* name for index column; NULL = default */
553
+ List *collation; /* name of collation; NIL = default */
554
+ List *opclass; /* name of desired opclass; NIL = default */
555
+ SortByDir ordering; /* ASC/DESC/default */
556
+ SortByNulls nulls_ordering; /* FIRST/LAST/default */
557
+ } IndexElem;
558
+
559
+ /*
560
+ * DefElem - a generic "name = value" option definition
561
+ *
562
+ * In some contexts the name can be qualified. Also, certain SQL commands
563
+ * allow a SET/ADD/DROP action to be attached to option settings, so it's
564
+ * convenient to carry a field for that too. (Note: currently, it is our
565
+ * practice that the grammar allows namespace and action only in statements
566
+ * where they are relevant; C code can just ignore those fields in other
567
+ * statements.)
568
+ */
569
+ typedef enum DefElemAction
570
+ {
571
+ DEFELEM_UNSPEC, /* no action given */
572
+ DEFELEM_SET,
573
+ DEFELEM_ADD,
574
+ DEFELEM_DROP
575
+ } DefElemAction;
576
+
577
+ typedef struct DefElem
578
+ {
579
+ NodeTag type;
580
+ char *defnamespace; /* NULL if unqualified name */
581
+ char *defname;
582
+ Node *arg; /* a (Value *) or a (TypeName *) */
583
+ DefElemAction defaction; /* unspecified action, or SET/ADD/DROP */
584
+ } DefElem;
585
+
586
+ /*
587
+ * LockingClause - raw representation of FOR UPDATE/SHARE options
588
+ *
589
+ * Note: lockedRels == NIL means "all relations in query". Otherwise it
590
+ * is a list of RangeVar nodes. (We use RangeVar mainly because it carries
591
+ * a location field --- currently, parse analysis insists on unqualified
592
+ * names in LockingClause.)
593
+ */
594
+ typedef struct LockingClause
595
+ {
596
+ NodeTag type;
597
+ List *lockedRels; /* FOR UPDATE or FOR SHARE relations */
598
+ bool forUpdate; /* true = FOR UPDATE, false = FOR SHARE */
599
+ bool noWait; /* NOWAIT option */
600
+ } LockingClause;
601
+
602
+ /*
603
+ * XMLSERIALIZE (in raw parse tree only)
604
+ */
605
+ typedef struct XmlSerialize
606
+ {
607
+ NodeTag type;
608
+ XmlOptionType xmloption; /* DOCUMENT or CONTENT */
609
+ Node *expr;
610
+ TypeName *typeName;
611
+ int location; /* token location, or -1 if unknown */
612
+ } XmlSerialize;
613
+
614
+
615
+ /****************************************************************************
616
+ * Nodes for a Query tree
617
+ ****************************************************************************/
618
+
619
+ /*--------------------
620
+ * RangeTblEntry -
621
+ * A range table is a List of RangeTblEntry nodes.
622
+ *
623
+ * A range table entry may represent a plain relation, a sub-select in
624
+ * FROM, or the result of a JOIN clause. (Only explicit JOIN syntax
625
+ * produces an RTE, not the implicit join resulting from multiple FROM
626
+ * items. This is because we only need the RTE to deal with SQL features
627
+ * like outer joins and join-output-column aliasing.) Other special
628
+ * RTE types also exist, as indicated by RTEKind.
629
+ *
630
+ * Note that we consider RTE_RELATION to cover anything that has a pg_class
631
+ * entry. relkind distinguishes the sub-cases.
632
+ *
633
+ * alias is an Alias node representing the AS alias-clause attached to the
634
+ * FROM expression, or NULL if no clause.
635
+ *
636
+ * eref is the table reference name and column reference names (either
637
+ * real or aliases). Note that system columns (OID etc) are not included
638
+ * in the column list.
639
+ * eref->aliasname is required to be present, and should generally be used
640
+ * to identify the RTE for error messages etc.
641
+ *
642
+ * In RELATION RTEs, the colnames in both alias and eref are indexed by
643
+ * physical attribute number; this means there must be colname entries for
644
+ * dropped columns. When building an RTE we insert empty strings ("") for
645
+ * dropped columns. Note however that a stored rule may have nonempty
646
+ * colnames for columns dropped since the rule was created (and for that
647
+ * matter the colnames might be out of date due to column renamings).
648
+ * The same comments apply to FUNCTION RTEs when the function's return type
649
+ * is a named composite type.
650
+ *
651
+ * In JOIN RTEs, the colnames in both alias and eref are one-to-one with
652
+ * joinaliasvars entries. A JOIN RTE will omit columns of its inputs when
653
+ * those columns are known to be dropped at parse time. Again, however,
654
+ * a stored rule might contain entries for columns dropped since the rule
655
+ * was created. (This is only possible for columns not actually referenced
656
+ * in the rule.) When loading a stored rule, we replace the joinaliasvars
657
+ * items for any such columns with NULL Consts. (We can't simply delete
658
+ * them from the joinaliasvars list, because that would affect the attnums
659
+ * of Vars referencing the rest of the list.)
660
+ *
661
+ * inh is TRUE for relation references that should be expanded to include
662
+ * inheritance children, if the rel has any. This *must* be FALSE for
663
+ * RTEs other than RTE_RELATION entries.
664
+ *
665
+ * inFromCl marks those range variables that are listed in the FROM clause.
666
+ * It's false for RTEs that are added to a query behind the scenes, such
667
+ * as the NEW and OLD variables for a rule, or the subqueries of a UNION.
668
+ * This flag is not used anymore during parsing, since the parser now uses
669
+ * a separate "namespace" data structure to control visibility, but it is
670
+ * needed by ruleutils.c to determine whether RTEs should be shown in
671
+ * decompiled queries.
672
+ *
673
+ * requiredPerms and checkAsUser specify run-time access permissions
674
+ * checks to be performed at query startup. The user must have *all*
675
+ * of the permissions that are OR'd together in requiredPerms (zero
676
+ * indicates no permissions checking). If checkAsUser is not zero,
677
+ * then do the permissions checks using the access rights of that user,
678
+ * not the current effective user ID. (This allows rules to act as
679
+ * setuid gateways.) Permissions checks only apply to RELATION RTEs.
680
+ *
681
+ * For SELECT/INSERT/UPDATE permissions, if the user doesn't have
682
+ * table-wide permissions then it is sufficient to have the permissions
683
+ * on all columns identified in selectedCols (for SELECT) and/or
684
+ * modifiedCols (for INSERT/UPDATE; we can tell which from the query type).
685
+ * selectedCols and modifiedCols are bitmapsets, which cannot have negative
686
+ * integer members, so we subtract FirstLowInvalidHeapAttributeNumber from
687
+ * column numbers before storing them in these fields. A whole-row Var
688
+ * reference is represented by setting the bit for InvalidAttrNumber.
689
+ *--------------------
690
+ */
691
+ typedef enum RTEKind
692
+ {
693
+ RTE_RELATION, /* ordinary relation reference */
694
+ RTE_SUBQUERY, /* subquery in FROM */
695
+ RTE_JOIN, /* join */
696
+ RTE_FUNCTION, /* function in FROM */
697
+ RTE_VALUES, /* VALUES (<exprlist>), (<exprlist>), ... */
698
+ RTE_CTE /* common table expr (WITH list element) */
699
+ } RTEKind;
700
+
701
+ typedef struct RangeTblEntry
702
+ {
703
+ NodeTag type;
704
+
705
+ RTEKind rtekind; /* see above */
706
+
707
+ /*
708
+ * XXX the fields applicable to only some rte kinds should be merged into
709
+ * a union. I didn't do this yet because the diffs would impact a lot of
710
+ * code that is being actively worked on. FIXME someday.
711
+ */
712
+
713
+ /*
714
+ * Fields valid for a plain relation RTE (else zero):
715
+ */
716
+ Oid relid; /* OID of the relation */
717
+ char relkind; /* relation kind (see pg_class.relkind) */
718
+
719
+ /*
720
+ * Fields valid for a subquery RTE (else NULL):
721
+ */
722
+ Query *subquery; /* the sub-query */
723
+ bool security_barrier; /* subquery from security_barrier view */
724
+
725
+ /*
726
+ * Fields valid for a join RTE (else NULL/zero):
727
+ *
728
+ * joinaliasvars is a list of Vars or COALESCE expressions corresponding
729
+ * to the columns of the join result. An alias Var referencing column K
730
+ * of the join result can be replaced by the K'th element of joinaliasvars
731
+ * --- but to simplify the task of reverse-listing aliases correctly, we
732
+ * do not do that until planning time. In a Query loaded from a stored
733
+ * rule, it is also possible for joinaliasvars items to be NULL Consts,
734
+ * denoting columns dropped since the rule was made.
735
+ */
736
+ JoinType jointype; /* type of join */
737
+ List *joinaliasvars; /* list of alias-var expansions */
738
+
739
+ /*
740
+ * Fields valid for a function RTE (else NULL):
741
+ *
742
+ * If the function returns RECORD, funccoltypes lists the column types
743
+ * declared in the RTE's column type specification, funccoltypmods lists
744
+ * their declared typmods, funccolcollations their collations. Otherwise,
745
+ * those fields are NIL.
746
+ */
747
+ Node *funcexpr; /* expression tree for func call */
748
+ List *funccoltypes; /* OID list of column type OIDs */
749
+ List *funccoltypmods; /* integer list of column typmods */
750
+ List *funccolcollations; /* OID list of column collation OIDs */
751
+
752
+ /*
753
+ * Fields valid for a values RTE (else NIL):
754
+ */
755
+ List *values_lists; /* list of expression lists */
756
+ List *values_collations; /* OID list of column collation OIDs */
757
+
758
+ /*
759
+ * Fields valid for a CTE RTE (else NULL/zero):
760
+ */
761
+ char *ctename; /* name of the WITH list item */
762
+ Index ctelevelsup; /* number of query levels up */
763
+ bool self_reference; /* is this a recursive self-reference? */
764
+ List *ctecoltypes; /* OID list of column type OIDs */
765
+ List *ctecoltypmods; /* integer list of column typmods */
766
+ List *ctecolcollations; /* OID list of column collation OIDs */
767
+
768
+ /*
769
+ * Fields valid in all RTEs:
770
+ */
771
+ Alias *alias; /* user-written alias clause, if any */
772
+ Alias *eref; /* expanded reference names */
773
+ bool inh; /* inheritance requested? */
774
+ bool inFromCl; /* present in FROM clause? */
775
+ AclMode requiredPerms; /* bitmask of required access permissions */
776
+ Oid checkAsUser; /* if valid, check access as this role */
777
+ Bitmapset *selectedCols; /* columns needing SELECT permission */
778
+ Bitmapset *modifiedCols; /* columns needing INSERT/UPDATE permission */
779
+ } RangeTblEntry;
780
+
781
+ /*
782
+ * SortGroupClause -
783
+ * representation of ORDER BY, GROUP BY, PARTITION BY,
784
+ * DISTINCT, DISTINCT ON items
785
+ *
786
+ * You might think that ORDER BY is only interested in defining ordering,
787
+ * and GROUP/DISTINCT are only interested in defining equality. However,
788
+ * one way to implement grouping is to sort and then apply a "uniq"-like
789
+ * filter. So it's also interesting to keep track of possible sort operators
790
+ * for GROUP/DISTINCT, and in particular to try to sort for the grouping
791
+ * in a way that will also yield a requested ORDER BY ordering. So we need
792
+ * to be able to compare ORDER BY and GROUP/DISTINCT lists, which motivates
793
+ * the decision to give them the same representation.
794
+ *
795
+ * tleSortGroupRef must match ressortgroupref of exactly one entry of the
796
+ * query's targetlist; that is the expression to be sorted or grouped by.
797
+ * eqop is the OID of the equality operator.
798
+ * sortop is the OID of the ordering operator (a "<" or ">" operator),
799
+ * or InvalidOid if not available.
800
+ * nulls_first means about what you'd expect. If sortop is InvalidOid
801
+ * then nulls_first is meaningless and should be set to false.
802
+ * hashable is TRUE if eqop is hashable (note this condition also depends
803
+ * on the datatype of the input expression).
804
+ *
805
+ * In an ORDER BY item, all fields must be valid. (The eqop isn't essential
806
+ * here, but it's cheap to get it along with the sortop, and requiring it
807
+ * to be valid eases comparisons to grouping items.) Note that this isn't
808
+ * actually enough information to determine an ordering: if the sortop is
809
+ * collation-sensitive, a collation OID is needed too. We don't store the
810
+ * collation in SortGroupClause because it's not available at the time the
811
+ * parser builds the SortGroupClause; instead, consult the exposed collation
812
+ * of the referenced targetlist expression to find out what it is.
813
+ *
814
+ * In a grouping item, eqop must be valid. If the eqop is a btree equality
815
+ * operator, then sortop should be set to a compatible ordering operator.
816
+ * We prefer to set eqop/sortop/nulls_first to match any ORDER BY item that
817
+ * the query presents for the same tlist item. If there is none, we just
818
+ * use the default ordering op for the datatype.
819
+ *
820
+ * If the tlist item's type has a hash opclass but no btree opclass, then
821
+ * we will set eqop to the hash equality operator, sortop to InvalidOid,
822
+ * and nulls_first to false. A grouping item of this kind can only be
823
+ * implemented by hashing, and of course it'll never match an ORDER BY item.
824
+ *
825
+ * The hashable flag is provided since we generally have the requisite
826
+ * information readily available when the SortGroupClause is constructed,
827
+ * and it's relatively expensive to get it again later. Note there is no
828
+ * need for a "sortable" flag since OidIsValid(sortop) serves the purpose.
829
+ *
830
+ * A query might have both ORDER BY and DISTINCT (or DISTINCT ON) clauses.
831
+ * In SELECT DISTINCT, the distinctClause list is as long or longer than the
832
+ * sortClause list, while in SELECT DISTINCT ON it's typically shorter.
833
+ * The two lists must match up to the end of the shorter one --- the parser
834
+ * rearranges the distinctClause if necessary to make this true. (This
835
+ * restriction ensures that only one sort step is needed to both satisfy the
836
+ * ORDER BY and set up for the Unique step. This is semantically necessary
837
+ * for DISTINCT ON, and presents no real drawback for DISTINCT.)
838
+ */
839
+ typedef struct SortGroupClause
840
+ {
841
+ NodeTag type;
842
+ Index tleSortGroupRef; /* reference into targetlist */
843
+ Oid eqop; /* the equality operator ('=' op) */
844
+ Oid sortop; /* the ordering operator ('<' op), or 0 */
845
+ bool nulls_first; /* do NULLs come before normal values? */
846
+ bool hashable; /* can eqop be implemented by hashing? */
847
+ } SortGroupClause;
848
+
849
+ /*
850
+ * WindowClause -
851
+ * transformed representation of WINDOW and OVER clauses
852
+ *
853
+ * A parsed Query's windowClause list contains these structs. "name" is set
854
+ * if the clause originally came from WINDOW, and is NULL if it originally
855
+ * was an OVER clause (but note that we collapse out duplicate OVERs).
856
+ * partitionClause and orderClause are lists of SortGroupClause structs.
857
+ * winref is an ID number referenced by WindowFunc nodes; it must be unique
858
+ * among the members of a Query's windowClause list.
859
+ * When refname isn't null, the partitionClause is always copied from there;
860
+ * the orderClause might or might not be copied (see copiedOrder); the framing
861
+ * options are never copied, per spec.
862
+ */
863
+ typedef struct WindowClause
864
+ {
865
+ NodeTag type;
866
+ char *name; /* window name (NULL in an OVER clause) */
867
+ char *refname; /* referenced window name, if any */
868
+ List *partitionClause; /* PARTITION BY list */
869
+ List *orderClause; /* ORDER BY list */
870
+ int frameOptions; /* frame_clause options, see WindowDef */
871
+ Node *startOffset; /* expression for starting bound, if any */
872
+ Node *endOffset; /* expression for ending bound, if any */
873
+ Index winref; /* ID referenced by window functions */
874
+ bool copiedOrder; /* did we copy orderClause from refname? */
875
+ } WindowClause;
876
+
877
+ /*
878
+ * RowMarkClause -
879
+ * parser output representation of FOR UPDATE/SHARE clauses
880
+ *
881
+ * Query.rowMarks contains a separate RowMarkClause node for each relation
882
+ * identified as a FOR UPDATE/SHARE target. If FOR UPDATE/SHARE is applied
883
+ * to a subquery, we generate RowMarkClauses for all normal and subquery rels
884
+ * in the subquery, but they are marked pushedDown = true to distinguish them
885
+ * from clauses that were explicitly written at this query level. Also,
886
+ * Query.hasForUpdate tells whether there were explicit FOR UPDATE/SHARE
887
+ * clauses in the current query level.
888
+ */
889
+ typedef struct RowMarkClause
890
+ {
891
+ NodeTag type;
892
+ Index rti; /* range table index of target relation */
893
+ bool forUpdate; /* true = FOR UPDATE, false = FOR SHARE */
894
+ bool noWait; /* NOWAIT option */
895
+ bool pushedDown; /* pushed down from higher query level? */
896
+ } RowMarkClause;
897
+
898
+ /*
899
+ * WithClause -
900
+ * representation of WITH clause
901
+ *
902
+ * Note: WithClause does not propagate into the Query representation;
903
+ * but CommonTableExpr does.
904
+ */
905
+ typedef struct WithClause
906
+ {
907
+ NodeTag type;
908
+ List *ctes; /* list of CommonTableExprs */
909
+ bool recursive; /* true = WITH RECURSIVE */
910
+ int location; /* token location, or -1 if unknown */
911
+ } WithClause;
912
+
913
+ /*
914
+ * CommonTableExpr -
915
+ * representation of WITH list element
916
+ *
917
+ * We don't currently support the SEARCH or CYCLE clause.
918
+ */
919
+ typedef struct CommonTableExpr
920
+ {
921
+ NodeTag type;
922
+ char *ctename; /* query name (never qualified) */
923
+ List *aliascolnames; /* optional list of column names */
924
+ /* SelectStmt/InsertStmt/etc before parse analysis, Query afterwards: */
925
+ Node *ctequery; /* the CTE's subquery */
926
+ int location; /* token location, or -1 if unknown */
927
+ /* These fields are set during parse analysis: */
928
+ bool cterecursive; /* is this CTE actually recursive? */
929
+ int cterefcount; /* number of RTEs referencing this CTE
930
+ * (excluding internal self-references) */
931
+ List *ctecolnames; /* list of output column names */
932
+ List *ctecoltypes; /* OID list of output column type OIDs */
933
+ List *ctecoltypmods; /* integer list of output column typmods */
934
+ List *ctecolcollations; /* OID list of column collation OIDs */
935
+ } CommonTableExpr;
936
+
937
+ /* Convenience macro to get the output tlist of a CTE's query */
938
+ #define GetCTETargetList(cte) \
939
+ (AssertMacro(IsA((cte)->ctequery, Query)), \
940
+ ((Query *) (cte)->ctequery)->commandType == CMD_SELECT ? \
941
+ ((Query *) (cte)->ctequery)->targetList : \
942
+ ((Query *) (cte)->ctequery)->returningList)
943
+
944
+
945
+ /*****************************************************************************
946
+ * Optimizable Statements
947
+ *****************************************************************************/
948
+
949
+ /* ----------------------
950
+ * Insert Statement
951
+ *
952
+ * The source expression is represented by SelectStmt for both the
953
+ * SELECT and VALUES cases. If selectStmt is NULL, then the query
954
+ * is INSERT ... DEFAULT VALUES.
955
+ * ----------------------
956
+ */
957
+ typedef struct InsertStmt
958
+ {
959
+ NodeTag type;
960
+ RangeVar *relation; /* relation to insert into */
961
+ List *cols; /* optional: names of the target columns */
962
+ Node *selectStmt; /* the source SELECT/VALUES, or NULL */
963
+ List *returningList; /* list of expressions to return */
964
+ WithClause *withClause; /* WITH clause */
965
+ } InsertStmt;
966
+
967
+ /* ----------------------
968
+ * Delete Statement
969
+ * ----------------------
970
+ */
971
+ typedef struct DeleteStmt
972
+ {
973
+ NodeTag type;
974
+ RangeVar *relation; /* relation to delete from */
975
+ List *usingClause; /* optional using clause for more tables */
976
+ Node *whereClause; /* qualifications */
977
+ List *returningList; /* list of expressions to return */
978
+ WithClause *withClause; /* WITH clause */
979
+ } DeleteStmt;
980
+
981
+ /* ----------------------
982
+ * Update Statement
983
+ * ----------------------
984
+ */
985
+ typedef struct UpdateStmt
986
+ {
987
+ NodeTag type;
988
+ RangeVar *relation; /* relation to update */
989
+ List *targetList; /* the target list (of ResTarget) */
990
+ Node *whereClause; /* qualifications */
991
+ List *fromClause; /* optional from clause for more tables */
992
+ List *returningList; /* list of expressions to return */
993
+ WithClause *withClause; /* WITH clause */
994
+ } UpdateStmt;
995
+
996
+ /* ----------------------
997
+ * Select Statement
998
+ *
999
+ * A "simple" SELECT is represented in the output of gram.y by a single
1000
+ * SelectStmt node; so is a VALUES construct. A query containing set
1001
+ * operators (UNION, INTERSECT, EXCEPT) is represented by a tree of SelectStmt
1002
+ * nodes, in which the leaf nodes are component SELECTs and the internal nodes
1003
+ * represent UNION, INTERSECT, or EXCEPT operators. Using the same node
1004
+ * type for both leaf and internal nodes allows gram.y to stick ORDER BY,
1005
+ * LIMIT, etc, clause values into a SELECT statement without worrying
1006
+ * whether it is a simple or compound SELECT.
1007
+ * ----------------------
1008
+ */
1009
+ typedef enum SetOperation
1010
+ {
1011
+ SETOP_NONE = 0,
1012
+ SETOP_UNION,
1013
+ SETOP_INTERSECT,
1014
+ SETOP_EXCEPT
1015
+ } SetOperation;
1016
+
1017
+ typedef struct SelectStmt
1018
+ {
1019
+ NodeTag type;
1020
+
1021
+ /*
1022
+ * These fields are used only in "leaf" SelectStmts.
1023
+ */
1024
+ List *distinctClause; /* NULL, list of DISTINCT ON exprs, or
1025
+ * lcons(NIL,NIL) for all (SELECT DISTINCT) */
1026
+ IntoClause *intoClause; /* target for SELECT INTO */
1027
+ List *targetList; /* the target list (of ResTarget) */
1028
+ List *fromClause; /* the FROM clause */
1029
+ Node *whereClause; /* WHERE qualification */
1030
+ List *groupClause; /* GROUP BY clauses */
1031
+ Node *havingClause; /* HAVING conditional-expression */
1032
+ List *windowClause; /* WINDOW window_name AS (...), ... */
1033
+ WithClause *withClause; /* WITH clause */
1034
+
1035
+ /*
1036
+ * In a "leaf" node representing a VALUES list, the above fields are all
1037
+ * null, and instead this field is set. Note that the elements of the
1038
+ * sublists are just expressions, without ResTarget decoration. Also note
1039
+ * that a list element can be DEFAULT (represented as a SetToDefault
1040
+ * node), regardless of the context of the VALUES list. It's up to parse
1041
+ * analysis to reject that where not valid.
1042
+ */
1043
+ List *valuesLists; /* untransformed list of expression lists */
1044
+
1045
+ /*
1046
+ * These fields are used in both "leaf" SelectStmts and upper-level
1047
+ * SelectStmts.
1048
+ */
1049
+ List *sortClause; /* sort clause (a list of SortBy's) */
1050
+ Node *limitOffset; /* # of result tuples to skip */
1051
+ Node *limitCount; /* # of result tuples to return */
1052
+ List *lockingClause; /* FOR UPDATE (list of LockingClause's) */
1053
+
1054
+ /*
1055
+ * These fields are used only in upper-level SelectStmts.
1056
+ */
1057
+ SetOperation op; /* type of set op */
1058
+ bool all; /* ALL specified? */
1059
+ struct SelectStmt *larg; /* left child */
1060
+ struct SelectStmt *rarg; /* right child */
1061
+ /* Eventually add fields for CORRESPONDING spec here */
1062
+ } SelectStmt;
1063
+
1064
+
1065
+ /* ----------------------
1066
+ * Set Operation node for post-analysis query trees
1067
+ *
1068
+ * After parse analysis, a SELECT with set operations is represented by a
1069
+ * top-level Query node containing the leaf SELECTs as subqueries in its
1070
+ * range table. Its setOperations field shows the tree of set operations,
1071
+ * with leaf SelectStmt nodes replaced by RangeTblRef nodes, and internal
1072
+ * nodes replaced by SetOperationStmt nodes. Information about the output
1073
+ * column types is added, too. (Note that the child nodes do not necessarily
1074
+ * produce these types directly, but we've checked that their output types
1075
+ * can be coerced to the output column type.) Also, if it's not UNION ALL,
1076
+ * information about the types' sort/group semantics is provided in the form
1077
+ * of a SortGroupClause list (same representation as, eg, DISTINCT).
1078
+ * The resolved common column collations are provided too; but note that if
1079
+ * it's not UNION ALL, it's okay for a column to not have a common collation,
1080
+ * so a member of the colCollations list could be InvalidOid even though the
1081
+ * column has a collatable type.
1082
+ * ----------------------
1083
+ */
1084
+ typedef struct SetOperationStmt
1085
+ {
1086
+ NodeTag type;
1087
+ SetOperation op; /* type of set op */
1088
+ bool all; /* ALL specified? */
1089
+ Node *larg; /* left child */
1090
+ Node *rarg; /* right child */
1091
+ /* Eventually add fields for CORRESPONDING spec here */
1092
+
1093
+ /* Fields derived during parse analysis: */
1094
+ List *colTypes; /* OID list of output column type OIDs */
1095
+ List *colTypmods; /* integer list of output column typmods */
1096
+ List *colCollations; /* OID list of output column collation OIDs */
1097
+ List *groupClauses; /* a list of SortGroupClause's */
1098
+ /* groupClauses is NIL if UNION ALL, but must be set otherwise */
1099
+ } SetOperationStmt;
1100
+
1101
+
1102
+ /*****************************************************************************
1103
+ * Other Statements (no optimizations required)
1104
+ *
1105
+ * These are not touched by parser/analyze.c except to put them into
1106
+ * the utilityStmt field of a Query. This is eventually passed to
1107
+ * ProcessUtility (by-passing rewriting and planning). Some of the
1108
+ * statements do need attention from parse analysis, and this is
1109
+ * done by routines in parser/parse_utilcmd.c after ProcessUtility
1110
+ * receives the command for execution.
1111
+ *****************************************************************************/
1112
+
1113
+ /*
1114
+ * When a command can act on several kinds of objects with only one
1115
+ * parse structure required, use these constants to designate the
1116
+ * object type. Note that commands typically don't support all the types.
1117
+ */
1118
+
1119
+ typedef enum ObjectType
1120
+ {
1121
+ OBJECT_AGGREGATE,
1122
+ OBJECT_ATTRIBUTE, /* type's attribute, when distinct from column */
1123
+ OBJECT_CAST,
1124
+ OBJECT_COLUMN,
1125
+ OBJECT_CONSTRAINT,
1126
+ OBJECT_COLLATION,
1127
+ OBJECT_CONVERSION,
1128
+ OBJECT_DATABASE,
1129
+ OBJECT_DOMAIN,
1130
+ OBJECT_EXTENSION,
1131
+ OBJECT_FDW,
1132
+ OBJECT_FOREIGN_SERVER,
1133
+ OBJECT_FOREIGN_TABLE,
1134
+ OBJECT_FUNCTION,
1135
+ OBJECT_INDEX,
1136
+ OBJECT_LANGUAGE,
1137
+ OBJECT_LARGEOBJECT,
1138
+ OBJECT_OPCLASS,
1139
+ OBJECT_OPERATOR,
1140
+ OBJECT_OPFAMILY,
1141
+ OBJECT_ROLE,
1142
+ OBJECT_RULE,
1143
+ OBJECT_SCHEMA,
1144
+ OBJECT_SEQUENCE,
1145
+ OBJECT_TABLE,
1146
+ OBJECT_TABLESPACE,
1147
+ OBJECT_TRIGGER,
1148
+ OBJECT_TSCONFIGURATION,
1149
+ OBJECT_TSDICTIONARY,
1150
+ OBJECT_TSPARSER,
1151
+ OBJECT_TSTEMPLATE,
1152
+ OBJECT_TYPE,
1153
+ OBJECT_VIEW
1154
+ } ObjectType;
1155
+
1156
+ /* ----------------------
1157
+ * Create Schema Statement
1158
+ *
1159
+ * NOTE: the schemaElts list contains raw parsetrees for component statements
1160
+ * of the schema, such as CREATE TABLE, GRANT, etc. These are analyzed and
1161
+ * executed after the schema itself is created.
1162
+ * ----------------------
1163
+ */
1164
+ typedef struct CreateSchemaStmt
1165
+ {
1166
+ NodeTag type;
1167
+ char *schemaname; /* the name of the schema to create */
1168
+ char *authid; /* the owner of the created schema */
1169
+ List *schemaElts; /* schema components (list of parsenodes) */
1170
+ } CreateSchemaStmt;
1171
+
1172
+ typedef enum DropBehavior
1173
+ {
1174
+ DROP_RESTRICT, /* drop fails if any dependent objects */
1175
+ DROP_CASCADE /* remove dependent objects too */
1176
+ } DropBehavior;
1177
+
1178
+ /* ----------------------
1179
+ * Alter Table
1180
+ * ----------------------
1181
+ */
1182
+ typedef struct AlterTableStmt
1183
+ {
1184
+ NodeTag type;
1185
+ RangeVar *relation; /* table to work on */
1186
+ List *cmds; /* list of subcommands */
1187
+ ObjectType relkind; /* type of object */
1188
+ bool missing_ok; /* skip error if table missing */
1189
+ } AlterTableStmt;
1190
+
1191
+ typedef enum AlterTableType
1192
+ {
1193
+ AT_AddColumn, /* add column */
1194
+ AT_AddColumnRecurse, /* internal to commands/tablecmds.c */
1195
+ AT_AddColumnToView, /* implicitly via CREATE OR REPLACE VIEW */
1196
+ AT_ColumnDefault, /* alter column default */
1197
+ AT_DropNotNull, /* alter column drop not null */
1198
+ AT_SetNotNull, /* alter column set not null */
1199
+ AT_SetStatistics, /* alter column set statistics */
1200
+ AT_SetOptions, /* alter column set ( options ) */
1201
+ AT_ResetOptions, /* alter column reset ( options ) */
1202
+ AT_SetStorage, /* alter column set storage */
1203
+ AT_DropColumn, /* drop column */
1204
+ AT_DropColumnRecurse, /* internal to commands/tablecmds.c */
1205
+ AT_AddIndex, /* add index */
1206
+ AT_ReAddIndex, /* internal to commands/tablecmds.c */
1207
+ AT_AddConstraint, /* add constraint */
1208
+ AT_AddConstraintRecurse, /* internal to commands/tablecmds.c */
1209
+ AT_ValidateConstraint, /* validate constraint */
1210
+ AT_ValidateConstraintRecurse, /* internal to commands/tablecmds.c */
1211
+ AT_ProcessedConstraint, /* pre-processed add constraint (local in
1212
+ * parser/parse_utilcmd.c) */
1213
+ AT_AddIndexConstraint, /* add constraint using existing index */
1214
+ AT_DropConstraint, /* drop constraint */
1215
+ AT_DropConstraintRecurse, /* internal to commands/tablecmds.c */
1216
+ AT_AlterColumnType, /* alter column type */
1217
+ AT_AlterColumnGenericOptions, /* alter column OPTIONS (...) */
1218
+ AT_ChangeOwner, /* change owner */
1219
+ AT_ClusterOn, /* CLUSTER ON */
1220
+ AT_DropCluster, /* SET WITHOUT CLUSTER */
1221
+ AT_AddOids, /* SET WITH OIDS */
1222
+ AT_AddOidsRecurse, /* internal to commands/tablecmds.c */
1223
+ AT_DropOids, /* SET WITHOUT OIDS */
1224
+ AT_SetTableSpace, /* SET TABLESPACE */
1225
+ AT_SetRelOptions, /* SET (...) -- AM specific parameters */
1226
+ AT_ResetRelOptions, /* RESET (...) -- AM specific parameters */
1227
+ AT_ReplaceRelOptions, /* replace reloption list in its entirety */
1228
+ AT_EnableTrig, /* ENABLE TRIGGER name */
1229
+ AT_EnableAlwaysTrig, /* ENABLE ALWAYS TRIGGER name */
1230
+ AT_EnableReplicaTrig, /* ENABLE REPLICA TRIGGER name */
1231
+ AT_DisableTrig, /* DISABLE TRIGGER name */
1232
+ AT_EnableTrigAll, /* ENABLE TRIGGER ALL */
1233
+ AT_DisableTrigAll, /* DISABLE TRIGGER ALL */
1234
+ AT_EnableTrigUser, /* ENABLE TRIGGER USER */
1235
+ AT_DisableTrigUser, /* DISABLE TRIGGER USER */
1236
+ AT_EnableRule, /* ENABLE RULE name */
1237
+ AT_EnableAlwaysRule, /* ENABLE ALWAYS RULE name */
1238
+ AT_EnableReplicaRule, /* ENABLE REPLICA RULE name */
1239
+ AT_DisableRule, /* DISABLE RULE name */
1240
+ AT_AddInherit, /* INHERIT parent */
1241
+ AT_DropInherit, /* NO INHERIT parent */
1242
+ AT_AddOf, /* OF <type_name> */
1243
+ AT_DropOf, /* NOT OF */
1244
+ AT_GenericOptions, /* OPTIONS (...) */
1245
+ /* this will be in a more natural position in 9.3: */
1246
+ AT_ReAddConstraint /* internal to commands/tablecmds.c */
1247
+ } AlterTableType;
1248
+
1249
+ typedef struct AlterTableCmd /* one subcommand of an ALTER TABLE */
1250
+ {
1251
+ NodeTag type;
1252
+ AlterTableType subtype; /* Type of table alteration to apply */
1253
+ char *name; /* column, constraint, or trigger to act on,
1254
+ * or new owner or tablespace */
1255
+ Node *def; /* definition of new column, index,
1256
+ * constraint, or parent table */
1257
+ DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */
1258
+ bool missing_ok; /* skip error if missing? */
1259
+ } AlterTableCmd;
1260
+
1261
+
1262
+ /* ----------------------
1263
+ * Alter Domain
1264
+ *
1265
+ * The fields are used in different ways by the different variants of
1266
+ * this command.
1267
+ * ----------------------
1268
+ */
1269
+ typedef struct AlterDomainStmt
1270
+ {
1271
+ NodeTag type;
1272
+ char subtype; /*------------
1273
+ * T = alter column default
1274
+ * N = alter column drop not null
1275
+ * O = alter column set not null
1276
+ * C = add constraint
1277
+ * X = drop constraint
1278
+ *------------
1279
+ */
1280
+ List *typeName; /* domain to work on */
1281
+ char *name; /* column or constraint name to act on */
1282
+ Node *def; /* definition of default or constraint */
1283
+ DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */
1284
+ bool missing_ok; /* skip error if missing? */
1285
+ } AlterDomainStmt;
1286
+
1287
+
1288
+ /* ----------------------
1289
+ * Grant|Revoke Statement
1290
+ * ----------------------
1291
+ */
1292
+ typedef enum GrantTargetType
1293
+ {
1294
+ ACL_TARGET_OBJECT, /* grant on specific named object(s) */
1295
+ ACL_TARGET_ALL_IN_SCHEMA, /* grant on all objects in given schema(s) */
1296
+ ACL_TARGET_DEFAULTS /* ALTER DEFAULT PRIVILEGES */
1297
+ } GrantTargetType;
1298
+
1299
+ typedef enum GrantObjectType
1300
+ {
1301
+ ACL_OBJECT_COLUMN, /* column */
1302
+ ACL_OBJECT_RELATION, /* table, view */
1303
+ ACL_OBJECT_SEQUENCE, /* sequence */
1304
+ ACL_OBJECT_DATABASE, /* database */
1305
+ ACL_OBJECT_DOMAIN, /* domain */
1306
+ ACL_OBJECT_FDW, /* foreign-data wrapper */
1307
+ ACL_OBJECT_FOREIGN_SERVER, /* foreign server */
1308
+ ACL_OBJECT_FUNCTION, /* function */
1309
+ ACL_OBJECT_LANGUAGE, /* procedural language */
1310
+ ACL_OBJECT_LARGEOBJECT, /* largeobject */
1311
+ ACL_OBJECT_NAMESPACE, /* namespace */
1312
+ ACL_OBJECT_TABLESPACE, /* tablespace */
1313
+ ACL_OBJECT_TYPE /* type */
1314
+ } GrantObjectType;
1315
+
1316
+ typedef struct GrantStmt
1317
+ {
1318
+ NodeTag type;
1319
+ bool is_grant; /* true = GRANT, false = REVOKE */
1320
+ GrantTargetType targtype; /* type of the grant target */
1321
+ GrantObjectType objtype; /* kind of object being operated on */
1322
+ List *objects; /* list of RangeVar nodes, FuncWithArgs nodes,
1323
+ * or plain names (as Value strings) */
1324
+ List *privileges; /* list of AccessPriv nodes */
1325
+ /* privileges == NIL denotes ALL PRIVILEGES */
1326
+ List *grantees; /* list of PrivGrantee nodes */
1327
+ bool grant_option; /* grant or revoke grant option */
1328
+ DropBehavior behavior; /* drop behavior (for REVOKE) */
1329
+ } GrantStmt;
1330
+
1331
+ typedef struct PrivGrantee
1332
+ {
1333
+ NodeTag type;
1334
+ char *rolname; /* if NULL then PUBLIC */
1335
+ } PrivGrantee;
1336
+
1337
+ /*
1338
+ * Note: FuncWithArgs carries only the types of the input parameters of the
1339
+ * function. So it is sufficient to identify an existing function, but it
1340
+ * is not enough info to define a function nor to call it.
1341
+ */
1342
+ typedef struct FuncWithArgs
1343
+ {
1344
+ NodeTag type;
1345
+ List *funcname; /* qualified name of function */
1346
+ List *funcargs; /* list of Typename nodes */
1347
+ } FuncWithArgs;
1348
+
1349
+ /*
1350
+ * An access privilege, with optional list of column names
1351
+ * priv_name == NULL denotes ALL PRIVILEGES (only used with a column list)
1352
+ * cols == NIL denotes "all columns"
1353
+ * Note that simple "ALL PRIVILEGES" is represented as a NIL list, not
1354
+ * an AccessPriv with both fields null.
1355
+ */
1356
+ typedef struct AccessPriv
1357
+ {
1358
+ NodeTag type;
1359
+ char *priv_name; /* string name of privilege */
1360
+ List *cols; /* list of Value strings */
1361
+ } AccessPriv;
1362
+
1363
+ /* ----------------------
1364
+ * Grant/Revoke Role Statement
1365
+ *
1366
+ * Note: because of the parsing ambiguity with the GRANT <privileges>
1367
+ * statement, granted_roles is a list of AccessPriv; the execution code
1368
+ * should complain if any column lists appear. grantee_roles is a list
1369
+ * of role names, as Value strings.
1370
+ * ----------------------
1371
+ */
1372
+ typedef struct GrantRoleStmt
1373
+ {
1374
+ NodeTag type;
1375
+ List *granted_roles; /* list of roles to be granted/revoked */
1376
+ List *grantee_roles; /* list of member roles to add/delete */
1377
+ bool is_grant; /* true = GRANT, false = REVOKE */
1378
+ bool admin_opt; /* with admin option */
1379
+ char *grantor; /* set grantor to other than current role */
1380
+ DropBehavior behavior; /* drop behavior (for REVOKE) */
1381
+ } GrantRoleStmt;
1382
+
1383
+ /* ----------------------
1384
+ * Alter Default Privileges Statement
1385
+ * ----------------------
1386
+ */
1387
+ typedef struct AlterDefaultPrivilegesStmt
1388
+ {
1389
+ NodeTag type;
1390
+ List *options; /* list of DefElem */
1391
+ GrantStmt *action; /* GRANT/REVOKE action (with objects=NIL) */
1392
+ } AlterDefaultPrivilegesStmt;
1393
+
1394
+ /* ----------------------
1395
+ * Copy Statement
1396
+ *
1397
+ * We support "COPY relation FROM file", "COPY relation TO file", and
1398
+ * "COPY (query) TO file". In any given CopyStmt, exactly one of "relation"
1399
+ * and "query" must be non-NULL.
1400
+ * ----------------------
1401
+ */
1402
+ typedef struct CopyStmt
1403
+ {
1404
+ NodeTag type;
1405
+ RangeVar *relation; /* the relation to copy */
1406
+ Node *query; /* the SELECT query to copy */
1407
+ List *attlist; /* List of column names (as Strings), or NIL
1408
+ * for all columns */
1409
+ bool is_from; /* TO or FROM */
1410
+ char *filename; /* filename, or NULL for STDIN/STDOUT */
1411
+ List *options; /* List of DefElem nodes */
1412
+ } CopyStmt;
1413
+
1414
+ /* ----------------------
1415
+ * SET Statement (includes RESET)
1416
+ *
1417
+ * "SET var TO DEFAULT" and "RESET var" are semantically equivalent, but we
1418
+ * preserve the distinction in VariableSetKind for CreateCommandTag().
1419
+ * ----------------------
1420
+ */
1421
+ typedef enum
1422
+ {
1423
+ VAR_SET_VALUE, /* SET var = value */
1424
+ VAR_SET_DEFAULT, /* SET var TO DEFAULT */
1425
+ VAR_SET_CURRENT, /* SET var FROM CURRENT */
1426
+ VAR_SET_MULTI, /* special case for SET TRANSACTION ... */
1427
+ VAR_RESET, /* RESET var */
1428
+ VAR_RESET_ALL /* RESET ALL */
1429
+ } VariableSetKind;
1430
+
1431
+ typedef struct VariableSetStmt
1432
+ {
1433
+ NodeTag type;
1434
+ VariableSetKind kind;
1435
+ char *name; /* variable to be set */
1436
+ List *args; /* List of A_Const nodes */
1437
+ bool is_local; /* SET LOCAL? */
1438
+ } VariableSetStmt;
1439
+
1440
+ /* ----------------------
1441
+ * Show Statement
1442
+ * ----------------------
1443
+ */
1444
+ typedef struct VariableShowStmt
1445
+ {
1446
+ NodeTag type;
1447
+ char *name;
1448
+ } VariableShowStmt;
1449
+
1450
+ /* ----------------------
1451
+ * Create Table Statement
1452
+ *
1453
+ * NOTE: in the raw gram.y output, ColumnDef and Constraint nodes are
1454
+ * intermixed in tableElts, and constraints is NIL. After parse analysis,
1455
+ * tableElts contains just ColumnDefs, and constraints contains just
1456
+ * Constraint nodes (in fact, only CONSTR_CHECK nodes, in the present
1457
+ * implementation).
1458
+ * ----------------------
1459
+ */
1460
+
1461
+ typedef struct CreateStmt
1462
+ {
1463
+ NodeTag type;
1464
+ RangeVar *relation; /* relation to create */
1465
+ List *tableElts; /* column definitions (list of ColumnDef) */
1466
+ List *inhRelations; /* relations to inherit from (list of
1467
+ * inhRelation) */
1468
+ TypeName *ofTypename; /* OF typename */
1469
+ List *constraints; /* constraints (list of Constraint nodes) */
1470
+ List *options; /* options from WITH clause */
1471
+ OnCommitAction oncommit; /* what do we do at COMMIT? */
1472
+ char *tablespacename; /* table space to use, or NULL */
1473
+ bool if_not_exists; /* just do nothing if it already exists? */
1474
+ } CreateStmt;
1475
+
1476
+ /* ----------
1477
+ * Definitions for constraints in CreateStmt
1478
+ *
1479
+ * Note that column defaults are treated as a type of constraint,
1480
+ * even though that's a bit odd semantically.
1481
+ *
1482
+ * For constraints that use expressions (CONSTR_CHECK, CONSTR_DEFAULT)
1483
+ * we may have the expression in either "raw" form (an untransformed
1484
+ * parse tree) or "cooked" form (the nodeToString representation of
1485
+ * an executable expression tree), depending on how this Constraint
1486
+ * node was created (by parsing, or by inheritance from an existing
1487
+ * relation). We should never have both in the same node!
1488
+ *
1489
+ * FKCONSTR_ACTION_xxx values are stored into pg_constraint.confupdtype
1490
+ * and pg_constraint.confdeltype columns; FKCONSTR_MATCH_xxx values are
1491
+ * stored into pg_constraint.confmatchtype. Changing the code values may
1492
+ * require an initdb!
1493
+ *
1494
+ * If skip_validation is true then we skip checking that the existing rows
1495
+ * in the table satisfy the constraint, and just install the catalog entries
1496
+ * for the constraint. A new FK constraint is marked as valid iff
1497
+ * initially_valid is true. (Usually skip_validation and initially_valid
1498
+ * are inverses, but we can set both true if the table is known empty.)
1499
+ *
1500
+ * Constraint attributes (DEFERRABLE etc) are initially represented as
1501
+ * separate Constraint nodes for simplicity of parsing. parse_utilcmd.c makes
1502
+ * a pass through the constraints list to insert the info into the appropriate
1503
+ * Constraint node.
1504
+ * ----------
1505
+ */
1506
+
1507
+ typedef enum ConstrType /* types of constraints */
1508
+ {
1509
+ CONSTR_NULL, /* not SQL92, but a lot of people expect it */
1510
+ CONSTR_NOTNULL,
1511
+ CONSTR_DEFAULT,
1512
+ CONSTR_CHECK,
1513
+ CONSTR_PRIMARY,
1514
+ CONSTR_UNIQUE,
1515
+ CONSTR_EXCLUSION,
1516
+ CONSTR_FOREIGN,
1517
+ CONSTR_ATTR_DEFERRABLE, /* attributes for previous constraint node */
1518
+ CONSTR_ATTR_NOT_DEFERRABLE,
1519
+ CONSTR_ATTR_DEFERRED,
1520
+ CONSTR_ATTR_IMMEDIATE
1521
+ } ConstrType;
1522
+
1523
+ /* Foreign key action codes */
1524
+ #define FKCONSTR_ACTION_NOACTION 'a'
1525
+ #define FKCONSTR_ACTION_RESTRICT 'r'
1526
+ #define FKCONSTR_ACTION_CASCADE 'c'
1527
+ #define FKCONSTR_ACTION_SETNULL 'n'
1528
+ #define FKCONSTR_ACTION_SETDEFAULT 'd'
1529
+
1530
+ /* Foreign key matchtype codes */
1531
+ #define FKCONSTR_MATCH_FULL 'f'
1532
+ #define FKCONSTR_MATCH_PARTIAL 'p'
1533
+ #define FKCONSTR_MATCH_UNSPECIFIED 'u'
1534
+
1535
+ typedef struct Constraint
1536
+ {
1537
+ NodeTag type;
1538
+ ConstrType contype; /* see above */
1539
+
1540
+ /* Fields used for most/all constraint types: */
1541
+ char *conname; /* Constraint name, or NULL if unnamed */
1542
+ bool deferrable; /* DEFERRABLE? */
1543
+ bool initdeferred; /* INITIALLY DEFERRED? */
1544
+ int location; /* token location, or -1 if unknown */
1545
+
1546
+ /* Fields used for constraints with expressions (CHECK and DEFAULT): */
1547
+ bool is_no_inherit; /* is constraint non-inheritable? */
1548
+ Node *raw_expr; /* expr, as untransformed parse tree */
1549
+ char *cooked_expr; /* expr, as nodeToString representation */
1550
+
1551
+ /* Fields used for unique constraints (UNIQUE and PRIMARY KEY): */
1552
+ List *keys; /* String nodes naming referenced column(s) */
1553
+
1554
+ /* Fields used for EXCLUSION constraints: */
1555
+ List *exclusions; /* list of (IndexElem, operator name) pairs */
1556
+
1557
+ /* Fields used for index constraints (UNIQUE, PRIMARY KEY, EXCLUSION): */
1558
+ List *options; /* options from WITH clause */
1559
+ char *indexname; /* existing index to use; otherwise NULL */
1560
+ char *indexspace; /* index tablespace; NULL for default */
1561
+ /* These could be, but currently are not, used for UNIQUE/PKEY: */
1562
+ char *access_method; /* index access method; NULL for default */
1563
+ Node *where_clause; /* partial index predicate */
1564
+
1565
+ /* Fields used for FOREIGN KEY constraints: */
1566
+ RangeVar *pktable; /* Primary key table */
1567
+ List *fk_attrs; /* Attributes of foreign key */
1568
+ List *pk_attrs; /* Corresponding attrs in PK table */
1569
+ char fk_matchtype; /* FULL, PARTIAL, UNSPECIFIED */
1570
+ char fk_upd_action; /* ON UPDATE action */
1571
+ char fk_del_action; /* ON DELETE action */
1572
+ List *old_conpfeqop; /* pg_constraint.conpfeqop of my former self */
1573
+
1574
+ /* Fields used for constraints that allow a NOT VALID specification */
1575
+ bool skip_validation; /* skip validation of existing rows? */
1576
+ bool initially_valid; /* mark the new constraint as valid? */
1577
+ } Constraint;
1578
+
1579
+ /* ----------------------
1580
+ * Create/Drop Table Space Statements
1581
+ * ----------------------
1582
+ */
1583
+
1584
+ typedef struct CreateTableSpaceStmt
1585
+ {
1586
+ NodeTag type;
1587
+ char *tablespacename;
1588
+ char *owner;
1589
+ char *location;
1590
+ } CreateTableSpaceStmt;
1591
+
1592
+ typedef struct DropTableSpaceStmt
1593
+ {
1594
+ NodeTag type;
1595
+ char *tablespacename;
1596
+ bool missing_ok; /* skip error if missing? */
1597
+ } DropTableSpaceStmt;
1598
+
1599
+ typedef struct AlterTableSpaceOptionsStmt
1600
+ {
1601
+ NodeTag type;
1602
+ char *tablespacename;
1603
+ List *options;
1604
+ bool isReset;
1605
+ } AlterTableSpaceOptionsStmt;
1606
+
1607
+ /* ----------------------
1608
+ * Create/Alter Extension Statements
1609
+ * ----------------------
1610
+ */
1611
+
1612
+ typedef struct CreateExtensionStmt
1613
+ {
1614
+ NodeTag type;
1615
+ char *extname;
1616
+ bool if_not_exists; /* just do nothing if it already exists? */
1617
+ List *options; /* List of DefElem nodes */
1618
+ } CreateExtensionStmt;
1619
+
1620
+ /* Only used for ALTER EXTENSION UPDATE; later might need an action field */
1621
+ typedef struct AlterExtensionStmt
1622
+ {
1623
+ NodeTag type;
1624
+ char *extname;
1625
+ List *options; /* List of DefElem nodes */
1626
+ } AlterExtensionStmt;
1627
+
1628
+ typedef struct AlterExtensionContentsStmt
1629
+ {
1630
+ NodeTag type;
1631
+ char *extname; /* Extension's name */
1632
+ int action; /* +1 = add object, -1 = drop object */
1633
+ ObjectType objtype; /* Object's type */
1634
+ List *objname; /* Qualified name of the object */
1635
+ List *objargs; /* Arguments if needed (eg, for functions) */
1636
+ } AlterExtensionContentsStmt;
1637
+
1638
+ /* ----------------------
1639
+ * Create/Alter FOREIGN DATA WRAPPER Statements
1640
+ * ----------------------
1641
+ */
1642
+
1643
+ typedef struct CreateFdwStmt
1644
+ {
1645
+ NodeTag type;
1646
+ char *fdwname; /* foreign-data wrapper name */
1647
+ List *func_options; /* HANDLER/VALIDATOR options */
1648
+ List *options; /* generic options to FDW */
1649
+ } CreateFdwStmt;
1650
+
1651
+ typedef struct AlterFdwStmt
1652
+ {
1653
+ NodeTag type;
1654
+ char *fdwname; /* foreign-data wrapper name */
1655
+ List *func_options; /* HANDLER/VALIDATOR options */
1656
+ List *options; /* generic options to FDW */
1657
+ } AlterFdwStmt;
1658
+
1659
+ /* ----------------------
1660
+ * Create/Alter FOREIGN SERVER Statements
1661
+ * ----------------------
1662
+ */
1663
+
1664
+ typedef struct CreateForeignServerStmt
1665
+ {
1666
+ NodeTag type;
1667
+ char *servername; /* server name */
1668
+ char *servertype; /* optional server type */
1669
+ char *version; /* optional server version */
1670
+ char *fdwname; /* FDW name */
1671
+ List *options; /* generic options to server */
1672
+ } CreateForeignServerStmt;
1673
+
1674
+ typedef struct AlterForeignServerStmt
1675
+ {
1676
+ NodeTag type;
1677
+ char *servername; /* server name */
1678
+ char *version; /* optional server version */
1679
+ List *options; /* generic options to server */
1680
+ bool has_version; /* version specified */
1681
+ } AlterForeignServerStmt;
1682
+
1683
+ /* ----------------------
1684
+ * Create FOREIGN TABLE Statements
1685
+ * ----------------------
1686
+ */
1687
+
1688
+ typedef struct CreateForeignTableStmt
1689
+ {
1690
+ CreateStmt base;
1691
+ char *servername;
1692
+ List *options;
1693
+ } CreateForeignTableStmt;
1694
+
1695
+ /* ----------------------
1696
+ * Create/Drop USER MAPPING Statements
1697
+ * ----------------------
1698
+ */
1699
+
1700
+ typedef struct CreateUserMappingStmt
1701
+ {
1702
+ NodeTag type;
1703
+ char *username; /* username or PUBLIC/CURRENT_USER */
1704
+ char *servername; /* server name */
1705
+ List *options; /* generic options to server */
1706
+ } CreateUserMappingStmt;
1707
+
1708
+ typedef struct AlterUserMappingStmt
1709
+ {
1710
+ NodeTag type;
1711
+ char *username; /* username or PUBLIC/CURRENT_USER */
1712
+ char *servername; /* server name */
1713
+ List *options; /* generic options to server */
1714
+ } AlterUserMappingStmt;
1715
+
1716
+ typedef struct DropUserMappingStmt
1717
+ {
1718
+ NodeTag type;
1719
+ char *username; /* username or PUBLIC/CURRENT_USER */
1720
+ char *servername; /* server name */
1721
+ bool missing_ok; /* ignore missing mappings */
1722
+ } DropUserMappingStmt;
1723
+
1724
+ /* ----------------------
1725
+ * Create TRIGGER Statement
1726
+ * ----------------------
1727
+ */
1728
+ typedef struct CreateTrigStmt
1729
+ {
1730
+ NodeTag type;
1731
+ char *trigname; /* TRIGGER's name */
1732
+ RangeVar *relation; /* relation trigger is on */
1733
+ List *funcname; /* qual. name of function to call */
1734
+ List *args; /* list of (T_String) Values or NIL */
1735
+ bool row; /* ROW/STATEMENT */
1736
+ /* timing uses the TRIGGER_TYPE bits defined in catalog/pg_trigger.h */
1737
+ int16 timing; /* BEFORE, AFTER, or INSTEAD */
1738
+ /* events uses the TRIGGER_TYPE bits defined in catalog/pg_trigger.h */
1739
+ int16 events; /* "OR" of INSERT/UPDATE/DELETE/TRUNCATE */
1740
+ List *columns; /* column names, or NIL for all columns */
1741
+ Node *whenClause; /* qual expression, or NULL if none */
1742
+ bool isconstraint; /* This is a constraint trigger */
1743
+ /* The remaining fields are only used for constraint triggers */
1744
+ bool deferrable; /* [NOT] DEFERRABLE */
1745
+ bool initdeferred; /* INITIALLY {DEFERRED|IMMEDIATE} */
1746
+ RangeVar *constrrel; /* opposite relation, if RI trigger */
1747
+ } CreateTrigStmt;
1748
+
1749
+ /* ----------------------
1750
+ * Create PROCEDURAL LANGUAGE Statements
1751
+ * ----------------------
1752
+ */
1753
+ typedef struct CreatePLangStmt
1754
+ {
1755
+ NodeTag type;
1756
+ bool replace; /* T => replace if already exists */
1757
+ char *plname; /* PL name */
1758
+ List *plhandler; /* PL call handler function (qual. name) */
1759
+ List *plinline; /* optional inline function (qual. name) */
1760
+ List *plvalidator; /* optional validator function (qual. name) */
1761
+ bool pltrusted; /* PL is trusted */
1762
+ } CreatePLangStmt;
1763
+
1764
+ /* ----------------------
1765
+ * Create/Alter/Drop Role Statements
1766
+ *
1767
+ * Note: these node types are also used for the backwards-compatible
1768
+ * Create/Alter/Drop User/Group statements. In the ALTER and DROP cases
1769
+ * there's really no need to distinguish what the original spelling was,
1770
+ * but for CREATE we mark the type because the defaults vary.
1771
+ * ----------------------
1772
+ */
1773
+ typedef enum RoleStmtType
1774
+ {
1775
+ ROLESTMT_ROLE,
1776
+ ROLESTMT_USER,
1777
+ ROLESTMT_GROUP
1778
+ } RoleStmtType;
1779
+
1780
+ typedef struct CreateRoleStmt
1781
+ {
1782
+ NodeTag type;
1783
+ RoleStmtType stmt_type; /* ROLE/USER/GROUP */
1784
+ char *role; /* role name */
1785
+ List *options; /* List of DefElem nodes */
1786
+ } CreateRoleStmt;
1787
+
1788
+ typedef struct AlterRoleStmt
1789
+ {
1790
+ NodeTag type;
1791
+ char *role; /* role name */
1792
+ List *options; /* List of DefElem nodes */
1793
+ int action; /* +1 = add members, -1 = drop members */
1794
+ } AlterRoleStmt;
1795
+
1796
+ typedef struct AlterRoleSetStmt
1797
+ {
1798
+ NodeTag type;
1799
+ char *role; /* role name */
1800
+ char *database; /* database name, or NULL */
1801
+ VariableSetStmt *setstmt; /* SET or RESET subcommand */
1802
+ } AlterRoleSetStmt;
1803
+
1804
+ typedef struct DropRoleStmt
1805
+ {
1806
+ NodeTag type;
1807
+ List *roles; /* List of roles to remove */
1808
+ bool missing_ok; /* skip error if a role is missing? */
1809
+ } DropRoleStmt;
1810
+
1811
+ /* ----------------------
1812
+ * {Create|Alter} SEQUENCE Statement
1813
+ * ----------------------
1814
+ */
1815
+
1816
+ typedef struct CreateSeqStmt
1817
+ {
1818
+ NodeTag type;
1819
+ RangeVar *sequence; /* the sequence to create */
1820
+ List *options;
1821
+ Oid ownerId; /* ID of owner, or InvalidOid for default */
1822
+ } CreateSeqStmt;
1823
+
1824
+ typedef struct AlterSeqStmt
1825
+ {
1826
+ NodeTag type;
1827
+ RangeVar *sequence; /* the sequence to alter */
1828
+ List *options;
1829
+ bool missing_ok; /* skip error if a role is missing? */
1830
+ } AlterSeqStmt;
1831
+
1832
+ /* ----------------------
1833
+ * Create {Aggregate|Operator|Type} Statement
1834
+ * ----------------------
1835
+ */
1836
+ typedef struct DefineStmt
1837
+ {
1838
+ NodeTag type;
1839
+ ObjectType kind; /* aggregate, operator, type */
1840
+ bool oldstyle; /* hack to signal old CREATE AGG syntax */
1841
+ List *defnames; /* qualified name (list of Value strings) */
1842
+ List *args; /* a list of TypeName (if needed) */
1843
+ List *definition; /* a list of DefElem */
1844
+ } DefineStmt;
1845
+
1846
+ /* ----------------------
1847
+ * Create Domain Statement
1848
+ * ----------------------
1849
+ */
1850
+ typedef struct CreateDomainStmt
1851
+ {
1852
+ NodeTag type;
1853
+ List *domainname; /* qualified name (list of Value strings) */
1854
+ TypeName *typeName; /* the base type */
1855
+ CollateClause *collClause; /* untransformed COLLATE spec, if any */
1856
+ List *constraints; /* constraints (list of Constraint nodes) */
1857
+ } CreateDomainStmt;
1858
+
1859
+ /* ----------------------
1860
+ * Create Operator Class Statement
1861
+ * ----------------------
1862
+ */
1863
+ typedef struct CreateOpClassStmt
1864
+ {
1865
+ NodeTag type;
1866
+ List *opclassname; /* qualified name (list of Value strings) */
1867
+ List *opfamilyname; /* qualified name (ditto); NIL if omitted */
1868
+ char *amname; /* name of index AM opclass is for */
1869
+ TypeName *datatype; /* datatype of indexed column */
1870
+ List *items; /* List of CreateOpClassItem nodes */
1871
+ bool isDefault; /* Should be marked as default for type? */
1872
+ } CreateOpClassStmt;
1873
+
1874
+ #define OPCLASS_ITEM_OPERATOR 1
1875
+ #define OPCLASS_ITEM_FUNCTION 2
1876
+ #define OPCLASS_ITEM_STORAGETYPE 3
1877
+
1878
+ typedef struct CreateOpClassItem
1879
+ {
1880
+ NodeTag type;
1881
+ int itemtype; /* see codes above */
1882
+ /* fields used for an operator or function item: */
1883
+ List *name; /* operator or function name */
1884
+ List *args; /* argument types */
1885
+ int number; /* strategy num or support proc num */
1886
+ List *order_family; /* only used for ordering operators */
1887
+ List *class_args; /* only used for functions */
1888
+ /* fields used for a storagetype item: */
1889
+ TypeName *storedtype; /* datatype stored in index */
1890
+ } CreateOpClassItem;
1891
+
1892
+ /* ----------------------
1893
+ * Create Operator Family Statement
1894
+ * ----------------------
1895
+ */
1896
+ typedef struct CreateOpFamilyStmt
1897
+ {
1898
+ NodeTag type;
1899
+ List *opfamilyname; /* qualified name (list of Value strings) */
1900
+ char *amname; /* name of index AM opfamily is for */
1901
+ } CreateOpFamilyStmt;
1902
+
1903
+ /* ----------------------
1904
+ * Alter Operator Family Statement
1905
+ * ----------------------
1906
+ */
1907
+ typedef struct AlterOpFamilyStmt
1908
+ {
1909
+ NodeTag type;
1910
+ List *opfamilyname; /* qualified name (list of Value strings) */
1911
+ char *amname; /* name of index AM opfamily is for */
1912
+ bool isDrop; /* ADD or DROP the items? */
1913
+ List *items; /* List of CreateOpClassItem nodes */
1914
+ } AlterOpFamilyStmt;
1915
+
1916
+ /* ----------------------
1917
+ * Drop Table|Sequence|View|Index|Type|Domain|Conversion|Schema Statement
1918
+ * ----------------------
1919
+ */
1920
+
1921
+ typedef struct DropStmt
1922
+ {
1923
+ NodeTag type;
1924
+ List *objects; /* list of sublists of names (as Values) */
1925
+ List *arguments; /* list of sublists of arguments (as Values) */
1926
+ ObjectType removeType; /* object type */
1927
+ DropBehavior behavior; /* RESTRICT or CASCADE behavior */
1928
+ bool missing_ok; /* skip error if object is missing? */
1929
+ bool concurrent; /* drop index concurrently? */
1930
+ } DropStmt;
1931
+
1932
+ /* ----------------------
1933
+ * Truncate Table Statement
1934
+ * ----------------------
1935
+ */
1936
+ typedef struct TruncateStmt
1937
+ {
1938
+ NodeTag type;
1939
+ List *relations; /* relations (RangeVars) to be truncated */
1940
+ bool restart_seqs; /* restart owned sequences? */
1941
+ DropBehavior behavior; /* RESTRICT or CASCADE behavior */
1942
+ } TruncateStmt;
1943
+
1944
+ /* ----------------------
1945
+ * Comment On Statement
1946
+ * ----------------------
1947
+ */
1948
+ typedef struct CommentStmt
1949
+ {
1950
+ NodeTag type;
1951
+ ObjectType objtype; /* Object's type */
1952
+ List *objname; /* Qualified name of the object */
1953
+ List *objargs; /* Arguments if needed (eg, for functions) */
1954
+ char *comment; /* Comment to insert, or NULL to remove */
1955
+ } CommentStmt;
1956
+
1957
+ /* ----------------------
1958
+ * SECURITY LABEL Statement
1959
+ * ----------------------
1960
+ */
1961
+ typedef struct SecLabelStmt
1962
+ {
1963
+ NodeTag type;
1964
+ ObjectType objtype; /* Object's type */
1965
+ List *objname; /* Qualified name of the object */
1966
+ List *objargs; /* Arguments if needed (eg, for functions) */
1967
+ char *provider; /* Label provider (or NULL) */
1968
+ char *label; /* New security label to be assigned */
1969
+ } SecLabelStmt;
1970
+
1971
+ /* ----------------------
1972
+ * Declare Cursor Statement
1973
+ *
1974
+ * Note: the "query" field of DeclareCursorStmt is only used in the raw grammar
1975
+ * output. After parse analysis it's set to null, and the Query points to the
1976
+ * DeclareCursorStmt, not vice versa.
1977
+ * ----------------------
1978
+ */
1979
+ #define CURSOR_OPT_BINARY 0x0001 /* BINARY */
1980
+ #define CURSOR_OPT_SCROLL 0x0002 /* SCROLL explicitly given */
1981
+ #define CURSOR_OPT_NO_SCROLL 0x0004 /* NO SCROLL explicitly given */
1982
+ #define CURSOR_OPT_INSENSITIVE 0x0008 /* INSENSITIVE */
1983
+ #define CURSOR_OPT_HOLD 0x0010 /* WITH HOLD */
1984
+ /* these planner-control flags do not correspond to any SQL grammar: */
1985
+ #define CURSOR_OPT_FAST_PLAN 0x0020 /* prefer fast-start plan */
1986
+ #define CURSOR_OPT_GENERIC_PLAN 0x0040 /* force use of generic plan */
1987
+ #define CURSOR_OPT_CUSTOM_PLAN 0x0080 /* force use of custom plan */
1988
+
1989
+ typedef struct DeclareCursorStmt
1990
+ {
1991
+ NodeTag type;
1992
+ char *portalname; /* name of the portal (cursor) */
1993
+ int options; /* bitmask of options (see above) */
1994
+ Node *query; /* the raw SELECT query */
1995
+ } DeclareCursorStmt;
1996
+
1997
+ /* ----------------------
1998
+ * Close Portal Statement
1999
+ * ----------------------
2000
+ */
2001
+ typedef struct ClosePortalStmt
2002
+ {
2003
+ NodeTag type;
2004
+ char *portalname; /* name of the portal (cursor) */
2005
+ /* NULL means CLOSE ALL */
2006
+ } ClosePortalStmt;
2007
+
2008
+ /* ----------------------
2009
+ * Fetch Statement (also Move)
2010
+ * ----------------------
2011
+ */
2012
+ typedef enum FetchDirection
2013
+ {
2014
+ /* for these, howMany is how many rows to fetch; FETCH_ALL means ALL */
2015
+ FETCH_FORWARD,
2016
+ FETCH_BACKWARD,
2017
+ /* for these, howMany indicates a position; only one row is fetched */
2018
+ FETCH_ABSOLUTE,
2019
+ FETCH_RELATIVE
2020
+ } FetchDirection;
2021
+
2022
+ #define FETCH_ALL LONG_MAX
2023
+
2024
+ typedef struct FetchStmt
2025
+ {
2026
+ NodeTag type;
2027
+ FetchDirection direction; /* see above */
2028
+ long howMany; /* number of rows, or position argument */
2029
+ char *portalname; /* name of portal (cursor) */
2030
+ bool ismove; /* TRUE if MOVE */
2031
+ } FetchStmt;
2032
+
2033
+ /* ----------------------
2034
+ * Create Index Statement
2035
+ *
2036
+ * This represents creation of an index and/or an associated constraint.
2037
+ * If isconstraint is true, we should create a pg_constraint entry along
2038
+ * with the index. But if indexOid isn't InvalidOid, we are not creating an
2039
+ * index, just a UNIQUE/PKEY constraint using an existing index. isconstraint
2040
+ * must always be true in this case, and the fields describing the index
2041
+ * properties are empty.
2042
+ * ----------------------
2043
+ */
2044
+ typedef struct IndexStmt
2045
+ {
2046
+ NodeTag type;
2047
+ char *idxname; /* name of new index, or NULL for default */
2048
+ RangeVar *relation; /* relation to build index on */
2049
+ char *accessMethod; /* name of access method (eg. btree) */
2050
+ char *tableSpace; /* tablespace, or NULL for default */
2051
+ List *indexParams; /* columns to index: a list of IndexElem */
2052
+ List *options; /* WITH clause options: a list of DefElem */
2053
+ Node *whereClause; /* qualification (partial-index predicate) */
2054
+ List *excludeOpNames; /* exclusion operator names, or NIL if none */
2055
+ char *idxcomment; /* comment to apply to index, or NULL */
2056
+ Oid indexOid; /* OID of an existing index, if any */
2057
+ Oid oldNode; /* relfilenode of existing storage, if any */
2058
+ bool unique; /* is index unique? */
2059
+ bool primary; /* is index a primary key? */
2060
+ bool isconstraint; /* is it for a pkey/unique constraint? */
2061
+ bool deferrable; /* is the constraint DEFERRABLE? */
2062
+ bool initdeferred; /* is the constraint INITIALLY DEFERRED? */
2063
+ bool concurrent; /* should this be a concurrent index build? */
2064
+ } IndexStmt;
2065
+
2066
+ /* ----------------------
2067
+ * Create Function Statement
2068
+ * ----------------------
2069
+ */
2070
+ typedef struct CreateFunctionStmt
2071
+ {
2072
+ NodeTag type;
2073
+ bool replace; /* T => replace if already exists */
2074
+ List *funcname; /* qualified name of function to create */
2075
+ List *parameters; /* a list of FunctionParameter */
2076
+ TypeName *returnType; /* the return type */
2077
+ List *options; /* a list of DefElem */
2078
+ List *withClause; /* a list of DefElem */
2079
+ } CreateFunctionStmt;
2080
+
2081
+ typedef enum FunctionParameterMode
2082
+ {
2083
+ /* the assigned enum values appear in pg_proc, don't change 'em! */
2084
+ FUNC_PARAM_IN = 'i', /* input only */
2085
+ FUNC_PARAM_OUT = 'o', /* output only */
2086
+ FUNC_PARAM_INOUT = 'b', /* both */
2087
+ FUNC_PARAM_VARIADIC = 'v', /* variadic (always input) */
2088
+ FUNC_PARAM_TABLE = 't' /* table function output column */
2089
+ } FunctionParameterMode;
2090
+
2091
+ typedef struct FunctionParameter
2092
+ {
2093
+ NodeTag type;
2094
+ char *name; /* parameter name, or NULL if not given */
2095
+ TypeName *argType; /* TypeName for parameter type */
2096
+ FunctionParameterMode mode; /* IN/OUT/etc */
2097
+ Node *defexpr; /* raw default expr, or NULL if not given */
2098
+ } FunctionParameter;
2099
+
2100
+ typedef struct AlterFunctionStmt
2101
+ {
2102
+ NodeTag type;
2103
+ FuncWithArgs *func; /* name and args of function */
2104
+ List *actions; /* list of DefElem */
2105
+ } AlterFunctionStmt;
2106
+
2107
+ /* ----------------------
2108
+ * DO Statement
2109
+ *
2110
+ * DoStmt is the raw parser output, InlineCodeBlock is the execution-time API
2111
+ * ----------------------
2112
+ */
2113
+ typedef struct DoStmt
2114
+ {
2115
+ NodeTag type;
2116
+ List *args; /* List of DefElem nodes */
2117
+ } DoStmt;
2118
+
2119
+ typedef struct InlineCodeBlock
2120
+ {
2121
+ NodeTag type;
2122
+ char *source_text; /* source text of anonymous code block */
2123
+ Oid langOid; /* OID of selected language */
2124
+ bool langIsTrusted; /* trusted property of the language */
2125
+ } InlineCodeBlock;
2126
+
2127
+ /* ----------------------
2128
+ * Alter Object Rename Statement
2129
+ * ----------------------
2130
+ */
2131
+ typedef struct RenameStmt
2132
+ {
2133
+ NodeTag type;
2134
+ ObjectType renameType; /* OBJECT_TABLE, OBJECT_COLUMN, etc */
2135
+ ObjectType relationType; /* if column name, associated relation type */
2136
+ RangeVar *relation; /* in case it's a table */
2137
+ List *object; /* in case it's some other object */
2138
+ List *objarg; /* argument types, if applicable */
2139
+ char *subname; /* name of contained object (column, rule,
2140
+ * trigger, etc) */
2141
+ char *newname; /* the new name */
2142
+ DropBehavior behavior; /* RESTRICT or CASCADE behavior */
2143
+ bool missing_ok; /* skip error if missing? */
2144
+ } RenameStmt;
2145
+
2146
+ /* ----------------------
2147
+ * ALTER object SET SCHEMA Statement
2148
+ * ----------------------
2149
+ */
2150
+ typedef struct AlterObjectSchemaStmt
2151
+ {
2152
+ NodeTag type;
2153
+ ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */
2154
+ RangeVar *relation; /* in case it's a table */
2155
+ List *object; /* in case it's some other object */
2156
+ List *objarg; /* argument types, if applicable */
2157
+ char *addname; /* additional name if needed */
2158
+ char *newschema; /* the new schema */
2159
+ bool missing_ok; /* skip error if missing? */
2160
+ } AlterObjectSchemaStmt;
2161
+
2162
+ /* ----------------------
2163
+ * Alter Object Owner Statement
2164
+ * ----------------------
2165
+ */
2166
+ typedef struct AlterOwnerStmt
2167
+ {
2168
+ NodeTag type;
2169
+ ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */
2170
+ RangeVar *relation; /* in case it's a table */
2171
+ List *object; /* in case it's some other object */
2172
+ List *objarg; /* argument types, if applicable */
2173
+ char *addname; /* additional name if needed */
2174
+ char *newowner; /* the new owner */
2175
+ } AlterOwnerStmt;
2176
+
2177
+
2178
+ /* ----------------------
2179
+ * Create Rule Statement
2180
+ * ----------------------
2181
+ */
2182
+ typedef struct RuleStmt
2183
+ {
2184
+ NodeTag type;
2185
+ RangeVar *relation; /* relation the rule is for */
2186
+ char *rulename; /* name of the rule */
2187
+ Node *whereClause; /* qualifications */
2188
+ CmdType event; /* SELECT, INSERT, etc */
2189
+ bool instead; /* is a 'do instead'? */
2190
+ List *actions; /* the action statements */
2191
+ bool replace; /* OR REPLACE */
2192
+ } RuleStmt;
2193
+
2194
+ /* ----------------------
2195
+ * Notify Statement
2196
+ * ----------------------
2197
+ */
2198
+ typedef struct NotifyStmt
2199
+ {
2200
+ NodeTag type;
2201
+ char *conditionname; /* condition name to notify */
2202
+ char *payload; /* the payload string, or NULL if none */
2203
+ } NotifyStmt;
2204
+
2205
+ /* ----------------------
2206
+ * Listen Statement
2207
+ * ----------------------
2208
+ */
2209
+ typedef struct ListenStmt
2210
+ {
2211
+ NodeTag type;
2212
+ char *conditionname; /* condition name to listen on */
2213
+ } ListenStmt;
2214
+
2215
+ /* ----------------------
2216
+ * Unlisten Statement
2217
+ * ----------------------
2218
+ */
2219
+ typedef struct UnlistenStmt
2220
+ {
2221
+ NodeTag type;
2222
+ char *conditionname; /* name to unlisten on, or NULL for all */
2223
+ } UnlistenStmt;
2224
+
2225
+ /* ----------------------
2226
+ * {Begin|Commit|Rollback} Transaction Statement
2227
+ * ----------------------
2228
+ */
2229
+ typedef enum TransactionStmtKind
2230
+ {
2231
+ TRANS_STMT_BEGIN,
2232
+ TRANS_STMT_START, /* semantically identical to BEGIN */
2233
+ TRANS_STMT_COMMIT,
2234
+ TRANS_STMT_ROLLBACK,
2235
+ TRANS_STMT_SAVEPOINT,
2236
+ TRANS_STMT_RELEASE,
2237
+ TRANS_STMT_ROLLBACK_TO,
2238
+ TRANS_STMT_PREPARE,
2239
+ TRANS_STMT_COMMIT_PREPARED,
2240
+ TRANS_STMT_ROLLBACK_PREPARED
2241
+ } TransactionStmtKind;
2242
+
2243
+ typedef struct TransactionStmt
2244
+ {
2245
+ NodeTag type;
2246
+ TransactionStmtKind kind; /* see above */
2247
+ List *options; /* for BEGIN/START and savepoint commands */
2248
+ char *gid; /* for two-phase-commit related commands */
2249
+ } TransactionStmt;
2250
+
2251
+ /* ----------------------
2252
+ * Create Type Statement, composite types
2253
+ * ----------------------
2254
+ */
2255
+ typedef struct CompositeTypeStmt
2256
+ {
2257
+ NodeTag type;
2258
+ RangeVar *typevar; /* the composite type to be created */
2259
+ List *coldeflist; /* list of ColumnDef nodes */
2260
+ } CompositeTypeStmt;
2261
+
2262
+ /* ----------------------
2263
+ * Create Type Statement, enum types
2264
+ * ----------------------
2265
+ */
2266
+ typedef struct CreateEnumStmt
2267
+ {
2268
+ NodeTag type;
2269
+ List *typeName; /* qualified name (list of Value strings) */
2270
+ List *vals; /* enum values (list of Value strings) */
2271
+ } CreateEnumStmt;
2272
+
2273
+ /* ----------------------
2274
+ * Create Type Statement, range types
2275
+ * ----------------------
2276
+ */
2277
+ typedef struct CreateRangeStmt
2278
+ {
2279
+ NodeTag type;
2280
+ List *typeName; /* qualified name (list of Value strings) */
2281
+ List *params; /* range parameters (list of DefElem) */
2282
+ } CreateRangeStmt;
2283
+
2284
+ /* ----------------------
2285
+ * Alter Type Statement, enum types
2286
+ * ----------------------
2287
+ */
2288
+ typedef struct AlterEnumStmt
2289
+ {
2290
+ NodeTag type;
2291
+ List *typeName; /* qualified name (list of Value strings) */
2292
+ char *newVal; /* new enum value's name */
2293
+ char *newValNeighbor; /* neighboring enum value, if specified */
2294
+ bool newValIsAfter; /* place new enum value after neighbor? */
2295
+ } AlterEnumStmt;
2296
+
2297
+ /* ----------------------
2298
+ * Create View Statement
2299
+ * ----------------------
2300
+ */
2301
+ typedef struct ViewStmt
2302
+ {
2303
+ NodeTag type;
2304
+ RangeVar *view; /* the view to be created */
2305
+ List *aliases; /* target column names */
2306
+ Node *query; /* the SELECT query */
2307
+ bool replace; /* replace an existing view? */
2308
+ List *options; /* options from WITH clause */
2309
+ } ViewStmt;
2310
+
2311
+ /* ----------------------
2312
+ * Load Statement
2313
+ * ----------------------
2314
+ */
2315
+ typedef struct LoadStmt
2316
+ {
2317
+ NodeTag type;
2318
+ char *filename; /* file to load */
2319
+ } LoadStmt;
2320
+
2321
+ /* ----------------------
2322
+ * Createdb Statement
2323
+ * ----------------------
2324
+ */
2325
+ typedef struct CreatedbStmt
2326
+ {
2327
+ NodeTag type;
2328
+ char *dbname; /* name of database to create */
2329
+ List *options; /* List of DefElem nodes */
2330
+ } CreatedbStmt;
2331
+
2332
+ /* ----------------------
2333
+ * Alter Database
2334
+ * ----------------------
2335
+ */
2336
+ typedef struct AlterDatabaseStmt
2337
+ {
2338
+ NodeTag type;
2339
+ char *dbname; /* name of database to alter */
2340
+ List *options; /* List of DefElem nodes */
2341
+ } AlterDatabaseStmt;
2342
+
2343
+ typedef struct AlterDatabaseSetStmt
2344
+ {
2345
+ NodeTag type;
2346
+ char *dbname; /* database name */
2347
+ VariableSetStmt *setstmt; /* SET or RESET subcommand */
2348
+ } AlterDatabaseSetStmt;
2349
+
2350
+ /* ----------------------
2351
+ * Dropdb Statement
2352
+ * ----------------------
2353
+ */
2354
+ typedef struct DropdbStmt
2355
+ {
2356
+ NodeTag type;
2357
+ char *dbname; /* database to drop */
2358
+ bool missing_ok; /* skip error if db is missing? */
2359
+ } DropdbStmt;
2360
+
2361
+ /* ----------------------
2362
+ * Cluster Statement (support pbrown's cluster index implementation)
2363
+ * ----------------------
2364
+ */
2365
+ typedef struct ClusterStmt
2366
+ {
2367
+ NodeTag type;
2368
+ RangeVar *relation; /* relation being indexed, or NULL if all */
2369
+ char *indexname; /* original index defined */
2370
+ bool verbose; /* print progress info */
2371
+ } ClusterStmt;
2372
+
2373
+ /* ----------------------
2374
+ * Vacuum and Analyze Statements
2375
+ *
2376
+ * Even though these are nominally two statements, it's convenient to use
2377
+ * just one node type for both. Note that at least one of VACOPT_VACUUM
2378
+ * and VACOPT_ANALYZE must be set in options. VACOPT_FREEZE is an internal
2379
+ * convenience for the grammar and is not examined at runtime --- the
2380
+ * freeze_min_age and freeze_table_age fields are what matter.
2381
+ * ----------------------
2382
+ */
2383
+ typedef enum VacuumOption
2384
+ {
2385
+ VACOPT_VACUUM = 1 << 0, /* do VACUUM */
2386
+ VACOPT_ANALYZE = 1 << 1, /* do ANALYZE */
2387
+ VACOPT_VERBOSE = 1 << 2, /* print progress info */
2388
+ VACOPT_FREEZE = 1 << 3, /* FREEZE option */
2389
+ VACOPT_FULL = 1 << 4, /* FULL (non-concurrent) vacuum */
2390
+ VACOPT_NOWAIT = 1 << 5 /* don't wait to get lock (autovacuum only) */
2391
+ } VacuumOption;
2392
+
2393
+ typedef struct VacuumStmt
2394
+ {
2395
+ NodeTag type;
2396
+ int options; /* OR of VacuumOption flags */
2397
+ int freeze_min_age; /* min freeze age, or -1 to use default */
2398
+ int freeze_table_age; /* age at which to scan whole table */
2399
+ RangeVar *relation; /* single table to process, or NULL */
2400
+ List *va_cols; /* list of column names, or NIL for all */
2401
+ } VacuumStmt;
2402
+
2403
+ /* ----------------------
2404
+ * Explain Statement
2405
+ *
2406
+ * The "query" field is either a raw parse tree (SelectStmt, InsertStmt, etc)
2407
+ * or a Query node if parse analysis has been done. Note that rewriting and
2408
+ * planning of the query are always postponed until execution of EXPLAIN.
2409
+ * ----------------------
2410
+ */
2411
+ typedef struct ExplainStmt
2412
+ {
2413
+ NodeTag type;
2414
+ Node *query; /* the query (see comments above) */
2415
+ List *options; /* list of DefElem nodes */
2416
+ } ExplainStmt;
2417
+
2418
+ /* ----------------------
2419
+ * CREATE TABLE AS Statement (a/k/a SELECT INTO)
2420
+ *
2421
+ * A query written as CREATE TABLE AS will produce this node type natively.
2422
+ * A query written as SELECT ... INTO will be transformed to this form during
2423
+ * parse analysis.
2424
+ *
2425
+ * The "query" field is handled similarly to EXPLAIN, though note that it
2426
+ * can be a SELECT or an EXECUTE, but not other DML statements.
2427
+ * ----------------------
2428
+ */
2429
+ typedef struct CreateTableAsStmt
2430
+ {
2431
+ NodeTag type;
2432
+ Node *query; /* the query (see comments above) */
2433
+ IntoClause *into; /* destination table */
2434
+ bool is_select_into; /* it was written as SELECT INTO */
2435
+ } CreateTableAsStmt;
2436
+
2437
+ /* ----------------------
2438
+ * Checkpoint Statement
2439
+ * ----------------------
2440
+ */
2441
+ typedef struct CheckPointStmt
2442
+ {
2443
+ NodeTag type;
2444
+ } CheckPointStmt;
2445
+
2446
+ /* ----------------------
2447
+ * Discard Statement
2448
+ * ----------------------
2449
+ */
2450
+
2451
+ typedef enum DiscardMode
2452
+ {
2453
+ DISCARD_ALL,
2454
+ DISCARD_PLANS,
2455
+ DISCARD_TEMP
2456
+ } DiscardMode;
2457
+
2458
+ typedef struct DiscardStmt
2459
+ {
2460
+ NodeTag type;
2461
+ DiscardMode target;
2462
+ } DiscardStmt;
2463
+
2464
+ /* ----------------------
2465
+ * LOCK Statement
2466
+ * ----------------------
2467
+ */
2468
+ typedef struct LockStmt
2469
+ {
2470
+ NodeTag type;
2471
+ List *relations; /* relations to lock */
2472
+ int mode; /* lock mode */
2473
+ bool nowait; /* no wait mode */
2474
+ } LockStmt;
2475
+
2476
+ /* ----------------------
2477
+ * SET CONSTRAINTS Statement
2478
+ * ----------------------
2479
+ */
2480
+ typedef struct ConstraintsSetStmt
2481
+ {
2482
+ NodeTag type;
2483
+ List *constraints; /* List of names as RangeVars */
2484
+ bool deferred;
2485
+ } ConstraintsSetStmt;
2486
+
2487
+ /* ----------------------
2488
+ * REINDEX Statement
2489
+ * ----------------------
2490
+ */
2491
+ typedef struct ReindexStmt
2492
+ {
2493
+ NodeTag type;
2494
+ ObjectType kind; /* OBJECT_INDEX, OBJECT_TABLE, OBJECT_DATABASE */
2495
+ RangeVar *relation; /* Table or index to reindex */
2496
+ const char *name; /* name of database to reindex */
2497
+ bool do_system; /* include system tables in database case */
2498
+ bool do_user; /* include user tables in database case */
2499
+ } ReindexStmt;
2500
+
2501
+ /* ----------------------
2502
+ * CREATE CONVERSION Statement
2503
+ * ----------------------
2504
+ */
2505
+ typedef struct CreateConversionStmt
2506
+ {
2507
+ NodeTag type;
2508
+ List *conversion_name; /* Name of the conversion */
2509
+ char *for_encoding_name; /* source encoding name */
2510
+ char *to_encoding_name; /* destination encoding name */
2511
+ List *func_name; /* qualified conversion function name */
2512
+ bool def; /* is this a default conversion? */
2513
+ } CreateConversionStmt;
2514
+
2515
+ /* ----------------------
2516
+ * CREATE CAST Statement
2517
+ * ----------------------
2518
+ */
2519
+ typedef struct CreateCastStmt
2520
+ {
2521
+ NodeTag type;
2522
+ TypeName *sourcetype;
2523
+ TypeName *targettype;
2524
+ FuncWithArgs *func;
2525
+ CoercionContext context;
2526
+ bool inout;
2527
+ } CreateCastStmt;
2528
+
2529
+ /* ----------------------
2530
+ * PREPARE Statement
2531
+ * ----------------------
2532
+ */
2533
+ typedef struct PrepareStmt
2534
+ {
2535
+ NodeTag type;
2536
+ char *name; /* Name of plan, arbitrary */
2537
+ List *argtypes; /* Types of parameters (List of TypeName) */
2538
+ Node *query; /* The query itself (as a raw parsetree) */
2539
+ } PrepareStmt;
2540
+
2541
+
2542
+ /* ----------------------
2543
+ * EXECUTE Statement
2544
+ * ----------------------
2545
+ */
2546
+
2547
+ typedef struct ExecuteStmt
2548
+ {
2549
+ NodeTag type;
2550
+ char *name; /* The name of the plan to execute */
2551
+ List *params; /* Values to assign to parameters */
2552
+ } ExecuteStmt;
2553
+
2554
+
2555
+ /* ----------------------
2556
+ * DEALLOCATE Statement
2557
+ * ----------------------
2558
+ */
2559
+ typedef struct DeallocateStmt
2560
+ {
2561
+ NodeTag type;
2562
+ char *name; /* The name of the plan to remove */
2563
+ /* NULL means DEALLOCATE ALL */
2564
+ } DeallocateStmt;
2565
+
2566
+ /*
2567
+ * DROP OWNED statement
2568
+ */
2569
+ typedef struct DropOwnedStmt
2570
+ {
2571
+ NodeTag type;
2572
+ List *roles;
2573
+ DropBehavior behavior;
2574
+ } DropOwnedStmt;
2575
+
2576
+ /*
2577
+ * REASSIGN OWNED statement
2578
+ */
2579
+ typedef struct ReassignOwnedStmt
2580
+ {
2581
+ NodeTag type;
2582
+ List *roles;
2583
+ char *newrole;
2584
+ } ReassignOwnedStmt;
2585
+
2586
+ /*
2587
+ * TS Dictionary stmts: DefineStmt, RenameStmt and DropStmt are default
2588
+ */
2589
+ typedef struct AlterTSDictionaryStmt
2590
+ {
2591
+ NodeTag type;
2592
+ List *dictname; /* qualified name (list of Value strings) */
2593
+ List *options; /* List of DefElem nodes */
2594
+ } AlterTSDictionaryStmt;
2595
+
2596
+ /*
2597
+ * TS Configuration stmts: DefineStmt, RenameStmt and DropStmt are default
2598
+ */
2599
+ typedef struct AlterTSConfigurationStmt
2600
+ {
2601
+ NodeTag type;
2602
+ List *cfgname; /* qualified name (list of Value strings) */
2603
+
2604
+ /*
2605
+ * dicts will be non-NIL if ADD/ALTER MAPPING was specified. If dicts is
2606
+ * NIL, but tokentype isn't, DROP MAPPING was specified.
2607
+ */
2608
+ List *tokentype; /* list of Value strings */
2609
+ List *dicts; /* list of list of Value strings */
2610
+ bool override; /* if true - remove old variant */
2611
+ bool replace; /* if true - replace dictionary by another */
2612
+ bool missing_ok; /* for DROP - skip error if missing? */
2613
+ } AlterTSConfigurationStmt;
2614
+
2615
+ #endif /* PARSENODES_H */