pg_query 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (375) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/ext/pg_query/include/access/amapi.h +246 -0
  4. data/ext/pg_query/include/access/attmap.h +52 -0
  5. data/ext/pg_query/include/access/attnum.h +64 -0
  6. data/ext/pg_query/include/access/clog.h +61 -0
  7. data/ext/pg_query/include/access/commit_ts.h +77 -0
  8. data/ext/pg_query/include/access/detoast.h +92 -0
  9. data/ext/pg_query/include/access/genam.h +228 -0
  10. data/ext/pg_query/include/access/gin.h +78 -0
  11. data/ext/pg_query/include/access/htup.h +89 -0
  12. data/ext/pg_query/include/access/htup_details.h +819 -0
  13. data/ext/pg_query/include/access/itup.h +161 -0
  14. data/ext/pg_query/include/access/parallel.h +82 -0
  15. data/ext/pg_query/include/access/printtup.h +35 -0
  16. data/ext/pg_query/include/access/relation.h +28 -0
  17. data/ext/pg_query/include/access/relscan.h +176 -0
  18. data/ext/pg_query/include/access/rmgr.h +35 -0
  19. data/ext/pg_query/include/access/rmgrlist.h +49 -0
  20. data/ext/pg_query/include/access/sdir.h +58 -0
  21. data/ext/pg_query/include/access/skey.h +151 -0
  22. data/ext/pg_query/include/access/stratnum.h +83 -0
  23. data/ext/pg_query/include/access/sysattr.h +29 -0
  24. data/ext/pg_query/include/access/table.h +27 -0
  25. data/ext/pg_query/include/access/tableam.h +1825 -0
  26. data/ext/pg_query/include/access/transam.h +265 -0
  27. data/ext/pg_query/include/access/tupconvert.h +51 -0
  28. data/ext/pg_query/include/access/tupdesc.h +154 -0
  29. data/ext/pg_query/include/access/tupmacs.h +247 -0
  30. data/ext/pg_query/include/access/twophase.h +61 -0
  31. data/ext/pg_query/include/access/xact.h +463 -0
  32. data/ext/pg_query/include/access/xlog.h +398 -0
  33. data/ext/pg_query/include/access/xlog_internal.h +330 -0
  34. data/ext/pg_query/include/access/xlogdefs.h +109 -0
  35. data/ext/pg_query/include/access/xloginsert.h +64 -0
  36. data/ext/pg_query/include/access/xlogreader.h +327 -0
  37. data/ext/pg_query/include/access/xlogrecord.h +227 -0
  38. data/ext/pg_query/include/bootstrap/bootstrap.h +62 -0
  39. data/ext/pg_query/include/c.h +1322 -0
  40. data/ext/pg_query/include/catalog/catalog.h +42 -0
  41. data/ext/pg_query/include/catalog/catversion.h +58 -0
  42. data/ext/pg_query/include/catalog/dependency.h +275 -0
  43. data/ext/pg_query/include/catalog/genbki.h +64 -0
  44. data/ext/pg_query/include/catalog/index.h +199 -0
  45. data/ext/pg_query/include/catalog/indexing.h +366 -0
  46. data/ext/pg_query/include/catalog/namespace.h +188 -0
  47. data/ext/pg_query/include/catalog/objectaccess.h +197 -0
  48. data/ext/pg_query/include/catalog/objectaddress.h +84 -0
  49. data/ext/pg_query/include/catalog/pg_aggregate.h +176 -0
  50. data/ext/pg_query/include/catalog/pg_aggregate_d.h +77 -0
  51. data/ext/pg_query/include/catalog/pg_am.h +60 -0
  52. data/ext/pg_query/include/catalog/pg_am_d.h +45 -0
  53. data/ext/pg_query/include/catalog/pg_attribute.h +204 -0
  54. data/ext/pg_query/include/catalog/pg_attribute_d.h +59 -0
  55. data/ext/pg_query/include/catalog/pg_authid.h +58 -0
  56. data/ext/pg_query/include/catalog/pg_authid_d.h +49 -0
  57. data/ext/pg_query/include/catalog/pg_class.h +200 -0
  58. data/ext/pg_query/include/catalog/pg_class_d.h +103 -0
  59. data/ext/pg_query/include/catalog/pg_collation.h +73 -0
  60. data/ext/pg_query/include/catalog/pg_collation_d.h +45 -0
  61. data/ext/pg_query/include/catalog/pg_constraint.h +247 -0
  62. data/ext/pg_query/include/catalog/pg_constraint_d.h +67 -0
  63. data/ext/pg_query/include/catalog/pg_control.h +250 -0
  64. data/ext/pg_query/include/catalog/pg_conversion.h +72 -0
  65. data/ext/pg_query/include/catalog/pg_conversion_d.h +35 -0
  66. data/ext/pg_query/include/catalog/pg_depend.h +73 -0
  67. data/ext/pg_query/include/catalog/pg_depend_d.h +34 -0
  68. data/ext/pg_query/include/catalog/pg_event_trigger.h +51 -0
  69. data/ext/pg_query/include/catalog/pg_event_trigger_d.h +34 -0
  70. data/ext/pg_query/include/catalog/pg_index.h +80 -0
  71. data/ext/pg_query/include/catalog/pg_index_d.h +56 -0
  72. data/ext/pg_query/include/catalog/pg_language.h +67 -0
  73. data/ext/pg_query/include/catalog/pg_language_d.h +39 -0
  74. data/ext/pg_query/include/catalog/pg_namespace.h +59 -0
  75. data/ext/pg_query/include/catalog/pg_namespace_d.h +34 -0
  76. data/ext/pg_query/include/catalog/pg_opclass.h +85 -0
  77. data/ext/pg_query/include/catalog/pg_opclass_d.h +49 -0
  78. data/ext/pg_query/include/catalog/pg_operator.h +102 -0
  79. data/ext/pg_query/include/catalog/pg_operator_d.h +106 -0
  80. data/ext/pg_query/include/catalog/pg_opfamily.h +60 -0
  81. data/ext/pg_query/include/catalog/pg_opfamily_d.h +47 -0
  82. data/ext/pg_query/include/catalog/pg_partitioned_table.h +63 -0
  83. data/ext/pg_query/include/catalog/pg_partitioned_table_d.h +35 -0
  84. data/ext/pg_query/include/catalog/pg_proc.h +211 -0
  85. data/ext/pg_query/include/catalog/pg_proc_d.h +99 -0
  86. data/ext/pg_query/include/catalog/pg_publication.h +115 -0
  87. data/ext/pg_query/include/catalog/pg_publication_d.h +36 -0
  88. data/ext/pg_query/include/catalog/pg_replication_origin.h +57 -0
  89. data/ext/pg_query/include/catalog/pg_replication_origin_d.h +29 -0
  90. data/ext/pg_query/include/catalog/pg_statistic.h +275 -0
  91. data/ext/pg_query/include/catalog/pg_statistic_d.h +194 -0
  92. data/ext/pg_query/include/catalog/pg_statistic_ext.h +74 -0
  93. data/ext/pg_query/include/catalog/pg_statistic_ext_d.h +40 -0
  94. data/ext/pg_query/include/catalog/pg_transform.h +45 -0
  95. data/ext/pg_query/include/catalog/pg_transform_d.h +32 -0
  96. data/ext/pg_query/include/catalog/pg_trigger.h +137 -0
  97. data/ext/pg_query/include/catalog/pg_trigger_d.h +106 -0
  98. data/ext/pg_query/include/catalog/pg_ts_config.h +50 -0
  99. data/ext/pg_query/include/catalog/pg_ts_config_d.h +32 -0
  100. data/ext/pg_query/include/catalog/pg_ts_dict.h +54 -0
  101. data/ext/pg_query/include/catalog/pg_ts_dict_d.h +33 -0
  102. data/ext/pg_query/include/catalog/pg_ts_parser.h +57 -0
  103. data/ext/pg_query/include/catalog/pg_ts_parser_d.h +35 -0
  104. data/ext/pg_query/include/catalog/pg_ts_template.h +48 -0
  105. data/ext/pg_query/include/catalog/pg_ts_template_d.h +32 -0
  106. data/ext/pg_query/include/catalog/pg_type.h +372 -0
  107. data/ext/pg_query/include/catalog/pg_type_d.h +285 -0
  108. data/ext/pg_query/include/catalog/storage.h +48 -0
  109. data/ext/pg_query/include/commands/async.h +54 -0
  110. data/ext/pg_query/include/commands/dbcommands.h +35 -0
  111. data/ext/pg_query/include/commands/defrem.h +173 -0
  112. data/ext/pg_query/include/commands/event_trigger.h +88 -0
  113. data/ext/pg_query/include/commands/explain.h +127 -0
  114. data/ext/pg_query/include/commands/prepare.h +61 -0
  115. data/ext/pg_query/include/commands/tablespace.h +67 -0
  116. data/ext/pg_query/include/commands/trigger.h +277 -0
  117. data/ext/pg_query/include/commands/user.h +37 -0
  118. data/ext/pg_query/include/commands/vacuum.h +293 -0
  119. data/ext/pg_query/include/commands/variable.h +38 -0
  120. data/ext/pg_query/include/common/file_perm.h +56 -0
  121. data/ext/pg_query/include/common/hashfn.h +104 -0
  122. data/ext/pg_query/include/common/ip.h +37 -0
  123. data/ext/pg_query/include/common/keywords.h +33 -0
  124. data/ext/pg_query/include/common/kwlookup.h +44 -0
  125. data/ext/pg_query/include/common/relpath.h +90 -0
  126. data/ext/pg_query/include/common/string.h +19 -0
  127. data/ext/pg_query/include/common/unicode_combining_table.h +196 -0
  128. data/ext/pg_query/include/datatype/timestamp.h +197 -0
  129. data/ext/pg_query/include/executor/execdesc.h +70 -0
  130. data/ext/pg_query/include/executor/executor.h +614 -0
  131. data/ext/pg_query/include/executor/functions.h +41 -0
  132. data/ext/pg_query/include/executor/instrument.h +101 -0
  133. data/ext/pg_query/include/executor/spi.h +175 -0
  134. data/ext/pg_query/include/executor/tablefunc.h +67 -0
  135. data/ext/pg_query/include/executor/tuptable.h +487 -0
  136. data/ext/pg_query/include/fmgr.h +775 -0
  137. data/ext/pg_query/include/funcapi.h +348 -0
  138. data/ext/pg_query/include/getaddrinfo.h +162 -0
  139. data/ext/pg_query/include/jit/jit.h +105 -0
  140. data/ext/pg_query/include/kwlist_d.h +1072 -0
  141. data/ext/pg_query/include/lib/ilist.h +727 -0
  142. data/ext/pg_query/include/lib/pairingheap.h +102 -0
  143. data/ext/pg_query/include/lib/simplehash.h +1059 -0
  144. data/ext/pg_query/include/lib/stringinfo.h +161 -0
  145. data/ext/pg_query/include/libpq/auth.h +29 -0
  146. data/ext/pg_query/include/libpq/crypt.h +46 -0
  147. data/ext/pg_query/include/libpq/hba.h +140 -0
  148. data/ext/pg_query/include/libpq/libpq-be.h +326 -0
  149. data/ext/pg_query/include/libpq/libpq.h +133 -0
  150. data/ext/pg_query/include/libpq/pqcomm.h +208 -0
  151. data/ext/pg_query/include/libpq/pqformat.h +210 -0
  152. data/ext/pg_query/include/libpq/pqsignal.h +42 -0
  153. data/ext/pg_query/include/mb/pg_wchar.h +672 -0
  154. data/ext/pg_query/include/mb/stringinfo_mb.h +24 -0
  155. data/ext/pg_query/include/miscadmin.h +476 -0
  156. data/ext/pg_query/include/nodes/bitmapset.h +122 -0
  157. data/ext/pg_query/include/nodes/execnodes.h +2520 -0
  158. data/ext/pg_query/include/nodes/extensible.h +160 -0
  159. data/ext/pg_query/include/nodes/lockoptions.h +61 -0
  160. data/ext/pg_query/include/nodes/makefuncs.h +108 -0
  161. data/ext/pg_query/include/nodes/memnodes.h +108 -0
  162. data/ext/pg_query/include/nodes/nodeFuncs.h +162 -0
  163. data/ext/pg_query/include/nodes/nodes.h +842 -0
  164. data/ext/pg_query/include/nodes/params.h +170 -0
  165. data/ext/pg_query/include/nodes/parsenodes.h +3579 -0
  166. data/ext/pg_query/include/nodes/pathnodes.h +2556 -0
  167. data/ext/pg_query/include/nodes/pg_list.h +605 -0
  168. data/ext/pg_query/include/nodes/plannodes.h +1251 -0
  169. data/ext/pg_query/include/nodes/primnodes.h +1541 -0
  170. data/ext/pg_query/include/nodes/print.h +34 -0
  171. data/ext/pg_query/include/nodes/tidbitmap.h +75 -0
  172. data/ext/pg_query/include/nodes/value.h +61 -0
  173. data/ext/pg_query/include/optimizer/cost.h +206 -0
  174. data/ext/pg_query/include/optimizer/geqo.h +88 -0
  175. data/ext/pg_query/include/optimizer/geqo_gene.h +45 -0
  176. data/ext/pg_query/include/optimizer/optimizer.h +199 -0
  177. data/ext/pg_query/include/optimizer/paths.h +249 -0
  178. data/ext/pg_query/include/optimizer/planmain.h +119 -0
  179. data/ext/pg_query/include/parser/analyze.h +49 -0
  180. data/ext/pg_query/include/parser/gram.h +1067 -0
  181. data/ext/pg_query/include/parser/gramparse.h +75 -0
  182. data/ext/pg_query/include/parser/kwlist.h +477 -0
  183. data/ext/pg_query/include/parser/parse_agg.h +68 -0
  184. data/ext/pg_query/include/parser/parse_clause.h +54 -0
  185. data/ext/pg_query/include/parser/parse_coerce.h +97 -0
  186. data/ext/pg_query/include/parser/parse_collate.h +27 -0
  187. data/ext/pg_query/include/parser/parse_expr.h +26 -0
  188. data/ext/pg_query/include/parser/parse_func.h +73 -0
  189. data/ext/pg_query/include/parser/parse_node.h +327 -0
  190. data/ext/pg_query/include/parser/parse_oper.h +67 -0
  191. data/ext/pg_query/include/parser/parse_relation.h +123 -0
  192. data/ext/pg_query/include/parser/parse_target.h +46 -0
  193. data/ext/pg_query/include/parser/parse_type.h +60 -0
  194. data/ext/pg_query/include/parser/parser.h +41 -0
  195. data/ext/pg_query/include/parser/parsetree.h +61 -0
  196. data/ext/pg_query/include/parser/scanner.h +152 -0
  197. data/ext/pg_query/include/parser/scansup.h +30 -0
  198. data/ext/pg_query/include/partitioning/partdefs.h +26 -0
  199. data/ext/pg_query/include/pg_config.h +988 -0
  200. data/ext/pg_query/include/pg_config_ext.h +8 -0
  201. data/ext/pg_query/include/pg_config_manual.h +350 -0
  202. data/ext/pg_query/include/pg_config_os.h +8 -0
  203. data/ext/pg_query/include/pg_getopt.h +56 -0
  204. data/ext/pg_query/include/pg_query.h +121 -0
  205. data/ext/pg_query/include/pg_query_enum_defs.c +2454 -0
  206. data/ext/pg_query/include/pg_query_fingerprint_conds.c +875 -0
  207. data/ext/pg_query/include/pg_query_fingerprint_defs.c +12413 -0
  208. data/ext/pg_query/include/pg_query_json_helper.c +61 -0
  209. data/ext/pg_query/include/pg_query_outfuncs_conds.c +686 -0
  210. data/ext/pg_query/include/pg_query_outfuncs_defs.c +2437 -0
  211. data/ext/pg_query/include/pg_query_readfuncs_conds.c +222 -0
  212. data/ext/pg_query/include/pg_query_readfuncs_defs.c +2878 -0
  213. data/ext/pg_query/include/pg_trace.h +17 -0
  214. data/ext/pg_query/include/pgstat.h +1487 -0
  215. data/ext/pg_query/include/pgtime.h +84 -0
  216. data/ext/pg_query/include/pl_gram.h +385 -0
  217. data/ext/pg_query/include/pl_reserved_kwlist.h +52 -0
  218. data/ext/pg_query/include/pl_reserved_kwlist_d.h +114 -0
  219. data/ext/pg_query/include/pl_unreserved_kwlist.h +112 -0
  220. data/ext/pg_query/include/pl_unreserved_kwlist_d.h +246 -0
  221. data/ext/pg_query/include/plerrcodes.h +990 -0
  222. data/ext/pg_query/include/plpgsql.h +1347 -0
  223. data/ext/pg_query/include/port.h +524 -0
  224. data/ext/pg_query/include/port/atomics.h +524 -0
  225. data/ext/pg_query/include/port/atomics/arch-arm.h +26 -0
  226. data/ext/pg_query/include/port/atomics/arch-ppc.h +254 -0
  227. data/ext/pg_query/include/port/atomics/arch-x86.h +252 -0
  228. data/ext/pg_query/include/port/atomics/fallback.h +170 -0
  229. data/ext/pg_query/include/port/atomics/generic-gcc.h +286 -0
  230. data/ext/pg_query/include/port/atomics/generic.h +401 -0
  231. data/ext/pg_query/include/port/pg_bitutils.h +226 -0
  232. data/ext/pg_query/include/port/pg_bswap.h +161 -0
  233. data/ext/pg_query/include/port/pg_crc32c.h +101 -0
  234. data/ext/pg_query/include/portability/instr_time.h +256 -0
  235. data/ext/pg_query/include/postgres.h +764 -0
  236. data/ext/pg_query/include/postgres_ext.h +74 -0
  237. data/ext/pg_query/include/postmaster/autovacuum.h +83 -0
  238. data/ext/pg_query/include/postmaster/bgworker.h +161 -0
  239. data/ext/pg_query/include/postmaster/bgworker_internals.h +64 -0
  240. data/ext/pg_query/include/postmaster/bgwriter.h +45 -0
  241. data/ext/pg_query/include/postmaster/fork_process.h +17 -0
  242. data/ext/pg_query/include/postmaster/interrupt.h +32 -0
  243. data/ext/pg_query/include/postmaster/pgarch.h +39 -0
  244. data/ext/pg_query/include/postmaster/postmaster.h +77 -0
  245. data/ext/pg_query/include/postmaster/syslogger.h +98 -0
  246. data/ext/pg_query/include/postmaster/walwriter.h +21 -0
  247. data/ext/pg_query/include/protobuf-c.h +1106 -0
  248. data/ext/pg_query/include/protobuf-c/protobuf-c.h +1106 -0
  249. data/ext/pg_query/include/protobuf/pg_query.pb-c.h +10846 -0
  250. data/ext/pg_query/include/protobuf/pg_query.pb.h +124718 -0
  251. data/ext/pg_query/include/regex/regex.h +184 -0
  252. data/ext/pg_query/include/replication/logicallauncher.h +31 -0
  253. data/ext/pg_query/include/replication/logicalproto.h +110 -0
  254. data/ext/pg_query/include/replication/logicalworker.h +19 -0
  255. data/ext/pg_query/include/replication/origin.h +73 -0
  256. data/ext/pg_query/include/replication/reorderbuffer.h +467 -0
  257. data/ext/pg_query/include/replication/slot.h +219 -0
  258. data/ext/pg_query/include/replication/syncrep.h +115 -0
  259. data/ext/pg_query/include/replication/walreceiver.h +340 -0
  260. data/ext/pg_query/include/replication/walsender.h +74 -0
  261. data/ext/pg_query/include/rewrite/prs2lock.h +46 -0
  262. data/ext/pg_query/include/rewrite/rewriteHandler.h +40 -0
  263. data/ext/pg_query/include/rewrite/rewriteManip.h +87 -0
  264. data/ext/pg_query/include/rewrite/rewriteSupport.h +26 -0
  265. data/ext/pg_query/include/storage/backendid.h +37 -0
  266. data/ext/pg_query/include/storage/block.h +121 -0
  267. data/ext/pg_query/include/storage/buf.h +46 -0
  268. data/ext/pg_query/include/storage/bufmgr.h +292 -0
  269. data/ext/pg_query/include/storage/bufpage.h +459 -0
  270. data/ext/pg_query/include/storage/condition_variable.h +62 -0
  271. data/ext/pg_query/include/storage/dsm.h +61 -0
  272. data/ext/pg_query/include/storage/dsm_impl.h +75 -0
  273. data/ext/pg_query/include/storage/fd.h +168 -0
  274. data/ext/pg_query/include/storage/ipc.h +81 -0
  275. data/ext/pg_query/include/storage/item.h +19 -0
  276. data/ext/pg_query/include/storage/itemid.h +184 -0
  277. data/ext/pg_query/include/storage/itemptr.h +206 -0
  278. data/ext/pg_query/include/storage/large_object.h +100 -0
  279. data/ext/pg_query/include/storage/latch.h +190 -0
  280. data/ext/pg_query/include/storage/lmgr.h +114 -0
  281. data/ext/pg_query/include/storage/lock.h +612 -0
  282. data/ext/pg_query/include/storage/lockdefs.h +59 -0
  283. data/ext/pg_query/include/storage/lwlock.h +232 -0
  284. data/ext/pg_query/include/storage/lwlocknames.h +51 -0
  285. data/ext/pg_query/include/storage/off.h +57 -0
  286. data/ext/pg_query/include/storage/pg_sema.h +61 -0
  287. data/ext/pg_query/include/storage/pg_shmem.h +90 -0
  288. data/ext/pg_query/include/storage/pmsignal.h +94 -0
  289. data/ext/pg_query/include/storage/predicate.h +87 -0
  290. data/ext/pg_query/include/storage/proc.h +333 -0
  291. data/ext/pg_query/include/storage/proclist_types.h +51 -0
  292. data/ext/pg_query/include/storage/procsignal.h +75 -0
  293. data/ext/pg_query/include/storage/relfilenode.h +99 -0
  294. data/ext/pg_query/include/storage/s_lock.h +1047 -0
  295. data/ext/pg_query/include/storage/sharedfileset.h +45 -0
  296. data/ext/pg_query/include/storage/shm_mq.h +85 -0
  297. data/ext/pg_query/include/storage/shm_toc.h +58 -0
  298. data/ext/pg_query/include/storage/shmem.h +81 -0
  299. data/ext/pg_query/include/storage/sinval.h +153 -0
  300. data/ext/pg_query/include/storage/sinvaladt.h +43 -0
  301. data/ext/pg_query/include/storage/smgr.h +109 -0
  302. data/ext/pg_query/include/storage/spin.h +77 -0
  303. data/ext/pg_query/include/storage/standby.h +91 -0
  304. data/ext/pg_query/include/storage/standbydefs.h +74 -0
  305. data/ext/pg_query/include/storage/sync.h +62 -0
  306. data/ext/pg_query/include/tcop/cmdtag.h +58 -0
  307. data/ext/pg_query/include/tcop/cmdtaglist.h +217 -0
  308. data/ext/pg_query/include/tcop/deparse_utility.h +108 -0
  309. data/ext/pg_query/include/tcop/dest.h +149 -0
  310. data/ext/pg_query/include/tcop/fastpath.h +21 -0
  311. data/ext/pg_query/include/tcop/pquery.h +45 -0
  312. data/ext/pg_query/include/tcop/tcopprot.h +89 -0
  313. data/ext/pg_query/include/tcop/utility.h +108 -0
  314. data/ext/pg_query/include/tsearch/ts_cache.h +98 -0
  315. data/ext/pg_query/include/utils/acl.h +312 -0
  316. data/ext/pg_query/include/utils/aclchk_internal.h +45 -0
  317. data/ext/pg_query/include/utils/array.h +458 -0
  318. data/ext/pg_query/include/utils/builtins.h +127 -0
  319. data/ext/pg_query/include/utils/bytea.h +27 -0
  320. data/ext/pg_query/include/utils/catcache.h +231 -0
  321. data/ext/pg_query/include/utils/date.h +90 -0
  322. data/ext/pg_query/include/utils/datetime.h +343 -0
  323. data/ext/pg_query/include/utils/datum.h +68 -0
  324. data/ext/pg_query/include/utils/dsa.h +123 -0
  325. data/ext/pg_query/include/utils/dynahash.h +19 -0
  326. data/ext/pg_query/include/utils/elog.h +439 -0
  327. data/ext/pg_query/include/utils/errcodes.h +352 -0
  328. data/ext/pg_query/include/utils/expandeddatum.h +159 -0
  329. data/ext/pg_query/include/utils/expandedrecord.h +231 -0
  330. data/ext/pg_query/include/utils/float.h +356 -0
  331. data/ext/pg_query/include/utils/fmgroids.h +2657 -0
  332. data/ext/pg_query/include/utils/fmgrprotos.h +2646 -0
  333. data/ext/pg_query/include/utils/fmgrtab.h +48 -0
  334. data/ext/pg_query/include/utils/guc.h +443 -0
  335. data/ext/pg_query/include/utils/guc_tables.h +272 -0
  336. data/ext/pg_query/include/utils/hsearch.h +149 -0
  337. data/ext/pg_query/include/utils/inval.h +64 -0
  338. data/ext/pg_query/include/utils/lsyscache.h +197 -0
  339. data/ext/pg_query/include/utils/memdebug.h +82 -0
  340. data/ext/pg_query/include/utils/memutils.h +225 -0
  341. data/ext/pg_query/include/utils/numeric.h +76 -0
  342. data/ext/pg_query/include/utils/palloc.h +136 -0
  343. data/ext/pg_query/include/utils/partcache.h +102 -0
  344. data/ext/pg_query/include/utils/pg_locale.h +119 -0
  345. data/ext/pg_query/include/utils/pg_lsn.h +29 -0
  346. data/ext/pg_query/include/utils/pidfile.h +56 -0
  347. data/ext/pg_query/include/utils/plancache.h +235 -0
  348. data/ext/pg_query/include/utils/portal.h +241 -0
  349. data/ext/pg_query/include/utils/probes.h +114 -0
  350. data/ext/pg_query/include/utils/ps_status.h +25 -0
  351. data/ext/pg_query/include/utils/queryenvironment.h +74 -0
  352. data/ext/pg_query/include/utils/regproc.h +28 -0
  353. data/ext/pg_query/include/utils/rel.h +644 -0
  354. data/ext/pg_query/include/utils/relcache.h +151 -0
  355. data/ext/pg_query/include/utils/reltrigger.h +81 -0
  356. data/ext/pg_query/include/utils/resowner.h +86 -0
  357. data/ext/pg_query/include/utils/rls.h +50 -0
  358. data/ext/pg_query/include/utils/ruleutils.h +44 -0
  359. data/ext/pg_query/include/utils/sharedtuplestore.h +61 -0
  360. data/ext/pg_query/include/utils/snapmgr.h +158 -0
  361. data/ext/pg_query/include/utils/snapshot.h +206 -0
  362. data/ext/pg_query/include/utils/sortsupport.h +276 -0
  363. data/ext/pg_query/include/utils/syscache.h +219 -0
  364. data/ext/pg_query/include/utils/timeout.h +88 -0
  365. data/ext/pg_query/include/utils/timestamp.h +116 -0
  366. data/ext/pg_query/include/utils/tuplesort.h +277 -0
  367. data/ext/pg_query/include/utils/tuplestore.h +91 -0
  368. data/ext/pg_query/include/utils/typcache.h +202 -0
  369. data/ext/pg_query/include/utils/tzparser.h +39 -0
  370. data/ext/pg_query/include/utils/varlena.h +39 -0
  371. data/ext/pg_query/include/utils/xml.h +84 -0
  372. data/ext/pg_query/include/xxhash.h +5445 -0
  373. data/ext/pg_query/include/xxhash/xxhash.h +5445 -0
  374. data/lib/pg_query/version.rb +1 -1
  375. metadata +372 -1
