Add missing errcode() in a few ereport calls.
authorAmit Kapila <akapila@postgresql.org>
Wed, 18 Mar 2020 03:57:14 +0000 (09:27 +0530)
committerAmit Kapila <akapila@postgresql.org>
Wed, 18 Mar 2020 03:57:14 +0000 (09:27 +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 7d0a19b29492da88efa47e8dcaa1951517fd2539..3f4b06fdbbdcd803dd68fb9b9fd7af4e58b49f04 100644 (file)
@@ -184,7 +184,7 @@ pg_file_write_internal(text *file, text *data, bool replace)
 
        if (stat(filename, &fst) >= 0)
            ereport(ERROR,
-                   (ERRCODE_DUPLICATE_FILE,
+                   (errcode(ERRCODE_DUPLICATE_FILE),
                     errmsg("file \"%s\" exists", filename)));
 
        f = AllocateFile(filename, "wb");
@@ -340,7 +340,7 @@ pg_file_rename_internal(text *file1, text *file2, text *file3)
    if (rc >= 0 || errno != ENOENT)
    {
        ereport(ERROR,
-               (ERRCODE_DUPLICATE_FILE,
+               (errcode(ERRCODE_DUPLICATE_FILE),
                 errmsg("cannot rename to target file \"%s\"",
                        fn3 ? fn3 : fn2)));
    }
@@ -371,7 +371,7 @@ pg_file_rename_internal(text *file1, text *file2, text *file3)
            else
            {
                ereport(ERROR,
-                       (ERRCODE_UNDEFINED_FILE,
+                       (errcode(ERRCODE_UNDEFINED_FILE),
                         errmsg("renaming \"%s\" to \"%s\" was reverted",
                                fn2, fn3)));
            }
index cb7b8c8a63dec69a35b4da351ac0fb96fd5e50e0..d708117a4067e0464172663e5d54b1e0ec011b51 100644 (file)
@@ -141,7 +141,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)));