Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfd61fbe

Browse files
committed
For some reason, CREATE TYPE has only accepted alignment specifications
of 'int4' and 'double'. Add 'char' and 'int2' to allow user-defined typesto access the full set of supported alignments.
1 parent8f0ee46 commitfd61fbe

File tree

3 files changed

+27
-14
lines changed

3 files changed

+27
-14
lines changed

‎doc/src/sgml/ref/create_type.sgml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_type.sgml,v 1.19 2001/03/24 02:35:25 thomas Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_type.sgml,v 1.20 2001/08/03 20:47:40 tgl Exp $
33
Postgres documentation
44
-->
55

@@ -153,7 +153,8 @@ CREATE TYPE <replaceable class="parameter">typename</replaceable> ( INPUT = <rep
153153
<listitem>
154154
<para>
155155
Storage alignment requirement of the data type. If specified, must
156-
be '<literal>int4</literal>' or '<literal>double</literal>';
156+
be '<literal>char</literal>', '<literal>int2</literal>',
157+
'<literal>int4</literal>', or '<literal>double</literal>';
157158
the default is '<literal>int4</literal>'.
158159
</para>
159160
</listitem>

‎src/backend/commands/define.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.57 2001/06/21 18:25:54 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.58 2001/08/03 20:47:40 tgl Exp $
1414
*
1515
* DESCRIPTION
1616
* The "DefineFoo" routines take the parse tree and pick out the
@@ -547,7 +547,7 @@ DefineType(char *typeName, List *parameters)
547547
chardelimiter=DEFAULT_TYPDELIM;
548548
char*shadow_type;
549549
List*pl;
550-
charalignment='i';/* default alignment */
550+
charalignment='i';/* default alignment */
551551
charstorage='p';/* default storage in TOAST */
552552

553553
/*
@@ -593,15 +593,26 @@ DefineType(char *typeName, List *parameters)
593593
{
594594
char*a=defGetString(defel);
595595

596+
/*
597+
* Note: if argument was an unquoted identifier, parser will have
598+
* applied xlateSqlType() to it, so be prepared to recognize
599+
* translated type names as well as the nominal form.
600+
*/
596601
if (strcasecmp(a,"double")==0)
597602
alignment='d';
603+
elseif (strcasecmp(a,"float8")==0)
604+
alignment='d';
598605
elseif (strcasecmp(a,"int4")==0)
599606
alignment='i';
607+
elseif (strcasecmp(a,"int2")==0)
608+
alignment='s';
609+
elseif (strcasecmp(a,"char")==0)
610+
alignment='c';
611+
elseif (strcasecmp(a,"bpchar")==0)
612+
alignment='c';
600613
else
601-
{
602614
elog(ERROR,"DefineType: \"%s\" alignment not recognized",
603615
a);
604-
}
605616
}
606617
elseif (strcasecmp(defel->defname,"storage")==0)
607618
{
@@ -616,10 +627,8 @@ DefineType(char *typeName, List *parameters)
616627
elseif (strcasecmp(a,"main")==0)
617628
storage='m';
618629
else
619-
{
620630
elog(ERROR,"DefineType: \"%s\" storage not recognized",
621631
a);
622-
}
623632
}
624633
else
625634
{

‎src/bin/pg_dump/pg_dump.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
*
2424
* IDENTIFICATION
25-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.217 2001/08/0319:43:05 tgl Exp $
25+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.218 2001/08/0320:47:40 tgl Exp $
2626
*
2727
* Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb
2828
*
@@ -3190,19 +3190,22 @@ dumpTypes(Archive *fout, FuncInfo *finfo, int numFuncs,
31903190
(*deps)[depIdx++]=strdup(tinfo[i].typelem);
31913191
}
31923192

3193-
/* XXX these are all the aligns currently handled by DefineType */
3194-
if (strcmp(tinfo[i].typalign,"i")==0)
3193+
if (strcmp(tinfo[i].typalign,"c")==0)
3194+
appendPQExpBuffer(q,", alignment = char");
3195+
elseif (strcmp(tinfo[i].typalign,"s")==0)
3196+
appendPQExpBuffer(q,", alignment = int2");
3197+
elseif (strcmp(tinfo[i].typalign,"i")==0)
31953198
appendPQExpBuffer(q,", alignment = int4");
31963199
elseif (strcmp(tinfo[i].typalign,"d")==0)
31973200
appendPQExpBuffer(q,", alignment = double");
31983201

31993202
if (strcmp(tinfo[i].typstorage,"p")==0)
32003203
appendPQExpBuffer(q,", storage = plain");
3201-
if (strcmp(tinfo[i].typstorage,"e")==0)
3204+
elseif (strcmp(tinfo[i].typstorage,"e")==0)
32023205
appendPQExpBuffer(q,", storage = external");
3203-
if (strcmp(tinfo[i].typstorage,"x")==0)
3206+
elseif (strcmp(tinfo[i].typstorage,"x")==0)
32043207
appendPQExpBuffer(q,", storage = extended");
3205-
if (strcmp(tinfo[i].typstorage,"m")==0)
3208+
elseif (strcmp(tinfo[i].typstorage,"m")==0)
32063209
appendPQExpBuffer(q,", storage = main");
32073210

32083211
if (tinfo[i].passedbyvalue)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp