Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qLxup-0015ce-HA for pgsql-hackers@arkaria.postgresql.org; Wed, 19 Jul 2023 03:31:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qLxun-00GoaA-RX for pgsql-hackers@arkaria.postgresql.org; Wed, 19 Jul 2023 03:31:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qLxun-00Goa2-Iu for pgsql-hackers@lists.postgresql.org; Wed, 19 Jul 2023 03:31:49 +0000 Received: from mail-oo1-xc2c.google.com ([2607:f8b0:4864:20::c2c]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qLxul-000Euf-3x for pgsql-hackers@lists.postgresql.org; Wed, 19 Jul 2023 03:31:48 +0000 Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-5607cdb0959so2983241eaf.2 for ; Tue, 18 Jul 2023 20:31:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689737506; x=1692329506; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=N+fPqqTlb7f5B1HO8H/M08CGeJfr68t9PEjL6hXPcNA=; b=c5A6SsUw1L76cSqfTPWb2L+XptezfSTNDmSBXrKAx1LfxIgbg5twLxZv5vqjOdGJRW 5PIvscEcgBxYpq5cjaLkKJlZ49X9J2hbQ37bDCvS5RXvJIVfohEPSVOmr8g9ufbAtv4z UgZWh0jjf/qkuo1vm8gVV8BbPZDTTfTHExgW4k8Omq+ZkNEfSeNOndOXZtp/i5PnIDVi Wla3LdZDQ1wl1v8DbMiMwuSdbbd/OcGWxbG2QvnF+cNmkQPpW0fpbOtFQWc7RcbxQVOE VdA6f93qN15GiuL5JQ6VlSPYNmQ7w9+7KQPHHCyVwiK8sosUO0m7n5rAIggusgrINLCJ hXvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689737506; x=1692329506; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N+fPqqTlb7f5B1HO8H/M08CGeJfr68t9PEjL6hXPcNA=; b=ZgmtkELFaTX7F2OWtxeUdFxLxvohEBlwrMkloPxBclaXVtacEadN6a4zj0/jg7DhI+ 9HBE8rMMJd7Xuw1xlVHjpO7SPUG88eSo8qBFdq2mk1rZcpH8tkRW5IyxAoc7BUX9JPyb tqEWWxN0bEPTwrsr4wH7FPbZf2dBhFN0Y9Um3I4wZbp0rGvE7xCEuDNVMXQqFJ4jjHIV lH7T0dm4y5UMZbmGm6gziU3wFnBjKuUMsrBddNqnS6wx/HHbNUT3uGRUCYsPwvpHfhWL 3SLJ57entTWSbtTldKsebrXLyRvojrmjYAvlkLiTwZsmW12RX2OxsSXRCrgSzGw1l/Xm 6C1Q== X-Gm-Message-State: ABy/qLZ//ybuwug7DMq/c9bZIW78DRawpW0J4+r8acSwm2mzeMurH7He xGdNGTEVK/ZuQHBCH5PJyZEcl5ZMSte/nzFSclgxtWcNSprqhw== X-Google-Smtp-Source: APBJJlGeokEZNA+giYq0+AFAnB0t6qyghQ3pkyuHcCJN6jpLB1UoSI2nhc1+zih6G1yYeZ3i0xCBhzIrwec5O8HNWbU= X-Received: by 2002:a4a:2744:0:b0:566:fd3b:4329 with SMTP id w4-20020a4a2744000000b00566fd3b4329mr6901073oow.7.1689737505885; Tue, 18 Jul 2023 20:31:45 -0700 (PDT) MIME-Version: 1.0 References: <20230717142452.74yml7mfqkypfixp@alvherre.pgsql> In-Reply-To: From: Amit Kapila Date: Wed, 19 Jul 2023 09:01:34 +0530 Message-ID: Subject: Re: logicalrep_message_type throws an error To: Masahiko Sawada Cc: Alvaro Herrera , Ashutosh Bapat , Euler Taveira , pgsql-hackers@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Jul 18, 2023 at 10:27=E2=80=AFAM Masahiko Sawada wrote: > > On Tue, Jul 18, 2023 at 12:15=E2=80=AFPM Amit Kapila wrote: > > > > On Mon, Jul 17, 2023 at 7:54=E2=80=AFPM Alvaro Herrera wrote: > > > > > > > I have tried to check whether we have such usage in any other error > > callbacks. Though I haven't scrutinized each and every error callback, > > I found a few of them where an error can be raised. For example, > > > > rm_redo_error_callback()->initStringInfo() > > CopyFromErrorCallback()->limit_printout_length() > > shared_buffer_write_error_callback()->relpathperm()->relpathbackend()->= GetRelationPath()->psprintf() > > > > > Let's > > > just do the thing in the original patch you submitted, to ensure all > > > these strings are compile-time constants; that's likely the most robu= st. > > > > > Or can we use snprintf() writing "??? (%d)" to a fixed length char[8 + > 11] allocated on the stack instead? > In the above size calculation, shouldn't it be 7 + 11 where 7 is for (3 (???) + 1 for space + 2 for () + 1 for terminating null char) and 11 is for %d? BTW, this avoids dynamic allocation of the err string in logicalrep_message_type() but we can't return a locally allocated string, so do you think we should change the prototype of the function to get this as an argument and then use it both for valid and invalid cases? I think if there is some simpler way to achieve this then fine, otherwise, let's return a constant string like "???" from logicalrep_message_type() for the invalid action. --=20 With Regards, Amit Kapila.