Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id D99521FC9B67 for ; Mon, 13 Feb 2012 14:57:47 -0400 (AST) Received: from mail-qy0-f174.google.com ([209.85.216.174]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Rx15u-0006hm-RQ for pgsql-docs@postgresql.org; Mon, 13 Feb 2012 18:57:48 +0000 Received: by qcqw6 with SMTP id w6so3134091qcq.19 for ; Mon, 13 Feb 2012 10:57:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=2zDv2thPXNLevZEOFOiyL1K5lfeTlDvmuUk72cKkajY=; b=MdBMLQKyANaMb+Uztc5Mkfos2eWutMVACSIX5pM49zsYQjYXwspNcx3GL3XQaDmvo0 oR+8+fc9QHcXsuzo4tpL5nViFMJXL6O3ZKkgYar1TBpHxtRjX/w5U6nzPDCeLh2uvQ3D b1/Pij+3bUtC/CWCGlW2C6MeEzmvUV+2UpTX0= Received: by 10.229.78.89 with SMTP id j25mr10155448qck.46.1329159454091; Mon, 13 Feb 2012 10:57:34 -0800 (PST) Received: from jay.local (c-24-63-250-125.hsd1.ma.comcast.net. [24.63.250.125]) by mx.google.com with ESMTPS id dm8sm35799195qab.18.2012.02.13.10.57.33 (version=SSLv3 cipher=OTHER); Mon, 13 Feb 2012 10:57:33 -0800 (PST) Message-ID: <4F395D1A.8070405@gmail.com> Date: Mon, 13 Feb 2012 13:57:30 -0500 From: Jay Levitt User-Agent: Postbox 3.0.2 (Macintosh/20111203) MIME-Version: 1.0 To: Tom Lane CC: "pgsql-docs@postgresql.org" Subject: Re: [PATCH] Use idiomatic style for varlena structs References: <4F392203.2040907@gmail.com> <10780.1329148311@sss.pgh.pa.us> In-Reply-To: <10780.1329148311@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201202/8 X-Sequence-Number: 7192 Tom Lane wrote: > Jay Levitt writes: >> I'm new to the codebase, but I think this patch reflects real-world usage; >> the PostgreSQL code itself always calls the length field "vl_len_", and I >> believe int32 is preferred over int4 (yes?) > > The point of calling it vl_len_ is that it should never be referenced by > that name, so I'm not sure that propagating that name into user > documentation is a good idea. I do agree with the part of this patch > that recommends use of SET_VARSIZE. Ah, ok. My confusion came from trying to build a new extension, using cube as a baseline; cube (and all the other contrib extensions) use vl_len_, so I saw a disconnect between the "int4 length" in the manual and the "int32 vl_len_" in all the real-world examples I had. My thought was that "vl_len_" *feels* more like a "this is mysterious and I'd better not touch it - I'll use that macro", while "length" feels more like something I might just set myself if I didn't know better. But maybe not. Either way, the int32/int4 thing should be fixed. > For context, the issues you're concerned about only matter when dealing > with a toastable datatype (not all varlena types are toastable). The > particular bit of docs here doesn't pretend to be explaining how to > write toast-safe code. I think it might be better from an expository > standpoint to cover that separately, rather than try to work it into the > very first pass over the concepts. Definitely; if anything, that's why I was favoring vl_len_. This is a magic field. Do not touch the magic. Jay