mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
Clean up code in analyze.c for SERIAL data type.
Remove _all_ PARSEDEBUG print statements.
This commit is contained in:
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.87 1998/09/16 14:25:37 thomas Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.88 1998/09/25 13:36:00 thomas Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -30,9 +30,6 @@
|
|||||||
#include "parser/parse_target.h"
|
#include "parser/parse_target.h"
|
||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
#include "utils/mcxt.h"
|
#include "utils/mcxt.h"
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
#include "nodes/print.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static Query *transformStmt(ParseState *pstate, Node *stmt);
|
static Query *transformStmt(ParseState *pstate, Node *stmt);
|
||||||
static Query *transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt);
|
static Query *transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt);
|
||||||
@ -68,10 +65,6 @@ parse_analyze(List *pl, ParseState *parentParseState)
|
|||||||
|
|
||||||
while (pl != NIL)
|
while (pl != NIL)
|
||||||
{
|
{
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
elog(DEBUG, "parse tree from yacc:\n---\n%s\n---\n", nodeToString(lfirst(pl)));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
pstate = make_parsestate(parentParseState);
|
pstate = make_parsestate(parentParseState);
|
||||||
result->qtrees[i++] = transformStmt(pstate, lfirst(pl));
|
result->qtrees[i++] = transformStmt(pstate, lfirst(pl));
|
||||||
if (pstate->p_target_relation != NULL)
|
if (pstate->p_target_relation != NULL)
|
||||||
@ -517,12 +510,15 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
|
|||||||
|
|
||||||
if (column->is_sequence)
|
if (column->is_sequence)
|
||||||
{
|
{
|
||||||
|
char *sname;
|
||||||
char *cstring;
|
char *cstring;
|
||||||
CreateSeqStmt *sequence;
|
CreateSeqStmt *sequence;
|
||||||
|
|
||||||
|
sname = makeTableName(stmt->relname, column->colname, "seq", NULL);
|
||||||
|
|
||||||
constraint = makeNode(Constraint);
|
constraint = makeNode(Constraint);
|
||||||
constraint->contype = CONSTR_DEFAULT;
|
constraint->contype = CONSTR_DEFAULT;
|
||||||
constraint->name = makeTableName(stmt->relname, column->colname, "seq", NULL);
|
constraint->name = sname;
|
||||||
cstring = palloc(9 + strlen(constraint->name) + 2 + 1);
|
cstring = palloc(9 + strlen(constraint->name) + 2 + 1);
|
||||||
strcpy(cstring, "nextval('");
|
strcpy(cstring, "nextval('");
|
||||||
strcat(cstring, constraint->name);
|
strcat(cstring, constraint->name);
|
||||||
@ -551,7 +547,7 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
sequence = makeNode(CreateSeqStmt);
|
sequence = makeNode(CreateSeqStmt);
|
||||||
sequence->seqname = pstrdup(constraint->name);
|
sequence->seqname = pstrdup(sname);
|
||||||
sequence->options = NIL;
|
sequence->options = NIL;
|
||||||
|
|
||||||
elog(NOTICE, "CREATE TABLE will create implicit sequence %s for SERIAL column %s.%s",
|
elog(NOTICE, "CREATE TABLE will create implicit sequence %s for SERIAL column %s.%s",
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.31 1998/09/16 14:29:35 thomas Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.32 1998/09/25 13:36:01 thomas Exp $
|
||||||
*
|
*
|
||||||
* HISTORY
|
* HISTORY
|
||||||
* AUTHOR DATE MAJOR EVENT
|
* AUTHOR DATE MAJOR EVENT
|
||||||
@ -5024,10 +5024,6 @@ FlattenStringList(List *list)
|
|||||||
};
|
};
|
||||||
*(s+len) = '\0';
|
*(s+len) = '\0';
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
elog(DEBUG, "flattened string is \"%s\"\n", s);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
} /* FlattenStringList() */
|
} /* FlattenStringList() */
|
||||||
|
|
||||||
@ -5075,10 +5071,6 @@ makeConstantList( A_Const *n)
|
|||||||
elog(ERROR,"Internal error in makeConstantList(): cannot encode node");
|
elog(ERROR,"Internal error in makeConstantList(): cannot encode node");
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
elog(DEBUG, "AexprConst argument is \"%s\"\n", defval);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
} /* makeConstantList() */
|
} /* makeConstantList() */
|
||||||
|
|
||||||
@ -5104,11 +5096,6 @@ fmtId(char *rawid)
|
|||||||
cp = rawid;
|
cp = rawid;
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
elog(DEBUG, "fmtId- %sconvert %s to %s\n",
|
|
||||||
((cp == rawid)? "do not ": ""), rawid, cp);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return cp;
|
return cp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.25 1998/09/01 04:30:27 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.26 1998/09/25 13:36:03 thomas Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -389,10 +389,6 @@ transformSortClause(ParseState *pstate,
|
|||||||
{
|
{
|
||||||
List *s = NIL;
|
List *s = NIL;
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("transformSortClause: entering\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while (orderlist != NIL)
|
while (orderlist != NIL)
|
||||||
{
|
{
|
||||||
SortGroupBy *sortby = lfirst(orderlist);
|
SortGroupBy *sortby = lfirst(orderlist);
|
||||||
@ -402,11 +398,6 @@ transformSortClause(ParseState *pstate,
|
|||||||
|
|
||||||
restarget = findTargetlistEntry(pstate, sortby->node, targetlist, ORDER_CLAUSE);
|
restarget = findTargetlistEntry(pstate, sortby->node, targetlist, ORDER_CLAUSE);
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("transformSortClause: find sorting operator for type %d\n",
|
|
||||||
restarget->resdom->restype);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
sortcl->resdom = resdom = restarget->resdom;
|
sortcl->resdom = resdom = restarget->resdom;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -478,11 +469,6 @@ transformSortClause(ParseState *pstate,
|
|||||||
/* not a member of the sortclauses yet */
|
/* not a member of the sortclauses yet */
|
||||||
SortClause *sortcl = makeNode(SortClause);
|
SortClause *sortcl = makeNode(SortClause);
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("transformSortClause: (2) find sorting operator for type %d\n",
|
|
||||||
tlelt->resdom->restype);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (tlelt->resdom->restype == InvalidOid)
|
if (tlelt->resdom->restype == InvalidOid)
|
||||||
tlelt->resdom->restype = INT4OID;
|
tlelt->resdom->restype = INT4OID;
|
||||||
|
|
||||||
@ -520,11 +506,6 @@ transformSortClause(ParseState *pstate,
|
|||||||
/* not a member of the sortclauses yet */
|
/* not a member of the sortclauses yet */
|
||||||
SortClause *sortcl = makeNode(SortClause);
|
SortClause *sortcl = makeNode(SortClause);
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("transformSortClause: try sorting type %d\n",
|
|
||||||
tlelt->resdom->restype);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
sortcl->resdom = tlelt->resdom;
|
sortcl->resdom = tlelt->resdom;
|
||||||
sortcl->opoid = any_ordering_op(tlelt->resdom->restype);
|
sortcl->opoid = any_ordering_op(tlelt->resdom->restype);
|
||||||
|
|
||||||
@ -576,10 +557,6 @@ transformUnionClause(List *unionClause, List *targetlist)
|
|||||||
otype = ((TargetEntry *) lfirst(prev_target))->resdom->restype;
|
otype = ((TargetEntry *) lfirst(prev_target))->resdom->restype;
|
||||||
itype = ((TargetEntry *) lfirst(next_target))->resdom->restype;
|
itype = ((TargetEntry *) lfirst(next_target))->resdom->restype;
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("transformUnionClause: types are %d -> %d\n", itype, otype);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* one or both is a NULL column? then don't convert... */
|
/* one or both is a NULL column? then don't convert... */
|
||||||
if (otype == InvalidOid)
|
if (otype == InvalidOid)
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.28 1998/09/01 04:30:31 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.29 1998/09/25 13:36:04 thomas Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -672,34 +672,22 @@ func_select_candidate(int nargs,
|
|||||||
if ((nmatch + nident) == nargs)
|
if ((nmatch + nident) == nargs)
|
||||||
return current_candidate->args;
|
return current_candidate->args;
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("func_select_candidate- candidate has %d matches\n", nmatch);
|
|
||||||
#endif
|
|
||||||
if ((nmatch > nbestMatch) || (last_candidate == NULL))
|
if ((nmatch > nbestMatch) || (last_candidate == NULL))
|
||||||
{
|
{
|
||||||
nbestMatch = nmatch;
|
nbestMatch = nmatch;
|
||||||
candidates = current_candidate;
|
candidates = current_candidate;
|
||||||
last_candidate = current_candidate;
|
last_candidate = current_candidate;
|
||||||
ncandidates = 1;
|
ncandidates = 1;
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("func_select_candidate- choose candidate as best match\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (nmatch == nbestMatch)
|
else if (nmatch == nbestMatch)
|
||||||
{
|
{
|
||||||
last_candidate->next = current_candidate;
|
last_candidate->next = current_candidate;
|
||||||
last_candidate = current_candidate;
|
last_candidate = current_candidate;
|
||||||
ncandidates++;
|
ncandidates++;
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("func_select_candidate- choose candidate as possible match\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
last_candidate->next = NULL;
|
last_candidate->next = NULL;
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("func_select_candidate- reject candidate as possible match\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -727,17 +715,10 @@ func_select_candidate(int nargs,
|
|||||||
{
|
{
|
||||||
slot_category = current_category;
|
slot_category = current_category;
|
||||||
slot_type = current_type;
|
slot_type = current_type;
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("func_select_candidate- assign column #%d first candidate slot type %s\n",
|
|
||||||
i, typeidTypeName(current_type));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if ((current_category != slot_category)
|
else if ((current_category != slot_category)
|
||||||
&& IS_BUILTIN_TYPE(current_type))
|
&& IS_BUILTIN_TYPE(current_type))
|
||||||
{
|
{
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("func_select_candidate- multiple possible types for column #%d; unable to choose candidate\n", i);
|
|
||||||
#endif
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else if (current_type != slot_type)
|
else if (current_type != slot_type)
|
||||||
@ -746,17 +727,9 @@ func_select_candidate(int nargs,
|
|||||||
{
|
{
|
||||||
slot_type = current_type;
|
slot_type = current_type;
|
||||||
candidates = current_candidate;
|
candidates = current_candidate;
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("func_select_candidate- column #%d found preferred candidate type %s\n",
|
|
||||||
i, typeidTypeName(slot_type));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("func_select_candidate- column #%d found possible candidate type %s\n",
|
|
||||||
i, typeidTypeName(current_type));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -764,18 +737,10 @@ func_select_candidate(int nargs,
|
|||||||
if (slot_type != InvalidOid)
|
if (slot_type != InvalidOid)
|
||||||
{
|
{
|
||||||
input_typeids[i] = slot_type;
|
input_typeids[i] = slot_type;
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("func_select_candidate- assign column #%d slot type %s\n",
|
|
||||||
i, typeidTypeName(input_typeids[i]));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("func_select_candidate- column #%d input type is %s\n",
|
|
||||||
i, typeidTypeName(input_typeids[i]));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.21 1998/09/01 04:30:33 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.22 1998/09/25 13:36:05 thomas Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -67,10 +67,6 @@ make_operand(char *opname,
|
|||||||
Node *result;
|
Node *result;
|
||||||
Type true_type;
|
Type true_type;
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("make_operand: constructing operand for '%s' %s->%s\n",
|
|
||||||
opname, typeidTypeName(orig_typeId), typeidTypeName(true_typeId));
|
|
||||||
#endif
|
|
||||||
if (tree != NULL)
|
if (tree != NULL)
|
||||||
{
|
{
|
||||||
result = tree;
|
result = tree;
|
||||||
@ -80,10 +76,6 @@ make_operand(char *opname,
|
|||||||
/* must coerce? */
|
/* must coerce? */
|
||||||
if (true_typeId != orig_typeId)
|
if (true_typeId != orig_typeId)
|
||||||
{
|
{
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("make_operand: try to convert node from %s to %s\n",
|
|
||||||
typeidTypeName(orig_typeId), typeidTypeName(true_typeId));
|
|
||||||
#endif
|
|
||||||
result = coerce_type(NULL, tree, orig_typeId, true_typeId);
|
result = coerce_type(NULL, tree, orig_typeId, true_typeId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,13 +147,7 @@ make_op(char *opname, Node *ltree, Node *rtree)
|
|||||||
{
|
{
|
||||||
rtypeId = (rtree == NULL) ? UNKNOWNOID : exprType(rtree);
|
rtypeId = (rtree == NULL) ? UNKNOWNOID : exprType(rtree);
|
||||||
tup = left_oper(opname, rtypeId);
|
tup = left_oper(opname, rtypeId);
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("make_op: returned from left_oper() with structure at %p\n", (void *) tup);
|
|
||||||
#endif
|
|
||||||
opform = (Form_pg_operator) GETSTRUCT(tup);
|
opform = (Form_pg_operator) GETSTRUCT(tup);
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("make_op: calling make_operand()\n");
|
|
||||||
#endif
|
|
||||||
right = make_operand(opname, rtree, rtypeId, opform->oprright);
|
right = make_operand(opname, rtree, rtypeId, opform->oprright);
|
||||||
left = NULL;
|
left = NULL;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.18 1998/09/16 14:22:22 thomas Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.19 1998/09/25 13:36:07 thomas Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -209,34 +209,22 @@ oper_select_candidate(int nargs,
|
|||||||
nmatch++;
|
nmatch++;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("oper_select_candidate- candidate has %d matches\n", nmatch);
|
|
||||||
#endif
|
|
||||||
if ((nmatch > nbestMatch) || (last_candidate == NULL))
|
if ((nmatch > nbestMatch) || (last_candidate == NULL))
|
||||||
{
|
{
|
||||||
nbestMatch = nmatch;
|
nbestMatch = nmatch;
|
||||||
candidates = current_candidate;
|
candidates = current_candidate;
|
||||||
last_candidate = current_candidate;
|
last_candidate = current_candidate;
|
||||||
ncandidates = 1;
|
ncandidates = 1;
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("oper_select_candidate- choose candidate as best match\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (nmatch == nbestMatch)
|
else if (nmatch == nbestMatch)
|
||||||
{
|
{
|
||||||
last_candidate->next = current_candidate;
|
last_candidate->next = current_candidate;
|
||||||
last_candidate = current_candidate;
|
last_candidate = current_candidate;
|
||||||
ncandidates++;
|
ncandidates++;
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("oper_select_candidate- choose candidate as possible match\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
last_candidate->next = NULL;
|
last_candidate->next = NULL;
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("oper_select_candidate- reject candidate as possible match\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,34 +263,22 @@ oper_select_candidate(int nargs,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("oper_select_candidate- candidate has %d matches\n", nmatch);
|
|
||||||
#endif
|
|
||||||
if ((nmatch > nbestMatch) || (last_candidate == NULL))
|
if ((nmatch > nbestMatch) || (last_candidate == NULL))
|
||||||
{
|
{
|
||||||
nbestMatch = nmatch;
|
nbestMatch = nmatch;
|
||||||
candidates = current_candidate;
|
candidates = current_candidate;
|
||||||
last_candidate = current_candidate;
|
last_candidate = current_candidate;
|
||||||
ncandidates = 1;
|
ncandidates = 1;
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("oper_select_candidate- choose candidate as best match\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (nmatch == nbestMatch)
|
else if (nmatch == nbestMatch)
|
||||||
{
|
{
|
||||||
last_candidate->next = current_candidate;
|
last_candidate->next = current_candidate;
|
||||||
last_candidate = current_candidate;
|
last_candidate = current_candidate;
|
||||||
ncandidates++;
|
ncandidates++;
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("oper_select_candidate- choose candidate as possible match\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
last_candidate->next = NULL;
|
last_candidate->next = NULL;
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("oper_select_candidate- reject candidate as possible match\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,9 +288,6 @@ oper_select_candidate(int nargs,
|
|||||||
|| ((nargs > 1) && !can_coerce_type(1, &input_typeids[1], &candidates->args[1])))
|
|| ((nargs > 1) && !can_coerce_type(1, &input_typeids[1], &candidates->args[1])))
|
||||||
{
|
{
|
||||||
ncandidates = 0;
|
ncandidates = 0;
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("oper_select_candidate- unable to coerce preferred candidate\n");
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
return (ncandidates == 1) ? candidates->args : NULL;
|
return (ncandidates == 1) ? candidates->args : NULL;
|
||||||
}
|
}
|
||||||
@ -370,16 +343,9 @@ oper_select_candidate(int nargs,
|
|||||||
{
|
{
|
||||||
slot_category = current_category;
|
slot_category = current_category;
|
||||||
slot_type = current_type;
|
slot_type = current_type;
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("oper_select_candidate- assign column #%d first candidate slot type %s\n",
|
|
||||||
i, typeidTypeName(current_type));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else if (current_category != slot_category)
|
else if (current_category != slot_category)
|
||||||
{
|
{
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("oper_select_candidate- multiple possible types for column #%d; unable to choose candidate\n", i);
|
|
||||||
#endif
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else if (current_type != slot_type)
|
else if (current_type != slot_type)
|
||||||
@ -388,17 +354,9 @@ oper_select_candidate(int nargs,
|
|||||||
{
|
{
|
||||||
slot_type = current_type;
|
slot_type = current_type;
|
||||||
candidates = current_candidate;
|
candidates = current_candidate;
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("oper_select_candidate- column #%d found preferred candidate type %s\n",
|
|
||||||
i, typeidTypeName(slot_type));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("oper_select_candidate- column #%d found possible candidate type %s\n",
|
|
||||||
i, typeidTypeName(current_type));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -406,18 +364,10 @@ oper_select_candidate(int nargs,
|
|||||||
if (slot_type != InvalidOid)
|
if (slot_type != InvalidOid)
|
||||||
{
|
{
|
||||||
input_typeids[i] = slot_type;
|
input_typeids[i] = slot_type;
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("oper_select_candidate- assign column #%d slot type %s\n",
|
|
||||||
i, typeidTypeName(input_typeids[i]));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("oper_select_candidate- column #%d input type is %s\n",
|
|
||||||
i, typeidTypeName(input_typeids[i]));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -474,15 +424,9 @@ oper_exact(char *op, Oid arg1, Oid arg2, Node **ltree, Node **rtree, bool noWarn
|
|||||||
{
|
{
|
||||||
Form_pg_operator opform;
|
Form_pg_operator opform;
|
||||||
|
|
||||||
#if PARSEDEBUG
|
|
||||||
printf("oper_exact: found possible commutative operator candidate\n");
|
|
||||||
#endif
|
|
||||||
opform = (Form_pg_operator) GETSTRUCT(tup);
|
opform = (Form_pg_operator) GETSTRUCT(tup);
|
||||||
if (opform->oprcom == tup->t_oid)
|
if (opform->oprcom == tup->t_oid)
|
||||||
{
|
{
|
||||||
#if PARSEDEBUG
|
|
||||||
printf("oper_exact: commutative operator found\n");
|
|
||||||
#endif
|
|
||||||
if ((ltree != NULL) && (rtree != NULL))
|
if ((ltree != NULL) && (rtree != NULL))
|
||||||
{
|
{
|
||||||
tree = *ltree;
|
tree = *ltree;
|
||||||
@ -541,11 +485,6 @@ oper_inexact(char *op, Oid arg1, Oid arg2, Node **ltree, Node **rtree, bool noWa
|
|||||||
ObjectIdGetDatum(candidates->args[1]),
|
ObjectIdGetDatum(candidates->args[1]),
|
||||||
CharGetDatum('b'));
|
CharGetDatum('b'));
|
||||||
Assert(HeapTupleIsValid(tup));
|
Assert(HeapTupleIsValid(tup));
|
||||||
|
|
||||||
#if PARSEDEBUG
|
|
||||||
printf("oper_inexact: found single candidate\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Otherwise, multiple operators of the desired types found... */
|
/* Otherwise, multiple operators of the desired types found... */
|
||||||
@ -556,9 +495,6 @@ oper_inexact(char *op, Oid arg1, Oid arg2, Node **ltree, Node **rtree, bool noWa
|
|||||||
targetOids = oper_select_candidate(2, inputOids, candidates);
|
targetOids = oper_select_candidate(2, inputOids, candidates);
|
||||||
if (targetOids != NULL)
|
if (targetOids != NULL)
|
||||||
{
|
{
|
||||||
#if PARSEDEBUG
|
|
||||||
printf("oper_inexact: found candidate\n");
|
|
||||||
#endif
|
|
||||||
tup = SearchSysCacheTuple(OPRNAME,
|
tup = SearchSysCacheTuple(OPRNAME,
|
||||||
PointerGetDatum(op),
|
PointerGetDatum(op),
|
||||||
ObjectIdGetDatum(targetOids[0]),
|
ObjectIdGetDatum(targetOids[0]),
|
||||||
@ -641,9 +577,6 @@ unary_oper_get_candidates(char *op,
|
|||||||
fmgr_info(F_CHAREQ, (FmgrInfo *) &opKey[1].sk_func);
|
fmgr_info(F_CHAREQ, (FmgrInfo *) &opKey[1].sk_func);
|
||||||
opKey[1].sk_argument = CharGetDatum(rightleft);
|
opKey[1].sk_argument = CharGetDatum(rightleft);
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("unary_oper_get_candidates: start scan for '%s'\n", op);
|
|
||||||
#endif
|
|
||||||
pg_operator_desc = heap_openr(OperatorRelationName);
|
pg_operator_desc = heap_openr(OperatorRelationName);
|
||||||
pg_operator_scan = heap_beginscan(pg_operator_desc,
|
pg_operator_scan = heap_beginscan(pg_operator_desc,
|
||||||
0,
|
0,
|
||||||
@ -663,19 +596,12 @@ unary_oper_get_candidates(char *op,
|
|||||||
current_candidate->args[0] = oper->oprright;
|
current_candidate->args[0] = oper->oprright;
|
||||||
current_candidate->next = *candidates;
|
current_candidate->next = *candidates;
|
||||||
*candidates = current_candidate;
|
*candidates = current_candidate;
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("unary_oper_get_candidates: found candidate '%s' for type %s\n",
|
|
||||||
op, typeidTypeName(current_candidate->args[0]));
|
|
||||||
#endif
|
|
||||||
ncandidates++;
|
ncandidates++;
|
||||||
}
|
}
|
||||||
|
|
||||||
heap_endscan(pg_operator_scan);
|
heap_endscan(pg_operator_scan);
|
||||||
heap_close(pg_operator_desc);
|
heap_close(pg_operator_desc);
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("unary_oper_get_candidates: found %d candidates\n", ncandidates);
|
|
||||||
#endif
|
|
||||||
return ncandidates;
|
return ncandidates;
|
||||||
} /* unary_oper_get_candidates() */
|
} /* unary_oper_get_candidates() */
|
||||||
|
|
||||||
@ -774,10 +700,6 @@ left_oper(char *op, Oid arg)
|
|||||||
ObjectIdGetDatum(candidates->args[0]),
|
ObjectIdGetDatum(candidates->args[0]),
|
||||||
CharGetDatum('l'));
|
CharGetDatum('l'));
|
||||||
Assert(HeapTupleIsValid(tup));
|
Assert(HeapTupleIsValid(tup));
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("left_oper: searched cache for single left oper candidate '%s %s'\n",
|
|
||||||
op, typeidTypeName((Oid) candidates->args[0]));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -801,10 +723,6 @@ left_oper(char *op, Oid arg)
|
|||||||
op, typeidTypeName(arg));
|
op, typeidTypeName(arg));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("left_oper: searched cache for best left oper candidate '%s %s'\n",
|
|
||||||
op, typeidTypeName(*targetOid));
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (Operator) tup;
|
return (Operator) tup;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.28 1998/09/02 23:05:27 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.29 1998/09/25 13:36:08 thomas Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -19,6 +19,7 @@
|
|||||||
#include "catalog/pg_type.h"
|
#include "catalog/pg_type.h"
|
||||||
#include "nodes/makefuncs.h"
|
#include "nodes/makefuncs.h"
|
||||||
#include "nodes/primnodes.h"
|
#include "nodes/primnodes.h"
|
||||||
|
#include "nodes/print.h"
|
||||||
#include "parser/parse_expr.h"
|
#include "parser/parse_expr.h"
|
||||||
#include "parser/parse_func.h"
|
#include "parser/parse_func.h"
|
||||||
#include "parser/parse_node.h"
|
#include "parser/parse_node.h"
|
||||||
@ -116,10 +117,6 @@ MakeTargetEntryIdent(ParseState *pstate,
|
|||||||
attrtype_target = attnumTypeId(pstate->p_target_relation, resdomno_target);
|
attrtype_target = attnumTypeId(pstate->p_target_relation, resdomno_target);
|
||||||
attrtypmod_target = get_atttypmod(pstate->p_target_relation->rd_id, resdomno_target);
|
attrtypmod_target = get_atttypmod(pstate->p_target_relation->rd_id, resdomno_target);
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("MakeTargetEntryIdent- transform type %d to %d\n",
|
|
||||||
attrtype_id, attrtype_target);
|
|
||||||
#endif
|
|
||||||
if ((attrtype_id != attrtype_target)
|
if ((attrtype_id != attrtype_target)
|
||||||
|| ((attrtypmod_target >= 0) && (attrtypmod_target != attrtypmod)))
|
|| ((attrtypmod_target >= 0) && (attrtypmod_target != attrtypmod)))
|
||||||
{
|
{
|
||||||
@ -155,9 +152,6 @@ MakeTargetEntryIdent(ParseState *pstate,
|
|||||||
|
|
||||||
name = ((*resname != NULL) ? *resname : colname);
|
name = ((*resname != NULL) ? *resname : colname);
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("MakeTargetEntryIdent- call transformIdent()\n");
|
|
||||||
#endif
|
|
||||||
#if FALSE
|
#if FALSE
|
||||||
expr = transformIdent(pstate, (Node *) ident, EXPR_COLUMN_FIRST);
|
expr = transformIdent(pstate, (Node *) ident, EXPR_COLUMN_FIRST);
|
||||||
#else
|
#else
|
||||||
@ -170,10 +164,6 @@ MakeTargetEntryIdent(ParseState *pstate,
|
|||||||
else
|
else
|
||||||
type_mod = -1;
|
type_mod = -1;
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("MakeTargetEntryIdent- attrtype_target = %d; type_mod = %d\n", attrtype_target, type_mod);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
tent->resdom = makeResdom((AttrNumber) pstate->p_last_resno++,
|
tent->resdom = makeResdom((AttrNumber) pstate->p_last_resno++,
|
||||||
(Oid) attrtype_target,
|
(Oid) attrtype_target,
|
||||||
type_mod,
|
type_mod,
|
||||||
@ -269,10 +259,6 @@ MakeTargetEntryExpr(ParseState *pstate,
|
|||||||
typeidTypeName(type_id));
|
typeidTypeName(type_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("MakeTargetEntryExpr: attrtypmod is %d\n", (int4) attrtypmod);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Apparently going to a fixed-length string? Then explicitly
|
* Apparently going to a fixed-length string? Then explicitly
|
||||||
* size for storage...
|
* size for storage...
|
||||||
@ -338,8 +324,8 @@ MakeTargetEntryExpr(ParseState *pstate,
|
|||||||
} /* MakeTargetEntryExpr() */
|
} /* MakeTargetEntryExpr() */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MakeTargetlistComplex()
|
* MakeTargetEntryComplex()
|
||||||
* pMake a TargetEntry from an complex node.
|
* Make a TargetEntry from a complex node.
|
||||||
*/
|
*/
|
||||||
static TargetEntry *
|
static TargetEntry *
|
||||||
MakeTargetEntryComplex(ParseState *pstate,
|
MakeTargetEntryComplex(ParseState *pstate,
|
||||||
@ -347,10 +333,6 @@ MakeTargetEntryComplex(ParseState *pstate,
|
|||||||
{
|
{
|
||||||
Node *expr = transformExpr(pstate, (Node *) res->val, EXPR_COLUMN_FIRST);
|
Node *expr = transformExpr(pstate, (Node *) res->val, EXPR_COLUMN_FIRST);
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("transformTargetList: decode T_Expr\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
handleTargetColname(pstate, &res->name, NULL, NULL);
|
handleTargetColname(pstate, &res->name, NULL, NULL);
|
||||||
/* note indirection has not been transformed */
|
/* note indirection has not been transformed */
|
||||||
if (pstate->p_is_insert && res->indirection != NIL)
|
if (pstate->p_is_insert && res->indirection != NIL)
|
||||||
@ -450,8 +432,8 @@ MakeTargetEntryComplex(ParseState *pstate,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MakeTargetlistComplex()
|
* MakeTargetEntryAttr()
|
||||||
* pMake a TargetEntry from an complex node.
|
* Make a TargetEntry from a complex node.
|
||||||
*/
|
*/
|
||||||
static TargetEntry *
|
static TargetEntry *
|
||||||
MakeTargetEntryAttr(ParseState *pstate,
|
MakeTargetEntryAttr(ParseState *pstate,
|
||||||
@ -473,9 +455,6 @@ MakeTargetEntryAttr(ParseState *pstate,
|
|||||||
/*
|
/*
|
||||||
* Target item is fully specified: ie. relation.attribute
|
* Target item is fully specified: ie. relation.attribute
|
||||||
*/
|
*/
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("transformTargetList: decode T_Attr\n");
|
|
||||||
#endif
|
|
||||||
result = ParseNestedFuncOrColumn(pstate, att, &pstate->p_last_resno, EXPR_COLUMN_FIRST);
|
result = ParseNestedFuncOrColumn(pstate, att, &pstate->p_last_resno, EXPR_COLUMN_FIRST);
|
||||||
handleTargetColname(pstate, &res->name, att->relname, attrname);
|
handleTargetColname(pstate, &res->name, att->relname, attrname);
|
||||||
if (att->indirection != NIL)
|
if (att->indirection != NIL)
|
||||||
@ -549,9 +528,6 @@ transformTargetList(ParseState *pstate, List *targetlist)
|
|||||||
{
|
{
|
||||||
char *identname;
|
char *identname;
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("transformTargetList: decode T_Ident\n");
|
|
||||||
#endif
|
|
||||||
identname = ((Ident *) res->val)->name;
|
identname = ((Ident *) res->val)->name;
|
||||||
tent = MakeTargetEntryIdent(pstate, (Node *) res->val, &res->name, NULL, identname, FALSE);
|
tent = MakeTargetEntryIdent(pstate, (Node *) res->val, &res->name, NULL, identname, FALSE);
|
||||||
break;
|
break;
|
||||||
@ -654,10 +630,6 @@ CoerceTargetExpr(ParseState *pstate,
|
|||||||
{
|
{
|
||||||
if (can_coerce_type(1, &type_id, &attrtype))
|
if (can_coerce_type(1, &type_id, &attrtype))
|
||||||
{
|
{
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("CoerceTargetExpr: coerce type from %s to %s\n",
|
|
||||||
typeidTypeName(type_id), typeidTypeName(attrtype));
|
|
||||||
#endif
|
|
||||||
expr = coerce_type(pstate, expr, type_id, attrtype);
|
expr = coerce_type(pstate, expr, type_id, attrtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -671,10 +643,6 @@ CoerceTargetExpr(ParseState *pstate,
|
|||||||
{
|
{
|
||||||
Oid text_id = TEXTOID;
|
Oid text_id = TEXTOID;
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("CoerceTargetExpr: try coercing from %s to %s via text\n",
|
|
||||||
typeidTypeName(type_id), typeidTypeName(attrtype));
|
|
||||||
#endif
|
|
||||||
if (type_id == TEXTOID)
|
if (type_id == TEXTOID)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -710,20 +678,12 @@ SizeTargetExpr(ParseState *pstate,
|
|||||||
FuncCall *func;
|
FuncCall *func;
|
||||||
A_Const *cons;
|
A_Const *cons;
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("SizeTargetExpr: ensure target fits storage\n");
|
|
||||||
#endif
|
|
||||||
funcname = typeidTypeName(attrtype);
|
funcname = typeidTypeName(attrtype);
|
||||||
oid_array[0] = attrtype;
|
oid_array[0] = attrtype;
|
||||||
oid_array[1] = INT4OID;
|
oid_array[1] = INT4OID;
|
||||||
for (i = 2; i < 8; i++)
|
for (i = 2; i < 8; i++)
|
||||||
oid_array[i] = InvalidOid;
|
oid_array[i] = InvalidOid;
|
||||||
|
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("SizeTargetExpr: look for conversion function %s(%s,%s)\n",
|
|
||||||
funcname, typeidTypeName(attrtype), typeidTypeName(INT4OID));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* attempt to find with arguments exactly as specified... */
|
/* attempt to find with arguments exactly as specified... */
|
||||||
ftup = SearchSysCacheTuple(PRONAME,
|
ftup = SearchSysCacheTuple(PRONAME,
|
||||||
PointerGetDatum(funcname),
|
PointerGetDatum(funcname),
|
||||||
@ -733,9 +693,6 @@ SizeTargetExpr(ParseState *pstate,
|
|||||||
|
|
||||||
if (HeapTupleIsValid(ftup))
|
if (HeapTupleIsValid(ftup))
|
||||||
{
|
{
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
printf("SizeTargetExpr: found conversion function for sizing\n");
|
|
||||||
#endif
|
|
||||||
func = makeNode(FuncCall);
|
func = makeNode(FuncCall);
|
||||||
func->funcname = funcname;
|
func->funcname = funcname;
|
||||||
|
|
||||||
@ -746,10 +703,6 @@ SizeTargetExpr(ParseState *pstate,
|
|||||||
|
|
||||||
expr = transformExpr(pstate, (Node *) func, EXPR_COLUMN_FIRST);
|
expr = transformExpr(pstate, (Node *) func, EXPR_COLUMN_FIRST);
|
||||||
}
|
}
|
||||||
#ifdef PARSEDEBUG
|
|
||||||
else
|
|
||||||
printf("SizeTargetExpr: no conversion function for sizing\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return expr;
|
return expr;
|
||||||
} /* SizeTargetExpr() */
|
} /* SizeTargetExpr() */
|
||||||
|
Reference in New Issue
Block a user