Commit 111d8e52 authored by Bruce Momjian's avatar Bruce Momjian

Back out array mega-patch.

Joe Conway
parent 621691d8
This diff is collapsed.
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.155 2003/06/24 23:14:42 momjian Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.156 2003/06/25 21:30:25 momjian Exp $
PostgreSQL documentation
-->
......@@ -6962,203 +6962,6 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
</sect1>
<sect1 id="functions-array">
<title>Array Functions</title>
<para>
<xref linkend="array-operators-table"> shows the operators
available for the <type>array</type> types.
</para>
<table id="array-operators-table">
<title><type>array</type> Operators</title>
<tgroup cols="4">
<thead>
<row>
<entry>Operator</entry>
<entry>Description</entry>
<entry>Example</entry>
<entry>Result</entry>
</row>
</thead>
<tbody>
<row>
<entry> <literal>=</literal> </entry>
<entry>equals</entry>
<entry><literal>ARRAY[1.1,2.1,3.1]::int[] = ARRAY[1,2,3]</literal></entry>
<entry><literal>t</literal></entry>
</row>
<row>
<entry> <literal>||</literal> </entry>
<entry>array-to-array concatenation</entry>
<entry><literal>ARRAY[1,2,3] || ARRAY[4,5,6]</literal></entry>
<entry><literal>{{1,2,3},{4,5,6}}</literal></entry>
</row>
<row>
<entry> <literal>||</literal> </entry>
<entry>array-to-array concatenation</entry>
<entry><literal>ARRAY[1,2,3] || ARRAY[[4,5,6],[7,8,9]]</literal></entry>
<entry><literal>{{1,2,3},{4,5,6},{7,8,9}}</literal></entry>
</row>
<row>
<entry> <literal>||</literal> </entry>
<entry>element-to-array concatenation</entry>
<entry><literal>3 || ARRAY[4,5,6]</literal></entry>
<entry><literal>{3,4,5,6}</literal></entry>
</row>
<row>
<entry> <literal>||</literal> </entry>
<entry>array-to-element concatenation</entry>
<entry><literal>ARRAY[4,5,6] || 7</literal></entry>
<entry><literal>{4,5,6,7}</literal></entry>
</row>
</tbody>
</tgroup>
</table>
<para>
<xref linkend="array-functions-table"> shows the functions
available for use with array types. See <xref linkend="arrays">
for more discussion and examples for the use of these functions.
</para>
<table id="array-functions-table">
<title><type>array</type> Functions</title>
<tgroup cols="5">
<thead>
<row>
<entry>Function</entry>
<entry>Return Type</entry>
<entry>Description</entry>
<entry>Example</entry>
<entry>Result</entry>
</row>
</thead>
<tbody>
<row>
<entry>
<literal>
<function>array_append</function>
(<type>anyarray</type>, <type>anyelement</type>)
</literal>
</entry>
<entry><type>anyarray</type></entry>
<entry>
append an element to the end of an array, returning
<literal>NULL</literal> for <literal>NULL</literal> inputs
</entry>
<entry><literal>array_append(ARRAY[1,2], 3)</literal></entry>
<entry><literal>{1,2,3}</literal></entry>
</row>
<row>
<entry>
<literal>
<function>array_cat</function>
(<type>anyarray</type>, <type>anyarray</type>)
</literal>
</entry>
<entry><type>anyarray</type></entry>
<entry>
concatenate two arrays, returning <literal>NULL</literal>
for <literal>NULL</literal> inputs
</entry>
<entry><literal>array_cat(ARRAY[1,2,3], ARRAY[4,5,6])</literal></entry>
<entry><literal>{{1,2,3},{4,5,6}}</literal></entry>
</row>
<row>
<entry>
<literal>
<function>array_dims</function>
(<type>anyarray</type>)
</literal>
</entry>
<entry><type>text</type></entry>
<entry>
returns a text representation of array dimension lower and upper bounds,
generating an ERROR for <literal>NULL</literal> inputs
</entry>
<entry><literal>array_dims(array[[1,2,3],[4,5,6]])</literal></entry>
<entry><literal>[1:2][1:3]</literal></entry>
</row>
<row>
<entry>
<literal>
<function>array_lower</function>
(<type>anyarray</type>, <type>integer</type>)
</literal>
</entry>
<entry><type>integer</type></entry>
<entry>
returns lower bound of the requested array dimension, returning
<literal>NULL</literal> for <literal>NULL</literal> inputs
</entry>
<entry><literal>array_lower(array_prepend(0, ARRAY[1,2,3]), 1)</literal></entry>
<entry><literal>0</literal></entry>
</row>
<row>
<entry>
<literal>
<function>array_prepend</function>
(<type>anyelement</type>, <type>anyarray</type>)
</literal>
</entry>
<entry><type>anyarray</type></entry>
<entry>
append an element to the beginning of an array, returning
<literal>NULL</literal> for <literal>NULL</literal> inputs
</entry>
<entry><literal>array_prepend(1, ARRAY[2,3])</literal></entry>
<entry><literal>{1,2,3}</literal></entry>
</row>
<row>
<entry>
<literal>
<function>array_to_string</function>
(<type>anyarray</type>, <type>text</type>)
</literal>
</entry>
<entry><type>text</type></entry>
<entry>
concatenates array elements using provided delimiter, returning
<literal>NULL</literal> for <literal>NULL</literal> inputs
</entry>
<entry><literal>array_to_string(array[1.1,2.2,3.3]::numeric(4,2)[],'~^~')</literal></entry>
<entry><literal>1.10~^~2.20~^~3.30</literal></entry>
</row>
<row>
<entry>
<literal>
<function>array_upper</function>
(<type>anyarray</type>, <type>integer</type>)
</literal>
</entry>
<entry><type>integer</type></entry>
<entry>
returns upper bound of the requested array dimension, returning
<literal>NULL</literal> for <literal>NULL</literal> inputs
</entry>
<entry><literal>array_upper(array_append(ARRAY[1,2,3], 4), 1)</literal></entry>
<entry><literal>4</literal></entry>
</row>
<row>
<entry>
<literal>
<function>string_to_array</function>
(<type>text</type>, <type>text</type>)
</literal>
</entry>
<entry><type>text[]</type></entry>
<entry>
splits string into array elements using provided delimiter, returning
<literal>NULL</literal> for <literal>NULL</literal> inputs
</entry>
<entry><literal>string_to_array('1.10~^~2.20~^~3.30','~^~')::float8[]</literal></entry>
<entry><literal>{1.1,2.2,3.3}</literal></entry>
</row>
</tbody>
</tgroup>
</table>
</sect1>
<sect1 id="functions-aggregate">
<title>Aggregate Functions</title>
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.57 2003/06/24 23:14:42 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.58 2003/06/25 21:30:25 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -50,16 +50,10 @@ AggregateCreate(const char *aggName,
Oid finalfn = InvalidOid; /* can be omitted */
Oid finaltype;
Oid fnArgs[FUNC_MAX_ARGS];
int nargs_transfn;
int nargs_finalfn;
int nargs;
Oid procOid;
TupleDesc tupDesc;
int i;
Oid rettype;
Oid *true_oid_array_transfn;
Oid *true_oid_array_finalfn;
bool retset;
FuncDetailCode fdresult;
ObjectAddress myself,
referenced;
......@@ -74,49 +68,24 @@ AggregateCreate(const char *aggName,
MemSet(fnArgs, 0, FUNC_MAX_ARGS * sizeof(Oid));
fnArgs[0] = aggTransType;
if (aggBaseType == ANYOID)
nargs_transfn = 1;
nargs = 1;
else
{
fnArgs[1] = aggBaseType;
nargs_transfn = 2;
nargs = 2;
}
/*
* func_get_detail looks up the function in the catalogs, does
* disambiguation for polymorphic functions, handles inheritance, and
* returns the funcid and type and set or singleton status of the
* function's return value. it also returns the true argument types
* to the function.
*/
fdresult = func_get_detail(aggtransfnName, NIL, nargs_transfn, fnArgs,
&transfn, &rettype, &retset,
&true_oid_array_transfn);
/* only valid case is a normal function */
if (fdresult != FUNCDETAIL_NORMAL)
func_error("AggregateCreate", aggtransfnName, nargs_transfn, fnArgs, NULL);
transfn = LookupFuncName(aggtransfnName, nargs, fnArgs);
if (!OidIsValid(transfn))
func_error("AggregateCreate", aggtransfnName, nargs_transfn, fnArgs, NULL);
/*
* enforce consistency with ANYARRAY and ANYELEMENT argument
* and return types, possibly modifying return type along the way
*/
rettype = enforce_generic_type_consistency(fnArgs, true_oid_array_transfn,
nargs_transfn, rettype);
if (rettype != aggTransType)
elog(ERROR, "return type of transition function %s is not %s",
NameListToString(aggtransfnName), format_type_be(aggTransType));
func_error("AggregateCreate", aggtransfnName, nargs, fnArgs, NULL);
tup = SearchSysCache(PROCOID,
ObjectIdGetDatum(transfn),
0, 0, 0);
if (!HeapTupleIsValid(tup))
func_error("AggregateCreate", aggtransfnName,
nargs_transfn, fnArgs, NULL);
func_error("AggregateCreate", aggtransfnName, nargs, fnArgs, NULL);
proc = (Form_pg_proc) GETSTRUCT(tup);
if (proc->prorettype != aggTransType)
elog(ERROR, "return type of transition function %s is not %s",
NameListToString(aggtransfnName), format_type_be(aggTransType));
/*
* If the transfn is strict and the initval is NULL, make sure input
......@@ -136,26 +105,17 @@ AggregateCreate(const char *aggName,
{
MemSet(fnArgs, 0, FUNC_MAX_ARGS * sizeof(Oid));
fnArgs[0] = aggTransType;
nargs_finalfn = 1;
fdresult = func_get_detail(aggfinalfnName, NIL, 1, fnArgs,
&finalfn, &rettype, &retset,
&true_oid_array_finalfn);
/* only valid case is a normal function */
if (fdresult != FUNCDETAIL_NORMAL)
func_error("AggregateCreate", aggfinalfnName, 1, fnArgs, NULL);
finalfn = LookupFuncName(aggfinalfnName, 1, fnArgs);
if (!OidIsValid(finalfn))
func_error("AggregateCreate", aggfinalfnName, 1, fnArgs, NULL);
/*
* enforce consistency with ANYARRAY and ANYELEMENT argument
* and return types, possibly modifying return type along the way
*/
finaltype = enforce_generic_type_consistency(fnArgs,
true_oid_array_finalfn,
nargs_finalfn, rettype);
tup = SearchSysCache(PROCOID,
ObjectIdGetDatum(finalfn),
0, 0, 0);
if (!HeapTupleIsValid(tup))
func_error("AggregateCreate", aggfinalfnName, 1, fnArgs, NULL);
proc = (Form_pg_proc) GETSTRUCT(tup);
finaltype = proc->prorettype;
ReleaseSysCache(tup);
}
else
{
......@@ -166,27 +126,6 @@ AggregateCreate(const char *aggName,
}
Assert(OidIsValid(finaltype));
/*
* special disallowed cases:
* 1) if finaltype is polymorphic, basetype cannot be ANY
* 2) if finaltype is polymorphic, both args to transfn must be
* polymorphic
*/
if (finaltype == ANYARRAYOID || finaltype == ANYELEMENTOID)
{
if (aggBaseType == ANYOID)
elog(ERROR, "aggregate with base type ANY must have a " \
"non-polymorphic return type");
if (nargs_transfn > 1 && (
(true_oid_array_transfn[0] != ANYARRAYOID &&
true_oid_array_transfn[0] != ANYELEMENTOID) ||
(true_oid_array_transfn[1] != ANYARRAYOID &&
true_oid_array_transfn[1] != ANYELEMENTOID)))
elog(ERROR, "aggregate with polymorphic return type requires " \
"state function with both arguments polymorphic");
}
/*
* Everything looks okay. Try to create the pg_proc entry for the
* aggregate. (This could fail if there's already a conflicting
......
......@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/aggregatecmds.c,v 1.6 2003/06/24 23:14:43 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/aggregatecmds.c,v 1.7 2003/06/25 21:30:26 momjian Exp $
*
* DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the
......@@ -119,9 +119,7 @@ DefineAggregate(List *names, List *parameters)
baseTypeId = typenameTypeId(baseType);
transTypeId = typenameTypeId(transType);
if (get_typtype(transTypeId) == 'p' &&
transTypeId != ANYARRAYOID &&
transTypeId != ANYELEMENTOID)
if (get_typtype(transTypeId) == 'p')
elog(ERROR, "Aggregate transition datatype cannot be %s",
format_type_be(transTypeId));
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.131 2003/06/24 23:14:43 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.132 2003/06/25 21:30:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -1528,17 +1528,17 @@ ExecEvalArray(ArrayExprState *astate, ExprContext *econtext,
{
/* Check other sub-arrays are compatible */
if (elem_ndims != ARR_NDIM(array))
elog(ERROR, "Multidimensional arrays must have array "
elog(ERROR, "Multiple dimension arrays must have array "
"expressions with matching number of dimensions");
if (memcmp(elem_dims, ARR_DIMS(array),
elem_ndims * sizeof(int)) != 0)
elog(ERROR, "Multidimensional arrays must have array "
elog(ERROR, "Multiple dimension arrays must have array "
"expressions with matching dimensions");
if (memcmp(elem_lbs, ARR_LBOUND(array),
elem_ndims * sizeof(int)) != 0)
elog(ERROR, "Multidimensional arrays must have array "
elog(ERROR, "Multiple dimension arrays must have array "
"expressions with matching dimensions");
}
......
......@@ -45,7 +45,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.108 2003/06/24 23:14:43 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.109 2003/06/25 21:30:28 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -58,7 +58,6 @@
#include "executor/executor.h"
#include "executor/nodeAgg.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "optimizer/clauses.h"
#include "parser/parse_coerce.h"
#include "parser/parse_expr.h"
......@@ -213,7 +212,7 @@ static TupleTableSlot *agg_retrieve_direct(AggState *aggstate);
static void agg_fill_hash_table(AggState *aggstate);
static TupleTableSlot *agg_retrieve_hash_table(AggState *aggstate);
static Datum GetAggInitVal(Datum textInitVal, Oid transtype);
static Oid resolve_type(Oid type_to_resolve, Oid context_type);
/*
* Initialize all aggregates for a new group of input values.
......@@ -352,12 +351,14 @@ advance_transition_function(AggState *aggstate,
fcinfo.context = NULL;
fcinfo.resultinfo = NULL;
fcinfo.isnull = false;
fcinfo.flinfo = &peraggstate->transfn;
fcinfo.nargs = 2;
fcinfo.arg[0] = pergroupstate->transValue;
fcinfo.argnull[0] = pergroupstate->transValueIsNull;
fcinfo.arg[1] = newVal;
fcinfo.argnull[1] = isNull;
newVal = FunctionCallInvoke(&fcinfo);
/*
......@@ -1186,21 +1187,7 @@ ExecInitAgg(Agg *node, EState *estate)
AclResult aclresult;
Oid transfn_oid,
finalfn_oid;
FuncExpr *transfnexpr,
*finalfnexpr;
Datum textInitVal;
List *fargs;
Oid agg_rt_type;
Oid *transfn_arg_types;
List *transfn_args = NIL;
int transfn_nargs;
Oid transfn_ret_type;
Oid *finalfn_arg_types = NULL;
List *finalfn_args = NIL;
Oid finalfn_ret_type = InvalidOid;
int finalfn_nargs = 0;
Node *arg0;
Node *arg1;
int i;
/* Planner should have assigned aggregate to correct level */
......@@ -1251,166 +1238,6 @@ ExecInitAgg(Agg *node, EState *estate)
&peraggstate->transtypeLen,
&peraggstate->transtypeByVal);
peraggstate->transfn_oid = transfn_oid = aggform->aggtransfn;
peraggstate->finalfn_oid = finalfn_oid = aggform->aggfinalfn;
/* get the runtime aggregate argument type */
fargs = aggref->args;
agg_rt_type = exprType((Node *) nth(0, fargs));
/* get the transition function argument and return types */
transfn_ret_type = get_func_rettype(transfn_oid);
transfn_arg_types = get_func_argtypes(transfn_oid, &transfn_nargs);
/* resolve any polymorphic types */
if (transfn_nargs == 2)
/* base type was not ANY */
{
if (transfn_arg_types[1] == ANYARRAYOID ||
transfn_arg_types[1] == ANYELEMENTOID)
transfn_arg_types[1] = agg_rt_type;
transfn_arg_types[0] = resolve_type(transfn_arg_types[0],
agg_rt_type);
/*
* Build arg list to use on the transfn FuncExpr node. We really
* only care that the node type is correct so that the transfn
* can discover the actual argument types at runtime using
* get_fn_expr_argtype()
*/
arg0 = (Node *) makeRelabelType((Expr *) NULL, transfn_arg_types[0],
-1, COERCE_DONTCARE);
arg1 = (Node *) makeRelabelType((Expr *) NULL, transfn_arg_types[1],
-1, COERCE_DONTCARE);
transfn_args = makeList2(arg0, arg1);
/*
* the state transition function always returns the same type
* as its first argument
*/
if (transfn_ret_type == ANYARRAYOID ||
transfn_ret_type == ANYELEMENTOID)
transfn_ret_type = transfn_arg_types[0];
}
else if (transfn_nargs == 1)
/*
* base type was ANY, therefore the aggregate return type should
* be non-polymorphic
*/
{
Oid finaltype = get_func_rettype(aggref->aggfnoid);
/*
* this should have been prevented in AggregateCreate,
* but check anyway
*/
if (finaltype == ANYARRAYOID || finaltype == ANYELEMENTOID)
elog(ERROR, "aggregate with base type ANY must have a " \
"non-polymorphic return type");
/* see if we have a final function */
if (OidIsValid(finalfn_oid))
{
finalfn_arg_types = get_func_argtypes(finalfn_oid, &finalfn_nargs);
if (finalfn_nargs != 1)
elog(ERROR, "final function takes unexpected number " \
"of arguments: %d", finalfn_nargs);
/*
* final function argument is always the same as the state
* function return type
*/
if (finalfn_arg_types[0] != ANYARRAYOID &&
finalfn_arg_types[0] != ANYELEMENTOID)
{
/* if it is not ambiguous, use it */
transfn_ret_type = finalfn_arg_types[0];
}
else
{
/* if it is ambiguous, try to derive it */
finalfn_ret_type = finaltype;
finalfn_arg_types[0] = resolve_type(finalfn_arg_types[0],
finalfn_ret_type);
transfn_ret_type = finalfn_arg_types[0];
}
}
else
transfn_ret_type = finaltype;
transfn_arg_types[0] = resolve_type(transfn_arg_types[0],
transfn_ret_type);
/*
* Build arg list to use on the transfn FuncExpr node. We really
* only care that the node type is correct so that the transfn
* can discover the actual argument types at runtime using
* get_fn_expr_argtype()
*/
arg0 = (Node *) makeRelabelType((Expr *) NULL, transfn_arg_types[0],
-1, COERCE_DONTCARE);
transfn_args = makeList1(arg0);
}
else
elog(ERROR, "state transition function takes unexpected number " \
"of arguments: %d", transfn_nargs);
if (OidIsValid(finalfn_oid))
{
/* get the final function argument and return types */
if (finalfn_ret_type == InvalidOid)
finalfn_ret_type = get_func_rettype(finalfn_oid);
if (!finalfn_arg_types)
{
finalfn_arg_types = get_func_argtypes(finalfn_oid, &finalfn_nargs);
if (finalfn_nargs != 1)
elog(ERROR, "final function takes unexpected number " \
"of arguments: %d", finalfn_nargs);
}
/*
* final function argument is always the same as the state
* function return type, which by now should have been resolved
*/
if (finalfn_arg_types[0] == ANYARRAYOID ||
finalfn_arg_types[0] == ANYELEMENTOID)
finalfn_arg_types[0] = transfn_ret_type;
/*
* Build arg list to use on the finalfn FuncExpr node. We really
* only care that the node type is correct so that the finalfn
* can discover the actual argument type at runtime using
* get_fn_expr_argtype()
*/
arg0 = (Node *) makeRelabelType((Expr *) NULL, finalfn_arg_types[0],
-1, COERCE_DONTCARE);
finalfn_args = makeList1(arg0);
finalfn_ret_type = resolve_type(finalfn_ret_type,
finalfn_arg_types[0]);
}
fmgr_info(transfn_oid, &peraggstate->transfn);
transfnexpr = (FuncExpr *) make_funcclause(transfn_oid,
transfn_ret_type,
false, /* cannot be a set */
COERCE_DONTCARE, /* to match any user expr */
transfn_args);
peraggstate->transfn.fn_expr = (Node *) transfnexpr;
if (OidIsValid(finalfn_oid))
{
fmgr_info(finalfn_oid, &peraggstate->finalfn);
finalfnexpr = (FuncExpr *) make_funcclause(finalfn_oid,
finalfn_ret_type,
false, /* cannot be a set */
COERCE_DONTCARE, /* to match any user expr */
finalfn_args);
peraggstate->finalfn.fn_expr = (Node *) finalfnexpr;
}
/*
* initval is potentially null, so don't try to access it as a
* struct field. Must do it the hard way with SysCacheGetAttr.
......@@ -1423,7 +1250,14 @@ ExecInitAgg(Agg *node, EState *estate)
peraggstate->initValue = (Datum) 0;
else
peraggstate->initValue = GetAggInitVal(textInitVal,
transfn_arg_types[0]);
aggform->aggtranstype);
peraggstate->transfn_oid = transfn_oid = aggform->aggtransfn;
peraggstate->finalfn_oid = finalfn_oid = aggform->aggfinalfn;
fmgr_info(transfn_oid, &peraggstate->transfn);
if (OidIsValid(finalfn_oid))
fmgr_info(finalfn_oid, &peraggstate->finalfn);
/*
* If the transfn is strict and the initval is NULL, make sure
......@@ -1635,36 +1469,3 @@ aggregate_dummy(PG_FUNCTION_ARGS)
fcinfo->flinfo->fn_oid);
return (Datum) 0; /* keep compiler quiet */
}
static Oid
resolve_type(Oid type_to_resolve, Oid context_type)
{
Oid resolved_type;
if (context_type == ANYARRAYOID || context_type == ANYELEMENTOID)
resolved_type = type_to_resolve;
else if (type_to_resolve == ANYARRAYOID)
/* any array */
{
Oid context_type_arraytype = get_array_type(context_type);
if (context_type_arraytype != InvalidOid)
resolved_type = context_type_arraytype;
else
resolved_type = context_type;
}
else if (type_to_resolve == ANYELEMENTOID)
/* any element */
{
Oid context_type_elemtype = get_element_type(context_type);
if (context_type_elemtype != InvalidOid)
resolved_type = context_type_elemtype;
else
resolved_type = context_type;
}
else
resolved_type = type_to_resolve;
return resolved_type;
}
This diff is collapsed.
......@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.255 2003/06/25 04:19:24 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.256 2003/06/25 21:30:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -728,7 +728,6 @@ _copyAggref(Aggref *from)
COPY_SCALAR_FIELD(agglevelsup);
COPY_SCALAR_FIELD(aggstar);
COPY_SCALAR_FIELD(aggdistinct);
COPY_NODE_FIELD(args);
return newnode;
}
......@@ -827,7 +826,6 @@ _copySubLink(SubLink *from)
COPY_SCALAR_FIELD(subLinkType);
COPY_SCALAR_FIELD(useOr);
COPY_SCALAR_FIELD(isExpr);
COPY_NODE_FIELD(lefthand);
COPY_NODE_FIELD(operName);
COPY_OIDLIST_FIELD(operOids);
......@@ -846,12 +844,6 @@ _copySubPlan(SubPlan *from)
COPY_SCALAR_FIELD(subLinkType);
COPY_SCALAR_FIELD(useOr);
COPY_SCALAR_FIELD(isExpr);
COPY_SCALAR_FIELD(exprtype);
COPY_SCALAR_FIELD(elemtype);
COPY_SCALAR_FIELD(elmlen);
COPY_SCALAR_FIELD(elmbyval);
COPY_SCALAR_FIELD(elmalign);
COPY_NODE_FIELD(exprs);
COPY_INTLIST_FIELD(paramIds);
COPY_NODE_FIELD(plan);
......
......@@ -18,7 +18,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.198 2003/06/25 04:19:24 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.199 2003/06/25 21:30:29 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -205,7 +205,6 @@ _equalAggref(Aggref *a, Aggref *b)
COMPARE_SCALAR_FIELD(agglevelsup);
COMPARE_SCALAR_FIELD(aggstar);
COMPARE_SCALAR_FIELD(aggdistinct);
COMPARE_NODE_FIELD(args);
return true;
}
......@@ -302,7 +301,6 @@ _equalSubLink(SubLink *a, SubLink *b)
{
COMPARE_SCALAR_FIELD(subLinkType);
COMPARE_SCALAR_FIELD(useOr);
COMPARE_SCALAR_FIELD(isExpr);
COMPARE_NODE_FIELD(lefthand);
COMPARE_NODE_FIELD(operName);
COMPARE_OIDLIST_FIELD(operOids);
......@@ -316,12 +314,6 @@ _equalSubPlan(SubPlan *a, SubPlan *b)
{
COMPARE_SCALAR_FIELD(subLinkType);
COMPARE_SCALAR_FIELD(useOr);
COMPARE_SCALAR_FIELD(isExpr);
COMPARE_SCALAR_FIELD(exprtype);
COMPARE_SCALAR_FIELD(elemtype);
COMPARE_SCALAR_FIELD(elmlen);
COMPARE_SCALAR_FIELD(elmbyval);
COMPARE_SCALAR_FIELD(elmalign);
COMPARE_NODE_FIELD(exprs);
COMPARE_INTLIST_FIELD(paramIds);
/* should compare plans, but have to settle for comparing plan IDs */
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.209 2003/06/24 23:14:43 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.210 2003/06/25 21:30:29 momjian Exp $
*
* NOTES
* Every node type that can appear in stored rules' parsetrees *must*
......@@ -616,7 +616,6 @@ _outAggref(StringInfo str, Aggref *node)
WRITE_UINT_FIELD(agglevelsup);
WRITE_BOOL_FIELD(aggstar);
WRITE_BOOL_FIELD(aggdistinct);
WRITE_NODE_FIELD(args);
}
static void
......@@ -702,7 +701,6 @@ _outSubLink(StringInfo str, SubLink *node)
WRITE_ENUM_FIELD(subLinkType, SubLinkType);
WRITE_BOOL_FIELD(useOr);
WRITE_BOOL_FIELD(isExpr);
WRITE_NODE_FIELD(lefthand);
WRITE_NODE_FIELD(operName);
WRITE_OIDLIST_FIELD(operOids);
......@@ -716,12 +714,6 @@ _outSubPlan(StringInfo str, SubPlan *node)
WRITE_ENUM_FIELD(subLinkType, SubLinkType);
WRITE_BOOL_FIELD(useOr);
WRITE_BOOL_FIELD(isExpr);
WRITE_OID_FIELD(exprtype);
WRITE_OID_FIELD(elemtype);
WRITE_INT_FIELD(elmlen);
WRITE_BOOL_FIELD(elmbyval);
WRITE_CHAR_FIELD(elmalign);
WRITE_NODE_FIELD(exprs);
WRITE_INTLIST_FIELD(paramIds);
WRITE_NODE_FIELD(plan);
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.155 2003/06/24 23:14:43 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.156 2003/06/25 21:30:30 momjian Exp $
*
* NOTES
* Path and Plan nodes do not have any readfuncs support, because we
......@@ -416,7 +416,6 @@ _readAggref(void)
READ_UINT_FIELD(agglevelsup);
READ_BOOL_FIELD(aggstar);
READ_BOOL_FIELD(aggdistinct);
READ_NODE_FIELD(args);
READ_DONE();
}
......@@ -546,7 +545,6 @@ _readSubLink(void)
READ_ENUM_FIELD(subLinkType, SubLinkType);
READ_BOOL_FIELD(useOr);
READ_BOOL_FIELD(isExpr);
READ_NODE_FIELD(lefthand);
READ_NODE_FIELD(operName);
READ_OIDLIST_FIELD(operOids);
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.77 2003/06/24 23:14:43 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.78 2003/06/25 21:30:30 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -83,7 +83,7 @@ typedef struct finalize_primnode_context
static List *convert_sublink_opers(List *lefthand, List *operOids,
List *targetlist, int rtindex,
bool isExpr, List **righthandIds);
List **righthandIds);
static bool subplan_is_hashable(SubLink *slink, SubPlan *node);
static Node *replace_correlation_vars_mutator(Node *node, void *context);
static Node *process_sublinks_mutator(Node *node, bool *isTopQual);
......@@ -299,12 +299,6 @@ make_subplan(SubLink *slink, List *lefthand, bool isTopQual)
*/
node->subLinkType = slink->subLinkType;
node->useOr = slink->useOr;
node->isExpr = slink->isExpr;
node->exprtype = InvalidOid;
node->elemtype = InvalidOid;
node->elmlen = 0;
node->elmbyval = false;
node->elmalign = '\0';
node->exprs = NIL;
node->paramIds = NIL;
node->useHashTable = false;
......@@ -380,7 +374,7 @@ make_subplan(SubLink *slink, List *lefthand, bool isTopQual)
exprs = convert_sublink_opers(lefthand,
slink->operOids,
plan->targetlist,
0, node->isExpr,
0,
&node->paramIds);
node->setParam = listCopy(node->paramIds);
PlannerInitPlan = lappend(PlannerInitPlan, node);
......@@ -463,7 +457,7 @@ make_subplan(SubLink *slink, List *lefthand, bool isTopQual)
node->exprs = convert_sublink_opers(lefthand,
slink->operOids,
plan->targetlist,
0, node->isExpr,
0,
&node->paramIds);
/*
......@@ -505,7 +499,7 @@ make_subplan(SubLink *slink, List *lefthand, bool isTopQual)
static List *
convert_sublink_opers(List *lefthand, List *operOids,
List *targetlist, int rtindex,
bool isExpr, List **righthandIds)
List **righthandIds)
{
List *result = NIL;
List *lst;
......@@ -560,38 +554,13 @@ convert_sublink_opers(List *lefthand, List *operOids,
* are not expecting to have to resolve unknown Params, so
* it's okay to pass a null pstate.)
*/
if (!isExpr)
{
result = lappend(result,
make_op_expr(NULL,
tup,
leftop,
rightop,
exprType(leftop),
te->resdom->restype));
}
else
{
Oid exprtype = te->resdom->restype;
Oid elemtype = get_element_type(exprtype);
if (elemtype != InvalidOid)
result = lappend(result,
make_op_expr(NULL,
tup,
leftop,
rightop,
exprType(leftop),
elemtype));
else
result = lappend(result,
make_op_expr(NULL,
tup,
leftop,
rightop,
exprType(leftop),
exprtype));
}
result = lappend(result,
make_op_expr(NULL,
tup,
leftop,
rightop,
exprType(leftop),
te->resdom->restype));
ReleaseSysCache(tup);
......@@ -702,17 +671,13 @@ convert_IN_to_join(Query *parse, SubLink *sublink)
/*
* The sublink type must be "= ANY" --- that is, an IN operator.
* (We require the operator name to be unqualified, which may be
* overly paranoid, or may not be.) It must not be an Expression
* sublink.
* overly paranoid, or may not be.)
*/
if (sublink->subLinkType != ANY_SUBLINK)
return NULL;
if (length(sublink->operName) != 1 ||
strcmp(strVal(lfirst(sublink->operName)), "=") != 0)
return NULL;
if (sublink->isExpr)
return NULL;
/*
* The sub-select must not refer to any Vars of the parent query.
* (Vars of higher levels should be okay, though.)
......@@ -765,7 +730,7 @@ convert_IN_to_join(Query *parse, SubLink *sublink)
exprs = convert_sublink_opers(sublink->lefthand,
sublink->operOids,
subselect->targetList,
rtindex, sublink->isExpr,
rtindex,
&ininfo->sub_targetlist);
return (Node *) make_ands_explicit(exprs);
}
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.140 2003/06/24 23:14:43 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.141 2003/06/25 21:30:30 momjian Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
......@@ -132,28 +132,6 @@ get_rightop(Expr *clause)
return NULL;
}
/*****************************************************************************
* FUNCTION clause functions
*****************************************************************************/
/*
* make_funcclause
* Creates a function clause given its function info and argument list.
*/
Expr *
make_funcclause(Oid funcid, Oid funcresulttype, bool funcretset,
CoercionForm funcformat, List *funcargs)
{
FuncExpr *expr = makeNode(FuncExpr);
expr->funcid = funcid;
expr->funcresulttype = funcresulttype;
expr->funcretset = funcretset;
expr->funcformat = funcformat;
expr->args = funcargs;
return (Expr *) expr;
}
/*****************************************************************************
* NOT clause functions
*****************************************************************************/
......
......@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.420 2003/06/25 04:19:24 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.421 2003/06/25 21:30:30 momjian Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
......@@ -5505,7 +5505,6 @@ r_expr: row IN_P select_with_parens
{
SubLink *n = makeNode(SubLink);
n->subLinkType = ANY_SUBLINK;
n->isExpr = false;
n->lefthand = $1;
n->operName = makeList1(makeString("="));
n->subselect = $3;
......@@ -5516,7 +5515,6 @@ r_expr: row IN_P select_with_parens
/* Make an IN node */
SubLink *n = makeNode(SubLink);
n->subLinkType = ANY_SUBLINK;
n->isExpr = false;
n->lefthand = $1;
n->operName = makeList1(makeString("="));
n->subselect = $4;
......@@ -5528,7 +5526,6 @@ r_expr: row IN_P select_with_parens
{
SubLink *n = makeNode(SubLink);
n->subLinkType = $3;
n->isExpr = false;
n->lefthand = $1;
n->operName = $2;
n->subselect = $4;
......@@ -5539,7 +5536,6 @@ r_expr: row IN_P select_with_parens
{
SubLink *n = makeNode(SubLink);
n->subLinkType = MULTIEXPR_SUBLINK;
n->isExpr = false;
n->lefthand = $1;
n->operName = $2;
n->subselect = $3;
......@@ -5923,7 +5919,6 @@ a_expr: c_expr { $$ = $1; }
{
SubLink *n = (SubLink *)$3;
n->subLinkType = ANY_SUBLINK;
n->isExpr = false;
n->lefthand = makeList1($1);
n->operName = makeList1(makeString("="));
$$ = (Node *)n;
......@@ -5951,7 +5946,6 @@ a_expr: c_expr { $$ = $1; }
{
/* Make an IN node */
SubLink *n = (SubLink *)$4;
n->isExpr = false;
n->subLinkType = ANY_SUBLINK;
n->lefthand = makeList1($1);
n->operName = makeList1(makeString("="));
......@@ -5978,38 +5972,11 @@ a_expr: c_expr { $$ = $1; }
{
SubLink *n = makeNode(SubLink);
n->subLinkType = $3;
n->isExpr = false;
n->lefthand = makeList1($1);
n->operName = $2;
n->subselect = $4;
$$ = (Node *)n;
}
| a_expr qual_all_Op sub_type '(' a_expr ')' %prec Op
{
SubLink *n = makeNode(SubLink);
SelectStmt *s = makeNode(SelectStmt);
ResTarget *r = makeNode(ResTarget);
r->name = NULL;
r->indirection = NIL;
r->val = (Node *)$5;
s->distinctClause = NIL;
s->targetList = makeList1(r);
s->into = NULL;
s->intoColNames = NIL;
s->fromClause = NIL;
s->whereClause = NULL;
s->groupClause = NIL;
s->havingClause = NULL;
n->subLinkType = $3;
n->isExpr = true;
n->lefthand = makeList1($1);
n->operName = $2;
n->subselect = (Node *) s;
$$ = (Node *)n;
}
| UNIQUE select_with_parens %prec Op
{
/* Not sure how to get rid of the parentheses
......@@ -6586,7 +6553,6 @@ c_expr: columnref { $$ = (Node *) $1; }
{
SubLink *n = makeNode(SubLink);
n->subLinkType = EXPR_SUBLINK;
n->isExpr = false;
n->lefthand = NIL;
n->operName = NIL;
n->subselect = $1;
......@@ -6596,7 +6562,6 @@ c_expr: columnref { $$ = (Node *) $1; }
{
SubLink *n = makeNode(SubLink);
n->subLinkType = EXISTS_SUBLINK;
n->isExpr = false;
n->lefthand = NIL;
n->operName = NIL;
n->subselect = $2;
......@@ -6606,7 +6571,6 @@ c_expr: columnref { $$ = (Node *) $1; }
{
SubLink *n = makeNode(SubLink);
n->subLinkType = ARRAY_SUBLINK;
n->isExpr = false;
n->lefthand = NIL;
n->operName = NIL;
n->subselect = $2;
......@@ -6781,7 +6745,6 @@ trim_list: a_expr FROM expr_list { $$ = lappend($3, $1); }
in_expr: select_with_parens
{
SubLink *n = makeNode(SubLink);
n->isExpr = false;
n->subselect = $1;
/* other fields will be filled later */
$$ = (Node *)n;
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.99 2003/06/25 04:32:03 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.100 2003/06/25 21:30:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -859,11 +859,7 @@ enforce_generic_type_consistency(Oid *actual_arg_types,
/* Get the element type based on the array type, if we have one */
if (OidIsValid(array_typeid))
{
if (array_typeid != ANYARRAYOID)
array_typelem = get_element_type(array_typeid);
else
array_typelem = ANYELEMENTOID;
array_typelem = get_element_type(array_typeid);
if (!OidIsValid(array_typelem))
elog(ERROR, "Argument declared ANYARRAY is not an array: %s",
format_type_be(array_typeid));
......@@ -923,11 +919,7 @@ enforce_generic_type_consistency(Oid *actual_arg_types,
{
if (!OidIsValid(array_typeid))
{
if (elem_typeid != ANYELEMENTOID)
array_typeid = get_array_type(elem_typeid);
else
array_typeid = ANYARRAYOID;
array_typeid = get_array_type(elem_typeid);
if (!OidIsValid(array_typeid))
elog(ERROR, "Cannot find array type for datatype %s",
format_type_be(elem_typeid));
......@@ -1178,11 +1170,6 @@ IsBinaryCoercible(Oid srctype, Oid targettype)
if (srctype == targettype)
return true;
/* Last of the fast-paths: check for matching polymorphic arrays */
if (targettype == ANYARRAYOID)
if (get_element_type(srctype) != InvalidOid)
return true;
/* Else look in pg_cast */
tuple = SearchSysCache(CASTSOURCETARGET,
ObjectIdGetDatum(srctype),
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.149 2003/06/24 23:14:45 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.150 2003/06/25 21:30:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -436,7 +436,6 @@ transformExpr(ParseState *pstate, Node *expr)
sublink->operName = NIL;
sublink->operOids = NIL;
sublink->useOr = FALSE;
sublink->isExpr = FALSE;
}
else if (sublink->subLinkType == EXPR_SUBLINK ||
sublink->subLinkType == ARRAY_SUBLINK)
......@@ -464,7 +463,6 @@ transformExpr(ParseState *pstate, Node *expr)
sublink->operName = NIL;
sublink->operOids = NIL;
sublink->useOr = FALSE;
sublink->isExpr = FALSE;
}
else
{
......@@ -540,30 +538,10 @@ transformExpr(ParseState *pstate, Node *expr)
* here, because make_subplan() will insert type
* coercion calls if needed.
*/
if (!sublink->isExpr)
{
optup = oper(op,
exprType(lexpr),
exprType((Node *) tent->expr),
false);
}
else
{
Oid exprtype = exprType((Node *) tent->expr);
Oid elemtype = get_element_type(exprtype);
if (elemtype != InvalidOid)
optup = oper(op,
exprType(lexpr),
elemtype,
false);
else
optup = oper(op,
exprType(lexpr),
exprtype,
false);
}
optup = oper(op,
exprType(lexpr),
exprType((Node *) tent->expr),
false);
opform = (Form_pg_operator) GETSTRUCT(optup);
if (opform->oprresult != BOOLOID)
......@@ -765,7 +743,7 @@ transformExpr(ParseState *pstate, Node *expr)
ArrayExpr *e = (ArrayExpr *) lfirst(element);
if (!IsA(e, ArrayExpr))
elog(ERROR, "Multidimensional ARRAY[] must be built from nested array expressions");
elog(ERROR, "Multi-dimensional ARRAY[] must be built from nested array expressions");
if (ndims == 0)
ndims = e->ndims;
else if (e->ndims != ndims)
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.151 2003/06/25 20:07:39 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.152 2003/06/25 21:30:31 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -336,7 +336,6 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
aggref->target = lfirst(fargs);
aggref->aggstar = agg_star;
aggref->aggdistinct = agg_distinct;
aggref->args = fargs;
/* parse_agg.c does additional aggregate-specific processing */
transformAggregateCall(pstate, aggref);
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.65 2003/06/24 23:14:45 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.66 2003/06/25 21:30:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -137,33 +137,6 @@ Operator
equality_oper(Oid argtype, bool noError)
{
Operator optup;
Oid elem_type = get_element_type(argtype);
if (OidIsValid(elem_type))
{
bool found = false;
/*
* If the datatype is an array, look for an "=" operator for the
* element datatype. We require it to be an exact or binary-compatible
* match, since most callers are not prepared to cope with adding any
* run-time type coercion steps.
*/
optup = equality_oper(elem_type, true);
if (optup != NULL)
{
found = true;
ReleaseSysCache(optup);
}
if (!found)
{
if (!noError)
elog(ERROR, "Unable to identify an equality operator for " \
"array type's element type %s",
format_type_be(elem_type));
return NULL;
}
}
/*
* Look for an "=" operator for the datatype. We require it to be
......@@ -202,33 +175,6 @@ Operator
ordering_oper(Oid argtype, bool noError)
{
Operator optup;
Oid elem_type = get_element_type(argtype);
if (OidIsValid(elem_type))
{
bool found = false;
/*
* If the datatype is an array, find the array element type's equality
* operator, and use its lsortop (it *must* be mergejoinable). We use
* this definition because for sorting and grouping purposes, it's
* important that the equality and ordering operators are consistent.
*/
optup = ordering_oper(elem_type, true);
if (optup != NULL)
{
found = true;
ReleaseSysCache(optup);
}
if (!found)
{
if (!noError)
elog(ERROR, "Unable to identify an ordering operator for " \
"array type's element type %s",
format_type_be(elem_type));
return NULL;
}
}
/*
* Find the type's equality operator, and use its lsortop (it *must*
......@@ -274,21 +220,6 @@ equality_oper_funcid(Oid argtype)
return result;
}
/*
* ordering_oper_funcid - convenience routine for oprfuncid(ordering_oper())
*/
Oid
ordering_oper_funcid(Oid argtype)
{
Operator optup;
Oid result;
optup = ordering_oper(argtype, false);
result = oprfuncid(optup);
ReleaseSysCache(optup);
return result;
}
/*
* ordering_oper_opid - convenience routine for oprid(ordering_oper())
*
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.89 2003/06/24 23:14:45 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.90 2003/06/25 21:30:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -427,15 +427,6 @@ aclitemeq(const AclItem *a1, const AclItem *a2)
a1->ai_grantor == a2->ai_grantor;
}
/*
* user-facing version of aclitemeq() for use as the
* aclitem equality operator
*/
Datum
aclitem_eq(PG_FUNCTION_ARGS)
{
PG_RETURN_BOOL(aclitemeq(PG_GETARG_ACLITEM_P(0), PG_GETARG_ACLITEM_P(1)));
}
/*
* acldefault() --- create an ACL describing default access permissions
......
This diff is collapsed.
This diff is collapsed.
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.99 2003/06/24 23:14:46 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.100 2003/06/25 21:30:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -19,14 +19,11 @@
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "access/tuptoaster.h"
#include "catalog/pg_type.h"
#include "lib/stringinfo.h"
#include "libpq/crypt.h"
#include "libpq/pqformat.h"
#include "utils/array.h"
#include "utils/builtins.h"
#include "utils/pg_locale.h"
#include "utils/lsyscache.h"
typedef struct varlena unknown;
......@@ -1986,7 +1983,8 @@ split_text(PG_FUNCTION_ARGS)
if (fldnum == 1) /* first field - just return the input
* string */
PG_RETURN_TEXT_P(inputstring);
else /* otherwise return an empty string */
else
/* otherwise return an empty string */
PG_RETURN_TEXT_P(PG_STR_GET_TEXT(""));
}
......@@ -2006,7 +2004,8 @@ split_text(PG_FUNCTION_ARGS)
if (fldnum == 1) /* first field - just return the input
* string */
PG_RETURN_TEXT_P(inputstring);
else /* otherwise return an empty string */
else
/* otherwise return an empty string */
PG_RETURN_TEXT_P(PG_STR_GET_TEXT(""));
}
else if ((start_posn != 0) && (end_posn == 0))
......@@ -2029,191 +2028,6 @@ split_text(PG_FUNCTION_ARGS)
}
}
/*
* text_to_array
* parse input string
* return text array of elements
* based on provided field separator
*/
Datum
text_to_array(PG_FUNCTION_ARGS)
{
text *inputstring = PG_GETARG_TEXT_P(0);
int inputstring_len = TEXTLEN(inputstring);
text *fldsep = PG_GETARG_TEXT_P(1);
int fldsep_len = TEXTLEN(fldsep);
int fldnum;
int start_posn = 0;
int end_posn = 0;
text *result_text = NULL;
ArrayBuildState *astate = NULL;
MemoryContext oldcontext = CurrentMemoryContext;
/* return NULL for empty input string */
if (inputstring_len < 1)
PG_RETURN_NULL();
/* empty field separator
* return one element, 1D, array using the input string */
if (fldsep_len < 1)
PG_RETURN_ARRAYTYPE_P(create_singleton_array(fcinfo, TEXTOID,
CStringGetDatum(inputstring), 1));
/* start with end position holding the initial start position */
end_posn = 0;
for (fldnum=1;;fldnum++) /* field number is 1 based */
{
Datum dvalue;
bool disnull = false;
start_posn = end_posn;
end_posn = text_position(PointerGetDatum(inputstring),
PointerGetDatum(fldsep),
fldnum);
if ((start_posn == 0) && (end_posn == 0)) /* fldsep not found */
{
if (fldnum == 1)
{
/* first element
* return one element, 1D, array using the input string */
PG_RETURN_ARRAYTYPE_P(create_singleton_array(fcinfo, TEXTOID,
CStringGetDatum(inputstring), 1));
}
else
{
/* otherwise create array and exit */
PG_RETURN_ARRAYTYPE_P(makeArrayResult(astate, oldcontext));
}
}
else if ((start_posn != 0) && (end_posn == 0))
{
/* last field requested */
result_text = text_substring(PointerGetDatum(inputstring), start_posn + fldsep_len, -1, true);
}
else if ((start_posn == 0) && (end_posn != 0))
{
/* first field requested */
result_text = LEFT(inputstring, fldsep);
}
else
{
/* prior to last field requested */
result_text = text_substring(PointerGetDatum(inputstring), start_posn + fldsep_len, end_posn - start_posn - fldsep_len, false);
}
/* stash away current value */
dvalue = PointerGetDatum(result_text);
astate = accumArrayResult(astate, dvalue,
disnull, TEXTOID, oldcontext);
}
/* never reached -- keep compiler quiet */
PG_RETURN_NULL();
}
/*
* array_to_text
* concatenate Cstring representation of input array elements
* using provided field separator
*/
Datum
array_to_text(PG_FUNCTION_ARGS)
{
ArrayType *v = PG_GETARG_ARRAYTYPE_P(0);
char *fldsep = PG_TEXTARG_GET_STR(1);
int nitems, *dims, ndims;
char *p;
Oid element_type;
int typlen;
bool typbyval;
char typdelim;
Oid typoutput,
typelem;
FmgrInfo outputproc;
char typalign;
StringInfo result_str = makeStringInfo();
int i;
ArrayMetaState *my_extra;
p = ARR_DATA_PTR(v);
ndims = ARR_NDIM(v);
dims = ARR_DIMS(v);
nitems = ArrayGetNItems(ndims, dims);
/* if there are no elements, return an empty string */
if (nitems == 0)
PG_RETURN_TEXT_P(PG_STR_GET_TEXT(""));
element_type = ARR_ELEMTYPE(v);
/*
* We arrange to look up info about element type, including its output
* conversion proc only once per series of calls, assuming the element
* type doesn't change underneath us.
*/
my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra;
if (my_extra == NULL)
{
fcinfo->flinfo->fn_extra = MemoryContextAlloc(fcinfo->flinfo->fn_mcxt,
sizeof(ArrayMetaState));
my_extra = (ArrayMetaState *) fcinfo->flinfo->fn_extra;
my_extra->element_type = InvalidOid;
}
if (my_extra->element_type != element_type)
{
/* Get info about element type, including its output conversion proc */
get_type_metadata(element_type, IOFunc_output,
&typlen, &typbyval, &typdelim,
&typelem, &typoutput, &typalign);
fmgr_info(typoutput, &outputproc);
my_extra->element_type = element_type;
my_extra->typlen = typlen;
my_extra->typbyval = typbyval;
my_extra->typdelim = typdelim;
my_extra->typelem = typelem;
my_extra->typiofunc = typoutput;
my_extra->typalign = typalign;
my_extra->proc = outputproc;
}
else
{
typlen = my_extra->typlen;
typbyval = my_extra->typbyval;
typdelim = my_extra->typdelim;
typelem = my_extra->typelem;
typoutput = my_extra->typiofunc;
typalign = my_extra->typalign;
outputproc = my_extra->proc;
}
for (i = 0; i < nitems; i++)
{
Datum itemvalue;
char *value;
itemvalue = fetch_att(p, typbyval, typlen);
value = DatumGetCString(FunctionCall3(&outputproc,
itemvalue,
ObjectIdGetDatum(typelem),
Int32GetDatum(-1)));
if (i > 0)
appendStringInfo(result_str, "%s%s", fldsep, value);
else
appendStringInfo(result_str, "%s", value);
p = att_addlength(p, typlen, PointerGetDatum(p));
p = (char *) att_align(p, typalign);
}
PG_RETURN_TEXT_P(PG_STR_GET_TEXT(result_str->data));
}
#define HEXBASE 16
/*
* Convert a int32 to a string containing a base 16 (hex) representation of
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.98 2003/06/25 03:56:31 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.99 2003/06/25 21:30:32 momjian Exp $
*
* NOTES
* Eventually, the index information should go through here, too.
......@@ -718,40 +718,6 @@ get_func_rettype(Oid funcid)
return result;
}
/*
* get_func_argtypes
* Given procedure id, return the function's argument types.
* Also pass back the number of arguments.
*/
Oid *
get_func_argtypes(Oid funcid, int *nargs)
{
HeapTuple tp;
Form_pg_proc procstruct;
Oid *result = NULL;
int i;
tp = SearchSysCache(PROCOID,
ObjectIdGetDatum(funcid),
0, 0, 0);
if (!HeapTupleIsValid(tp))
elog(ERROR, "Function OID %u does not exist", funcid);
procstruct = (Form_pg_proc) GETSTRUCT(tp);
*nargs = (int) procstruct->pronargs;
if (*nargs > 0)
{
result = (Oid *) palloc(*nargs * sizeof(Oid));
for (i = 0; i < *nargs; i++)
result[i] = procstruct->proargtypes[i];
}
ReleaseSysCache(tp);
return result;
}
/*
* get_func_retset
* Given procedure id, return the function's proretset flag.
......@@ -1124,56 +1090,6 @@ get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval,
ReleaseSysCache(tp);
}
/*
* get_type_metadata
*
* A six-fer: given the type OID, return typlen, typbyval, typalign,
* typdelim, typelem, IO function Oid. The IO function
* returned is controlled by IOFuncSelector
*/
void
get_type_metadata(Oid element_type,
IOFuncSelector which_func,
int *typlen,
bool *typbyval,
char *typdelim,
Oid *typelem,
Oid *proc,
char *typalign)
{
HeapTuple typeTuple;
Form_pg_type typeStruct;
typeTuple = SearchSysCache(TYPEOID,
ObjectIdGetDatum(element_type),
0, 0, 0);
if (!HeapTupleIsValid(typeTuple))
elog(ERROR, "cache lookup failed for type %u", element_type);
typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
*typlen = typeStruct->typlen;
*typbyval = typeStruct->typbyval;
*typdelim = typeStruct->typdelim;
*typelem = typeStruct->typelem;
*typalign = typeStruct->typalign;
switch (which_func)
{
case IOFunc_input:
*proc = typeStruct->typinput;
break;
case IOFunc_output:
*proc = typeStruct->typoutput;
break;
case IOFunc_receive:
*proc = typeStruct->typreceive;
break;
case IOFunc_send:
*proc = typeStruct->typsend;
break;
}
ReleaseSysCache(typeTuple);
}
#ifdef NOT_USED
char
get_typalign(Oid typid)
......
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.69 2003/06/24 23:14:46 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.70 2003/06/25 21:30:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -1673,29 +1673,3 @@ get_fn_expr_argtype(FunctionCallInfo fcinfo, int argnum)
return exprType((Node *) nth(argnum, args));
}
/*
* Get the OID of the function or operator
*
* Returns InvalidOid if information is not available
*/
Oid
get_fn_expr_functype(FunctionCallInfo fcinfo)
{
Node *expr;
/*
* can't return anything useful if we have no FmgrInfo or if
* its fn_expr node has not been initialized
*/
if (!fcinfo || !fcinfo->flinfo || !fcinfo->flinfo->fn_expr)
return InvalidOid;
expr = fcinfo->flinfo->fn_expr;
if (IsA(expr, FuncExpr))
return ((FuncExpr *) expr)->funcid;
else if (IsA(expr, OpExpr))
return ((OpExpr *) expr)->opno;
else
return InvalidOid;
}
......@@ -16,7 +16,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_amop.h,v 1.51 2003/06/24 23:14:46 momjian Exp $
* $Id: pg_amop.h,v 1.52 2003/06/25 21:30:32 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
......@@ -418,15 +418,6 @@ DATA(insert ( 2098 3 f 2334 ));
DATA(insert ( 2098 4 f 2335 ));
DATA(insert ( 2098 5 f 2336 ));
/*
* btree array_ops
*/
DATA(insert ( 397 1 f 1072 ));
DATA(insert ( 397 2 f 1074 ));
DATA(insert ( 397 3 f 1070 ));
DATA(insert ( 397 4 f 1075 ));
DATA(insert ( 397 5 f 1073 ));
/*
* hash index _ops
......
......@@ -14,7 +14,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_amproc.h,v 1.39 2003/06/24 23:14:46 momjian Exp $
* $Id: pg_amproc.h,v 1.40 2003/06/25 21:30:32 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
......@@ -78,7 +78,6 @@ DATA(insert ( 1993 3 199 ));
/* btree */
DATA(insert ( 397 1 382 ));
DATA(insert ( 421 1 357 ));
DATA(insert ( 423 1 1596 ));
DATA(insert ( 424 1 1693 ));
......
......@@ -26,7 +26,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_opclass.h,v 1.52 2003/06/24 23:14:46 momjian Exp $
* $Id: pg_opclass.h,v 1.53 2003/06/25 21:30:32 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
......@@ -87,8 +87,6 @@ typedef FormData_pg_opclass *Form_pg_opclass;
*/
DATA(insert OID = 421 ( 403 abstime_ops PGNSP PGUID 702 t 0 ));
DATA(insert OID = 397 ( 403 array_ops PGNSP PGUID 2277 t 0 ));
#define ARRAY_BTREE_OPS_OID 397
DATA(insert OID = 422 ( 402 bigbox_ops PGNSP PGUID 603 f 0 ));
DATA(insert OID = 423 ( 403 bit_ops PGNSP PGUID 1560 t 0 ));
DATA(insert OID = 424 ( 403 bool_ops PGNSP PGUID 16 t 0 ));
......
......@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_operator.h,v 1.116 2003/06/24 23:14:46 momjian Exp $
* $Id: pg_operator.h,v 1.117 2003/06/25 21:30:32 momjian Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
......@@ -116,15 +116,10 @@ DATA(insert OID = 96 ( "=" PGNSP PGUID b t 23 23 16 96 518 97 97 97 521 int
DATA(insert OID = 97 ( "<" PGNSP PGUID b f 23 23 16 521 525 0 0 0 0 int4lt scalarltsel scalarltjoinsel ));
DATA(insert OID = 98 ( "=" PGNSP PGUID b t 25 25 16 98 531 664 664 664 666 texteq eqsel eqjoinsel ));
DATA(insert OID = 1070 ( "=" PGNSP PGUID b f 2277 2277 16 1070 1071 1072 1072 1072 1073 array_eq eqsel eqjoinsel ));
DATA(insert OID = 1071 ( "<>" PGNSP PGUID b f 2277 2277 16 1071 1070 0 0 0 0 array_ne neqsel neqjoinsel ));
DATA(insert OID = 1072 ( "<" PGNSP PGUID b f 2277 2277 16 1073 1075 0 0 0 0 array_lt scalarltsel scalarltjoinsel ));
DATA(insert OID = 1073 ( ">" PGNSP PGUID b f 2277 2277 16 1072 1074 0 0 0 0 array_gt scalargtsel scalargtjoinsel ));
DATA(insert OID = 1074 ( "<=" PGNSP PGUID b f 2277 2277 16 1075 1073 0 0 0 0 array_le scalarltsel scalarltjoinsel ));
DATA(insert OID = 1075 ( ">=" PGNSP PGUID b f 2277 2277 16 1074 1072 0 0 0 0 array_ge scalargtsel scalargtjoinsel ));
DATA(insert OID = 349 ( "||" PGNSP PGUID b f 2277 2283 2277 0 0 0 0 0 0 array_append - - ));
DATA(insert OID = 374 ( "||" PGNSP PGUID b f 2283 2277 2277 0 0 0 0 0 0 array_prepend - - ));
DATA(insert OID = 375 ( "||" PGNSP PGUID b f 2277 2277 2277 0 0 0 0 0 0 array_cat - - ));
DATA(insert OID = 329 ( "=" PGNSP PGUID b f 2277 2277 16 329 0 0 0 0 0 array_eq eqsel eqjoinsel ));
DATA(insert OID = 349 ( "||" PGNSP PGUID b f 2277 2283 2277 0 0 0 0 0 0 array_append - - ));
DATA(insert OID = 374 ( "||" PGNSP PGUID b f 2283 2277 2277 0 0 0 0 0 0 array_prepend - - ));
DATA(insert OID = 375 ( "||" PGNSP PGUID b f 2277 2277 2277 0 0 0 0 0 0 array_cat - - ));
DATA(insert OID = 352 ( "=" PGNSP PGUID b t 28 28 16 352 0 0 0 0 0 xideq eqsel eqjoinsel ));
DATA(insert OID = 353 ( "=" PGNSP PGUID b f 28 23 16 0 0 0 0 0 0 xideqint4 eqsel eqjoinsel ));
......@@ -430,7 +425,6 @@ DATA(insert OID = 965 ( "^" PGNSP PGUID b f 701 701 701 0 0 0 0 0 0 dpow -
DATA(insert OID = 966 ( "+" PGNSP PGUID b f 1034 1033 1034 0 0 0 0 0 0 aclinsert - - ));
DATA(insert OID = 967 ( "-" PGNSP PGUID b f 1034 1033 1034 0 0 0 0 0 0 aclremove - - ));
DATA(insert OID = 968 ( "~" PGNSP PGUID b f 1034 1033 16 0 0 0 0 0 0 aclcontains - - ));
DATA(insert OID = 974 ( "=" PGNSP PGUID b f 1033 1033 16 0 0 0 0 0 0 aclitemeq eqsel eqjoinsel ));
/* additional geometric operators - thomas 1997-07-09 */
DATA(insert OID = 969 ( "@@" PGNSP PGUID l f 0 601 600 0 0 0 0 0 0 lseg_center - - ));
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: pg_proc.h,v 1.306 2003/06/24 23:14:47 momjian Exp $
* $Id: pg_proc.h,v 1.307 2003/06/25 21:30:32 momjian Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
......@@ -758,8 +758,6 @@ DATA(insert OID = 359 ( btnamecmp PGNSP PGUID 12 f f t f i 2 23 "19 19" btn
DESCR("btree less-equal-greater");
DATA(insert OID = 360 ( bttextcmp PGNSP PGUID 12 f f t f i 2 23 "25 25" bttextcmp - _null_ ));
DESCR("btree less-equal-greater");
DATA(insert OID = 382 ( btarraycmp PGNSP PGUID 12 f f t f i 2 23 "2277 2277" btarraycmp - _null_ ));
DESCR("btree less-equal-greater");
DATA(insert OID = 361 ( lseg_distance PGNSP PGUID 12 f f t f i 2 701 "601 601" lseg_distance - _null_ ));
DESCR("distance between");
......@@ -990,23 +988,14 @@ DESCR("greater-than");
DATA(insert OID = 743 ( text_ge PGNSP PGUID 12 f f t f i 2 16 "25 25" text_ge - _null_ ));
DESCR("greater-than-or-equal");
DATA(insert OID = 744 ( array_eq PGNSP PGUID 12 f f t f i 2 16 "2277 2277" array_eq - _null_ ));
DESCR("array equal");
DATA(insert OID = 745 ( current_user PGNSP PGUID 12 f f t f s 0 19 "" current_user - _null_ ));
DESCR("current user name");
DATA(insert OID = 746 ( session_user PGNSP PGUID 12 f f t f s 0 19 "" session_user - _null_ ));
DESCR("session user name");
DATA(insert OID = 744 ( array_eq PGNSP PGUID 12 f f t f i 2 16 "2277 2277" array_eq - _null_ ));
DESCR("array equal");
DATA(insert OID = 390 ( array_ne PGNSP PGUID 12 f f t f i 2 16 "2277 2277" array_ne - _null_ ));
DESCR("array not equal");
DATA(insert OID = 391 ( array_lt PGNSP PGUID 12 f f t f i 2 16 "2277 2277" array_lt - _null_ ));
DESCR("array less than");
DATA(insert OID = 392 ( array_gt PGNSP PGUID 12 f f t f i 2 16 "2277 2277" array_gt - _null_ ));
DESCR("array greater than");
DATA(insert OID = 393 ( array_le PGNSP PGUID 12 f f t f i 2 16 "2277 2277" array_le - _null_ ));
DESCR("array less than or equal");
DATA(insert OID = 396 ( array_ge PGNSP PGUID 12 f f t f i 2 16 "2277 2277" array_ge - _null_ ));
DESCR("array greater than or equal");
DATA(insert OID = 747 ( array_dims PGNSP PGUID 12 f f t f i 1 25 "2277" array_dims - _null_ ));
DESCR("array dimensions");
DATA(insert OID = 750 ( array_in PGNSP PGUID 12 f f t f s 3 2277 "2275 26 23" array_in - _null_ ));
......@@ -1017,18 +1006,22 @@ DATA(insert OID = 2091 ( array_lower PGNSP PGUID 12 f f t f i 2 23 "2277 23"
DESCR("array lower dimension");
DATA(insert OID = 2092 ( array_upper PGNSP PGUID 12 f f t f i 2 23 "2277 23" array_upper - _null_ ));
DESCR("array upper dimension");
DATA(insert OID = 377 ( singleton_array PGNSP PGUID 12 f f t f i 1 2277 "2283" singleton_array - _null_ ));
DESCR("create array from single element");
DATA(insert OID = 378 ( array_append PGNSP PGUID 12 f f t f i 2 2277 "2277 2283" array_push - _null_ ));
DESCR("append element onto end of array");
DATA(insert OID = 379 ( array_prepend PGNSP PGUID 12 f f t f i 2 2277 "2283 2277" array_push - _null_ ));
DESCR("prepend element onto front of array");
DATA(insert OID = 380 ( array_accum PGNSP PGUID 12 f f f f i 2 2277 "2277 2283" array_accum - _null_ ));
DESCR("push element onto end of array, creating array if needed");
DATA(insert OID = 381 ( array_assign PGNSP PGUID 12 f f t f i 3 2277 "2277 23 2283" array_assign - _null_ ));
DESCR("assign specific array element");
DATA(insert OID = 382 ( array_subscript PGNSP PGUID 12 f f t f i 2 2283 "2277 23" array_subscript - _null_ ));
DESCR("return specific array element");
DATA(insert OID = 383 ( array_cat PGNSP PGUID 12 f f t f i 2 2277 "2277 2277" array_cat - _null_ ));
DESCR("concatenate two arrays");
DATA(insert OID = 384 ( array_coerce PGNSP PGUID 12 f f t f i 1 2277 "2277" array_type_coerce - _null_ ));
DESCR("coerce array type to another array type");
DATA(insert OID = 394 ( string_to_array PGNSP PGUID 12 f f t f i 2 1009 "25 25" text_to_array - _null_ ));
DESCR("split delimited text into text[]");
DATA(insert OID = 395 ( array_to_string PGNSP PGUID 12 f f t f i 2 25 "2277 25" array_to_text - _null_ ));
DESCR("concatenate array elements, using delimiter, into text");
DATA(insert OID = 760 ( smgrin PGNSP PGUID 12 f f t f s 1 210 "2275" smgrin - _null_ ));
DESCR("I/O");
......@@ -1329,8 +1322,6 @@ DATA(insert OID = 1036 ( aclremove PGNSP PGUID 12 f f t f s 2 1034 "1034 10
DESCR("remove ACL item");
DATA(insert OID = 1037 ( aclcontains PGNSP PGUID 12 f f t f s 2 16 "1034 1033" aclcontains - _null_ ));
DESCR("does ACL contain item?");
DATA(insert OID = 1062 ( aclitemeq PGNSP PGUID 12 f f t f s 2 16 "1033 1033" aclitem_eq - _null_ ));
DESCR("equality operator for ACL items");
DATA(insert OID = 1365 ( makeaclitem PGNSP PGUID 12 f f t f s 5 1033 "23 23 23 25 16" makeaclitem - _null_ ));
DESCR("make ACL item");
DATA(insert OID = 1038 ( seteval PGNSP PGUID 12 f f t t v 1 23 "26" seteval - _null_ ));
......
......@@ -11,14 +11,13 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: fmgr.h,v 1.28 2003/06/24 23:14:46 momjian Exp $
* $Id: fmgr.h,v 1.29 2003/06/25 21:30:32 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef FMGR_H
#define FMGR_H
#include "nodes/nodes.h"
/*
* All functions that can be called directly by fmgr must have this signature.
......@@ -373,14 +372,14 @@ extern Datum OidFunctionCall9(Oid functionId, Datum arg1, Datum arg2,
Datum arg6, Datum arg7, Datum arg8,
Datum arg9);
/*
* Routines in fmgr.c
*/
extern Pg_finfo_record *fetch_finfo_record(void *filehandle, char *funcname);
extern Oid fmgr_internal_function(const char *proname);
extern Oid get_fn_expr_rettype(FunctionCallInfo fcinfo);
extern Oid get_fn_expr_argtype(FunctionCallInfo fcinfo, int argnum);
extern Oid get_fn_expr_functype(FunctionCallInfo fcinfo);
extern Oid fmgr_internal_function(const char *proname);
extern Oid get_fn_expr_rettype(FunctionCallInfo fcinfo);
extern Oid get_fn_expr_argtype(FunctionCallInfo fcinfo, int argnum);
/*
* Routines in dfmgr.c
......
......@@ -10,7 +10,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: primnodes.h,v 1.84 2003/06/24 23:14:48 momjian Exp $
* $Id: primnodes.h,v 1.85 2003/06/25 21:30:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -226,7 +226,6 @@ typedef struct Aggref
Index agglevelsup; /* > 0 if agg belongs to outer query */
bool aggstar; /* TRUE if argument was really '*' */
bool aggdistinct; /* TRUE if it's agg(DISTINCT ...) */
List *args; /* arguments to the aggregate */
} Aggref;
/* ----------------
......@@ -359,19 +358,15 @@ typedef struct BoolExpr
/* ----------------
* SubLink
*
* A SubLink represents a subselect, or an expression, appearing in an
* expression, and in some cases also the combining operator(s) just above
* it. The subLinkType indicates the form of the expression represented:
* A SubLink represents a subselect appearing in an expression, and in some
* cases also the combining operator(s) just above it. The subLinkType
* indicates the form of the expression represented:
* EXISTS_SUBLINK EXISTS(SELECT ...)
* ALL_SUBLINK (lefthand) op ALL (SELECT ...)
* ANY_SUBLINK (lefthand) op ANY (SELECT ...)
* MULTIEXPR_SUBLINK (lefthand) op (SELECT ...)
* EXPR_SUBLINK (SELECT with single targetlist item ...)
* ARRAY_SUBLINK ARRAY(SELECT with single targetlist item ...)
* If an expression is used in place of the subselect, it is transformed
* into a simple "(SELECT expr)" in gram.y. This is to allow arrays to be
* used as if they were the result of a single column subselect. If the
* expression is scalar, it is treated as a one element array.
* For ALL, ANY, and MULTIEXPR, the lefthand is a list of expressions of the
* same length as the subselect's targetlist. MULTIEXPR will *always* have
* a list with more than one entry; if the subselect has just one target
......@@ -420,8 +415,6 @@ typedef struct SubLink
SubLinkType subLinkType; /* EXISTS, ALL, ANY, MULTIEXPR, EXPR */
bool useOr; /* TRUE to combine column results with
* "OR" not "AND" */
bool isExpr; /* TRUE if the subselect is really derived
* from a single expression */
List *lefthand; /* list of outer-query expressions on the
* left */
List *operName; /* originally specified operator name */
......@@ -463,15 +456,6 @@ typedef struct SubPlan
SubLinkType subLinkType; /* EXISTS, ALL, ANY, MULTIEXPR, EXPR */
bool useOr; /* TRUE to combine column results with
* "OR" not "AND" */
bool isExpr; /* TRUE if the subselect is really derived
* from a single expression */
/* runtime cache for single array expressions */
Oid exprtype; /* array and element type, and other info
* needed deconstruct the array */
Oid elemtype;
int16 elmlen;
bool elmbyval;
char elmalign;
/* The combining operators, transformed to executable expressions: */
List *exprs; /* list of OpExpr expression trees */
List *paramIds; /* IDs of Params embedded in the above */
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: clauses.h,v 1.64 2003/06/24 23:14:49 momjian Exp $
* $Id: clauses.h,v 1.65 2003/06/25 21:30:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -28,9 +28,6 @@ extern Expr *make_opclause(Oid opno, Oid opresulttype, bool opretset,
extern Node *get_leftop(Expr *clause);
extern Node *get_rightop(Expr *clause);
extern Expr *make_funcclause(Oid funcid, Oid funcresulttype, bool funcretset,
CoercionForm funcformat, List *funcargs);
extern bool not_clause(Node *clause);
extern Expr *make_notclause(Expr *notclause);
extern Expr *get_notclausearg(Expr *notclause);
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: parse_oper.h,v 1.26 2003/06/24 23:14:49 momjian Exp $
* $Id: parse_oper.h,v 1.27 2003/06/25 21:30:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -44,7 +44,6 @@ extern Operator ordering_oper(Oid argtype, bool noError);
/* Convenience routines for common calls on the above */
extern Oid compatible_oper_opid(List *op, Oid arg1, Oid arg2, bool noError);
extern Oid equality_oper_funcid(Oid argtype);
extern Oid ordering_oper_funcid(Oid argtype);
extern Oid ordering_oper_opid(Oid argtype);
/* Extract operator OID or underlying-function OID from an Operator tuple */
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: acl.h,v 1.53 2003/06/24 23:14:49 momjian Exp $
* $Id: acl.h,v 1.54 2003/06/25 21:30:33 momjian Exp $
*
* NOTES
* For backward-compatibility purposes we have to allow there
......@@ -192,7 +192,6 @@ extern Datum aclinsert(PG_FUNCTION_ARGS);
extern Datum aclremove(PG_FUNCTION_ARGS);
extern Datum aclcontains(PG_FUNCTION_ARGS);
extern Datum makeaclitem(PG_FUNCTION_ARGS);
extern Datum aclitem_eq(PG_FUNCTION_ARGS);
/*
* prototypes for functions in aclchk.c
......
......@@ -10,7 +10,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: array.h,v 1.39 2003/06/24 23:14:49 momjian Exp $
* $Id: array.h,v 1.40 2003/06/25 21:30:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -32,37 +32,6 @@ typedef struct
Oid elemtype; /* element type OID */
} ArrayType;
typedef struct ArrayBuildState
{
MemoryContext mcontext; /* where all the temp stuff is kept */
Datum *dvalues; /* array of accumulated Datums */
/*
* The allocated size of dvalues[] is always a multiple of
* ARRAY_ELEMS_CHUNKSIZE
*/
#define ARRAY_ELEMS_CHUNKSIZE 64
int nelems; /* number of valid Datums in dvalues[] */
Oid element_type; /* data type of the Datums */
int16 typlen; /* needed info about datatype */
bool typbyval;
char typalign;
} ArrayBuildState;
/*
* structure to cache type metadata needed for array manipulation
*/
typedef struct ArrayMetaState
{
Oid element_type;
int typlen;
bool typbyval;
char typdelim;
Oid typelem;
Oid typiofunc;
char typalign;
FmgrInfo proc;
} ArrayMetaState;
/*
* fmgr macros for array objects
*/
......@@ -117,15 +86,11 @@ extern Datum array_recv(PG_FUNCTION_ARGS);
extern Datum array_send(PG_FUNCTION_ARGS);
extern Datum array_length_coerce(PG_FUNCTION_ARGS);
extern Datum array_eq(PG_FUNCTION_ARGS);
extern Datum array_ne(PG_FUNCTION_ARGS);
extern Datum array_lt(PG_FUNCTION_ARGS);
extern Datum array_gt(PG_FUNCTION_ARGS);
extern Datum array_le(PG_FUNCTION_ARGS);
extern Datum array_ge(PG_FUNCTION_ARGS);
extern Datum btarraycmp(PG_FUNCTION_ARGS);
extern Datum array_dims(PG_FUNCTION_ARGS);
extern Datum array_lower(PG_FUNCTION_ARGS);
extern Datum array_upper(PG_FUNCTION_ARGS);
extern Datum array_assign(PG_FUNCTION_ARGS);
extern Datum array_subscript(PG_FUNCTION_ARGS);
extern Datum array_type_coerce(PG_FUNCTION_ARGS);
extern Datum array_ref(ArrayType *array, int nSubscripts, int *indx,
......@@ -159,14 +124,7 @@ extern void deconstruct_array(ArrayType *array,
Oid elmtype,
int elmlen, bool elmbyval, char elmalign,
Datum **elemsp, int *nelemsp);
extern ArrayBuildState *accumArrayResult(ArrayBuildState *astate,
Datum dvalue, bool disnull,
Oid element_type,
MemoryContext rcontext);
extern Datum makeArrayResult(ArrayBuildState *astate,
MemoryContext rcontext);
extern Datum makeMdArrayResult(ArrayBuildState *astate, int ndims,
int *dims, int *lbs, MemoryContext rcontext);
/*
* prototypes for functions defined in arrayutils.c
......@@ -183,11 +141,12 @@ extern int mda_next_tuple(int n, int *curr, int *span);
/*
* prototypes for functions defined in array_userfuncs.c
*/
extern Datum singleton_array(PG_FUNCTION_ARGS);
extern Datum array_push(PG_FUNCTION_ARGS);
extern Datum array_accum(PG_FUNCTION_ARGS);
extern Datum array_cat(PG_FUNCTION_ARGS);
extern ArrayType *create_singleton_array(FunctionCallInfo fcinfo,
Oid element_type,
extern ArrayType *create_singleton_array(Oid element_type,
Datum element,
int ndims);
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: builtins.h,v 1.221 2003/06/24 23:14:49 momjian Exp $
* $Id: builtins.h,v 1.222 2003/06/25 21:30:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -530,8 +530,6 @@ extern bool SplitIdentifierString(char *rawstring, char separator,
List **namelist);
extern Datum replace_text(PG_FUNCTION_ARGS);
extern Datum split_text(PG_FUNCTION_ARGS);
extern Datum text_to_array(PG_FUNCTION_ARGS);
extern Datum array_to_text(PG_FUNCTION_ARGS);
extern Datum to_hex32(PG_FUNCTION_ARGS);
extern Datum to_hex64(PG_FUNCTION_ARGS);
extern Datum md5_text(PG_FUNCTION_ARGS);
......
......@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: lsyscache.h,v 1.73 2003/06/25 03:56:31 momjian Exp $
* $Id: lsyscache.h,v 1.74 2003/06/25 21:30:33 momjian Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -15,15 +15,6 @@
#include "access/htup.h"
/* I/O function selector for system_cache_lookup */
typedef enum IOFuncSelector
{
IOFunc_input,
IOFunc_output,
IOFunc_receive,
IOFunc_send
} IOFuncSelector;
extern bool op_in_opclass(Oid opno, Oid opclass);
extern bool op_requires_recheck(Oid opno, Oid opclass);
extern Oid get_opclass_member(Oid opclass, int16 strategy);
......@@ -50,7 +41,6 @@ extern RegProcedure get_oprrest(Oid opno);
extern RegProcedure get_oprjoin(Oid opno);
extern char *get_func_name(Oid funcid);
extern Oid get_func_rettype(Oid funcid);
extern Oid *get_func_argtypes(Oid funcid, int *nargs);
extern bool get_func_retset(Oid funcid);
extern bool func_strict(Oid funcid);
extern char func_volatile(Oid funcid);
......@@ -66,14 +56,6 @@ extern bool get_typbyval(Oid typid);
extern void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval);
extern void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval,
char *typalign);
extern void get_type_metadata(Oid element_type,
IOFuncSelector which_func,
int *typlen,
bool *typbyval,
char *typdelim,
Oid *typelem,
Oid *proc,
char *typalign);
extern char get_typstorage(Oid typid);
extern int32 get_typtypmod(Oid typid);
extern Node *get_typdefault(Oid typid);
......
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.238 2003/06/25 10:44:21 meskes Exp $ */
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Attic/preproc.y,v 1.239 2003/06/25 21:30:33 momjian Exp $ */
/* Copyright comment */
%{
......@@ -4599,7 +4599,7 @@ type_declaration: S_TYPEDEF
$3.type_enum != ECPGt_char &&
$3.type_enum != ECPGt_unsigned_char &&
atoi(this->type->type_index) >= 0)
mmerror(PARSE_ERROR, ET_ERROR, "No multidimensional array support for simple data types");
mmerror(PARSE_ERROR, ET_ERROR, "No multi-dimensional array support for simple data types");
types = this;
}
......@@ -5419,7 +5419,7 @@ ECPGTypedef: TYPE_P
$5.type_enum != ECPGt_char &&
$5.type_enum != ECPGt_unsigned_char &&
atoi(this->type->type_index) >= 0)
mmerror(PARSE_ERROR, ET_ERROR, "No multidimensional array support for simple data types");
mmerror(PARSE_ERROR, ET_ERROR, "No multi-dimensional array support for simple data types");
types = this;
}
......@@ -5486,7 +5486,7 @@ ECPGVar: SQL_VAR
default:
if (atoi(length) >= 0)
mmerror(PARSE_ERROR, ET_ERROR, "No multidimensional array support for simple data types");
mmerror(PARSE_ERROR, ET_ERROR, "No multi-dimensional array support for simple data types");
if (atoi(dimension) < 0)
type = ECPGmake_simple_type($5.type_enum, make_str("1"));
......
......@@ -504,7 +504,7 @@ ECPGfree_type(struct ECPGtype * type)
switch (type->u.element->type)
{
case ECPGt_array:
yyerror("internal error, found multidimensional array\n");
yyerror("internal error, found multi-dimensional array\n");
break;
case ECPGt_struct:
case ECPGt_union:
......
......@@ -436,7 +436,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
if (atoi(type_index) >= 0)
{
if (atoi(*length) >= 0)
mmerror(PARSE_ERROR, ET_FATAL, "No multidimensional array support");
mmerror(PARSE_ERROR, ET_FATAL, "No multi-dimensional array support");
*length = type_index;
}
......@@ -444,7 +444,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
if (atoi(type_dimension) >= 0)
{
if (atoi(*dimension) >= 0 && atoi(*length) >= 0)
mmerror(PARSE_ERROR, ET_FATAL, "No multidimensional array support");
mmerror(PARSE_ERROR, ET_FATAL, "No multi-dimensional array support");
if (atoi(*dimension) >= 0)
*length = *dimension;
......@@ -463,10 +463,10 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
mmerror(PARSE_ERROR, ET_FATAL, "No pointer to pointer supported for this type");
if (pointer_len > 1 && (atoi(*length) >= 0 || atoi(*dimension) >= 0))
mmerror(PARSE_ERROR, ET_FATAL, "No multidimensional array support");
mmerror(PARSE_ERROR, ET_FATAL, "No multi-dimensional array support");
if (atoi(*length) >= 0 && atoi(*dimension) >= 0 && pointer_len)
mmerror(PARSE_ERROR, ET_FATAL, "No multidimensional array support");
mmerror(PARSE_ERROR, ET_FATAL, "No multi-dimensional array support");
switch (type_enum)
{
......@@ -480,7 +480,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
}
if (atoi(*length) >= 0)
mmerror(PARSE_ERROR, ET_FATAL, "No multidimensional array support for structures");
mmerror(PARSE_ERROR, ET_FATAL, "No multi-dimensional array support for structures");
break;
case ECPGt_varchar:
......@@ -525,7 +525,7 @@ adjust_array(enum ECPGttype type_enum, char **dimension, char **length, char *ty
}
if (atoi(*length) >= 0)
mmerror(PARSE_ERROR, ET_FATAL, "No multidimensional array support for simple data types");
mmerror(PARSE_ERROR, ET_FATAL, "No multi-dimensional array support for simple data types");
break;
}
......
......@@ -178,13 +178,19 @@ SELECT ARRAY(select f2 from arrtest_f order by f2) AS "ARRAY";
(1 row)
-- functions
SELECT array_append(array[42], 6) AS "{42,6}";
SELECT singleton_array(42) AS "{42}";
{42}
------
{42}
(1 row)
SELECT array_append(singleton_array(42), 6) AS "{42,6}";
{42,6}
--------
{42,6}
(1 row)
SELECT array_prepend(6, array[42]) AS "{6,42}";
SELECT array_prepend(6, singleton_array(42)) AS "{6,42}";
{6,42}
--------
{6,42}
......@@ -208,6 +214,24 @@ SELECT array_cat(ARRAY[[3,4],[5,6]], ARRAY[1,2]) AS "{{3,4},{5,6},{1,2}}";
{{3,4},{5,6},{1,2}}
(1 row)
SELECT array_subscript(n, 2) AS "1.2" FROM arrtest2;
1.2
-----
1.2
(1 row)
SELECT array_assign(n, 2, 9.99) AS "{1.1,9.99,1.3}" FROM arrtest2;
{1.1,9.99,1.3}
----------------
{1.1,9.99,1.3}
(1 row)
SELECT array_subscript(array_assign(n, 2, 9.99), 2) AS "9.99" FROM arrtest2;
9.99
------
9.99
(1 row)
-- operators
SELECT a FROM arrtest WHERE b = ARRAY[[[113,142],[1,147]]];
a
......
......@@ -130,11 +130,15 @@ SELECT ARRAY[ARRAY['hello'],ARRAY['world']];
SELECT ARRAY(select f2 from arrtest_f order by f2) AS "ARRAY";
-- functions
SELECT array_append(array[42], 6) AS "{42,6}";
SELECT array_prepend(6, array[42]) AS "{6,42}";
SELECT singleton_array(42) AS "{42}";
SELECT array_append(singleton_array(42), 6) AS "{42,6}";
SELECT array_prepend(6, singleton_array(42)) AS "{6,42}";
SELECT array_cat(ARRAY[1,2], ARRAY[3,4]) AS "{{1,2},{3,4}}";
SELECT array_cat(ARRAY[1,2], ARRAY[[3,4],[5,6]]) AS "{{1,2},{3,4},{5,6}}";
SELECT array_cat(ARRAY[[3,4],[5,6]], ARRAY[1,2]) AS "{{3,4},{5,6},{1,2}}";
SELECT array_subscript(n, 2) AS "1.2" FROM arrtest2;
SELECT array_assign(n, 2, 9.99) AS "{1.1,9.99,1.3}" FROM arrtest2;
SELECT array_subscript(array_assign(n, 2, 9.99), 2) AS "9.99" FROM arrtest2;
-- operators
SELECT a FROM arrtest WHERE b = ARRAY[[[113,142],[1,147]]];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment