Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 38d9919

Browse files
committed
Now that fastpath protocol allows null arguments to be passed,
fastpath.c had better check for strict functions.
1 parent 0ac6298 commit 38d9919

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

src/backend/tcop/fastpath.c

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.63 2003/05/09 18:08:48 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.64 2003/05/09 18:18:54 tgl Exp $
1212
*
1313
* NOTES
1414
* This cruft is the server side of PQfn.
@@ -273,6 +273,7 @@ HandleFunctionRequest(StringInfo msgBuf)
273273
Datum retval;
274274
struct fp_info my_fp;
275275
struct fp_info *fip;
276+
bool callit;
276277

277278
/*
278279
* Read message contents if not already done.
@@ -341,8 +342,34 @@ HandleFunctionRequest(StringInfo msgBuf)
341342
/* Verify we reached the end of the message where expected. */
342343
pq_getmsgend(msgBuf);
343344

344-
/* Okay, do it ... */
345-
retval = FunctionCallInvoke(&fcinfo);
345+
/*
346+
* If func is strict, must not call it for null args.
347+
*/
348+
callit = true;
349+
if (fip->flinfo.fn_strict)
350+
{
351+
int i;
352+
353+
for (i = 0; i < fcinfo.nargs; i++)
354+
{
355+
if (fcinfo.argnull[i])
356+
{
357+
callit = false;
358+
break;
359+
}
360+
}
361+
}
362+
363+
if (callit)
364+
{
365+
/* Okay, do it ... */
366+
retval = FunctionCallInvoke(&fcinfo);
367+
}
368+
else
369+
{
370+
fcinfo.isnull = true;
371+
retval = (Datum) 0;
372+
}
346373

347374
SendFunctionResult(retval, fcinfo.isnull, fip->rettype, rformat);
348375

0 commit comments

Comments
 (0)