|
34 | 34 | #include "chunk.h" |
35 | 35 | #include "compression/compression.h" |
36 | 36 | #include "debug_point.h" |
37 | | -#include "extension.h" |
38 | | -#include "hypertable.h" |
39 | 37 | #include "utils.h" |
40 | 38 |
|
41 | 39 | /* Data in a frozen chunk cannot be modified. So any operation |
@@ -94,104 +92,3 @@ chunk_unfreeze_chunk(PG_FUNCTION_ARGS) |
94 | 92 | bool ret = ts_chunk_unset_frozen(chunk); |
95 | 93 | PG_RETURN_BOOL(ret); |
96 | 94 | } |
97 | | - |
98 | | -/* |
99 | | - * Invoke drop_chunks via fmgr so that the call can be deparsed and sent to |
100 | | - * remote data nodes. |
101 | | - * |
102 | | - * Given that drop_chunks is an SRF, and has pseudo parameter types, we need |
103 | | - * to provide a FuncExpr with type information for the deparser. |
104 | | - * |
105 | | - * Returns the number of dropped chunks. |
106 | | - */ |
107 | | -int |
108 | | -chunk_invoke_drop_chunks(Oid relid, Datum older_than, Datum older_than_type, bool use_creation_time) |
109 | | -{ |
110 | | - EState *estate; |
111 | | - ExprContext *econtext; |
112 | | - FuncExpr *fexpr; |
113 | | - List *args = NIL; |
114 | | - int num_results = 0; |
115 | | - SetExprState *state; |
116 | | - Oid restype; |
117 | | - Oid func_oid; |
118 | | - Const *TypeNullCons = makeNullConst(older_than_type, -1, InvalidOid); |
119 | | - Const *IntervalVal = makeConst(older_than_type, |
120 | | - -1, |
121 | | - InvalidOid, |
122 | | - get_typlen(older_than_type), |
123 | | - older_than, |
124 | | - false, |
125 | | - get_typbyval(older_than_type)); |
126 | | - Const *argarr[DROP_CHUNKS_NARGS] = { makeConst(REGCLASSOID, |
127 | | - -1, |
128 | | - InvalidOid, |
129 | | - sizeof(relid), |
130 | | - ObjectIdGetDatum(relid), |
131 | | - false, |
132 | | - false), |
133 | | - TypeNullCons, |
134 | | - TypeNullCons, |
135 | | - castNode(Const, makeBoolConst(false, true)), |
136 | | - TypeNullCons, |
137 | | - TypeNullCons }; |
138 | | - Oid type_id[DROP_CHUNKS_NARGS] = { REGCLASSOID, ANYOID, ANYOID, BOOLOID, ANYOID, ANYOID }; |
139 | | - char *const schema_name = ts_extension_schema_name(); |
140 | | - List *const fqn = list_make2(makeString(schema_name), makeString(DROP_CHUNKS_FUNCNAME)); |
141 | | - |
142 | | - StaticAssertStmt(lengthof(type_id) == lengthof(argarr), |
143 | | - "argarr and type_id should have matching lengths"); |
144 | | - |
145 | | - func_oid = LookupFuncName(fqn, lengthof(type_id), type_id, false); |
146 | | - Assert(func_oid); /* LookupFuncName should not return an invalid OID */ |
147 | | - |
148 | | - /* decide whether to use "older_than" or "drop_created_before" */ |
149 | | - if (use_creation_time) |
150 | | - { |
151 | | - argarr[4] = IntervalVal; |
152 | | - } |
153 | | - else |
154 | | - { |
155 | | - argarr[1] = IntervalVal; |
156 | | - } |
157 | | - |
158 | | - /* Prepare the function expr with argument list */ |
159 | | - get_func_result_type(func_oid, &restype, NULL); |
160 | | - |
161 | | - for (size_t i = 0; i < lengthof(argarr); i++) |
162 | | - { |
163 | | - args = lappend(args, argarr[i]); |
164 | | - } |
165 | | - |
166 | | - fexpr = makeFuncExpr(func_oid, restype, args, InvalidOid, InvalidOid, COERCE_EXPLICIT_CALL); |
167 | | - fexpr->funcretset = true; |
168 | | - |
169 | | - /* Execute the SRF */ |
170 | | - estate = CreateExecutorState(); |
171 | | - econtext = CreateExprContext(estate); |
172 | | - state = ExecInitFunctionResultSet(&fexpr->xpr, econtext, NULL); |
173 | | - |
174 | | - while (true) |
175 | | - { |
176 | | - ExprDoneCond isdone; |
177 | | - bool isnull; |
178 | | - |
179 | | - ExecMakeFunctionResultSet(state, econtext, estate->es_query_cxt, &isnull, &isdone); |
180 | | - |
181 | | - if (isdone == ExprEndResult) |
182 | | - { |
183 | | - break; |
184 | | - } |
185 | | - |
186 | | - if (!isnull) |
187 | | - { |
188 | | - num_results++; |
189 | | - } |
190 | | - } |
191 | | - |
192 | | - /* Cleanup */ |
193 | | - FreeExprContext(econtext, false); |
194 | | - FreeExecutorState(estate); |
195 | | - |
196 | | - return num_results; |
197 | | -} |
0 commit comments