Add new error code for "file name too long"
authorMichael Paquier <[email protected]>
Mon, 22 Jul 2024 00:28:01 +0000 (09:28 +0900)
committerMichael Paquier <[email protected]>
Mon, 22 Jul 2024 00:28:01 +0000 (09:28 +0900)
This new error code, named file_name_too_long, maps internally to the
errno ENAMETOOLONG to produce a proper error code rather than an
internal code under errcode_for_file_access().  This error code can be
reached with some SQL command patterns, like a snapshot file name.

Reported-by: Alexander Lakhin
Reviewed-by: Daniel Gustafsson
Discussion: https://postgr.es/m/[email protected]

src/backend/utils/errcodes.txt
src/backend/utils/error/elog.c

index 3250d539e1c467af6431283baf7ee1fa2704f55a..b43a24d4bcdb99891cce59ea5c8fc902343aa7f6 100644 (file)
@@ -439,6 +439,7 @@ Section: Class 58 - System Error (errors external to PostgreSQL itself)
 58030    E    ERRCODE_IO_ERROR                                               io_error
 58P01    E    ERRCODE_UNDEFINED_FILE                                         undefined_file
 58P02    E    ERRCODE_DUPLICATE_FILE                                         duplicate_file
+58P03    E    ERRCODE_FILE_NAME_TOO_LONG                                     file_name_too_long
 
 Section: Class F0 - Configuration File Error
 
index 3e42f5754fe633ccd4b03c2adf19389e1dc45984..479e312ba72db78992828a5b3ccaf35f51b8409e 100644 (file)
@@ -929,6 +929,10 @@ errcode_for_file_access(void)
            edata->sqlerrcode = ERRCODE_IO_ERROR;
            break;
 
+       case ENAMETOOLONG:      /* File name too long */
+           edata->sqlerrcode = ERRCODE_FILE_NAME_TOO_LONG;
+           break;
+
            /* All else is classified as internal errors */
        default:
            edata->sqlerrcode = ERRCODE_INTERNAL_ERROR;