"Tom Lane" <[EMAIL PROTECTED]> writes: > (It might be interesting to make textin produce a packed result when > possible, just to see what breaks; but I would be afraid to try to do > that for production...)
Reassuringly all checks pass with a hack like that in place. (attached) I think the right approach here is to define a new type text_packed * (which would just be a char* or varattrib_1b* or something like that). Then PG_GETARG_*_PP would return one of these new pointers. This does leave us with warnings whenever an old-style function calls a new-style function but I think there would be relatively few of those since we'll tackle the higher traffic areas first which will be the lower level functions. The benefit is that it will give us a warning if we try to pass a pointer from a new-style function to an old-style function which isn't prepared to receive it.
Index: src/backend/utils/adt/varlena.c =================================================================== RCS file: /home/stark/src/REPOSITORY/pgsql/src/backend/utils/adt/varlena.c,v retrieving revision 1.159 diff -c -r1.159 varlena.c *** src/backend/utils/adt/varlena.c 22 Sep 2007 04:40:03 -0000 1.159 --- src/backend/utils/adt/varlena.c 24 Sep 2007 14:08:30 -0000 *************** *** 263,268 **** --- 263,278 ---- int len; len = strlen(inputText); + + #ifdef DEBUG_PACKED_VARLENA + if (len < VARATT_SHORT_MAX-VARHDRSZ_SHORT) { + result = (text*) palloc(len + VARHDRSZ_SHORT); + memcpy(VARDATA_SHORT(result), inputText, len); + SET_VARSIZE_SHORT(result, len+VARHDRSZ_SHORT); + PG_RETURN_TEXT_P(result); + } + #endif + result = (text *) palloc(len + VARHDRSZ); SET_VARSIZE(result, len + VARHDRSZ);
-- Gregory Stark EnterpriseDB http://www.enterprisedb.com
---------------------------(end of broadcast)--------------------------- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate