Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nrScs-0004fz-4k for pgsql-hackers@arkaria.postgresql.org; Wed, 18 May 2022 22:58:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nrSbt-0003hW-0z for pgsql-hackers@arkaria.postgresql.org; Wed, 18 May 2022 22:57:41 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nrSbs-0003hK-MJ for pgsql-hackers@lists.postgresql.org; Wed, 18 May 2022 22:57:40 +0000 Received: from mail-lf1-x12a.google.com ([2a00:1450:4864:20::12a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nrSbq-0001YM-Fi for pgsql-hackers@lists.postgresql.org; Wed, 18 May 2022 22:57:39 +0000 Received: by mail-lf1-x12a.google.com with SMTP id u23so6144735lfc.1 for ; Wed, 18 May 2022 15:57:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yugabyte.com; s=google; h=mime-version:from:date:message-id:subject:to; bh=v8uyE8nxWcalsBQ/DDYLQ6FuWwG6UJYqn4znwvHoEV8=; b=c6aMML5aJZhom9YywZF1MCrwEj5Tz2mxDkAZ4IXA2JwYZuuQoooGCOh2vilrXPu/CN HWeM+u4+tb4cmaB78Bib1EPUn3e1Cba1drz81MzdYnlAiQ/qfIXWbl5/xDzrFbXmxeVj RJZROmR6vwXvpr7P10dU5jvjBbq6r1LlzeP/k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=v8uyE8nxWcalsBQ/DDYLQ6FuWwG6UJYqn4znwvHoEV8=; b=26sfYU1JkPPyjcwSPTW8HB07S84FXUMEpD/a4ZCGKhsQwkOVl9w/BCxmpp+7A19z5k Ssmk3u+DjxxuUmf+an6ZYUrCvoihOq3yiA9+FSv0DpE0lyCP9bUG90i8ST4Fx3nuv6F1 6ad7CQ0b16eXQmfnAzfTcs5SeM6kg2FYr1JnKikuB+lfqD+pplV8+2eokBod6XDhK8yr UyQ0rAiGeBzBNcQlEn4dfS/j229+q8bD8GMBKWICU22zzYKIlbw4R4t1wuEw5OJN2bFa 6T39/aYSh/ELSrKuRxRGfCxpft6ZKPBQLTAgTPExuHyY+bfL0dPnNiIO9dB1Kgz5G3YD EqIg== X-Gm-Message-State: AOAM533jeFyGCcjfVgbKvgr2agOy9162HJMM+54yEgt/NMMIJraO76Ev jtDmoxjzRW4VGV25ROgGn1zA/sUx/w79ZHQy23a4xWSXza/GWw== X-Google-Smtp-Source: ABdhPJxGD0L5wSPwKV7GuhZEmiEvUQGa4wzq2lkb+hrx2H/BSqgFWct/s6CVKLWNRcJ/mZpr/5ZtwcjkJI3EoFGD9wg= X-Received: by 2002:a05:6512:1694:b0:448:3fd4:c7a9 with SMTP id bu20-20020a056512169400b004483fd4c7a9mr1226514lfb.29.1652914656823; Wed, 18 May 2022 15:57:36 -0700 (PDT) MIME-Version: 1.0 From: Zhihong Yu Date: Wed, 18 May 2022 16:02:51 -0700 Message-ID: Subject: Re: ALTER TABLE SET ACCESS METHOD on partitioned tables To: PostgreSQL Developers Content-Type: multipart/alternative; boundary="000000000000f6ddca05df512e4e" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000f6ddca05df512e4e Content-Type: text/plain; charset="UTF-8" Hi, + tup = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); + accessMethodId = ((Form_pg_class) GETSTRUCT(tup))->relam; - /* look up the access method, verify it is for a table */ - if (accessMethod != NULL) - accessMethodId = get_table_am_oid(accessMethod, false); + if (!HeapTupleIsValid(tup)) + elog(ERROR, "cache lookup failed for relation %u", relid); Shouldn't the validity of tup be checked before relam field is accessed ? Cheers --000000000000f6ddca05df512e4e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

+ =C2=A0 =C2=A0 =C2=A0 tup =3D Sear= chSysCache1(RELOID, ObjectIdGetDatum(relid));
+ =C2=A0 =C2=A0 =C2=A0 acc= essMethodId =3D ((Form_pg_class) GETSTRUCT(tup))->relam;

- =C2=A0= /* look up the access method, verify it is for a table */
- =C2=A0 if (= accessMethod !=3D NULL)
- =C2=A0 =C2=A0 =C2=A0 accessMethodId =3D get_ta= ble_am_oid(accessMethod, false);
+ =C2=A0 =C2=A0 =C2=A0 if (!HeapTupleIs= Valid(tup))
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 elog(ERROR, "cache= lookup failed for relation %u", relid);

= Shouldn't the validity of tup be checked before relam=C2=A0field is acc= essed ?

Cheers
--000000000000f6ddca05df512e4e--