aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2011-04-08 16:11:04 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2011-04-08 16:11:41 -0400
commitc5ff3ff49229e8fb7da0e46b463bfc9b12219078 (patch)
tree30704db0fc4f3059ae87f6ea6bfe0a95caf1ae8b /src
parentcba9cd419270a9b7f442877e21685ac0de5730b3 (diff)
downloadpostgresql-c5ff3ff49229e8fb7da0e46b463bfc9b12219078.tar.gz
postgresql-c5ff3ff49229e8fb7da0e46b463bfc9b12219078.zip
Avoid an unnecessary syscache lookup in parse_coerce.c.
All the other fields of the constant are being extracted from the syscache entry we already have, so handle collation similarly. (There don't seem to be any other uses for the new function at the moment.)
Diffstat (limited to 'src')
-rw-r--r--src/backend/parser/parse_coerce.c2
-rw-r--r--src/backend/parser/parse_type.c16
-rw-r--r--src/include/parser/parse_type.h1
3 files changed, 15 insertions, 4 deletions
diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c
index dd3e748c9f6..895c3ad9856 100644
--- a/src/backend/parser/parse_coerce.c
+++ b/src/backend/parser/parse_coerce.c
@@ -219,7 +219,7 @@ coerce_type(ParseState *pstate, Node *node,
newcon->consttype = baseTypeId;
newcon->consttypmod = inputTypeMod;
- newcon->constcollid = get_typcollation(newcon->consttype);
+ newcon->constcollid = typeTypeCollation(targetType);
newcon->constlen = typeLen(targetType);
newcon->constbyval = typeByVal(targetType);
newcon->constisnull = con->constisnull;
diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c
index f413593f602..ac62cbc8c33 100644
--- a/src/backend/parser/parse_type.c
+++ b/src/backend/parser/parse_type.c
@@ -528,7 +528,7 @@ typeLen(Type t)
return typ->typlen;
}
-/* given type (as type struct), return the value of its 'byval' attribute.*/
+/* given type (as type struct), return its 'byval' attribute */
bool
typeByVal(Type t)
{
@@ -538,7 +538,7 @@ typeByVal(Type t)
return typ->typbyval;
}
-/* given type (as type struct), return the name of type */
+/* given type (as type struct), return the type's name */
char *
typeTypeName(Type t)
{
@@ -549,16 +549,26 @@ typeTypeName(Type t)
return pstrdup(NameStr(typ->typname));
}
+/* given type (as type struct), return its 'typrelid' attribute */
Oid
typeTypeRelid(Type typ)
{
Form_pg_type typtup;
typtup = (Form_pg_type) GETSTRUCT(typ);
-
return typtup->typrelid;
}
+/* given type (as type struct), return its 'typcollation' attribute */
+Oid
+typeTypeCollation(Type typ)
+{
+ Form_pg_type typtup;
+
+ typtup = (Form_pg_type) GETSTRUCT(typ);
+ return typtup->typcollation;
+}
+
/*
* Given a type structure and a string, returns the internal representation
* of that string. The "string" can be NULL to perform conversion of a NULL
diff --git a/src/include/parser/parse_type.h b/src/include/parser/parse_type.h
index 92c9ecba4ac..509e3b7f11a 100644
--- a/src/include/parser/parse_type.h
+++ b/src/include/parser/parse_type.h
@@ -40,6 +40,7 @@ extern int16 typeLen(Type t);
extern bool typeByVal(Type t);
extern char *typeTypeName(Type t);
extern Oid typeTypeRelid(Type typ);
+extern Oid typeTypeCollation(Type typ);
extern Datum stringTypeDatum(Type tp, char *string, int32 atttypmod);
extern Oid typeidTypeRelid(Oid type_id);