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

Commitaaf11b9

Browse files
committed
Back out to_char fixes until regression tests are fixed.
1 parent05f916e commitaaf11b9

File tree

1 file changed

+38
-53
lines changed

1 file changed

+38
-53
lines changed

‎src/backend/utils/adt/formatting.c

Lines changed: 38 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* -----------------------------------------------------------------------
22
* formatting.c
33
*
4-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.59 2003/03/20 05:19:26 momjian Exp $
4+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.60 2003/03/22 02:12:24 momjian Exp $
55
*
66
*
77
* Portions Copyright (c) 1999-2002, PostgreSQL Global Development Group
@@ -276,19 +276,17 @@ typedef struct
276276
* Flags for NUMBER version
277277
* ----------
278278
*/
279-
#defineNUM_F_DECIMAL1 << 1
280-
#defineNUM_F_LDECIMAL1 << 2
281-
#defineNUM_F_ZERO1 << 3
282-
#defineNUM_F_BLANK 1 << 4
283-
#defineNUM_F_FILLMODE1 << 5
284-
#defineNUM_F_LSIGN 1 << 6
285-
#defineNUM_F_BRACKET1 << 7
286-
#defineNUM_F_MINUS 1 << 8
287-
#defineNUM_F_PLUS1 << 9
288-
#defineNUM_F_ROMAN 1 << 10
289-
#defineNUM_F_MULTI1 << 11
290-
#defineNUM_F_PLUS_POST 1 << 12
291-
#defineNUM_F_MINUS_POST1 << 13
279+
#defineNUM_F_DECIMAL0x01
280+
#defineNUM_F_LDECIMAL0x02
281+
#defineNUM_F_ZERO0x04
282+
#defineNUM_F_BLANK 0x08
283+
#defineNUM_F_FILLMODE0x10
284+
#defineNUM_F_LSIGN 0x20
285+
#defineNUM_F_BRACKET0x40
286+
#defineNUM_F_MINUS 0x80
287+
#defineNUM_F_PLUS0x100
288+
#defineNUM_F_ROMAN 0x200
289+
#defineNUM_F_MULTI 0x400
292290

293291
#defineNUM_LSIGN_PRE-1
294292
#defineNUM_LSIGN_POST1
@@ -1054,8 +1052,6 @@ NUMDesc_prepare(NUMDesc *num, FormatNode *n)
10541052
elog(ERROR,"to_char/to_number(): can't use 'S' and 'MI' together.");
10551053
}
10561054
num->flag |=NUM_F_MINUS;
1057-
if (IS_DECIMAL(num))
1058-
num->flag |=NUM_F_MINUS_POST;
10591055
break;
10601056

10611057
caseNUM_PL:
@@ -1065,8 +1061,6 @@ NUMDesc_prepare(NUMDesc *num, FormatNode *n)
10651061
elog(ERROR,"to_char/to_number(): can't use 'S' and 'PL' together.");
10661062
}
10671063
num->flag |=NUM_F_PLUS;
1068-
if (IS_DECIMAL(num))
1069-
num->flag |=NUM_F_PLUS_POST;
10701064
break;
10711065

10721066
caseNUM_SG:
@@ -3886,36 +3880,28 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
38863880
else
38873881
{
38883882
Np->sign=sign;
3889-
3890-
/* MI/PL/SG - write sign itself and not in number */
3891-
if (IS_PLUS(Np->Num)||IS_MINUS(Np->Num))
3883+
3884+
if (Np->sign!='-')
38923885
{
3893-
if (IS_PLUS(Np->Num)&&IS_MINUS(Np->Num)==FALSE)
3894-
Np->sign_wrote= FALSE;
3895-
Np->sign_pos=-1;
3886+
Np->Num->flag &= ~NUM_F_BRACKET;
3887+
Np->Num->flag &= ~NUM_F_MINUS;
38963888
}
3889+
elseif (Np->sign!='+')
3890+
Np->Num->flag &= ~NUM_F_PLUS;
3891+
3892+
if (Np->sign=='+'&&IS_FILLMODE(Np->Num)&& !IS_LSIGN(Np->Num))
3893+
Np->sign_wrote= TRUE;/* needn't sign */
38973894
else
3898-
{
3899-
if (Np->sign!='-')
3900-
{
3901-
if (IS_BRACKET(Np->Num))
3902-
Np->Num->flag &= ~NUM_F_BRACKET;
3903-
if (IS_MINUS(Np->Num))
3904-
Np->Num->flag &= ~NUM_F_MINUS;
3905-
}
3906-
elseif (Np->sign!='+'&&IS_PLUS(Np->Num))
3907-
Np->Num->flag &= ~NUM_F_PLUS;
3895+
Np->sign_wrote= FALSE;/* need sign */
39083896

3909-
if (Np->sign=='+'&&IS_FILLMODE(Np->Num)&& !IS_LSIGN(Np->Num))
3910-
Np->sign_wrote= TRUE;/* needn't sign */
3911-
else
3912-
Np->sign_wrote= FALSE;/* need sign */
3897+
Np->sign_pos=-1;
39133898

3914-
Np->sign_pos=-1;
3899+
if (Np->Num->lsign==NUM_LSIGN_PRE&&Np->Num->pre==Np->Num->pre_lsign_num)
3900+
Np->Num->lsign=NUM_LSIGN_POST;
39153901

3916-
if (Np->Num->lsign==NUM_LSIGN_PRE&&Np->Num->pre==Np->Num->pre_lsign_num)
3917-
Np->Num->lsign=NUM_LSIGN_POST;
3918-
}
3902+
/* MI/PL/SG - write sign itself and not in number */
3903+
if (IS_PLUS(Np->Num)||IS_MINUS(Np->Num))
3904+
Np->sign_wrote= TRUE;/* needn't sign */
39193905
}
39203906

