@@ -178,8 +178,6 @@ static void send_message_to_server_log(ErrorData *edata);
178
178
static void write_pipe_chunks (char * data , int len , int dest );
179
179
static void send_message_to_frontend (ErrorData * edata );
180
180
static char * expand_fmt_string (const char * fmt , ErrorData * edata );
181
- static const char * useful_strerror (int errnum );
182
- static const char * get_errno_symbol (int errnum );
183
181
static const char * error_severity (int elevel );
184
182
static void append_with_tabs (StringInfo buf , const char * str );
185
183
static bool is_log_level_output (int elevel , int log_min_level );
@@ -3360,7 +3358,7 @@ expand_fmt_string(const char *fmt, ErrorData *edata)
3360
3358
*/
3361
3359
const char * cp2 ;
3362
3360
3363
- cp2 = useful_strerror (edata -> saved_errno );
3361
+ cp2 = strerror (edata -> saved_errno );
3364
3362
for (; * cp2 ; cp2 ++ )
3365
3363
{
3366
3364
if (* cp2 == '%' )
@@ -3383,219 +3381,6 @@ expand_fmt_string(const char *fmt, ErrorData *edata)
3383
3381
}
3384
3382
3385
3383
3386
- /*
3387
- * A slightly cleaned-up version of strerror()
3388
- */
3389
- static const char *
3390
- useful_strerror (int errnum )
3391
- {
3392
- /* this buffer is only used if strerror() and get_errno_symbol() fail */
3393
- static char errorstr_buf [48 ];
3394
- const char * str ;
3395
-
3396
- #ifdef WIN32
3397
- /* Winsock error code range, per WinError.h */
3398
- if (errnum >= 10000 && errnum <= 11999 )
3399
- return pgwin32_socket_strerror (errnum );
3400
- #endif
3401
- str = strerror (errnum );
3402
-
3403
- /*
3404
- * Some strerror()s return an empty string for out-of-range errno. This
3405
- * is ANSI C spec compliant, but not exactly useful. Also, we may get
3406
- * back strings of question marks if libc cannot transcode the message to
3407
- * the codeset specified by LC_CTYPE. If we get nothing useful, first try
3408
- * get_errno_symbol(), and if that fails, print the numeric errno.
3409
- */
3410
- if (str == NULL || * str == '\0' || * str == '?' )
3411
- str = get_errno_symbol (errnum );
3412
-
3413
- if (str == NULL )
3414
- {
3415
- snprintf (errorstr_buf , sizeof (errorstr_buf ),
3416
- /*------
3417
- translator: This string will be truncated at 47
3418
- characters expanded. */
3419
- _ ("operating system error %d" ), errnum );
3420
- str = errorstr_buf ;
3421
- }
3422
-
3423
- return str ;
3424
- }
3425
-
3426
- /*
3427
- * Returns a symbol (e.g. "ENOENT") for an errno code.
3428
- * Returns NULL if the code is unrecognized.
3429
- */
3430
- static const char *
3431
- get_errno_symbol (int errnum )
3432
- {
3433
- switch (errnum )
3434
- {
3435
- case E2BIG :
3436
- return "E2BIG" ;
3437
- case EACCES :
3438
- return "EACCES" ;
3439
- #ifdef EADDRINUSE
3440
- case EADDRINUSE :
3441
- return "EADDRINUSE" ;
3442
- #endif
3443
- #ifdef EADDRNOTAVAIL
3444
- case EADDRNOTAVAIL :
3445
- return "EADDRNOTAVAIL" ;
3446
- #endif
3447
- case EAFNOSUPPORT :
3448
- return "EAFNOSUPPORT" ;
3449
- #ifdef EAGAIN
3450
- case EAGAIN :
3451
- return "EAGAIN" ;
3452
- #endif
3453
- #ifdef EALREADY
3454
- case EALREADY :
3455
- return "EALREADY" ;
3456
- #endif
3457
- case EBADF :
3458
- return "EBADF" ;
3459
- #ifdef EBADMSG
3460
- case EBADMSG :
3461
- return "EBADMSG" ;
3462
- #endif
3463
- case EBUSY :
3464
- return "EBUSY" ;
3465
- case ECHILD :
3466
- return "ECHILD" ;
3467
- #ifdef ECONNABORTED
3468
- case ECONNABORTED :
3469
- return "ECONNABORTED" ;
3470
- #endif
3471
- case ECONNREFUSED :
3472
- return "ECONNREFUSED" ;
3473
- #ifdef ECONNRESET
3474
- case ECONNRESET :
3475
- return "ECONNRESET" ;
3476
- #endif
3477
- case EDEADLK :
3478
- return "EDEADLK" ;
3479
- case EDOM :
3480
- return "EDOM" ;
3481
- case EEXIST :
3482
- return "EEXIST" ;
3483
- case EFAULT :
3484
- return "EFAULT" ;
3485
- case EFBIG :
3486
- return "EFBIG" ;
3487
- #ifdef EHOSTUNREACH
3488
- case EHOSTUNREACH :
3489
- return "EHOSTUNREACH" ;
3490
- #endif
3491
- case EIDRM :
3492
- return "EIDRM" ;
3493
- case EINPROGRESS :
3494
- return "EINPROGRESS" ;
3495
- case EINTR :
3496
- return "EINTR" ;
3497
- case EINVAL :
3498
- return "EINVAL" ;
3499
- case EIO :
3500
- return "EIO" ;
3501
- #ifdef EISCONN
3502
- case EISCONN :
3503
- return "EISCONN" ;
3504
- #endif
3505
- case EISDIR :
3506
- return "EISDIR" ;
3507
- #ifdef ELOOP
3508
- case ELOOP :
3509
- return "ELOOP" ;
3510
- #endif
3511
- case EMFILE :
3512
- return "EMFILE" ;
3513
- case EMLINK :
3514
- return "EMLINK" ;
3515
- case EMSGSIZE :
3516
- return "EMSGSIZE" ;
3517
- case ENAMETOOLONG :
3518
- return "ENAMETOOLONG" ;
3519
- case ENFILE :
3520
- return "ENFILE" ;
3521
- case ENOBUFS :
3522
- return "ENOBUFS" ;
3523
- case ENODEV :
3524
- return "ENODEV" ;
3525
- case ENOENT :
3526
- return "ENOENT" ;
3527
- case ENOEXEC :
3528
- return "ENOEXEC" ;
3529
- case ENOMEM :
3530
- return "ENOMEM" ;
3531
- case ENOSPC :
3532
- return "ENOSPC" ;
3533
- case ENOSYS :
3534
- return "ENOSYS" ;
3535
- #ifdef ENOTCONN
3536
- case ENOTCONN :
3537
- return "ENOTCONN" ;
3538
- #endif
3539
- case ENOTDIR :
3540
- return "ENOTDIR" ;
3541
- #if defined(ENOTEMPTY ) && (ENOTEMPTY != EEXIST ) /* same code on AIX */
3542
- case ENOTEMPTY :
3543
- return "ENOTEMPTY" ;
3544
- #endif
3545
- #ifdef ENOTSOCK
3546
- case ENOTSOCK :
3547
- return "ENOTSOCK" ;
3548
- #endif
3549
- #ifdef ENOTSUP
3550
- case ENOTSUP :
3551
- return "ENOTSUP" ;
3552
- #endif
3553
- case ENOTTY :
3554
- return "ENOTTY" ;
3555
- case ENXIO :
3556
- return "ENXIO" ;
3557
- #if defined(EOPNOTSUPP ) && (!defined(ENOTSUP ) || (EOPNOTSUPP != ENOTSUP ))
3558
- case EOPNOTSUPP :
3559
- return "EOPNOTSUPP" ;
3560
- #endif
3561
- #ifdef EOVERFLOW
3562
- case EOVERFLOW :
3563
- return "EOVERFLOW" ;
3564
- #endif
3565
- case EPERM :
3566
- return "EPERM" ;
3567
- case EPIPE :
3568
- return "EPIPE" ;
3569
- case EPROTONOSUPPORT :
3570
- return "EPROTONOSUPPORT" ;
3571
- case ERANGE :
3572
- return "ERANGE" ;
3573
- #ifdef EROFS
3574
- case EROFS :
3575
- return "EROFS" ;
3576
- #endif
3577
- case ESRCH :
3578
- return "ESRCH" ;
3579
- #ifdef ETIMEDOUT
3580
- case ETIMEDOUT :
3581
- return "ETIMEDOUT" ;
3582
- #endif
3583
- #ifdef ETXTBSY
3584
- case ETXTBSY :
3585
- return "ETXTBSY" ;
3586
- #endif
3587
- #if defined(EWOULDBLOCK ) && (!defined(EAGAIN ) || (EWOULDBLOCK != EAGAIN ))
3588
- case EWOULDBLOCK :
3589
- return "EWOULDBLOCK" ;
3590
- #endif
3591
- case EXDEV :
3592
- return "EXDEV" ;
3593
- }
3594
-
3595
- return NULL ;
3596
- }
3597
-
3598
-
3599
3384
/*
3600
3385
* error_severity --- get string representing elevel
3601
3386
*
0 commit comments