agora inbox for [email protected]
help / color / mirror / Atom feedFrom: Alvaro Herrera <[email protected]>
Subject: [PATCH 6/6] Add comment and asserts to makeUniqueTypeName
Date: Fri, 29 Nov 2019 23:03:13 -0300
---
src/backend/catalog/pg_type.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c
index de0bb24649..7b871e7b0d 100644
--- a/src/backend/catalog/pg_type.c
+++ b/src/backend/catalog/pg_type.c
@@ -912,8 +912,14 @@ makeMultirangeTypeName(const char *rangeTypeName, Oid typeNamespace)
}
/*
- * makeUniqueTypeName: Prepend underscores as needed until we make a name that
- * doesn't collide with anything. Tries the original typeName if requested.
+ * makeUniqueTypeName
+ * Generate a unique name for a prospective new type
+ *
+ * Given a typeName of length namelen, produce a new name into dest (an output
+ * buffer allocated by caller, which must of length NAMEDATALEN) by prepending
+ * underscores, until a non-conflicting name results.
+ *
+ * If tryOriginalName, first try with zero underscores.
*
* Returns the number of underscores added.
*/
@@ -924,6 +930,9 @@ makeUniqueTypeName(char *dest, const char *typeName, size_t namelen, Oid typeNam
Relation pg_type_desc;
int i;
+ Assert(strlen(typeName) == namelen);
+ Assert(namelen < NAMEDATALEN);
+
pg_type_desc = table_open(TypeRelationId, AccessShareLock);
for (i = 0; i < NAMEDATALEN - 1; i++)
--
2.20.1
--+QahgC5+KEYLbs62--
view thread (2+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [PATCH 6/6] Add comment and asserts to makeUniqueTypeName
In-Reply-To: <no-message-id-210125@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox