Dead code?

Started by Gregory Starkover 19 years ago4 messages
#1Gregory Stark
stark@enterprisedb.com

Is there anywhere we make use of this code that handles attlen == -2?

If so I'm curious where because I was thinking of doing something similar and
didn't realise we already had this capability. But I suspect it's just dead
code left over, possibly from the days before the Name data type?

/*
* att_addlength increments the given offset by the length of the attribute.
* attval is only accessed if we are dealing with a variable-length attribute.
*/
#define att_addlength(cur_offset, attlen, attval) \
( \
((attlen) > 0) ? \
( \
(cur_offset) + (attlen) \
) \
: (((attlen) == -1) ? \
( \
(cur_offset) + VARATT_SIZE(DatumGetPointer(attval)) \
) \
: \
( \
AssertMacro((attlen) == -2), \
(cur_offset) + (strlen(DatumGetCString(attval)) + 1) \
)) \
)

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com

#2Martijn van Oosterhout
kleptog@svana.org
In reply to: Gregory Stark (#1)
Re: Dead code?

On Tue, Sep 05, 2006 at 01:21:46PM +0100, Gregory Stark wrote:

Is there anywhere we make use of this code that handles attlen == -2?

If so I'm curious where because I was thinking of doing something similar and
didn't realise we already had this capability. But I suspect it's just dead
code left over, possibly from the days before the Name data type?

attlen -2 is used for cstring (null terminated strings).

Hope this helps,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/

Show quoted text

From each according to his ability. To each according to his ability to litigate.

#3Gregory Stark
stark@enterprisedb.com
In reply to: Martijn van Oosterhout (#2)
Re: Dead code?

Martijn van Oosterhout <kleptog@svana.org> writes:

attlen -2 is used for cstring (null terminated strings).

Hope this helps,

Well that's what the code I quoted indicates. But when do we ever store a
cstring in a tuple? Certainly I can't find any standard data types that use
it.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com

#4Martijn van Oosterhout
kleptog@svana.org
In reply to: Gregory Stark (#3)
Re: Dead code?

On Tue, Sep 05, 2006 at 01:42:57PM +0100, Gregory Stark wrote:

Martijn van Oosterhout <kleptog@svana.org> writes:

attlen -2 is used for cstring (null terminated strings).

Hope this helps,

Well that's what the code I quoted indicates. But when do we ever store a
cstring in a tuple? Certainly I can't find any standard data types that use
it.

# select textout('text');
textout
---------
text
(1 row)

The output is cstring, and stored in a tuple to send...

Hope this helps,
--
Martijn van Oosterhout <kleptog@svana.org> http://svana.org/kleptog/

Show quoted text

From each according to his ability. To each according to his ability to litigate.