mirror of
https://github.com/postgres/postgres.git
synced 2025-04-24 10:47:04 +03:00
For some reason, CREATE TYPE has only accepted alignment specifications
of 'int4' and 'double'. Add 'char' and 'int2' to allow user-defined types to access the full set of supported alignments.
This commit is contained in:
parent
8f0ee46dcb
commit
fd61fbe837
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_type.sgml,v 1.19 2001/03/24 02:35:25 thomas Exp $
|
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_type.sgml,v 1.20 2001/08/03 20:47:40 tgl Exp $
|
||||||
Postgres documentation
|
Postgres documentation
|
||||||
-->
|
-->
|
||||||
|
|
||||||
@ -153,7 +153,8 @@ CREATE TYPE <replaceable class="parameter">typename</replaceable> ( INPUT = <rep
|
|||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Storage alignment requirement of the data type. If specified, must
|
Storage alignment requirement of the data type. If specified, must
|
||||||
be '<literal>int4</literal>' or '<literal>double</literal>';
|
be '<literal>char</literal>', '<literal>int2</literal>',
|
||||||
|
'<literal>int4</literal>', or '<literal>double</literal>';
|
||||||
the default is '<literal>int4</literal>'.
|
the default is '<literal>int4</literal>'.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.57 2001/06/21 18:25:54 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.58 2001/08/03 20:47:40 tgl Exp $
|
||||||
*
|
*
|
||||||
* DESCRIPTION
|
* DESCRIPTION
|
||||||
* The "DefineFoo" routines take the parse tree and pick out the
|
* The "DefineFoo" routines take the parse tree and pick out the
|
||||||
@ -593,16 +593,27 @@ DefineType(char *typeName, List *parameters)
|
|||||||
{
|
{
|
||||||
char *a = defGetString(defel);
|
char *a = defGetString(defel);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Note: if argument was an unquoted identifier, parser will have
|
||||||
|
* applied xlateSqlType() to it, so be prepared to recognize
|
||||||
|
* translated type names as well as the nominal form.
|
||||||
|
*/
|
||||||
if (strcasecmp(a, "double") == 0)
|
if (strcasecmp(a, "double") == 0)
|
||||||
alignment = 'd';
|
alignment = 'd';
|
||||||
|
else if (strcasecmp(a, "float8") == 0)
|
||||||
|
alignment = 'd';
|
||||||
else if (strcasecmp(a, "int4") == 0)
|
else if (strcasecmp(a, "int4") == 0)
|
||||||
alignment = 'i';
|
alignment = 'i';
|
||||||
|
else if (strcasecmp(a, "int2") == 0)
|
||||||
|
alignment = 's';
|
||||||
|
else if (strcasecmp(a, "char") == 0)
|
||||||
|
alignment = 'c';
|
||||||
|
else if (strcasecmp(a, "bpchar") == 0)
|
||||||
|
alignment = 'c';
|
||||||
else
|
else
|
||||||
{
|
|
||||||
elog(ERROR, "DefineType: \"%s\" alignment not recognized",
|
elog(ERROR, "DefineType: \"%s\" alignment not recognized",
|
||||||
a);
|
a);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (strcasecmp(defel->defname, "storage") == 0)
|
else if (strcasecmp(defel->defname, "storage") == 0)
|
||||||
{
|
{
|
||||||
char *a = defGetString(defel);
|
char *a = defGetString(defel);
|
||||||
@ -616,11 +627,9 @@ DefineType(char *typeName, List *parameters)
|
|||||||
else if (strcasecmp(a, "main") == 0)
|
else if (strcasecmp(a, "main") == 0)
|
||||||
storage = 'm';
|
storage = 'm';
|
||||||
else
|
else
|
||||||
{
|
|
||||||
elog(ERROR, "DefineType: \"%s\" storage not recognized",
|
elog(ERROR, "DefineType: \"%s\" storage not recognized",
|
||||||
a);
|
a);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
elog(NOTICE, "DefineType: attribute \"%s\" not recognized",
|
elog(NOTICE, "DefineType: attribute \"%s\" not recognized",
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.217 2001/08/03 19:43:05 tgl Exp $
|
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.218 2001/08/03 20:47:40 tgl Exp $
|
||||||
*
|
*
|
||||||
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
|
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
|
||||||
*
|
*
|
||||||
@ -3190,19 +3190,22 @@ dumpTypes(Archive *fout, FuncInfo *finfo, int numFuncs,
|
|||||||
(*deps)[depIdx++] = strdup(tinfo[i].typelem);
|
(*deps)[depIdx++] = strdup(tinfo[i].typelem);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX these are all the aligns currently handled by DefineType */
|
if (strcmp(tinfo[i].typalign, "c") == 0)
|
||||||
if (strcmp(tinfo[i].typalign, "i") == 0)
|
appendPQExpBuffer(q, ", alignment = char");
|
||||||
|
else if (strcmp(tinfo[i].typalign, "s") == 0)
|
||||||
|
appendPQExpBuffer(q, ", alignment = int2");
|
||||||
|
else if (strcmp(tinfo[i].typalign, "i") == 0)
|
||||||
appendPQExpBuffer(q, ", alignment = int4");
|
appendPQExpBuffer(q, ", alignment = int4");
|
||||||
else if (strcmp(tinfo[i].typalign, "d") == 0)
|
else if (strcmp(tinfo[i].typalign, "d") == 0)
|
||||||
appendPQExpBuffer(q, ", alignment = double");
|
appendPQExpBuffer(q, ", alignment = double");
|
||||||
|
|
||||||
if (strcmp(tinfo[i].typstorage, "p") == 0)
|
if (strcmp(tinfo[i].typstorage, "p") == 0)
|
||||||
appendPQExpBuffer(q, ", storage = plain");
|
appendPQExpBuffer(q, ", storage = plain");
|
||||||
if (strcmp(tinfo[i].typstorage, "e") == 0)
|
else if (strcmp(tinfo[i].typstorage, "e") == 0)
|
||||||
appendPQExpBuffer(q, ", storage = external");
|
appendPQExpBuffer(q, ", storage = external");
|
||||||
if (strcmp(tinfo[i].typstorage, "x") == 0)
|
else if (strcmp(tinfo[i].typstorage, "x") == 0)
|
||||||
appendPQExpBuffer(q, ", storage = extended");
|
appendPQExpBuffer(q, ", storage = extended");
|
||||||
if (strcmp(tinfo[i].typstorage, "m") == 0)
|
else if (strcmp(tinfo[i].typstorage, "m") == 0)
|
||||||
appendPQExpBuffer(q, ", storage = main");
|
appendPQExpBuffer(q, ", storage = main");
|
||||||
|
|
||||||
if (tinfo[i].passedbyvalue)
|
if (tinfo[i].passedbyvalue)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user