39213907
/*
@@ -3931,7 +3917,7 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
39313917
{
39323918
if (IS_DECIMAL(Np->Num))
39333919
Np->last_relevant=get_last_relevant_decnum(
3934-
Np->number+
3920+
Np->number+
39353921
((Np->Num->zero_end-Np->num_pre>0) ?
39363922
Np->Num->zero_end-Np->num_pre :0));
39373923
}
@@ -3960,15 +3946,17 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
39603946
/*
39613947
* terrible Ora format
39623948
*/
3963-
if (IS_ZERO(Np->Num)==FALSE&&*Np->number=='0'&&
3964-
IS_FILLMODE(Np->Num)==FALSE&&Np->Num->post)
3949+
if (!IS_ZERO(Np->Num)&&*Np->number=='0'&&
3950+
!IS_FILLMODE(Np->Num)&&Np->Num->post!=0)
39653951
{
39663952

39673953
++Np->sign_pos;
39683954

39693955
if (IS_LSIGN(Np->Num))
39703956
{
3971-
if (Np->Num->lsign!=NUM_LSIGN_PRE)
3957+
if (Np->Num->lsign==NUM_LSIGN_PRE)
3958+
++Np->sign_pos;
3959+
else
39723960
--Np->sign_pos;
39733961
}
39743962
}
@@ -3987,8 +3975,8 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
39873975

39883976
#ifdefDEBUG_TO_FROM_CHAR
39893977
elog(DEBUG_elog_output,
3990-
"\n\tSIGN: '%c'\n\tNUM: '%s'\n\tPRE: %d\n\tPOST: %d\n\tNUM_COUNT: %d\n\tNUM_PRE: %d\n\tSIGN_POS: %d\n\tSIGN_WROTE: %s\n\tZERO: %s\n\tZERO_START: %d\n\tZERO_END: %d\n\tLAST_RELEVANT: %s\n\tBRACKET: %s\n\tPLUS: %s\n\tMINUS: %s",
3991-
Np->sign,
3978+
3979+
"\n\tNUM: '%s'\n\tPRE: %d\n\tPOST: %d\n\tNUM_COUNT: %d\n\tNUM_PRE: %d\n\tSIGN_POS: %d\n\tSIGN_WROTE: %s\n\tZERO: %s\n\tZERO_START: %d\n\tZERO_END: %d\n\tLAST_RELEVANT: %s",
39923980
Np->number,
39933981
Np->Num->pre,
39943982
Np->Num->post,
@@ -3999,11 +3987,8 @@ NUM_processor(FormatNode *node, NUMDesc *Num, char *inout, char *number,
39993987
IS_ZERO(Np->Num) ?"Yes" :"No",
40003988
Np->Num->zero_start,
40013989
Np->Num->zero_end,
4002-
Np->last_relevant ?Np->last_relevant :"<not set>",
4003-
IS_BRACKET(Np->Num) ?"Yes" :"No",
4004-
IS_PLUS(Np->Num) ?"Yes" :"No",
4005-
IS_MINUS(Np->Num) ?"Yes" :"No"
4006-
);
3990+
Np->last_relevant ?Np->last_relevant :"<not set>"
3991+
);
40073992
#endif
40083993

40093994
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp