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.96) (envelope-from ) id 1vwtnS-002gd8-1p for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Mar 2026 03:18:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vwtnQ-00F7pP-15 for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Mar 2026 03:18:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vwtnQ-00F7pG-01 for pgsql-hackers@lists.postgresql.org; Mon, 02 Mar 2026 03:18:12 +0000 Received: from mail-yx1-xb141.google.com ([2607:f8b0:4864:20::b141]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vwtnM-00000001xgi-3f5t for pgsql-hackers@lists.postgresql.org; Mon, 02 Mar 2026 03:18:11 +0000 Received: by mail-yx1-xb141.google.com with SMTP id 956f58d0204a3-64c9ebd1369so3354024d50.1 for ; Sun, 01 Mar 2026 19:18:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772421488; cv=none; d=google.com; s=arc-20240605; b=fXDfikyQhLHEfbW1unnt2qhY4vTQzlHacO4lKyuWO6iM274ps/XDBY1mg07ZYygT/B VhA/yAD02PhlYeOSYZb0QFXk08wT/zVNn07T7nyOTd2o0y16OoHUN5Af5Lr+jeWtY0SW htYo+3ofBdF4gU60YO9+sbKTPLKu+dUuyvaJOy/so7K66QohmugyTCriuQGc49e4sQUJ qoluaccQzCYMZk/DkWAXdc8iw5nD7uoBxh8FDVdNYkOUD6n+i3EWYC6ZV/I9W/bFH/U6 nReTI82kSBv89LyYmr2cfXbM+XFJsuPS1x8cbSY4vqYV7EqSRXWTtn0fNncibAVhbgYA aMlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=VL36IlSZiIZkty5VCWwZux7pDXrl/3HLxdCzgzQpKjE=; fh=4D6DQOWZB3a79KAYyOqATQ3p3ElcLJyzpub2ZHhK/FI=; b=PLhFAdaPDflkwpZBV6cIHEfJINz0NbJfQVRC/xOwtNy70T0uhD8JtwiAv1t5cTk8rC H2VEQvJDiUS8p2au71EnWC+vE8owkra21H4BTUP0ZfjDW5R7D/j0uLhoy+Z7DRYmdoFd 0gAk8UIu5e4pFvDBj+tY15/XmpzlcofrQA0UWfwwrf/BG8Z0YD7ju9NqjvxPXZJbeIb5 50MYj1p7nhbzXytMFsPxyP7C1q/XUuh1staC7rAi1qwFubVtYcRX84O+wgMGD1o+Vymn du/hkVpTUmIBBOH7AL8fca3V6SX5Rox5Njy7TR4tkYI3YcL9jSaHIsm/Da4dHdEYeIwL YrCw==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772421488; x=1773026288; darn=lists.postgresql.org; 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=VL36IlSZiIZkty5VCWwZux7pDXrl/3HLxdCzgzQpKjE=; b=Y/c4V6AXtJYukbpXhZ81zsCUWDUa7rcgwtdSxPH72RzwcoFv3GBXhmDygQ08j19ayY utl9KGG/ZxtRbdGMLCAdsZ38AxNQsUlM//hswBgBTskO51jqjbdAdbMwtevyAgrMXzGx YJvOBBrEBtYUoR+GIA/9KbppLQioSCy3jzUQ0HSf4vby9xekbgZy8OoNFDqxDT4zxM0U J+0TLwCXVmfrq0WomtB+Wjs0yNpucJcboYQkj01UIPZpjQSXKseFT8lW7BK2onDF28PL SpCahwDJ6ekV4lgxZ9M2ge3vFMCKshy7ygc6mhM2UH5tZ2OIJerudVBu0m9rqdg5LYB0 10Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772421488; x=1773026288; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=VL36IlSZiIZkty5VCWwZux7pDXrl/3HLxdCzgzQpKjE=; b=JW+ayn4AMC3RmTOqwcv/Gn0lhn5DO0dZcxk446u3bl0YzqMZ6d0Ufy1SAjEjIKC/TD s6JCK//syxbECvxG8X8nGn6pZ73UWy2yn1fexnNxHIYR5gN1IjBYw30u5+J9b7zkn9YY luu8J/VDsStcTZmbI8ZO/ZyFjH7OJkmsgnthO821bBjyLPZEPQJhpkswfSLMsdjlxy/Z pOm5s/caFV+uFYho6sge5oLv6XA5/I/AKc+V3aRLok7xOvK3G79i/myK2r2dlGFwN8CJ hDrNVxEB1Xw8RpTihc0GxDey1afyAb0wFmfRoAlAuWcqqtwXJD+KFozWma4puBcmYdUl CYNA== X-Forwarded-Encrypted: i=1; AJvYcCX/gqNUiadl3Ir1rSedPkKP3QX23w6L4ZRgUc/IBSEnCWnhWk7407SEwOp85FhD0MDPo5TDfu6oezO2Mpza@lists.postgresql.org X-Gm-Message-State: AOJu0YwfW3URZM44YJC09ViHMrzoCZGWnTEI/PAF1rQtNaLe2M6AZmn7 PETr5rs9KKtJVR0JYZj5kSEy1tm/5W5FqOInMkN6qt901/YdXWVywu9hzZZw2G5SNT4o28EFLx0 R86fkF1kL6zx9cs+6PQ1LeoaaltnrgeQ= X-Gm-Gg: ATEYQzxBw6qsfxEnx2Sr2xueNLye45IGm5AO4Mex/y2WFZ4GjUbWDA9e8aitHLH5+DQ DOgXrWnH52L2RdvrXiRCQyGSdXs6ylkK8atn0FNUqsiM9apsnNarIV+JxIIxm8wM7SKzYl7FkrM IaipRQWxb6j+HC4KKHyf92bxR2Sb0sDrW53iRj/gs2FRZKXxDI1Adex0Uo6XvyDuSP2UoR67w0C HtRz5nuwGt64zs1A5rB3O0gaDQt2GJT2OJjMWACvUrrjMbuvrsom1XHMfeNW0t+YnjCv4xN7rOs +IGcaFU= X-Received: by 2002:a05:690e:200f:b0:64c:2a4b:72f with SMTP id 956f58d0204a3-64cc22e1f21mr7603821d50.44.1772421487726; Sun, 01 Mar 2026 19:18:07 -0800 (PST) MIME-Version: 1.0 References: <202602261236.ttanikrvfx6w@alvherre.pgsql> <63229AD5-48DB-417C-9361-EA478DAF57AF@gmail.com> In-Reply-To: From: zhanghu Date: Mon, 2 Mar 2026 11:17:56 +0800 X-Gm-Features: AaiRm51HksXzs5rOGNbqr0Bj18GyhRLT4bW_IVQqmaLYSRqN8xQndA2v12m_1zY Message-ID: Subject: Re: guc: make dereference style consistent in check_backtrace_functions To: Chao Li Cc: =?UTF-8?Q?=C3=81lvaro_Herrera?= , Junwang Zhao , 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 zhanghu =E4=BA=8E2026=E5=B9=B42=E6=9C=8827=E6=97=A5= =E5=91=A8=E4=BA=94 16:46=E5=86=99=E9=81=93=EF=BC=9A > > > > Chao Li =E4=BA=8E2026=E5=B9=B42=E6=9C=8827=E6=97= =A5=E5=91=A8=E4=BA=94 09:34=E5=86=99=E9=81=93=EF=BC=9A >> >> >> >> > On Feb 26, 2026, at 20:37, =C3=81lvaro Herrera = wrote: >> > >> > There is at least one more place in the code where this is done. >> > >> >> I did a search with the command: grep -RInE '\*[[:space:]]*[A-Za-z_][A-Z= a-z0-9_]*\[0\]' src contrib --include=3D'*.c' >> >> Excluding irrelevant results, there are 3 more occurrences: >> >> 1 - contrib/basic_archive/basic_archive.c line 105 >> ``` >> if (*newval =3D=3D NULL || *newval[0] =3D=3D '\0') >> return true; >> ``` >> >> Here, the code checks *newval first, which implies that the subsequent *= newval[0] is unintentional syntax. >> >> 2 - src/interfaces/ecpg/pgtypeslib/interval.c line 62 >> ``` >> int >> DecodeInterval(char **field, int *ftype, int nf, /* int range, */ >> int *dtype, struct /* pg_ */ tm *tm, fsec_t *= fsec) >> { >> ... >> if (IntervalStyle =3D=3D INTSTYLE_SQL_STANDARD && *field[0] =3D= =3D '-') >> { >> /* Check for additional explicit signs */ >> bool more_signs =3D false; >> >> for (i =3D 1; i < nf; i++) >> { >> if (*field[i] =3D=3D '-' || *field[i] =3D=3D '+'= ) >> { >> more_signs =3D true; >> break; >> } >> } >> ``` >> >> 3 - src/backend/utils/adt/datatime.c line 3522 >> ``` >> int >> DecodeInterval(char **field, int *ftype, int nf, int range, >> int *dtype, struct pg_itm_in *itm_in) >> { >> ... >> if (IntervalStyle =3D=3D INTSTYLE_SQL_STANDARD && nf > 0 && *fie= ld[0] =3D=3D '-') >> { >> force_negative =3D true; >> /* Check for additional explicit signs */ >> for (i =3D 1; i < nf; i++) >> { >> if (*field[i] =3D=3D '-' || *field[i] =3D=3D '+'= ) >> { >> force_negative =3D false; >> break; >> } >> } >> } >> ``` >> >> Where 2&3 makes this patch more interesting. >> >> Both occurrences are inside functions named DecodeInterval. For non-zero= i, the code also performs *field[i]: >> >> Given this code has been there for years, I don=E2=80=99t believe it is = a bug. I checked the callers of DecodeInterval in both files and found that= field is defined as: >> ``` >> char *field[MAXDATEFIELDS]; >> ``` >> >> This explains why *field[i] works; it is doing the intended thing by get= ting the first character of the string at array position i. >> >> However, since the precedence between the [] and * operators frequently = confuses people, I suggest adding parentheses to make the intention explici= t as *(field[i]). Furthermore, I think we should change the function signat= ures to use the type char *field[] to reflect the actual type the functions= expect. If a caller were to pass a true char ** typed field to DecodeInter= val, the current logic would result in a bug. >> >> See the attached diff for my suggested changes. >> >> Best regards, >> -- >> Chao Li (Evan) >> HighGo Software Co., Ltd. >> https://www.highgo.com/ >> >> Hi, >> >> Thank you all for the reviews and detailed feedback. >> >> =C3=81lvaro, thanks for pointing out that there were additional >> occurrences elsewhere in the tree. I have updated the original >> patch to address those cases; the revised version is attached >> as v2-0001. >> >> I also appreciate the review and suggestions from >> Chao and Junwang. >> >> Regarding the additional changes suggested by Chao: they go >> somewhat beyond the original scope of my original patch. >> To keep the discussion concrete, I have included Chao=E2=80=99s proposed >> diff as a separate patch (v2-0002) so it can be reviewed independently. >> >> I have reviewed v2-0002 locally, and it looks good to me. >> >> Thanks again for the guidance. >> >> Regards, >> Zhang Hu >> >> Hi, I am planning to add this patch to the current CommitFest, but when logging in to commitfest.postgresql.org I get the message: =E2=80=9CYou have not passed the cool off period yet.=E2=80=9D It seems my account is still within the cool-off period after registration. Could someone please add this patch to the CommitFest on my behalf? Thanks. Best regards, Zhang Hu