summaryrefslogtreecommitdiff
path: root/src/backend
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend')
-rw-r--r--src/backend/access/common/tupdesc.c17
-rw-r--r--src/backend/catalog/catalog.c11
-rw-r--r--src/backend/catalog/index.c24
-rw-r--r--src/backend/commands/command.c9
-rw-r--r--src/backend/commands/copy.c4
-rw-r--r--src/backend/commands/sequence.c1
-rw-r--r--src/backend/executor/execAmi.c28
-rw-r--r--src/backend/executor/execMain.c9
-rw-r--r--src/backend/executor/execUtils.c75
-rw-r--r--src/backend/nodes/copyfuncs.c4
-rw-r--r--src/backend/nodes/outfuncs.c8
-rw-r--r--src/backend/optimizer/prep/preptlist.c6
-rw-r--r--src/backend/parser/gram.y4
-rw-r--r--src/backend/parser/parse_expr.c13
-rw-r--r--src/backend/parser/parse_oper.c6
-rw-r--r--src/backend/parser/parse_relation.c15
-rw-r--r--src/backend/parser/parse_target.c19
-rw-r--r--src/backend/parser/parse_type.c7
-rw-r--r--src/backend/utils/adt/varchar.c22
19 files changed, 78 insertions, 204 deletions
diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c
index 9324a95c76..f23c8e8657 100644
--- a/src/backend/access/common/tupdesc.c
+++ b/src/backend/access/common/tupdesc.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.31 1998/01/07 21:00:45 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.32 1998/01/16 23:19:16 momjian Exp $
*
* NOTES
* some of the executor utility code such as "ExecTypeFromTL" should be
@@ -301,11 +301,12 @@ TupleDescInitEntry(TupleDesc desc,
att->attdisbursion = 0; /* dummy value */
att->attcacheoff = -1;
+ att->atttypmod = 0;
att->attnum = attributeNumber;
att->attnelems = attdim;
att->attisset = attisset;
-
+
att->attnotnull = false;
att->atthasdef = false;
@@ -512,17 +513,7 @@ BuildDescForRelation(List *schema, char *relname)
typename);
}
- /*
- * this is for char() and varchar(). When an entry is of type
- * char() or varchar(), typlen is set to the appropriate length,
- * which we'll use here instead. (The catalog lookup only returns
- * the length of bpchar and varchar which is not what we want!) -
- * ay 6/95
- */
- if (entry->typename->typlen > 0)
- {
- desc->attrs[attnum - 1]->attlen = entry->typename->typlen;
- }
+ desc->attrs[attnum - 1]->atttypmod = entry->typename->typmod;
/* This is for constraints */
if (entry->is_not_null)
diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index 2669a4481f..f45685ea8a 100644
--- a/src/backend/catalog/catalog.c
+++ b/src/backend/catalog/catalog.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.12 1998/01/06 19:42:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.13 1998/01/16 23:19:23 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -190,16 +190,9 @@ fillatt(TupleDesc tupleDesc)
* and byval, since those were already set in
* TupleDescInitEntry. In fact, this seems redundant here,
* but who knows what I'll break if I take it out...
- *
- * same for char() and varchar() stuff. I share the same
- * sentiments. This function is poorly written anyway. -ay
- * 6/95
*/
- if (!(*attributeP)->attisset &&
- (*attributeP)->atttypid != BPCHAROID &&
- (*attributeP)->atttypid != VARCHAROID)
+ if (!(*attributeP)->attisset)
{
-
typp = (TypeTupleForm) GETSTRUCT(tuple); /* XXX */
(*attributeP)->attlen = typp->typlen;
(*attributeP)->attbyval = typp->typbyval;
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index c98c877d7d..6772f8b665 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.35 1998/01/15 19:42:27 pgsql Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.36 1998/01/16 23:19:27 momjian Exp $
*
*
* INTERFACE ROUTINES
@@ -107,6 +107,7 @@ DefaultBuild(Relation heapRelation, Relation indexRelation,
* AttrNumber attnum;
* uint32 attnelems;
* int32 attcacheoff;
+ * int16 atttypmod;
* bool attbyval;
* bool attisset;
* char attalign;
@@ -117,12 +118,12 @@ DefaultBuild(Relation heapRelation, Relation indexRelation,
* ----------------------------------------------------------------
*/
static FormData_pg_attribute sysatts[] = {
- {0l, {"ctid"}, 27l, 0l, 6, -1, 0, -1, '\0', '\0', 'i', '\0', '\0'},
- {0l, {"oid"}, 26l, 0l, 4, -2, 0, -1, '\001', '\0', 'i', '\0', '\0'},
- {0l, {"xmin"}, 28l, 0l, 4, -3, 0, -1, '\0', '\0', 'i', '\0', '\0'},
- {0l, {"cmin"}, 29l, 0l, 4, -4, 0, -1, '\001', '\0', 'i', '\0', '\0'},
- {0l, {"xmax"}, 28l, 0l, 4, -5, 0, -1, '\0', '\0', 'i', '\0', '\0'},
- {0l, {"cmax"}, 29l, 0l, 4, -6, 0, -1, '\001', '\0', 'i', '\0', '\0'},
+ {0l, {"ctid"}, 27l, 0l, 6, -1, 0, -1, 0, '\0', '\0', 'i', '\0', '\0'},
+ {0l, {"oid"}, 26l, 0l, 4, -2, 0, -1, 0, '\001', '\0', 'i', '\0', '\0'},
+ {0l, {"xmin"}, 28l, 0l, 4, -3, 0, -1, 0, '\0', '\0', 'i', '\0', '\0'},
+ {0l, {"cmin"}, 29l, 0l, 4, -4, 0, -1, 0, '\001', '\0', 'i', '\0', '\0'},
+ {0l, {"xmax"}, 28l, 0l, 4, -5, 0, -1, 0, '\0', '\0', 'i', '\0', '\0'},
+ {0l, {"cmax"}, 29l, 0l, 4, -6, 0, -1, 0, '\001', '\0', 'i', '\0', '\0'},
};
/* ----------------------------------------------------------------
@@ -436,6 +437,7 @@ ConstructTupleDescriptor(Oid heapoid,
((AttributeTupleForm) to)->attnotnull = false;
((AttributeTupleForm) to)->atthasdef = false;
+ ((AttributeTupleForm) to)->atttypmod = 0;
/*
* if the keytype is defined, we need to change the tuple form's
@@ -454,11 +456,11 @@ ConstructTupleDescriptor(Oid heapoid,
((AttributeTupleForm) to)->atttypid = tup->t_oid;
((AttributeTupleForm) to)->attbyval =
((TypeTupleForm) ((char *) tup + tup->t_hoff))->typbyval;
- if (IndexKeyType->typlen > 0)
- ((AttributeTupleForm) to)->attlen = IndexKeyType->typlen;
- else
- ((AttributeTupleForm) to)->attlen =
+
+ ((AttributeTupleForm) to)->attlen =
((TypeTupleForm) ((char *) tup + tup->t_hoff))->typlen;
+
+ ((AttributeTupleForm) to)->atttypmod = IndexKeyType->typmod;
}
diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c
index d9a4281ea1..5f7bcd2d07 100644
--- a/src/backend/commands/command.c
+++ b/src/backend/commands/command.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.23 1998/01/05 16:38:44 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.24 1998/01/16 23:19:33 momjian Exp $
*
* NOTES
* The PortalExecutorHeapMemory crap needs to be eliminated
@@ -482,11 +482,8 @@ PerformAddAttribute(char *relationName,
}
namestrcpy(&(attribute->attname), (char *) key[1].sk_argument);
attribute->atttypid = typeTuple->t_oid;
- if (colDef->typename->typlen > 0)
- attribute->attlen = colDef->typename->typlen;
- else
-/* bpchar, varchar, text */
- attribute->attlen = form->typlen;
+ attribute->attlen = form->typlen;
+ attribute->atttypmod = colDef->typename->typmod;
attribute->attnum = i;
attribute->attbyval = form->typbyval;
attribute->attnelems = attnelems;
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 9b5fbda69e..b3017dcd74 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.38 1998/01/15 19:42:36 pgsql Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.39 1998/01/16 23:19:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -574,7 +574,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
values[i] =
(Datum) (*fmgr_faddr(&in_functions[i])) (string,
elements[i],
- attr[i]->attlen);
+ attr[i]->atttypmod);
/*
* Sanity check - by reference attributes cannot
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index bf7e79d3ed..58008dd138 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -98,6 +98,7 @@ DefineSequence(CreateSeqStmt *seq)
typnam = makeNode(TypeName);
typnam->setof = FALSE;
typnam->arrayBounds = NULL;
+ typnam->typmod = 0;
coldef = makeNode(ColumnDef);
coldef->typename = typnam;
coldef->defval = NULL;
diff --git a/src/backend/executor/execAmi.c b/src/backend/executor/execAmi.c
index 675a58d649..2349f32411 100644
--- a/src/backend/executor/execAmi.c
+++ b/src/backend/executor/execAmi.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.15 1998/01/16 05:03:45 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.16 1998/01/16 23:19:47 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -42,7 +42,6 @@
#include "access/genam.h"
#include "access/heapam.h"
#include "catalog/heap.h"
-#include "catalog/pg_type.h"
static Pointer
ExecBeginScan(Relation relation, int nkeys, ScanKey skeys,
@@ -125,31 +124,6 @@ ExecOpenR(Oid relationOid, bool isindex)
if (relation == NULL)
elog(DEBUG, "ExecOpenR: relation == NULL, heap_open failed.");
- {
- int i;
- Relation trel = palloc(sizeof(RelationData));
- TupleDesc tdesc = palloc(sizeof(struct tupleDesc));
- AttributeTupleForm *tatt =
- palloc(sizeof(AttributeTupleForm*)*relation->rd_att->natts);
-
- memcpy(trel, relation, sizeof(RelationData));
- memcpy(tdesc, relation->rd_att, sizeof(struct tupleDesc));
- trel->rd_att = tdesc;
- tdesc->attrs = tatt;
-
- for (i = 0; i < relation->rd_att->natts; i++)
- {
- if (relation->rd_att->attrs[i]->atttypid != VARCHAROID)
- tdesc->attrs[i] = relation->rd_att->attrs[i];
- else
- {
- tdesc->attrs[i] = palloc(sizeof(FormData_pg_attribute));
- memcpy(tdesc->attrs[i], relation->rd_att->attrs[i],
- sizeof(FormData_pg_attribute));
- tdesc->attrs[i]->attlen = -1;
- }
- }
- }
return relation;
}
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index b4716cc2bb..ecfc4d9a95 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -26,7 +26,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.38 1998/01/14 15:48:09 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.39 1998/01/16 23:19:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -563,13 +563,8 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate)
*/
tupdesc = CreateTupleDescCopy(tupType);
- /* fixup to prevent zero-length columns in create */
- setVarAttrLenForCreateTable(tupdesc, targetList, rangeTable);
-
intoRelationId = heap_create_with_catalog(intoName, tupdesc);
-#ifdef NOT_USED /* it's copy ... */
- resetVarAttrLenForCreateTable(tupdesc);
-#endif
+
FreeTupleDesc(tupdesc);
/* ----------------
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c
index 75f44e865e..8d93ecf9cc 100644
--- a/src/backend/executor/execUtils.c
+++ b/src/backend/executor/execUtils.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.23 1998/01/07 21:02:50 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.24 1998/01/16 23:19:52 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1177,76 +1177,3 @@ ExecInsertIndexTuples(TupleTableSlot *slot,
if (econtext != NULL)
pfree(econtext);
}
-
-/* ----------------------------------------------------------------
- * setVarAttrLenForCreateTable -
- * called when we do a SELECT * INTO TABLE tab
- * needed for attributes that have a defined length, like bpchar and
- * varchar
- * ----------------------------------------------------------------
- */
-void
-setVarAttrLenForCreateTable(TupleDesc tupType, List *targetList,
- List *rangeTable)
-{
- List *tl;
- TargetEntry *tle;
- Node *expr;
- int varno;
-
- tl = targetList;
-
- for (varno = 0; varno < tupType->natts; varno++)
- {
- tle = lfirst(tl);
-
- if (tupType->attrs[varno]->atttypid == BPCHAROID ||
- tupType->attrs[varno]->atttypid == VARCHAROID)
- {
- expr = tle->expr;
- if (expr && IsA(expr, Var))
- {
- Var *var;
- RangeTblEntry *rtentry;
- Relation rd;
-
- var = (Var *) expr;
- rtentry = rt_fetch(var->varnoold, rangeTable);
- rd = heap_open(rtentry->relid);
- /* set length to that defined in relation */
- tupType->attrs[varno]->attlen =
- (*rd->rd_att->attrs[var->varoattno - 1]).attlen;
- heap_close(rd);
- }
- else
- elog(ERROR, "setVarAttrLenForCreateTable: can't get length for variable-length field");
- }
- tl = lnext(tl);
- }
-}
-
-
-#ifdef NOT_USED /* look at execMain.c */
-/* ----------------------------------------------------------------
- * resetVarAttrLenForCreateTable -
- * called when we do a SELECT * INTO TABLE tab
- * needed for attributes that have a defined length, like bpchar and
- * varchar
- * resets length to -1 for those types
- * ----------------------------------------------------------------
- */
-void
-resetVarAttrLenForCreateTable(TupleDesc tupType)
-{
- int varno;
-
- for (varno = 0; varno < tupType->natts; varno++)
- {
- if (tupType->attrs[varno]->atttypid == BPCHAROID ||
- tupType->attrs[varno]->atttypid == VARCHAROID)
- /* set length to original -1 */
- tupType->attrs[varno]->attlen = -1;
- }
-}
-
-#endif
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index e0ccc63f35..fe04553922 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.30 1998/01/15 18:59:20 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.31 1998/01/16 23:19:56 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1480,8 +1480,8 @@ _copyTypeName(TypeName *from)
newnode->name = pstrdup(from->name);
newnode->timezone = from->timezone;
newnode->setof = from->setof;
+ newnode->typmod = from->typmod;
Node_Copy(from, newnode, arrayBounds);
- newnode->typlen = from->typlen;
return newnode;
}
diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c
index ba4b27f822..41f3022c13 100644
--- a/src/backend/nodes/outfuncs.c
+++ b/src/backend/nodes/outfuncs.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.21 1998/01/15 18:59:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.22 1998/01/16 23:19:59 momjian Exp $
*
* NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which
@@ -137,11 +137,11 @@ _outTypeName(StringInfo str, TypeName *node)
appendStringInfo(str, (node->timezone ? "true" : "false"));
appendStringInfo(str, " :setof ");
appendStringInfo(str, (node->setof ? "true" : "false"));
+ appendStringInfo(str, " :typmod ");
+ sprintf(buf," %d ", node->typmod);
+ appendStringInfo(str, buf);
appendStringInfo(str, " :arrayBounds ");
_outNode(str, node->arrayBounds);
- appendStringInfo(str, " :typlen ");
- sprintf(buf," %d ", node->typlen);
- appendStringInfo(str, buf);
}
static void
diff --git a/src/backend/optimizer/prep/preptlist.c b/src/backend/optimizer/prep/preptlist.c
index faf281985e..e92fbb3332 100644
--- a/src/backend/optimizer/prep/preptlist.c
+++ b/src/backend/optimizer/prep/preptlist.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.6 1997/11/25 22:00:06 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.7 1998/01/16 23:20:09 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -278,13 +278,9 @@ new_relation_targetlist(Oid relid, Index rt_index, NodeTag node_type)
*/
attisset = get_attisset( /* type_id, */ relid, attname);
if (attisset)
- {
typlen = typeLen(typeidType(OIDOID));
- }
else
- {
typlen = get_typlen(atttype);
- }
switch (node_type)
{
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index d2ed0d2633..77a2e0b7c2 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.90 1998/01/11 20:01:59 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 1.91 1998/01/16 23:20:14 momjian Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -2754,7 +2754,7 @@ Character: character '(' Iconst ')'
* between this and "text" is that we blank-pad and
* truncate where necessary
*/
- $$->typlen = VARHDRSZ + $3;
+ $$->typmod = VARHDRSZ + $3;
}
| character
{
diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c
index c17c3e9d48..00efc044dc 100644
--- a/src/backend/parser/parse_expr.c
+++ b/src/backend/parser/parse_expr.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.6 1998/01/05 03:32:27 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.7 1998/01/16 23:20:18 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -30,7 +30,7 @@
#include "parser/parse_target.h"
#include "utils/builtins.h"
-static Node *parser_typecast(Value *expr, TypeName *typename, int typlen);
+static Node *parser_typecast(Value *expr, TypeName *typename, int atttypmod);
/*
* transformExpr -
@@ -403,7 +403,7 @@ handleNestedDots(ParseState *pstate, Attr *attr, int *curr_resno, int precedence
}
static Node *
-parser_typecast(Value *expr, TypeName *typename, int typlen)
+parser_typecast(Value *expr, TypeName *typename, int atttypmod)
{
/* check for passing non-ints */
Const *adt;
@@ -492,7 +492,7 @@ parser_typecast(Value *expr, TypeName *typename, int typlen)
}
#endif
- cp = stringTypeString(tp, const_string, typlen);
+ cp = stringTypeString(tp, const_string, atttypmod);
if (!typeByVal(tp))
{
@@ -540,7 +540,7 @@ parser_typecast(Value *expr, TypeName *typename, int typlen)
}
Node *
-parser_typecast2(Node *expr, Oid exprType, Type tp, int typlen)
+parser_typecast2(Node *expr, Oid exprType, Type tp, int atttypmod)
{
/* check for passing non-ints */
Const *adt;
@@ -627,8 +627,7 @@ parser_typecast2(Node *expr, Oid exprType, Type tp, int typlen)
return ((Node *) adt);
}
- cp = stringTypeString(tp, const_string, typlen);
-
+ cp = stringTypeString(tp, const_string, atttypmod);
if (!typeByVal(tp))
{
diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c
index 66961ca79a..253fed7ced 100644
--- a/src/backend/parser/parse_oper.c
+++ b/src/backend/parser/parse_oper.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.6 1998/01/15 20:54:28 scrappy Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.7 1998/01/16 23:20:20 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -401,9 +401,9 @@ unary_oper_get_candidates(char *op,
*candidates = NULL;
- fmgr_info(NameEqualRegProcedure, (func_ptr *) &opKey[0].sk_func);
+ fmgr_info(NameEqualRegProcedure, (FmgrInfo *) &opKey[0].sk_func);
opKey[0].sk_argument = NameGetDatum(op);
- fmgr_info(CharacterEqualRegProcedure, (func_ptr *) &opKey[1].sk_func);
+ fmgr_info(CharacterEqualRegProcedure, (FmgrInfo *) &opKey[1].sk_func);
opKey[1].sk_argument = CharGetDatum(rightleft);
/* currently, only "unknown" can be coerced */
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index dc5a11a8df..692b1eb116 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.5 1998/01/05 03:32:30 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.6 1998/01/16 23:20:21 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -430,10 +430,15 @@ checkTargetTypes(ParseState *pstate, char *target_colname,
elog(ERROR, "Type of %s does not match target column %s",
colname, target_colname);
- if ((attrtype_id == BPCHAROID || attrtype_id == VARCHAROID) &&
- rd->rd_att->attrs[resdomno_id - 1]->attlen !=
- pstate->p_target_relation->rd_att->attrs[resdomno_target - 1]->attlen)
- elog(ERROR, "Length of %s does not match length of target column %s",
+ if (attrtype_id == BPCHAROID &&
+ rd->rd_att->attrs[resdomno_id - 1]->atttypmod !=
+ pstate->p_target_relation->rd_att->attrs[resdomno_target - 1]->atttypmod)
+ elog(ERROR, "Length of %s is longer than length of target column %s",
+ colname, target_colname);
+ if (attrtype_id == VARCHAROID &&
+ rd->rd_att->attrs[resdomno_id - 1]->atttypmod >
+ pstate->p_target_relation->rd_att->attrs[resdomno_target - 1]->atttypmod)
+ elog(ERROR, "Length of %s is longer than length of target column %s",
colname, target_colname);
heap_close(rd);
diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c
index eccdbda6b4..895411aa1d 100644
--- a/src/backend/parser/parse_target.c
+++ b/src/backend/parser/parse_target.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.5 1998/01/05 03:32:31 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.6 1998/01/16 23:20:22 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -326,7 +326,8 @@ make_targetlist_expr(ParseState *pstate,
Oid type_id,
attrtype;
int type_len,
- attrlen;
+ attrlen,
+ attrtypmod;
int resdomno;
Relation rd;
bool attrisset;
@@ -360,14 +361,8 @@ make_targetlist_expr(ParseState *pstate,
attrtype = attnumTypeId(rd, resdomno);
if ((arrayRef != NIL) && (lfirst(arrayRef) == NIL))
attrtype = GetArrayElementType(attrtype);
- if (attrtype == BPCHAROID || attrtype == VARCHAROID)
- {
- attrlen = rd->rd_att->attrs[resdomno - 1]->attlen;
- }
- else
- {
- attrlen = typeLen(typeidType(attrtype));
- }
+ attrlen = typeLen(typeidType(attrtype));
+ attrtypmod = rd->rd_att->attrs[resdomno - 1]->atttypmod;
#if 0
if (Input_is_string && Typecast_ok)
{
@@ -438,13 +433,13 @@ make_targetlist_expr(ParseState *pstate,
expr = (Node *) parser_typecast2(expr,
type_id,
typeidType(typelem),
- attrlen);
+ attrtypmod);
}
else
expr = (Node *) parser_typecast2(expr,
type_id,
typeidType(attrtype),
- attrlen);
+ attrtypmod);
}
else
{
diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c
index ef238f9fd0..4562623808 100644
--- a/src/backend/parser/parse_type.c
+++ b/src/backend/parser/parse_type.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.3 1998/01/05 03:32:33 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.4 1998/01/16 23:20:23 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -136,15 +136,14 @@ typeTypeFlag(Type t)
/* Given a type structure and a string, returns the internal form of
that string */
char *
-stringTypeString(Type tp, char *string, int typlen)
+stringTypeString(Type tp, char *string, int atttypmod)
{
Oid op;
Oid typelem;
op = ((TypeTupleForm) GETSTRUCT(tp))->typinput;
typelem = ((TypeTupleForm) GETSTRUCT(tp))->typelem; /* XXX - used for array_in */
- /* typlen is for bpcharin() and varcharin() */
- return ((char *) fmgr(op, string, typelem, typlen));
+ return ((char *) fmgr(op, string, typelem, atttypmod));
}
/* Given a type id, returns the out-conversion function of the type */
diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c
index 2aaf0a58b8..cb17194e25 100644
--- a/src/backend/utils/adt/varchar.c
+++ b/src/backend/utils/adt/varchar.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.23 1998/01/08 06:18:18 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.24 1998/01/16 23:20:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -50,7 +50,7 @@
* because we pass typelem as the second argument for array_in.)
*/
char *
-bpcharin(char *s, int dummy, int typlen)
+bpcharin(char *s, int dummy, int atttypmod)
{
char *result,
*r;
@@ -60,23 +60,23 @@ bpcharin(char *s, int dummy, int typlen)
if (s == NULL)
return ((char *) NULL);
- if (typlen == -1)
+ if (atttypmod == -1)
{
/*
- * this is here because some functions can't supply the typlen
+ * this is here because some functions can't supply the atttypmod
*/
len = strlen(s);
- typlen = len + VARHDRSZ;
+ atttypmod = len + VARHDRSZ;
}
else
- len = typlen - VARHDRSZ;
+ len = atttypmod - VARHDRSZ;
if (len > 4096)
elog(ERROR, "bpcharin: length of char() must be less than 4096");
- result = (char *) palloc(typlen);
- VARSIZE(result) = typlen;
+ result = (char *) palloc(atttypmod);
+ VARSIZE(result) = atttypmod;
r = VARDATA(result);
for (i = 0; i < len; i++, r++, s++)
{
@@ -124,7 +124,7 @@ bpcharout(char *s)
* because we pass typelem as the second argument for array_in.)
*/
char *
-varcharin(char *s, int dummy, int typlen)
+varcharin(char *s, int dummy, int atttypmod)
{
char *result;
int len;
@@ -133,8 +133,8 @@ varcharin(char *s, int dummy, int typlen)
return ((char *) NULL);
len = strlen(s) + VARHDRSZ;
- if (typlen != -1 && len > typlen)
- len = typlen; /* clip the string at max length */
+ if (atttypmod != -1 && len > atttypmod)
+ len = atttypmod; /* clip the string at max length */
if (len > 4096)
elog(ERROR, "varcharin: length of char() must be less than 4096");