Add missing errcode() in a few ereport calls.
authorAmit Kapila
Wed, 18 Mar 2020 04:16:52 +0000 (09:46 +0530)
committerAmit Kapila
Wed, 18 Mar 2020 04:16:52 +0000 (09:46 +0530)
This will allow to specifying SQLSTATE error code for the errors in the
missing places.

Reported-by: Sawada Masahiko
Author: Sawada Masahiko
Backpatch-through: 9.5
Discussion: https://postgr.es/m/CA+fd4k6N8EjNvZpM8nme+y+05mz-SM8Z_BgkixzkA34R+ej0Kw@mail.gmail.com

contrib/adminpack/adminpack.c
src/backend/storage/page/bufpage.c

index 628ae11eed2a05aecb77142eeb22550d481c5811..2b1fbc8adb72a5324bfe8bbfcb15c7fa67baba9c 100644 (file)
@@ -128,7 +128,7 @@ pg_file_write(PG_FUNCTION_ARGS)
 
        if (stat(filename, &fst) >= 0)
            ereport(ERROR,
-                   (ERRCODE_DUPLICATE_FILE,
+                   (errcode(ERRCODE_DUPLICATE_FILE),
                     errmsg("file \"%s\" exists", filename)));
 
        f = AllocateFile(filename, "wb");
@@ -194,7 +194,7 @@ pg_file_rename(PG_FUNCTION_ARGS)
    if (rc >= 0 || errno != ENOENT)
    {
        ereport(ERROR,
-               (ERRCODE_DUPLICATE_FILE,
+               (errcode(ERRCODE_DUPLICATE_FILE),
                 errmsg("cannot rename to target file \"%s\"",
                        fn3 ? fn3 : fn2)));
    }
@@ -225,7 +225,7 @@ pg_file_rename(PG_FUNCTION_ARGS)
            else
            {
                ereport(ERROR,
-                       (ERRCODE_UNDEFINED_FILE,
+                       (errcode(ERRCODE_UNDEFINED_FILE),
                         errmsg("renaming \"%s\" to \"%s\" was reverted",
                                fn2, fn3)));
            }
index 41642eb59c41282b7a7d9d0e8aadb0abf9437e1f..5b2c1c179ce9452fe066b22909db3c345a4c41ba 100644 (file)
@@ -147,7 +147,7 @@ PageIsVerified(Page page, BlockNumber blkno)
    if (checksum_failure)
    {
        ereport(WARNING,
-               (ERRCODE_DATA_CORRUPTED,
+               (errcode(ERRCODE_DATA_CORRUPTED),
                 errmsg("page verification failed, calculated checksum %u but expected %u",
                        checksum, p->pd_checksum)));