| 3486 | } |
| 3487 | |
| 3488 | Datum |
| 3489 | pg_get_function_sqlbody(PG_FUNCTION_ARGS) |
| 3490 | { |
| 3491 | Oid funcid = PG_GETARG_OID(0); |
| 3492 | StringInfoData buf; |
| 3493 | HeapTuple proctup; |
| 3494 | bool isnull; |
| 3495 | |
| 3496 | initStringInfo(&buf); |
| 3497 | |
| 3498 | /* Look up the function */ |
| 3499 | proctup = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); |
| 3500 | if (!HeapTupleIsValid(proctup)) |
| 3501 | PG_RETURN_NULL(); |
| 3502 | |
| 3503 | (void) SysCacheGetAttr(PROCOID, proctup, Anum_pg_proc_prosqlbody, &isnull); |
| 3504 | if (isnull) |
| 3505 | { |
| 3506 | ReleaseSysCache(proctup); |
| 3507 | PG_RETURN_NULL(); |
| 3508 | } |
| 3509 | |
| 3510 | print_function_sqlbody(&buf, proctup); |
| 3511 | |
| 3512 | ReleaseSysCache(proctup); |
| 3513 | |
| 3514 | PG_RETURN_TEXT_P(cstring_to_text(buf.data)); |
| 3515 | } |
| 3516 | |
| 3517 | |
| 3518 | /* |
nothing calls this directly
no test coverage detected