summaryrefslogtreecommitdiff
path: root/src/tutorial
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-02-27 23:48:10 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-02-27 23:48:10 +0000
commit234a02b2a888cacc4c09363cc1411ae4eac9bb51 (patch)
tree4aadb74b5d7bbcfc3cdae9c8703eac168d6108ae /src/tutorial
parent0459b591fc90b197ed31923b170c658cc30758d5 (diff)
downloadpostgresql-234a02b2a888cacc4c09363cc1411ae4eac9bb51.tar.gz
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/tutorial')
-rw-r--r--src/tutorial/funcs.c6
-rw-r--r--src/tutorial/funcs_new.c6
2 files changed, 6 insertions, 6 deletions
diff --git a/src/tutorial/funcs.c b/src/tutorial/funcs.c
index 18f8467ddd..f9f28a5c5e 100644
--- a/src/tutorial/funcs.c
+++ b/src/tutorial/funcs.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/tutorial/funcs.c,v 1.16 2006/09/27 16:19:42 tgl Exp $ */
+/* $PostgreSQL: pgsql/src/tutorial/funcs.c,v 1.17 2007/02/27 23:48:10 tgl Exp $ */
/******************************************************************************
These are user-defined functions that can be bound to a Postgres backend
@@ -71,7 +71,7 @@ copytext(text *t)
*/
text *new_t = (text *) palloc(VARSIZE(t));
- VARATT_SIZEP(new_t) = VARSIZE(t);
+ SET_VARSIZE(new_t, VARSIZE(t));
/*
* VARDATA is a pointer to the data region of the struct.
@@ -90,7 +90,7 @@ concat_text(text *arg1, text *arg2)
int32 new_text_size = arg1_size + arg2_size + VARHDRSZ;
text *new_text = (text *) palloc(new_text_size);
- VARATT_SIZEP(new_text) = new_text_size;
+ SET_VARSIZE(new_text, new_text_size);
memcpy(VARDATA(new_text), VARDATA(arg1), arg1_size);
memcpy(VARDATA(new_text) + arg1_size, VARDATA(arg2), arg2_size);
return new_text;
diff --git a/src/tutorial/funcs_new.c b/src/tutorial/funcs_new.c
index 88fff266c4..9811f5421b 100644
--- a/src/tutorial/funcs_new.c
+++ b/src/tutorial/funcs_new.c
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/tutorial/funcs_new.c,v 1.12 2006/09/27 16:19:42 tgl Exp $ */
+/* $PostgreSQL: pgsql/src/tutorial/funcs_new.c,v 1.13 2007/02/27 23:48:10 tgl Exp $ */
/******************************************************************************
These are user-defined functions that can be bound to a Postgres backend
@@ -83,7 +83,7 @@ copytext(PG_FUNCTION_ARGS)
*/
text *new_t = (text *) palloc(VARSIZE(t));
- VARATT_SIZEP(new_t) = VARSIZE(t);
+ SET_VARSIZE(new_t, VARSIZE(t));
/*
* VARDATA is a pointer to the data region of the struct.
@@ -106,7 +106,7 @@ concat_text(PG_FUNCTION_ARGS)
int32 new_text_size = arg1_size + arg2_size + VARHDRSZ;
text *new_text = (text *) palloc(new_text_size);
- VARATT_SIZEP(new_text) = new_text_size;
+ SET_VARSIZE(new_text, new_text_size);
memcpy(VARDATA(new_text), VARDATA(arg1), arg1_size);
memcpy(VARDATA(new_text) + arg1_size, VARDATA(arg2), arg2_size);
PG_RETURN_TEXT_P(new_text);