summaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_relation.c
diff options
context:
space:
mode:
authorThomas G. Lockhart <lockhart@fourpalms.org>1998-07-08 14:04:11 +0000
committerThomas G. Lockhart <lockhart@fourpalms.org>1998-07-08 14:04:11 +0000
commit92ed9294de6f12ca22f7111a1c8eaec20c863620 (patch)
treee0a7c4c4d08d71e4cb058f5a065a68ec20dd9a7e /src/backend/parser/parse_relation.c
parentfa838876e9f0be3612d06b1170e9931edaa5d833 (diff)
Allow floating point constants for "def_arg" numeric arguments.
Used in the generic "CREATE xxx" parsing. Do some automatic type conversion for inserts from other columns. Previous trouble with "resjunk" regression test remains for now.
Diffstat (limited to 'src/backend/parser/parse_relation.c')
-rw-r--r--src/backend/parser/parse_relation.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 6bd26066b23..fef834d2c6d 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.11 1998/02/26 04:33:34 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.12 1998/07/08 14:04:11 thomas Exp $
*
*-------------------------------------------------------------------------
*/
@@ -20,6 +20,7 @@
#include "catalog/pg_type.h"
#include "nodes/makefuncs.h"
#include "parser/parse_relation.h"
+#include "parser/parse_coerce.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
@@ -371,9 +372,8 @@ attnumTypeId(Relation rd, int attid)
return (rd->rd_att->attrs[attid - 1]->atttypid);
}
-/*
- * handleTargetColname -
- * use column names from insert
+/* handleTargetColname()
+ * Use column names from insert.
*/
void
handleTargetColname(ParseState *pstate, char **resname,
@@ -395,9 +395,8 @@ handleTargetColname(ParseState *pstate, char **resname,
checkTargetTypes(pstate, *resname, refname, colname);
}
-/*
- * checkTargetTypes -
- * checks value and target column types
+/* checkTargetTypes()
+ * Checks value and target column types.
*/
static void
checkTargetTypes(ParseState *pstate, char *target_colname,
@@ -432,6 +431,27 @@ checkTargetTypes(ParseState *pstate, char *target_colname,
resdomno_target = attnameAttNum(pstate->p_target_relation, target_colname);
attrtype_target = attnumTypeId(pstate->p_target_relation, resdomno_target);
+#if FALSE
+ if ((attrtype_id != attrtype_target)
+ || (get_atttypmod(rte->relid, resdomno_id) !=
+ get_atttypmod(pstate->p_target_relation->rd_id, resdomno_target)))
+ {
+ if (can_coerce_type(1, &attrtype_id, &attrtype_target))
+ {
+ Node *expr = coerce_type(pstate, expr, attrtype_id, attrtype_target);
+
+ elog(ERROR, "Type %s(%d) can be coerced to match target column %s(%d)",
+ colname, get_atttypmod(rte->relid, resdomno_id),
+ target_colname, get_atttypmod(pstate->p_target_relation->rd_id, resdomno_target));
+ }
+ else
+ {
+ elog(ERROR, "Type or size of %s(%d) does not match target column %s(%d)",
+ colname, get_atttypmod(rte->relid, resdomno_id),
+ target_colname, get_atttypmod(pstate->p_target_relation->rd_id, resdomno_target));
+ }
+ }
+#else
if (attrtype_id != attrtype_target)
elog(ERROR, "Type of %s does not match target column %s",
colname, target_colname);
@@ -446,5 +466,5 @@ checkTargetTypes(ParseState *pstate, char *target_colname,
get_atttypmod(pstate->p_target_relation->rd_id, resdomno_target))
elog(ERROR, "Length of %s is longer than length of target column %s",
colname, target_colname);
-
+#endif
}