------------------------------------ * pg_file_unlink - old version * * The superuser() check here must be kept as the library might be upgraded * without the extension being upgraded, meaning that in pre-1.1 installations * these functions could be called by any user. */
| 399 | * these functions could be called by any user. |
| 400 | */ |
| 401 | Datum |
| 402 | pg_file_unlink(PG_FUNCTION_ARGS) |
| 403 | { |
| 404 | char *filename; |
| 405 | |
| 406 | requireSuperuser(); |
| 407 | |
| 408 | filename = convert_and_check_filename(PG_GETARG_TEXT_PP(0)); |
| 409 | |
| 410 | if (access(filename, W_OK) < 0) |
| 411 | { |
| 412 | if (errno == ENOENT) |
| 413 | PG_RETURN_BOOL(false); |
| 414 | else |
| 415 | ereport(ERROR, |
| 416 | (errcode_for_file_access(), |
| 417 | errmsg("file \"%s\" is not accessible: %m", filename))); |
| 418 | } |
| 419 | |
| 420 | if (unlink(filename) < 0) |
| 421 | { |
| 422 | ereport(WARNING, |
| 423 | (errcode_for_file_access(), |
| 424 | errmsg("could not unlink file \"%s\": %m", filename))); |
| 425 | |
| 426 | PG_RETURN_BOOL(false); |
| 427 | } |
| 428 | PG_RETURN_BOOL(true); |
| 429 | } |
| 430 | |
| 431 | |
| 432 | /* ------------------------------------ |
nothing calls this directly
no test coverage detected