diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2007-02-27 23:48:10 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2007-02-27 23:48:10 +0000 |
commit | 234a02b2a888cacc4c09363cc1411ae4eac9bb51 (patch) | |
tree | 4aadb74b5d7bbcfc3cdae9c8703eac168d6108ae /src/backend/utils/adt/oracle_compat.c | |
parent | 0459b591fc90b197ed31923b170c658cc30758d5 (diff) | |
download | postgresql-234a02b2a888cacc4c09363cc1411ae4eac9bb51.tar.gz postgresql-234a02b2a888cacc4c09363cc1411ae4eac9bb51.zip |
Replace direct assignments to VARATT_SIZEP(x) with SET_VARSIZE(x, len).
Get rid of VARATT_SIZE and VARATT_DATA, which were simply redundant with
VARSIZE and VARDATA, and as a consequence almost no code was using the
longer names. Rename the length fields of struct varlena and various
derived structures to catch anyplace that was accessing them directly;
and clean up various places so caught. In itself this patch doesn't
change any behavior at all, but it is necessary infrastructure if we hope
to play any games with the representation of varlena headers.
Greg Stark and Tom Lane
Diffstat (limited to 'src/backend/utils/adt/oracle_compat.c')
-rw-r--r-- | src/backend/utils/adt/oracle_compat.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/backend/utils/adt/oracle_compat.c b/src/backend/utils/adt/oracle_compat.c index 6da6b30cca3..9fcd5ae747a 100644 --- a/src/backend/utils/adt/oracle_compat.c +++ b/src/backend/utils/adt/oracle_compat.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/oracle_compat.c,v 1.69 2007/02/08 18:19:33 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/oracle_compat.c,v 1.70 2007/02/27 23:48:08 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -144,7 +144,7 @@ wcstotext(const wchar_t *str, int ncodes) Assert(nbytes <= (size_t) (ncodes * MB_CUR_MAX)); - VARATT_SIZEP(result) = nbytes + VARHDRSZ; + SET_VARSIZE(result, nbytes + VARHDRSZ); return result; } @@ -229,7 +229,7 @@ win32_utf8_wcstotext(const wchar_t *str) errmsg("UTF-16 to UTF-8 translation failed: %lu", GetLastError()))); - VARATT_SIZEP(result) = nbytes + VARHDRSZ - 1; /* -1 to ignore null */ + SET_VARSIZE(result, nbytes + VARHDRSZ - 1); /* -1 to ignore null */ return result; } @@ -278,7 +278,7 @@ wstring_upper(char *str) in_text = palloc(nbytes + VARHDRSZ); memcpy(VARDATA(in_text), str, nbytes); - VARATT_SIZEP(in_text) = nbytes + VARHDRSZ; + SET_VARSIZE(in_text, nbytes + VARHDRSZ); workspace = texttowcs(in_text); @@ -312,7 +312,7 @@ wstring_lower(char *str) in_text = palloc(nbytes + VARHDRSZ); memcpy(VARDATA(in_text), str, nbytes); - VARATT_SIZEP(in_text) = nbytes + VARHDRSZ; + SET_VARSIZE(in_text, nbytes + VARHDRSZ); workspace = texttowcs(in_text); @@ -639,7 +639,7 @@ lpad(PG_FUNCTION_ARGS) ptr1 += mlen; } - VARATT_SIZEP(ret) = ptr_ret - (char *) ret; + SET_VARSIZE(ret, ptr_ret - (char *) ret); PG_RETURN_TEXT_P(ret); } @@ -735,7 +735,7 @@ rpad(PG_FUNCTION_ARGS) ptr2 = VARDATA(string2); } - VARATT_SIZEP(ret) = ptr_ret - (char *) ret; + SET_VARSIZE(ret, ptr_ret - (char *) ret); PG_RETURN_TEXT_P(ret); } @@ -944,7 +944,7 @@ dotrim(const char *string, int stringlen, /* Return selected portion of string */ result = (text *) palloc(VARHDRSZ + stringlen); - VARATT_SIZEP(result) = VARHDRSZ + stringlen; + SET_VARSIZE(result, VARHDRSZ + stringlen); memcpy(VARDATA(result), string, stringlen); return result; @@ -1017,7 +1017,7 @@ byteatrim(PG_FUNCTION_ARGS) } ret = (bytea *) palloc(VARHDRSZ + m); - VARATT_SIZEP(ret) = VARHDRSZ + m; + SET_VARSIZE(ret, VARHDRSZ + m); memcpy(VARDATA(ret), ptr, m); PG_RETURN_BYTEA_P(ret); @@ -1223,7 +1223,7 @@ translate(PG_FUNCTION_ARGS) m -= source_len; } - VARATT_SIZEP(result) = retlen + VARHDRSZ; + SET_VARSIZE(result, retlen + VARHDRSZ); /* * There may be some wasted space in the result if deletions occurred, but @@ -1275,13 +1275,13 @@ ascii(PG_FUNCTION_ARGS) ********************************************************************/ Datum -chr (PG_FUNCTION_ARGS) +chr(PG_FUNCTION_ARGS) { int32 cvalue = PG_GETARG_INT32(0); text *result; result = (text *) palloc(VARHDRSZ + 1); - VARATT_SIZEP(result) = VARHDRSZ + 1; + SET_VARSIZE(result, VARHDRSZ + 1); *VARDATA(result) = (char) cvalue; PG_RETURN_TEXT_P(result); @@ -1332,7 +1332,7 @@ repeat(PG_FUNCTION_ARGS) result = (text *) palloc(tlen); - VARATT_SIZEP(result) = tlen; + SET_VARSIZE(result, tlen); cp = VARDATA(result); for (i = 0; i < count; i++) { |