mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Fix the problem that creating a user-defined type named _foo, followed by one
named foo, would work but the other ordering would not. If a user-specified type or table name collides with an existing auto-generated array name, just rename the array type out of the way by prepending more underscores. This should not create any backward-compatibility issues, since the cases in which this will happen would have failed outright in prior releases. Also fix an oversight in the arrays-of-composites patch: ALTER TABLE RENAME renamed the table's rowtype but not its array type.
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$PostgreSQL: pgsql/doc/src/sgml/ref/create_type.sgml,v 1.70 2007/05/11 17:57:11 tgl Exp $
|
||||
$PostgreSQL: pgsql/doc/src/sgml/ref/create_type.sgml,v 1.71 2007/05/12 00:54:59 tgl Exp $
|
||||
PostgreSQL documentation
|
||||
-->
|
||||
|
||||
@ -529,18 +529,6 @@ CREATE TYPE <replaceable class="parameter">name</replaceable>
|
||||
<refsect1 id="SQL-CREATETYPE-notes">
|
||||
<title>Notes</title>
|
||||
|
||||
<para>
|
||||
It is best to avoid using type names that begin with the underscore
|
||||
character (<literal>_</literal>). <productname>PostgreSQL</productname>
|
||||
forms the name of an array type by prepending one or more underscores
|
||||
to the element type's name, and these names may collide with user-defined
|
||||
type names that begin with underscore. While the system will modify
|
||||
generated array type names to avoid collisions, this does not help if the
|
||||
conflicting array type already exists when you try to create your type.
|
||||
Also, various old client software may assume that names beginning with
|
||||
underscores always represent arrays.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Because there are no restrictions on use of a data type once it's been
|
||||
created, creating a base type is tantamount to granting public execute
|
||||
@ -552,6 +540,27 @@ CREATE TYPE <replaceable class="parameter">name</replaceable>
|
||||
while converting it to or from external form.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Before <productname>PostgreSQL</productname> version 8.3, the name of
|
||||
a generated array type was always exactly the element type's name with one
|
||||
underscore character (<literal>_</literal>) prepended. (Type names were
|
||||
therefore restricted in length to one less character than other names.)
|
||||
While this is still usually the case, the array type name may vary from
|
||||
this in case of maximum-length names or collisions with user type names
|
||||
that begin with underscore. Writing code that depends on this convention
|
||||
is therefore deprecated. Instead, use
|
||||
<structname>pg_type</>.<structfield>typarray</> to locate the array type
|
||||
associated with a given type.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
It may be advisable to avoid using type and table names that begin with
|
||||
underscore. While the server will change generated array type names to
|
||||
avoid collisions with user-given names, there is still risk of confusion,
|
||||
particularly with old client software that may assume that type names
|
||||
beginning with underscores always represent arrays.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Before <productname>PostgreSQL</productname> version 8.2, the syntax
|
||||
<literal>CREATE TYPE <replaceable>name</></literal> did not exist.
|
||||
|
Reference in New Issue
Block a user