112 Oid *types; |
119 Oid *types; |
113 const char **values; |
120 const char **values; |
114 int *lengths; |
121 int *lengths; |
115 int *formats; |
122 int *formats; |
116 |
123 |
|
124 // storage for numeric values |
|
125 union evsql_item_value *item_vals; |
|
126 |
117 int result_format; |
127 int result_format; |
118 } params; |
128 } params; |
119 |
129 |
120 // our callback |
130 // our callback |
121 evsql_query_cb cb_fn; |
131 evsql_query_cb cb_fn; |
122 void *cb_arg; |
132 void *cb_arg; |
|
133 |
|
134 // the result we get |
|
135 union evsql_result_handle result; |
123 |
136 |
124 // our position in the query list |
137 // our position in the query list |
125 TAILQ_ENTRY(evsql_query) entry; |
138 TAILQ_ENTRY(evsql_query) entry; |
126 }; |
139 }; |
127 |
140 |
128 // the result |
141 // the result |
129 struct evsql_result { |
142 struct evsql_result { |
|
143 struct evsql *evsql; |
|
144 |
|
145 // possible error code |
130 int error; |
146 int error; |
131 |
147 |
132 union { |
148 // the actual result |
133 PGresult *pq; |
149 union evsql_result_handle result; |
134 } result; |
|
135 |
150 |
136 // result_* state |
151 // result_* state |
137 struct evsql_result_info *info; |
152 struct evsql_result_info *info; |
138 size_t row_offset; |
153 size_t row_offset; |
139 }; |
154 }; |
153 * |
168 * |
154 * This does not actually enqueue the query anywhere, no reference is stored anywhere. |
169 * This does not actually enqueue the query anywhere, no reference is stored anywhere. |
155 * |
170 * |
156 * Returns the new evsql_query on success, NULL on failure. |
171 * Returns the new evsql_query on success, NULL on failure. |
157 */ |
172 */ |
158 static struct evsql_query *_evsql_query_new (struct evsql *evsql, struct evsql_trans *trans, evsql_query_cb query_fn, void *cb_arg); |
173 struct evsql_query *_evsql_query_new (struct evsql *evsql, struct evsql_trans *trans, evsql_query_cb query_fn, void *cb_arg); |
159 |
174 |
160 /* |
175 /* |
161 * Begin processing the given query, which should now be fully filled out. |
176 * Begin processing the given query, which should now be fully filled out. |
162 * |
177 * |
163 * If trans is given, it MUST be idle, and the query will be executed. Otherwise, it will either be executed directly |
178 * If trans is given, it MUST be idle, and the query will be executed. Otherwise, it will either be executed directly |
164 * or enqueued for future execution. |
179 * or enqueued for future execution. |
165 * |
180 * |
166 * Returns zero on success, nonzero on failure. |
181 * Returns zero on success, nonzero on failure. |
167 */ |
182 */ |
168 static int _evsql_query_enqueue (struct evsql *evsql, struct evsql_trans *trans, struct evsql_query *query, const char *command); |
183 int _evsql_query_enqueue (struct evsql *evsql, struct evsql_trans *trans, struct evsql_query *query, const char *command); |
169 |
184 |
170 /* |
185 /* |
171 * Validate and allocate the basic stuff for a new query. |
186 * Free the query and related resources, doesn't trigger any callbacks or remove from any queues. |
|
187 * |
|
188 * The command should already be taken care of (NULL). |
172 */ |
189 */ |
173 |
190 void _evsql_query_free (struct evsql_query *query); |
174 |
191 |
175 #endif /* EVSQL_INTERNAL_H */ |
192 #endif /* EVSQL_INTERNAL_H */ |