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 1osWkm-0006GU-Jj for pgsql-docs@arkaria.postgresql.org; Tue, 08 Nov 2022 22:07:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1osWkl-0001Wa-50 for pgsql-docs@arkaria.postgresql.org; Tue, 08 Nov 2022 22:07:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1osWkk-0001WR-U1 for pgsql-docs@lists.postgresql.org; Tue, 08 Nov 2022 22:07:30 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1osWki-0005Ds-Jj for pgsql-docs@lists.postgresql.org; Tue, 08 Nov 2022 22:07:30 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 2A8M7P1M3868104; Tue, 8 Nov 2022 17:07:25 -0500 From: Tom Lane To: ray.brinzer@gmail.com cc: pgsql-docs@lists.postgresql.org Subject: Re: Example code bug: destination->data In-reply-to: <166786713708.652.15395196776183543224@wrigleys.postgresql.org> References: <166786713708.652.15395196776183543224@wrigleys.postgresql.org> Comments: In-reply-to PG Doc comments form message dated "Tue, 08 Nov 2022 00:25:37 +0000" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <3868102.1667945245.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Tue, 08 Nov 2022 17:07:25 -0500 Message-ID: <3868103.1667945245@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Doc comments form writes: > 38.10.2. Base Types in C-Language Functions > In the last example of the section, this line appears: > memcpy(destination->data, buffer, 40); > For me, this gave the following error: > error: ‘text’ {aka ‘struct varlena’} has no member named ‘data’ > After tracking down the struct definition, I got the example working with: > destination->vl_dat instead. I assume this is correct, and that the member > name changed somewhere along the way. Hmm. It's correct by reference to the sample definition of struct text just above ... but you're right that that has relatively little to do with the definition we actually use nowadays. However, referencing vl_dat[] isn't considered good style either --- AFAICS there are exactly zero direct uses of that name. The style actually used in the code is to rely on VARDATA() or VARDATA_ANY(), as in the concat_text() example further down. Maybe the best fix is to leave the example as it stands but add a note that this is an oversimplified example? regards, tom lane