10
10
*
11
11
*
12
12
* IDENTIFICATION
13
- * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.58 2001/08/03 20:47:40 tgl Exp $
13
+ * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.59 2001/09/06 02:07:42 tgl Exp $
14
14
*
15
15
* DESCRIPTION
16
16
* The "DefineFoo" routines take the parse tree and pick out the
@@ -535,31 +535,29 @@ DefineAggregate(char *aggName, List *parameters)
535
535
void
536
536
DefineType (char * typeName , List * parameters )
537
537
{
538
- int16 internalLength = 0 ; /* int2 */
539
- int16 externalLength = 0 ; /* int2 */
538
+ int16 internalLength = -1 ; /* int2 */
539
+ int16 externalLength = -1 ; /* int2 */
540
540
char * elemName = NULL ;
541
541
char * inputName = NULL ;
542
542
char * outputName = NULL ;
543
543
char * sendName = NULL ;
544
544
char * receiveName = NULL ;
545
- char * defaultValue = NULL ; /* Datum */
545
+ char * defaultValue = NULL ;
546
546
bool byValue = false;
547
547
char delimiter = DEFAULT_TYPDELIM ;
548
548
char * shadow_type ;
549
549
List * pl ;
550
550
char alignment = 'i' ; /* default alignment */
551
- char storage = 'p' ; /* default storage in TOAST */
551
+ char storage = 'p' ; /* default TOAST storage method */
552
552
553
553
/*
554
554
* Type names must be one character shorter than other names, allowing
555
555
* room to create the corresponding array type name with prepended
556
556
* "_".
557
557
*/
558
558
if (strlen (typeName ) > (NAMEDATALEN - 2 ))
559
- {
560
559
elog (ERROR , "DefineType: type names must be %d characters or less" ,
561
560
NAMEDATALEN - 2 );
562
- }
563
561
564
562
foreach (pl , parameters )
565
563
{
@@ -645,9 +643,6 @@ DefineType(char *typeName, List *parameters)
645
643
if (outputName == NULL )
646
644
elog (ERROR , "Define: \"output\" unspecified" );
647
645
648
- if (internalLength != -1 && storage != 'p' )
649
- elog (ERROR , "Define: fixed size types must have storage PLAIN" );
650
-
651
646
/*
652
647
* now have TypeCreate do all the real work.
653
648
*/
@@ -674,6 +669,9 @@ DefineType(char *typeName, List *parameters)
674
669
*/
675
670
shadow_type = makeArrayTypeName (typeName );
676
671
672
+ /* alignment must be 'i' or 'd' for arrays */
673
+ alignment = (alignment == 'd' ) ? 'd' : 'i' ;
674
+
677
675
TypeCreate (shadow_type , /* type name */
678
676
InvalidOid , /* preassigned type oid (not done here) */
679
677
InvalidOid , /* relation oid (n/a here) */
@@ -688,7 +686,7 @@ DefineType(char *typeName, List *parameters)
688
686
typeName , /* element type name */
689
687
NULL , /* never a default type value */
690
688
false, /* never passed by value */
691
- alignment , /* NB: must be 'i' or 'd' for arrays... */
689
+ alignment , /* see above */
692
690
'x' ); /* ARRAY is always toastable */
693
691
694
692
pfree (shadow_type );
0 commit comments