|
7 | 7 |
|
8 | 8 | INTRO_LOOKUP_TYPES = '''\
|
9 | 9 | WITH RECURSIVE typeinfo_tree(
|
10 |
| - oid, ns, name, kind, basetype, elemtype, range_subtype, |
11 |
| - elem_has_bin_input, elem_has_bin_output, attrtypoids, attrnames, depth) |
| 10 | + oid, ns, name, kind, basetype, has_bin_io, elemtype, elemdelim, |
| 11 | + range_subtype, elem_has_bin_io, attrtypoids, attrnames, depth) |
12 | 12 | AS (
|
13 | 13 | WITH composite_attrs
|
14 | 14 | AS (
|
|
58 | 58 |
|
59 | 59 | ELSE NULL
|
60 | 60 | END) AS basetype,
|
| 61 | + t.typreceive::oid != 0 AND t.typsend::oid != 0 |
| 62 | + AS has_bin_io, |
61 | 63 | t.typelem AS elemtype,
|
| 64 | + elem_t.typdelim AS elemdelim, |
62 | 65 | range_t.rngsubtype AS range_subtype,
|
63 |
| - elem_t.typreceive::oid != 0 AS elem_has_bin_input, |
64 |
| - elem_t.typsend::oid != 0 AS elem_has_bin_output, |
| 66 | + (CASE WHEN t.typtype = 'r' THEN |
| 67 | + (SELECT |
| 68 | + range_elem_t.typreceive::oid != 0 AND |
| 69 | + range_elem_t.typsend::oid != 0 |
| 70 | + FROM |
| 71 | + pg_catalog.pg_type AS range_elem_t |
| 72 | + WHERE |
| 73 | + range_elem_t.oid = range_t.rngsubtype) |
| 74 | + ELSE |
| 75 | + elem_t.typreceive::oid != 0 AND |
| 76 | + elem_t.typsend::oid != 0 |
| 77 | + END) AS elem_has_bin_io, |
65 | 78 | (CASE WHEN t.typtype = 'c' THEN
|
66 | 79 | (SELECT ca.typoids
|
67 | 80 | FROM composite_attrs AS ca
|
|
91 | 104 | )
|
92 | 105 |
|
93 | 106 | SELECT
|
94 |
| - ti.oid, ti.ns, ti.name, ti.kind, ti.basetype, ti.elemtype, |
95 |
| - ti.range_subtype, ti.elem_has_bin_input, ti.elem_has_bin_output, |
| 107 | + ti.oid, ti.ns, ti.name, ti.kind, ti.basetype, ti.has_bin_io, |
| 108 | + ti.elemtype, ti.elemdelim, ti.range_subtype, ti.elem_has_bin_io, |
96 | 109 | ti.attrtypoids, ti.attrnames, 0
|
97 | 110 | FROM
|
98 | 111 | typeinfo AS ti
|
|
102 | 115 | UNION ALL
|
103 | 116 |
|
104 | 117 | SELECT
|
105 |
| - ti.oid, ti.ns, ti.name, ti.kind, ti.basetype, ti.elemtype, |
106 |
| - ti.range_subtype, ti.elem_has_bin_input, ti.elem_has_bin_output, |
| 118 | + ti.oid, ti.ns, ti.name, ti.kind, ti.basetype, ti.has_bin_io, |
| 119 | + ti.elemtype, ti.elemdelim, ti.range_subtype, ti.elem_has_bin_io, |
107 | 120 | ti.attrtypoids, ti.attrnames, tt.depth + 1
|
108 | 121 | FROM
|
109 | 122 | typeinfo ti,
|
|
126 | 139 | # Prior to 9.2 PostgreSQL did not have range types.
|
127 | 140 | INTRO_LOOKUP_TYPES_91 = '''\
|
128 | 141 | WITH RECURSIVE typeinfo_tree(
|
129 |
| - oid, ns, name, kind, basetype, elemtype, range_subtype, |
130 |
| - elem_has_bin_input, elem_has_bin_output, attrtypoids, attrnames, depth) |
| 142 | + oid, ns, name, kind, basetype, has_bin_io, elemtype, elemdelim, |
| 143 | + range_subtype, elem_has_bin_io, attrtypoids, attrnames, depth) |
131 | 144 | AS (
|
132 | 145 | WITH composite_attrs
|
133 | 146 | AS (
|
|
177 | 190 |
|
178 | 191 | ELSE NULL
|
179 | 192 | END) AS basetype,
|
| 193 | + t.typreceive::oid != 0 AND t.typsend::oid != 0 |
| 194 | + AS has_bin_io, |
180 | 195 | t.typelem AS elemtype,
|
| 196 | + elem_t.typdelim AS elemdelim, |
181 | 197 | NULL::oid AS range_subtype,
|
182 |
| - elem_t.typreceive::oid != 0 AS elem_has_bin_input, |
183 |
| - elem_t.typsend::oid != 0 AS elem_has_bin_output, |
| 198 | + elem_t.typreceive::oid != 0 AND |
| 199 | + elem_t.typsend::oid != 0 |
| 200 | + AS elem_has_bin_io, |
184 | 201 | (CASE WHEN t.typtype = 'c' THEN
|
185 | 202 | (SELECT ca.typoids
|
186 | 203 | FROM composite_attrs AS ca
|
|
207 | 224 | )
|
208 | 225 |
|
209 | 226 | SELECT
|
210 |
| - ti.oid, ti.ns, ti.name, ti.kind, ti.basetype, ti.elemtype, |
211 |
| - ti.range_subtype, ti.elem_has_bin_input, ti.elem_has_bin_output, |
| 227 | + ti.oid, ti.ns, ti.name, ti.kind, ti.basetype, ti.has_bin_io, |
| 228 | + ti.elemtype, ti.elemdelim, ti.range_subtype, ti.elem_has_bin_io, |
212 | 229 | ti.attrtypoids, ti.attrnames, 0
|
213 | 230 | FROM
|
214 | 231 | typeinfo AS ti
|
|
218 | 235 | UNION ALL
|
219 | 236 |
|
220 | 237 | SELECT
|
221 |
| - ti.oid, ti.ns, ti.name, ti.kind, ti.basetype, ti.elemtype, |
222 |
| - ti.range_subtype, ti.elem_has_bin_input, ti.elem_has_bin_output, |
| 238 | + ti.oid, ti.ns, ti.name, ti.kind, ti.basetype, ti.has_bin_io, |
| 239 | + ti.elemtype, ti.elemdelim, ti.range_subtype, ti.elem_has_bin_io, |
223 | 240 | ti.attrtypoids, ti.attrnames, tt.depth + 1
|
224 | 241 | FROM
|
225 | 242 | typeinfo ti,
|
|
0 commit comments