mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Change CREATE TYPE to require datatype output and send functions to have
only one argument. (Per recent discussion, the option to accept multiple arguments is pretty useless for user-defined types, and would be a likely source of security holes if it was used.) Simplify call sites of output/send functions to not bother passing more than one argument.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.119 2005/03/29 03:01:31 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.120 2005/05/01 18:56:18 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -885,7 +885,6 @@ array_out(PG_FUNCTION_ARGS)
|
||||
bool typbyval;
|
||||
char typalign;
|
||||
char typdelim;
|
||||
Oid typioparam;
|
||||
char *p,
|
||||
*tmp,
|
||||
*retval,
|
||||
@@ -944,7 +943,6 @@ array_out(PG_FUNCTION_ARGS)
|
||||
typbyval = my_extra->typbyval;
|
||||
typalign = my_extra->typalign;
|
||||
typdelim = my_extra->typdelim;
|
||||
typioparam = my_extra->typioparam;
|
||||
|
||||
ndim = ARR_NDIM(v);
|
||||
dims = ARR_DIMS(v);
|
||||
@@ -986,10 +984,8 @@ array_out(PG_FUNCTION_ARGS)
|
||||
bool needquote;
|
||||
|
||||
itemvalue = fetch_att(p, typbyval, typlen);
|
||||
values[i] = DatumGetCString(FunctionCall3(&my_extra->proc,
|
||||
itemvalue,
|
||||
ObjectIdGetDatum(typioparam),
|
||||
Int32GetDatum(-1)));
|
||||
values[i] = DatumGetCString(FunctionCall1(&my_extra->proc,
|
||||
itemvalue));
|
||||
p = att_addlength(p, typlen, PointerGetDatum(p));
|
||||
p = (char *) att_align(p, typalign);
|
||||
|
||||
@@ -1344,7 +1340,6 @@ array_send(PG_FUNCTION_ARGS)
|
||||
int typlen;
|
||||
bool typbyval;
|
||||
char typalign;
|
||||
Oid typioparam;
|
||||
char *p;
|
||||
int nitems,
|
||||
i;
|
||||
@@ -1389,7 +1384,6 @@ array_send(PG_FUNCTION_ARGS)
|
||||
typlen = my_extra->typlen;
|
||||
typbyval = my_extra->typbyval;
|
||||
typalign = my_extra->typalign;
|
||||
typioparam = my_extra->typioparam;
|
||||
|
||||
ndim = ARR_NDIM(v);
|
||||
dim = ARR_DIMS(v);
|
||||
@@ -1416,9 +1410,8 @@ array_send(PG_FUNCTION_ARGS)
|
||||
|
||||
itemvalue = fetch_att(p, typbyval, typlen);
|
||||
|
||||
outputbytes = DatumGetByteaP(FunctionCall2(&my_extra->proc,
|
||||
itemvalue,
|
||||
ObjectIdGetDatum(typioparam)));
|
||||
outputbytes = DatumGetByteaP(FunctionCall1(&my_extra->proc,
|
||||
itemvalue));
|
||||
/* We assume the result will not have been toasted */
|
||||
pq_sendint(&buf, VARSIZE(outputbytes) - VARHDRSZ, 4);
|
||||
pq_sendbytes(&buf, VARDATA(outputbytes),
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/rowtypes.c,v 1.10 2005/04/30 20:04:33 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/rowtypes.c,v 1.11 2005/05/01 18:56:18 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -362,17 +362,14 @@ record_out(PG_FUNCTION_ARGS)
|
||||
|
||||
getTypeOutputInfo(column_type,
|
||||
&column_info->typiofunc,
|
||||
&column_info->typioparam,
|
||||
&typIsVarlena);
|
||||
fmgr_info_cxt(column_info->typiofunc, &column_info->proc,
|
||||
fcinfo->flinfo->fn_mcxt);
|
||||
column_info->column_type = column_type;
|
||||
}
|
||||
|
||||
value = DatumGetCString(FunctionCall3(&column_info->proc,
|
||||
values[i],
|
||||
ObjectIdGetDatum(column_info->typioparam),
|
||||
Int32GetDatum(tupdesc->attrs[i]->atttypmod)));
|
||||
value = DatumGetCString(FunctionCall1(&column_info->proc,
|
||||
values[i]));
|
||||
|
||||
/* Detect whether we need double quotes for this value */
|
||||
nq = (value[0] == '\0'); /* force quotes for empty string */
|
||||
@@ -702,16 +699,14 @@ record_send(PG_FUNCTION_ARGS)
|
||||
|
||||
getTypeBinaryOutputInfo(column_type,
|
||||
&column_info->typiofunc,
|
||||
&column_info->typioparam,
|
||||
&typIsVarlena);
|
||||
fmgr_info_cxt(column_info->typiofunc, &column_info->proc,
|
||||
fcinfo->flinfo->fn_mcxt);
|
||||
column_info->column_type = column_type;
|
||||
}
|
||||
|
||||
outputbytes = DatumGetByteaP(FunctionCall2(&column_info->proc,
|
||||
values[i],
|
||||
ObjectIdGetDatum(column_info->typioparam)));
|
||||
outputbytes = DatumGetByteaP(FunctionCall1(&column_info->proc,
|
||||
values[i]));
|
||||
|
||||
/* We assume the result will not have been toasted */
|
||||
pq_sendint(&buf, VARSIZE(outputbytes) - VARHDRSZ, 4);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* back to source text
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.194 2005/04/30 08:08:50 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.195 2005/05/01 18:56:18 tgl Exp $
|
||||
*
|
||||
* This software is copyrighted by Jan Wieck - Hamburg.
|
||||
*
|
||||
@@ -3594,7 +3594,6 @@ get_const_expr(Const *constval, deparse_context *context)
|
||||
{
|
||||
StringInfo buf = context->buf;
|
||||
Oid typoutput;
|
||||
Oid typioparam;
|
||||
bool typIsVarlena;
|
||||
char *extval;
|
||||
char *valptr;
|
||||
@@ -3613,12 +3612,10 @@ get_const_expr(Const *constval, deparse_context *context)
|
||||
}
|
||||
|
||||
getTypeOutputInfo(constval->consttype,
|
||||
&typoutput, &typioparam, &typIsVarlena);
|
||||
&typoutput, &typIsVarlena);
|
||||
|
||||
extval = DatumGetCString(OidFunctionCall3(typoutput,
|
||||
constval->constvalue,
|
||||
ObjectIdGetDatum(typioparam),
|
||||
Int32GetDatum(-1)));
|
||||
extval = DatumGetCString(OidFunctionCall1(typoutput,
|
||||
constval->constvalue));
|
||||
|
||||
switch (constval->consttype)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.119 2005/02/23 22:46:17 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.120 2005/05/01 18:56:18 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -2174,7 +2174,6 @@ array_to_text(PG_FUNCTION_ARGS)
|
||||
int typlen;
|
||||
bool typbyval;
|
||||
char typalign;
|
||||
Oid typioparam;
|
||||
StringInfo result_str = makeStringInfo();
|
||||
int i;
|
||||
ArrayMetaState *my_extra;
|
||||
@@ -2221,7 +2220,6 @@ array_to_text(PG_FUNCTION_ARGS)
|
||||
typlen = my_extra->typlen;
|
||||
typbyval = my_extra->typbyval;
|
||||
typalign = my_extra->typalign;
|
||||
typioparam = my_extra->typioparam;
|
||||
|
||||
for (i = 0; i < nitems; i++)
|
||||
{
|
||||
@@ -2230,10 +2228,8 @@ array_to_text(PG_FUNCTION_ARGS)
|
||||
|
||||
itemvalue = fetch_att(p, typbyval, typlen);
|
||||
|
||||
value = DatumGetCString(FunctionCall3(&my_extra->proc,
|
||||
itemvalue,
|
||||
ObjectIdGetDatum(typioparam),
|
||||
Int32GetDatum(-1)));
|
||||
value = DatumGetCString(FunctionCall1(&my_extra->proc,
|
||||
itemvalue));
|
||||
|
||||
if (i > 0)
|
||||
appendStringInfo(result_str, "%s%s", fldsep, value);
|
||||
|
||||
Reference in New Issue
Block a user