@@ -0,0 +1,42 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * pqsignal.h
4
+ * Backend signal(2) support (see also src/port/pqsignal.c)
5
+ *
6
+ * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
7
+ * Portions Copyright (c) 1994, Regents of the University of California
8
+ *
9
+ * src/include/libpq/pqsignal.h
10
+ *
11
+ *-------------------------------------------------------------------------
12
+ */
13
+ #ifndef PQSIGNAL_H
14
+ #define PQSIGNAL_H
15
+
16
+ #include <signal.h>
17
+
18
+ #ifndef WIN32
19
+ #define PG_SETMASK(mask) sigprocmask(SIG_SETMASK, mask, NULL)
20
+ #else
21
+ /* Emulate POSIX sigset_t APIs on Windows */
22
+ typedef int sigset_t;
23
+
24
+ extern int pqsigsetmask(int mask);
25
+
26
+ #define PG_SETMASK(mask) pqsigsetmask(*(mask))
27
+ #define sigemptyset(set) (*(set) = 0)
28
+ #define sigfillset(set) (*(set) = ~0)
29
+ #define sigaddset(set, signum) (*(set) |= (sigmask(signum)))
30
+ #define sigdelset(set, signum) (*(set) &= ~(sigmask(signum)))
31
+ #endif /* WIN32 */
32
+
33
+ extern sigset_t UnBlockSig,
34
+ BlockSig,
35
+ StartupBlockSig;
36
+
37
+ extern void pqinitmask(void);
38
+
39
+ /* pqsigfunc is declared in src/include/port.h */
40
+ extern pqsigfunc pqsignal_pm(int signo, pqsigfunc func);
41
+
42
+ #endif /* PQSIGNAL_H */
@@ -0,0 +1,672 @@
1
+ /*-------------------------------------------------------------------------
2
+ *
3
+ * pg_wchar.h
4
+ * multibyte-character support
5
+ *
6
+ * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
7
+ * Portions Copyright (c) 1994, Regents of the University of California
8
+ *
9
+ * src/include/mb/pg_wchar.h
10
+ *
11
+ * NOTES
12
+ * This is used both by the backend and by frontends, but should not be
13
+ * included by libpq client programs. In particular, a libpq client
14
+ * should not assume that the encoding IDs used by the version of libpq
15
+ * it's linked to match up with the IDs declared here.
16
+ *
17
+ *-------------------------------------------------------------------------
18
+ */
19
+ #ifndef PG_WCHAR_H
20
+ #define PG_WCHAR_H
21
+
22
+ /*
23
+ * The pg_wchar type
24
+ */
25
+ typedef unsigned int pg_wchar;
26
+
27
+ /*
28
+ * Maximum byte length of multibyte characters in any backend encoding
29
+ */
30
+ #define MAX_MULTIBYTE_CHAR_LEN 4
31
+
32
+ /*
33
+ * various definitions for EUC
34
+ */
35
+ #define SS2 0x8e /* single shift 2 (JIS0201) */
36
+ #define SS3 0x8f /* single shift 3 (JIS0212) */
37
+
38
+ /*
39
+ * SJIS validation macros
40
+ */
41
+ #define ISSJISHEAD(c) (((c) >= 0x81 && (c) <= 0x9f) || ((c) >= 0xe0 && (c) <= 0xfc))
42
+ #define ISSJISTAIL(c) (((c) >= 0x40 && (c) <= 0x7e) || ((c) >= 0x80 && (c) <= 0xfc))
43
+
44
+ /*----------------------------------------------------
45
+ * MULE Internal Encoding (MIC)
46
+ *
47
+ * This encoding follows the design used within XEmacs; it is meant to
48
+ * subsume many externally-defined character sets. Each character includes
49
+ * identification of the character set it belongs to, so the encoding is
50
+ * general but somewhat bulky.
51
+ *
52
+ * Currently PostgreSQL supports 5 types of MULE character sets:
53
+ *
54
+ * 1) 1-byte ASCII characters. Each byte is below 0x80.
55
+ *
56
+ * 2) "Official" single byte charsets such as ISO-8859-1 (Latin1).
57
+ * Each MULE character consists of 2 bytes: LC1 + C1, where LC1 is
58
+ * an identifier for the charset (in the range 0x81 to 0x8d) and C1
59
+ * is the character code (in the range 0xa0 to 0xff).
60
+ *
61
+ * 3) "Private" single byte charsets such as SISHENG. Each MULE
62
+ * character consists of 3 bytes: LCPRV1 + LC12 + C1, where LCPRV1
63
+ * is a private-charset flag, LC12 is an identifier for the charset,
64
+ * and C1 is the character code (in the range 0xa0 to 0xff).
65
+ * LCPRV1 is either 0x9a (if LC12 is in the range 0xa0 to 0xdf)
66
+ * or 0x9b (if LC12 is in the range 0xe0 to 0xef).
67
+ *
68
+ * 4) "Official" multibyte charsets such as JIS X0208. Each MULE
69
+ * character consists of 3 bytes: LC2 + C1 + C2, where LC2 is
70
+ * an identifier for the charset (in the range 0x90 to 0x99) and C1
71
+ * and C2 form the character code (each in the range 0xa0 to 0xff).
72
+ *
73
+ * 5) "Private" multibyte charsets such as CNS 11643-1992 Plane 3.
74
+ * Each MULE character consists of 4 bytes: LCPRV2 + LC22 + C1 + C2,
75
+ * where LCPRV2 is a private-charset flag, LC22 is an identifier for
76
+ * the charset, and C1 and C2 form the character code (each in the range
77
+ * 0xa0 to 0xff). LCPRV2 is either 0x9c (if LC22 is in the range 0xf0
78
+ * to 0xf4) or 0x9d (if LC22 is in the range 0xf5 to 0xfe).
79
+ *
80
+ * "Official" encodings are those that have been assigned code numbers by
81
+ * the XEmacs project; "private" encodings have Postgres-specific charset
82
+ * identifiers.
83
+ *
84
+ * See the "XEmacs Internals Manual", available at http://www.xemacs.org,
85
+ * for more details. Note that for historical reasons, Postgres'
86
+ * private-charset flag values do not match what XEmacs says they should be,
87
+ * so this isn't really exactly MULE (not that private charsets would be
88
+ * interoperable anyway).
89
+ *
90
+ * Note that XEmacs's implementation is different from what emacs does.
91
+ * We follow emacs's implementation, rather than XEmacs's.
92
+ *----------------------------------------------------
93
+ */
94
+
95
+ /*
96
+ * Charset identifiers (also called "leading bytes" in the MULE documentation)
97
+ */
98
+
99
+ /*
100
+ * Charset IDs for official single byte encodings (0x81-0x8e)
101
+ */
102
+ #define LC_ISO8859_1 0x81 /* ISO8859 Latin 1 */
103
+ #define LC_ISO8859_2 0x82 /* ISO8859 Latin 2 */
104
+ #define LC_ISO8859_3 0x83 /* ISO8859 Latin 3 */
105
+ #define LC_ISO8859_4 0x84 /* ISO8859 Latin 4 */
106
+ #define LC_TIS620 0x85 /* Thai (not supported yet) */
107
+ #define LC_ISO8859_7 0x86 /* Greek (not supported yet) */
108
+ #define LC_ISO8859_6 0x87 /* Arabic (not supported yet) */
109
+ #define LC_ISO8859_8 0x88 /* Hebrew (not supported yet) */
110
+ #define LC_JISX0201K 0x89 /* Japanese 1 byte kana */
111
+ #define LC_JISX0201R 0x8a /* Japanese 1 byte Roman */
112
+ /* Note that 0x8b seems to be unused as of Emacs 20.7.
113
+ * However, there might be a chance that 0x8b could be used
114
+ * in later versions of Emacs.
115
+ */
116
+ #define LC_KOI8_R 0x8b /* Cyrillic KOI8-R */
117
+ #define LC_ISO8859_5 0x8c /* ISO8859 Cyrillic */
118
+ #define LC_ISO8859_9 0x8d /* ISO8859 Latin 5 (not supported yet) */
119
+ #define LC_ISO8859_15 0x8e /* ISO8859 Latin 15 (not supported yet) */
120
+ /* #define CONTROL_1 0x8f control characters (unused) */
121
+
122
+ /* Is a leading byte for "official" single byte encodings? */
123
+ #define IS_LC1(c) ((unsigned char)(c) >= 0x81 && (unsigned char)(c) <= 0x8d)
124
+
125
+ /*
126
+ * Charset IDs for official multibyte encodings (0x90-0x99)
127
+ * 0x9a-0x9d are free. 0x9e and 0x9f are reserved.
128
+ */
129
+ #define LC_JISX0208_1978 0x90 /* Japanese Kanji, old JIS (not supported) */
130
+ #define LC_GB2312_80 0x91 /* Chinese */
131
+ #define LC_JISX0208 0x92 /* Japanese Kanji (JIS X 0208) */
132
+ #define LC_KS5601 0x93 /* Korean */
133
+ #define LC_JISX0212 0x94 /* Japanese Kanji (JIS X 0212) */
134
+ #define LC_CNS11643_1 0x95 /* CNS 11643-1992 Plane 1 */
135
+ #define LC_CNS11643_2 0x96 /* CNS 11643-1992 Plane 2 */
136
+ #define LC_JISX0213_1 0x97 /* Japanese Kanji (JIS X 0213 Plane 1)
137
+ * (not supported) */
138
+ #define LC_BIG5_1 0x98 /* Plane 1 Chinese traditional (not
139
+ * supported) */
140
+ #define LC_BIG5_2 0x99 /* Plane 1 Chinese traditional (not
141
+ * supported) */
142
+
143
+ /* Is a leading byte for "official" multibyte encodings? */
144
+ #define IS_LC2(c) ((unsigned char)(c) >= 0x90 && (unsigned char)(c) <= 0x99)
145
+
146
+ /*
147
+ * Postgres-specific prefix bytes for "private" single byte encodings
148
+ * (According to the MULE docs, we should be using 0x9e for this)
149
+ */
150
+ #define LCPRV1_A 0x9a
151
+ #define LCPRV1_B 0x9b
152
+ #define IS_LCPRV1(c) ((unsigned char)(c) == LCPRV1_A || (unsigned char)(c) == LCPRV1_B)
153
+ #define IS_LCPRV1_A_RANGE(c) \
154
+ ((unsigned char)(c) >= 0xa0 && (unsigned char)(c) <= 0xdf)
155
+ #define IS_LCPRV1_B_RANGE(c) \
156
+ ((unsigned char)(c) >= 0xe0 && (unsigned char)(c) <= 0xef)
157
+
158
+ /*
159
+ * Postgres-specific prefix bytes for "private" multibyte encodings
160
+ * (According to the MULE docs, we should be using 0x9f for this)
161
+ */
162
+ #define LCPRV2_A 0x9c
163
+ #define LCPRV2_B 0x9d
164
+ #define IS_LCPRV2(c) ((unsigned char)(c) == LCPRV2_A || (unsigned char)(c) == LCPRV2_B)
165
+ #define IS_LCPRV2_A_RANGE(c) \
166
+ ((unsigned char)(c) >= 0xf0 && (unsigned char)(c) <= 0xf4)
167
+ #define IS_LCPRV2_B_RANGE(c) \
168
+ ((unsigned char)(c) >= 0xf5 && (unsigned char)(c) <= 0xfe)
169
+
170
+ /*
171
+ * Charset IDs for private single byte encodings (0xa0-0xef)
172
+ */
173
+ #define LC_SISHENG 0xa0 /* Chinese SiSheng characters for
174
+ * PinYin/ZhuYin (not supported) */
175
+ #define LC_IPA 0xa1 /* IPA (International Phonetic
176
+ * Association) (not supported) */
177
+ #define LC_VISCII_LOWER 0xa2 /* Vietnamese VISCII1.1 lower-case (not
178
+ * supported) */
179
+ #define LC_VISCII_UPPER 0xa3 /* Vietnamese VISCII1.1 upper-case (not
180
+ * supported) */
181
+ #define LC_ARABIC_DIGIT 0xa4 /* Arabic digit (not supported) */
182
+ #define LC_ARABIC_1_COLUMN 0xa5 /* Arabic 1-column (not supported) */
183
+ #define LC_ASCII_RIGHT_TO_LEFT 0xa6 /* ASCII (left half of ISO8859-1) with
184
+ * right-to-left direction (not
185
+ * supported) */
186
+ #define LC_LAO 0xa7 /* Lao characters (ISO10646 0E80..0EDF)
187
+ * (not supported) */
188
+ #define LC_ARABIC_2_COLUMN 0xa8 /* Arabic 1-column (not supported) */
189
+
190
+ /*
191
+ * Charset IDs for private multibyte encodings (0xf0-0xff)
192
+ */
193
+ #define LC_INDIAN_1_COLUMN 0xf0 /* Indian charset for 1-column width
194
+ * glyphs (not supported) */
195
+ #define LC_TIBETAN_1_COLUMN 0xf1 /* Tibetan 1-column width glyphs (not
196
+ * supported) */
197
+ #define LC_UNICODE_SUBSET_2 0xf2 /* Unicode characters of the range
198
+ * U+2500..U+33FF. (not supported) */
199
+ #define LC_UNICODE_SUBSET_3 0xf3 /* Unicode characters of the range
200
+ * U+E000..U+FFFF. (not supported) */
201
+ #define LC_UNICODE_SUBSET 0xf4 /* Unicode characters of the range
202
+ * U+0100..U+24FF. (not supported) */
203
+ #define LC_ETHIOPIC 0xf5 /* Ethiopic characters (not supported) */
204
+ #define LC_CNS11643_3 0xf6 /* CNS 11643-1992 Plane 3 */
205
+ #define LC_CNS11643_4 0xf7 /* CNS 11643-1992 Plane 4 */
206
+ #define LC_CNS11643_5 0xf8 /* CNS 11643-1992 Plane 5 */
207
+ #define LC_CNS11643_6 0xf9 /* CNS 11643-1992 Plane 6 */
208
+ #define LC_CNS11643_7 0xfa /* CNS 11643-1992 Plane 7 */
209
+ #define LC_INDIAN_2_COLUMN 0xfb /* Indian charset for 2-column width
210
+ * glyphs (not supported) */
211
+ #define LC_TIBETAN 0xfc /* Tibetan (not supported) */
212
+ /* #define FREE 0xfd free (unused) */
213
+ /* #define FREE 0xfe free (unused) */
214
+ /* #define FREE 0xff free (unused) */
215
+
216
+ /*----------------------------------------------------
217
+ * end of MULE stuff
218
+ *----------------------------------------------------
219
+ */
220
+
221
+ /*
222
+ * PostgreSQL encoding identifiers
223
+ *
224
+ * WARNING: the order of this enum must be same as order of entries
225
+ * in the pg_enc2name_tbl[] array (in src/common/encnames.c), and
226
+ * in the pg_wchar_table[] array (in src/common/wchar.c)!
227
+ *
228
+ * If you add some encoding don't forget to check
229
+ * PG_ENCODING_BE_LAST macro.
230
+ *
231
+ * PG_SQL_ASCII is default encoding and must be = 0.
232
+ *
233
+ * XXX We must avoid renumbering any backend encoding until libpq's major
234
+ * version number is increased beyond 5; it turns out that the backend
235
+ * encoding IDs are effectively part of libpq's ABI as far as 8.2 initdb and
236
+ * psql are concerned.
237
+ */
238
+ typedef enum pg_enc
239
+ {
240
+ PG_SQL_ASCII = 0, /* SQL/ASCII */
241
+ PG_EUC_JP, /* EUC for Japanese */
242
+ PG_EUC_CN, /* EUC for Chinese */
243
+ PG_EUC_KR, /* EUC for Korean */
244
+ PG_EUC_TW, /* EUC for Taiwan */
245
+ PG_EUC_JIS_2004, /* EUC-JIS-2004 */
246
+ PG_UTF8, /* Unicode UTF8 */
247
+ PG_MULE_INTERNAL, /* Mule internal code */
248
+ PG_LATIN1, /* ISO-8859-1 Latin 1 */
249
+ PG_LATIN2, /* ISO-8859-2 Latin 2 */
250
+ PG_LATIN3, /* ISO-8859-3 Latin 3 */
251
+ PG_LATIN4, /* ISO-8859-4 Latin 4 */
252
+ PG_LATIN5, /* ISO-8859-9 Latin 5 */
253
+ PG_LATIN6, /* ISO-8859-10 Latin6 */
254
+ PG_LATIN7, /* ISO-8859-13 Latin7 */
255
+ PG_LATIN8, /* ISO-8859-14 Latin8 */
256
+ PG_LATIN9, /* ISO-8859-15 Latin9 */
257
+ PG_LATIN10, /* ISO-8859-16 Latin10 */
258
+ PG_WIN1256, /* windows-1256 */
259
+ PG_WIN1258, /* Windows-1258 */
260
+ PG_WIN866, /* (MS-DOS CP866) */
261
+ PG_WIN874, /* windows-874 */
262
+ PG_KOI8R, /* KOI8-R */
263
+ PG_WIN1251, /* windows-1251 */
264
+ PG_WIN1252, /* windows-1252 */
265
+ PG_ISO_8859_5, /* ISO-8859-5 */
266
+ PG_ISO_8859_6, /* ISO-8859-6 */
267
+ PG_ISO_8859_7, /* ISO-8859-7 */
268
+ PG_ISO_8859_8, /* ISO-8859-8 */
269
+ PG_WIN1250, /* windows-1250 */
270
+ PG_WIN1253, /* windows-1253 */
271
+ PG_WIN1254, /* windows-1254 */
272
+ PG_WIN1255, /* windows-1255 */
273
+ PG_WIN1257, /* windows-1257 */
274
+ PG_KOI8U, /* KOI8-U */
275
+ /* PG_ENCODING_BE_LAST points to the above entry */
276
+
277
+ /* followings are for client encoding only */
278
+ PG_SJIS, /* Shift JIS (Windows-932) */
279
+ PG_BIG5, /* Big5 (Windows-950) */
280
+ PG_GBK, /* GBK (Windows-936) */
281
+ PG_UHC, /* UHC (Windows-949) */
282
+ PG_GB18030, /* GB18030 */
283
+ PG_JOHAB, /* EUC for Korean JOHAB */
284
+ PG_SHIFT_JIS_2004, /* Shift-JIS-2004 */
285
+ _PG_LAST_ENCODING_ /* mark only */
286
+
287
+ } pg_enc;
288
+
289
+ #define PG_ENCODING_BE_LAST PG_KOI8U
290
+
291
+ /*
292
+ * Please use these tests before access to pg_enc2name_tbl[]
293
+ * or to other places...
294
+ */
295
+ #define PG_VALID_BE_ENCODING(_enc) \
296
+ ((_enc) >= 0 && (_enc) <= PG_ENCODING_BE_LAST)
297
+
298
+ #define PG_ENCODING_IS_CLIENT_ONLY(_enc) \
299
+ ((_enc) > PG_ENCODING_BE_LAST && (_enc) < _PG_LAST_ENCODING_)
300
+
301
+ #define PG_VALID_ENCODING(_enc) \
302
+ ((_enc) >= 0 && (_enc) < _PG_LAST_ENCODING_)
303
+
304
+ /* On FE are possible all encodings */
305
+ #define PG_VALID_FE_ENCODING(_enc) PG_VALID_ENCODING(_enc)
306
+
307
+ /*
308
+ * When converting strings between different encodings, we assume that space
309
+ * for converted result is 4-to-1 growth in the worst case. The rate for
310
+ * currently supported encoding pairs are within 3 (SJIS JIS X0201 half width
311
+ * kanna -> UTF8 is the worst case). So "4" should be enough for the moment.
312
+ *
313
+ * Note that this is not the same as the maximum character width in any
314
+ * particular encoding.
315
+ */
316
+ #define MAX_CONVERSION_GROWTH 4
317
+
318
+ /*
319
+ * Maximum byte length of the string equivalent to any one Unicode code point,
320
+ * in any backend encoding. The current value assumes that a 4-byte UTF-8
321
+ * character might expand by MAX_CONVERSION_GROWTH, which is a huge
322
+ * overestimate. But in current usage we don't allocate large multiples of
323
+ * this, so there's little point in being stingy.
324
+ */
325
+ #define MAX_UNICODE_EQUIVALENT_STRING 16
326
+
327
+ /*
328
+ * Table for mapping an encoding number to official encoding name and
329
+ * possibly other subsidiary data. Be careful to check encoding number
330
+ * before accessing a table entry!
331
+ *
332
+ * if (PG_VALID_ENCODING(encoding))
333
+ * pg_enc2name_tbl[ encoding ];
334
+ */
335
+ typedef struct pg_enc2name
336
+ {
337
+ const char *name;
338
+ pg_enc encoding;
339
+ #ifdef WIN32
340
+ unsigned codepage; /* codepage for WIN32 */
341
+ #endif
342
+ } pg_enc2name;
343
+
344
+ extern const pg_enc2name pg_enc2name_tbl[];
345
+
346
+ /*
347
+ * Encoding names for gettext
348
+ */
349
+ typedef struct pg_enc2gettext
350
+ {
351
+ pg_enc encoding;
352
+ const char *name;
353
+ } pg_enc2gettext;
354
+
355
+ extern const pg_enc2gettext pg_enc2gettext_tbl[];
356
+
357
+ /*
358
+ * pg_wchar stuff
359
+ */
360
+ typedef int (*mb2wchar_with_len_converter) (const unsigned char *from,
361
+ pg_wchar *to,
362
+ int len);
363
+
364
+ typedef int (*wchar2mb_with_len_converter) (const pg_wchar *from,
365
+ unsigned char *to,
366
+ int len);
367
+
368
+ typedef int (*mblen_converter) (const unsigned char *mbstr);
369
+
370
+ typedef int (*mbdisplaylen_converter) (const unsigned char *mbstr);
371
+
372
+ typedef bool (*mbcharacter_incrementer) (unsigned char *mbstr, int len);
373
+
374
+ typedef int (*mbverifier) (const unsigned char *mbstr, int len);
375
+
376
+ typedef struct
377
+ {
378
+ mb2wchar_with_len_converter mb2wchar_with_len; /* convert a multibyte
379
+ * string to a wchar */
380
+ wchar2mb_with_len_converter wchar2mb_with_len; /* convert a wchar string
381
+ * to a multibyte */
382
+ mblen_converter mblen; /* get byte length of a char */
383
+ mbdisplaylen_converter dsplen; /* get display width of a char */
384
+ mbverifier mbverify; /* verify multibyte sequence */
385
+ int maxmblen; /* max bytes for a char in this encoding */
386
+ } pg_wchar_tbl;
387
+
388
+ extern const pg_wchar_tbl pg_wchar_table[];
389
+
390
+ /*
391
+ * Data structures for conversions between UTF-8 and other encodings
392
+ * (UtfToLocal() and LocalToUtf()). In these data structures, characters of
393
+ * either encoding are represented by uint32 words; hence we can only support
394
+ * characters up to 4 bytes long. For example, the byte sequence 0xC2 0x89
395
+ * would be represented by 0x0000C289, and 0xE8 0xA2 0xB4 by 0x00E8A2B4.
396
+ *
397
+ * There are three possible ways a character can be mapped:
398
+ *
399
+ * 1. Using a radix tree, from source to destination code.
400
+ * 2. Using a sorted array of source -> destination code pairs. This
401
+ * method is used for "combining" characters. There are so few of
402
+ * them that building a radix tree would be wasteful.
403
+ * 3. Using a conversion function.
404
+ */
405
+
406
+ /*
407
+ * Radix tree for character conversion.
408
+ *
409
+ * Logically, this is actually four different radix trees, for 1-byte,
410
+ * 2-byte, 3-byte and 4-byte inputs. The 1-byte tree is a simple lookup
411
+ * table from source to target code. The 2-byte tree consists of two levels:
412
+ * one lookup table for the first byte, where the value in the lookup table
413
+ * points to a lookup table for the second byte. And so on.
414
+ *
415
+ * Physically, all the trees are stored in one big array, in 'chars16' or
416
+ * 'chars32', depending on the maximum value that needs to be represented. For
417
+ * each level in each tree, we also store lower and upper bound of allowed
418
+ * values - values outside those bounds are considered invalid, and are left
419
+ * out of the tables.
420
+ *
421
+ * In the intermediate levels of the trees, the values stored are offsets
422
+ * into the chars[16|32] array.
423
+ *
424
+ * In the beginning of the chars[16|32] array, there is always a number of
425
+ * zeros, so that you safely follow an index from an intermediate table
426
+ * without explicitly checking for a zero. Following a zero any number of
427
+ * times will always bring you to the dummy, all-zeros table in the
428
+ * beginning. This helps to shave some cycles when looking up values.
429
+ */
430
+ typedef struct
431
+ {
432
+ /*
433
+ * Array containing all the values. Only one of chars16 or chars32 is
434
+ * used, depending on how wide the values we need to represent are.
435
+ */
436
+ const uint16 *chars16;
437
+ const uint32 *chars32;
438
+
439
+ /* Radix tree for 1-byte inputs */
440
+ uint32 b1root; /* offset of table in the chars[16|32] array */
441
+ uint8 b1_lower; /* min allowed value for a single byte input */
442
+ uint8 b1_upper; /* max allowed value for a single byte input */
443
+
444
+ /* Radix tree for 2-byte inputs */
445
+ uint32 b2root; /* offset of 1st byte's table */
446
+ uint8 b2_1_lower; /* min/max allowed value for 1st input byte */
447
+ uint8 b2_1_upper;
448
+ uint8 b2_2_lower; /* min/max allowed value for 2nd input byte */
449
+ uint8 b2_2_upper;
450
+
451
+ /* Radix tree for 3-byte inputs */
452
+ uint32 b3root; /* offset of 1st byte's table */
453
+ uint8 b3_1_lower; /* min/max allowed value for 1st input byte */
454
+ uint8 b3_1_upper;
455
+ uint8 b3_2_lower; /* min/max allowed value for 2nd input byte */
456
+ uint8 b3_2_upper;
457
+ uint8 b3_3_lower; /* min/max allowed value for 3rd input byte */
458
+ uint8 b3_3_upper;
459
+
460
+ /* Radix tree for 4-byte inputs */
461
+ uint32 b4root; /* offset of 1st byte's table */
462
+ uint8 b4_1_lower; /* min/max allowed value for 1st input byte */
463
+ uint8 b4_1_upper;
464
+ uint8 b4_2_lower; /* min/max allowed value for 2nd input byte */
465
+ uint8 b4_2_upper;
466
+ uint8 b4_3_lower; /* min/max allowed value for 3rd input byte */
467
+ uint8 b4_3_upper;
468
+ uint8 b4_4_lower; /* min/max allowed value for 4th input byte */
469
+ uint8 b4_4_upper;
470
+
471
+ } pg_mb_radix_tree;
472
+
473
+ /*
474
+ * UTF-8 to local code conversion map (for combined characters)
475
+ */
476
+ typedef struct
477
+ {
478
+ uint32 utf1; /* UTF-8 code 1 */
479
+ uint32 utf2; /* UTF-8 code 2 */
480
+ uint32 code; /* local code */
481
+ } pg_utf_to_local_combined;
482
+
483
+ /*
484
+ * local code to UTF-8 conversion map (for combined characters)
485
+ */
486
+ typedef struct
487
+ {
488
+ uint32 code; /* local code */
489
+ uint32 utf1; /* UTF-8 code 1 */
490
+ uint32 utf2; /* UTF-8 code 2 */
491
+ } pg_local_to_utf_combined;
492
+
493
+ /*
494
+ * callback function for algorithmic encoding conversions (in either direction)
495
+ *
496
+ * if function returns zero, it does not know how to convert the code
497
+ */
498
+ typedef uint32 (*utf_local_conversion_func) (uint32 code);
499
+
500
+ /*
501
+ * Support macro for encoding conversion functions to validate their
502
+ * arguments. (This could be made more compact if we included fmgr.h
503
+ * here, but we don't want to do that because this header file is also
504
+ * used by frontends.)
505
+ */
506
+ #define CHECK_ENCODING_CONVERSION_ARGS(srcencoding,destencoding) \
507
+ check_encoding_conversion_args(PG_GETARG_INT32(0), \
508
+ PG_GETARG_INT32(1), \
509
+ PG_GETARG_INT32(4), \
510
+ (srcencoding), \
511
+ (destencoding))
512
+
513
+
514
+ /*
515
+ * Some handy functions for Unicode-specific tests.
516
+ */
517
+ static inline bool
518
+ is_valid_unicode_codepoint(pg_wchar c)
519
+ {
520
+ return (c > 0 && c <= 0x10FFFF);
521
+ }
522
+
523
+ static inline bool
524
+ is_utf16_surrogate_first(pg_wchar c)
525
+ {
526
+ return (c >= 0xD800 && c <= 0xDBFF);
527
+ }
528
+
529
+ static inline bool
530
+ is_utf16_surrogate_second(pg_wchar c)
531
+ {
532
+ return (c >= 0xDC00 && c <= 0xDFFF);
533
+ }
534
+
535
+ static inline pg_wchar
536
+ surrogate_pair_to_codepoint(pg_wchar first, pg_wchar second)
537
+ {
538
+ return ((first & 0x3FF) << 10) + 0x10000 + (second & 0x3FF);
539
+ }
540
+
541
+
542
+ /*
543
+ * These functions are considered part of libpq's exported API and
544
+ * are also declared in libpq-fe.h.
545
+ */
546
+ extern int pg_char_to_encoding(const char *name);
547
+ extern const char *pg_encoding_to_char(int encoding);
548
+ extern int pg_valid_server_encoding_id(int encoding);
549
+
550
+ /*
551
+ * These functions are available to frontend code that links with libpgcommon
552
+ * (in addition to the ones just above). The constant tables declared
553
+ * earlier in this file are also available from libpgcommon.
554
+ */
555
+ extern int pg_encoding_mblen(int encoding, const char *mbstr);
556
+ extern int pg_encoding_dsplen(int encoding, const char *mbstr);
557
+ extern int pg_encoding_verifymb(int encoding, const char *mbstr, int len);
558
+ extern int pg_encoding_max_length(int encoding);
559
+ extern int pg_valid_client_encoding(const char *name);
560
+ extern int pg_valid_server_encoding(const char *name);
561
+ extern bool is_encoding_supported_by_icu(int encoding);
562
+ extern const char *get_encoding_name_for_icu(int encoding);
563
+
564
+ extern unsigned char *unicode_to_utf8(pg_wchar c, unsigned char *utf8string);
565
+ extern pg_wchar utf8_to_unicode(const unsigned char *c);
566
+ extern bool pg_utf8_islegal(const unsigned char *source, int length);
567
+ extern int pg_utf_mblen(const unsigned char *s);
568
+ extern int pg_mule_mblen(const unsigned char *s);
569
+
570
+ /*
571
+ * The remaining functions are backend-only.
572
+ */
573
+ extern int pg_mb2wchar(const char *from, pg_wchar *to);
574
+ extern int pg_mb2wchar_with_len(const char *from, pg_wchar *to, int len);
575
+ extern int pg_encoding_mb2wchar_with_len(int encoding,
576
+ const char *from, pg_wchar *to, int len);
577
+ extern int pg_wchar2mb(const pg_wchar *from, char *to);
578
+ extern int pg_wchar2mb_with_len(const pg_wchar *from, char *to, int len);
579
+ extern int pg_encoding_wchar2mb_with_len(int encoding,
580
+ const pg_wchar *from, char *to, int len);
581
+ extern int pg_char_and_wchar_strcmp(const char *s1, const pg_wchar *s2);
582
+ extern int pg_wchar_strncmp(const pg_wchar *s1, const pg_wchar *s2, size_t n);
583
+ extern int pg_char_and_wchar_strncmp(const char *s1, const pg_wchar *s2, size_t n);
584
+ extern size_t pg_wchar_strlen(const pg_wchar *wstr);
585
+ extern int pg_mblen(const char *mbstr);
586
+ extern int pg_dsplen(const char *mbstr);
587
+ extern int pg_mbstrlen(const char *mbstr);
588
+ extern int pg_mbstrlen_with_len(const char *mbstr, int len);
589
+ extern int pg_mbcliplen(const char *mbstr, int len, int limit);
590
+ extern int pg_encoding_mbcliplen(int encoding, const char *mbstr,
591
+ int len, int limit);
592
+ extern int pg_mbcharcliplen(const char *mbstr, int len, int limit);
593
+ extern int pg_database_encoding_max_length(void);
594
+ extern mbcharacter_incrementer pg_database_encoding_character_incrementer(void);
595
+
596
+ extern int PrepareClientEncoding(int encoding);
597
+ extern int SetClientEncoding(int encoding);
598
+ extern void InitializeClientEncoding(void);
599
+ extern int pg_get_client_encoding(void);
600
+ extern const char *pg_get_client_encoding_name(void);
601
+
602
+ extern void SetDatabaseEncoding(int encoding);
603
+ extern int GetDatabaseEncoding(void);
604
+ extern const char *GetDatabaseEncodingName(void);
605
+ extern void SetMessageEncoding(int encoding);
606
+ extern int GetMessageEncoding(void);
607
+
608
+ #ifdef ENABLE_NLS
609
+ extern int pg_bind_textdomain_codeset(const char *domainname);
610
+ #endif
611
+
612
+ extern unsigned char *pg_do_encoding_conversion(unsigned char *src, int len,
613
+ int src_encoding,
614
+ int dest_encoding);
615
+
616
+ extern char *pg_client_to_server(const char *s, int len);
617
+ extern char *pg_server_to_client(const char *s, int len);
618
+ extern char *pg_any_to_server(const char *s, int len, int encoding);
619
+ extern char *pg_server_to_any(const char *s, int len, int encoding);
620
+
621
+ extern void pg_unicode_to_server(pg_wchar c, unsigned char *s);
622
+
623
+ extern unsigned short BIG5toCNS(unsigned short big5, unsigned char *lc);
624
+ extern unsigned short CNStoBIG5(unsigned short cns, unsigned char lc);
625
+
626
+ extern void UtfToLocal(const unsigned char *utf, int len,
627
+ unsigned char *iso,
628
+ const pg_mb_radix_tree *map,
629
+ const pg_utf_to_local_combined *cmap, int cmapsize,
630
+ utf_local_conversion_func conv_func,
631
+ int encoding);
632
+ extern void LocalToUtf(const unsigned char *iso, int len,
633
+ unsigned char *utf,
634
+ const pg_mb_radix_tree *map,
635
+ const pg_local_to_utf_combined *cmap, int cmapsize,
636
+ utf_local_conversion_func conv_func,
637
+ int encoding);
638
+
639
+ extern bool pg_verifymbstr(const char *mbstr, int len, bool noError);
640
+ extern bool pg_verify_mbstr(int encoding, const char *mbstr, int len,
641
+ bool noError);
642
+ extern int pg_verify_mbstr_len(int encoding, const char *mbstr, int len,
643
+ bool noError);
644
+
645
+ extern void check_encoding_conversion_args(int src_encoding,
646
+ int dest_encoding,
647
+ int len,
648
+ int expected_src_encoding,
649
+ int expected_dest_encoding);
650
+
651
+ extern void report_invalid_encoding(int encoding, const char *mbstr, int len) pg_attribute_noreturn();
652
+ extern void report_untranslatable_char(int src_encoding, int dest_encoding,
653
+ const char *mbstr, int len) pg_attribute_noreturn();
654
+
655
+ extern void local2local(const unsigned char *l, unsigned char *p, int len,
656
+ int src_encoding, int dest_encoding, const unsigned char *tab);
657
+ extern void latin2mic(const unsigned char *l, unsigned char *p, int len,
658
+ int lc, int encoding);
659
+ extern void mic2latin(const unsigned char *mic, unsigned char *p, int len,
660
+ int lc, int encoding);
661
+ extern void latin2mic_with_table(const unsigned char *l, unsigned char *p,
662
+ int len, int lc, int encoding,
663
+ const unsigned char *tab);
664
+ extern void mic2latin_with_table(const unsigned char *mic, unsigned char *p,
665
+ int len, int lc, int encoding,
666
+ const unsigned char *tab);
667
+
668
+ #ifdef WIN32
669
+ extern WCHAR *pgwin32_message_to_UTF16(const char *str, int len, int *utf16len);
670
+ #endif
671
+
672
+ #endif /* PG_WCHAR_H */