PostgreSQL Source Code: src/backend/tcop/fastpath.c Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
19
35
36
37
38
39
40
41
42
43
44
45
46
47
49{
52 Oid namespace;
56};
57
58
61
62
63
64
65
66static void
68{
70
72
73 if (isnull)
74 {
76 }
77 else
78 {
80 {
81 Oid typoutput;
82 bool typisvarlena;
83 char *outputstr;
84
89 }
91 {
92 Oid typsend;
93 bool typisvarlena;
94 bytea *outputbytes;
95
101 pfree(outputbytes);
102 }
103 else
105 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
106 errmsg("unsupported format code: %d", format)));
107 }
108
110}
111
112
113
114
115
116
117
118static void
120{
123
125
126
127
128
129
130
131
132
133
136
140 (errcode(ERRCODE_UNDEFINED_FUNCTION),
141 errmsg("function with OID %u does not exist", func_id)));
143
144
145 if (pp->prokind != PROKIND_FUNCTION || pp->proretset)
147 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
148 errmsg("cannot call function \"%s\" via fastpath interface",
150
151
153 elog(ERROR, "function %s has more than %d arguments",
155
156 fip->namespace = pp->pronamespace;
157 fip->rettype = pp->prorettype;
158 memcpy(fip->argtypes, pp->proargtypes.values, pp->pronargs * sizeof(Oid));
160
162
164
165
166
167
168 fip->funcid = func_id;
169}
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187void
189{
197 bool callit;
198 bool was_logged = false;
199 char msec_str[32];
200
201
202
203
204
207 (errcode(ERRCODE_IN_FAILED_SQL_TRANSACTION),
208 errmsg("current transaction is aborted, "
209 "commands ignored until end of transaction block")));
210
211
212
213
214
216
217
218
219
221
222
223
224
225
226 fip = &my_fp;
228
229
231 {
233 (errmsg("fastpath function call: \"%s\" (OID %u)",
234 fip->fname, fid)));
235 was_logged = true;
236 }
237
238
239
240
241
247
253
254
255
256
257
258
259
260
262
264
265
267
268
269
270
271 callit = true;
273 {
274 int i;
275
276 for (i = 0; i < fcinfo->nargs; i++)
277 {
278 if (fcinfo->args[i].isnull)
279 {
280 callit = false;
281 break;
282 }
283 }
284 }
285
286 if (callit)
287 {
288
290 }
291 else
292 {
293 fcinfo->isnull = true;
294 retval = (Datum) 0;
295 }
296
297
299
301
302
304
305
306
307
309 {
310 case 1:
312 (errmsg("duration: %s ms", msec_str)));
313 break;
314 case 2:
316 (errmsg("duration: %s ms fastpath function call: \"%s\" (OID %u)",
317 msec_str, fip->fname, fid)));
318 break;
319 }
320}
321
322
323
324
325
326
327
331{
332 int nargs;
333 int i;
334 int numAFormats;
335 int16 *aformats = NULL;
337
338
340 if (numAFormats > 0)
341 {
343 for (i = 0; i < numAFormats; i++)
345 }
346
347 nargs = pq_getmsgint(msgBuf, 2);
348
351 (errcode(ERRCODE_PROTOCOL_VIOLATION),
352 errmsg("function call message contains %d arguments but function requires %d",
354
355 fcinfo->nargs = nargs;
356
357 if (numAFormats > 1 && numAFormats != nargs)
359 (errcode(ERRCODE_PROTOCOL_VIOLATION),
360 errmsg("function call message contains %d argument formats but %d arguments",
361 numAFormats, nargs)));
362
364
365
366
367
368 for (i = 0; i < nargs; ++i)
369 {
370 int argsize;
372
374 if (argsize == -1)
375 {
377 }
378 else
379 {
381 if (argsize < 0)
383 (errcode(ERRCODE_PROTOCOL_VIOLATION),
384 errmsg("invalid argument size %d in function call message",
385 argsize)));
386
387
391 argsize);
392 }
393
394 if (numAFormats > 1)
395 aformat = aformats[i];
396 else if (numAFormats > 0)
397 aformat = aformats[0];
398 else
399 aformat = 0;
400
401 if (aformat == 0)
402 {
403 Oid typinput;
404 Oid typioparam;
405 char *pstring;
406
408
409
410
411
412
413
414
415 if (argsize == -1)
416 pstring = NULL;
417 else
419
421 typioparam, -1);
422
423 if (pstring && pstring != abuf.data)
425 }
426 else if (aformat == 1)
427 {
428 Oid typreceive;
429 Oid typioparam;
431
432
434
435 if (argsize == -1)
436 bufptr = NULL;
437 else
438 bufptr = &abuf;
439
441 typioparam, -1);
442
443
444 if (argsize != -1 && abuf.cursor != abuf.len)
446 (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION),
447 errmsg("incorrect binary data format in function argument %d",
448 i + 1)));
449 }
450 else
452 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
453 errmsg("unsupported format code: %d", aformat)));
454 }
455
456
458}
void aclcheck_error(AclResult aclerr, ObjectType objtype, const char *objectname)
AclResult object_aclcheck(Oid classid, Oid objectid, Oid roleid, AclMode mode)
#define MemSet(start, val, len)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
static void fetch_fp_info(Oid func_id, struct fp_info *fip)
static int16 parse_fcall_arguments(StringInfo msgBuf, struct fp_info *fip, FunctionCallInfo fcinfo)
static void SendFunctionResult(Datum retval, bool isnull, Oid rettype, int16 format)
void HandleFunctionRequest(StringInfo msgBuf)
Datum OidReceiveFunctionCall(Oid functionId, StringInfo buf, Oid typioparam, int32 typmod)
void fmgr_info(Oid functionId, FmgrInfo *finfo)
Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
char * OidOutputFunctionCall(Oid functionId, Datum val)
bytea * OidSendFunctionCall(Oid functionId, Datum val)
#define InitFunctionCallInfoData(Fcinfo, Flinfo, Nargs, Collation, Context, Resultinfo)
#define LOCAL_FCINFO(name, nargs)
#define FunctionCallInvoke(fcinfo)
Assert(PointerIsAligned(start, uint64))
#define HeapTupleIsValid(tuple)
static void * GETSTRUCT(const HeapTupleData *tuple)
void getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena)
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam)
char * get_func_name(Oid funcid)
char * get_namespace_name(Oid nspid)
void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam)
char * pg_client_to_server(const char *s, int len)
void pfree(void *pointer)
#define CHECK_FOR_INTERRUPTS()
#define InvokeNamespaceSearchHook(objectId, ereport_on_violation)
#define InvokeFunctionExecuteHook(objectId)
FormData_pg_proc * Form_pg_proc
size_t strlcpy(char *dst, const char *src, size_t siz)
int check_log_duration(char *msec_str, bool was_logged)
static Datum ObjectIdGetDatum(Oid X)
unsigned int pq_getmsgint(StringInfo msg, int b)
void pq_sendbytes(StringInfo buf, const void *data, int datalen)
void pq_getmsgend(StringInfo msg)
void pq_endmessage(StringInfo buf)
void pq_beginmessage(StringInfo buf, char msgtype)
const char * pq_getmsgbytes(StringInfo msg, int datalen)
void pq_sendcountedtext(StringInfo buf, const char *str, int slen)
static void pq_sendint32(StringInfo buf, uint32 i)
#define PqMsg_FunctionCallResponse
Snapshot GetTransactionSnapshot(void)
void PushActiveSnapshot(Snapshot snapshot)
void PopActiveSnapshot(void)
void resetStringInfo(StringInfo str)
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
void initStringInfo(StringInfo str)
NullableDatum args[FLEXIBLE_ARRAY_MEMBER]
Oid argtypes[FUNC_MAX_ARGS]
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
bool IsAbortedTransactionBlockState(void)