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

Commitafca5d5

Browse files
author
Neil Conway
committed
Cleanup: move the 'Value' node into a separate file, rather than putting
it in the same file as the 'List' node.
1 parent7f5e12a commitafca5d5

File tree

7 files changed

+146
-128
lines changed

7 files changed

+146
-128
lines changed

‎src/backend/nodes/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Makefile for backend/nodes
55
#
66
# IDENTIFICATION
7-
# $PostgreSQL: pgsql/src/backend/nodes/Makefile,v 1.15 2003/11/29 19:51:49 pgsql Exp $
7+
# $PostgreSQL: pgsql/src/backend/nodes/Makefile,v 1.16 2004/01/07 18:43:36 neilc Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -14,7 +14,7 @@ include $(top_builddir)/src/Makefile.global
1414

1515
OBJS = nodeFuncs.o nodes.o list.o bitmapset.o\
1616
copyfuncs.o equalfuncs.o makefuncs.o\
17-
outfuncs.o readfuncs.o print.o read.o
17+
outfuncs.o readfuncs.o print.o read.o value.o
1818

1919
all: SUBSYS.o
2020

‎src/backend/nodes/list.c

Lines changed: 2 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,22 @@
11
/*-------------------------------------------------------------------------
22
*
33
* list.c
4-
*POSTGRESgeneric list package
4+
*implementation for PostgreSQLgeneric linked list package
55
*
66
*
77
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/nodes/list.c,v 1.55 2003/11/29 19:51:49 pgsql Exp $
13-
*
14-
* NOTES
15-
* XXX a few of the following functions are duplicated to handle
16-
* List of pointers and List of integers separately. Some day,
17-
* someone should unify them.- ay 11/2/94
18-
* This file needs cleanup.
19-
*
20-
* HISTORY
21-
* AUTHORDATEMAJOR EVENT
22-
* Andrew YuOct, 1994file creation
12+
* $PostgreSQL: pgsql/src/backend/nodes/list.c,v 1.56 2004/01/07 18:43:36 neilc Exp $
2313
*
2414
*-------------------------------------------------------------------------
2515
*/
2616
#include"postgres.h"
2717

2818
#include"nodes/parsenodes.h"
2919

30-
31-
/*
32-
*makeInteger
33-
*/
34-
Value*
35-
makeInteger(longi)
36-
{
37-
Value*v=makeNode(Value);
38-
39-
v->type=T_Integer;
40-
v->val.ival=i;
41-
returnv;
42-
}
43-
44-
/*
45-
*makeFloat
46-
*
47-
* Caller is responsible for passing a palloc'd string.
48-
*/
49-
Value*
50-
makeFloat(char*numericStr)
51-
{
52-
Value*v=makeNode(Value);
53-
54-
v->type=T_Float;
55-
v->val.str=numericStr;
56-
returnv;
57-
}
58-
59-
/*
60-
*makeString
61-
*
62-
* Caller is responsible for passing a palloc'd string.
63-
*/
64-
Value*
65-
makeString(char*str)
66-
{
67-
Value*v=makeNode(Value);
68-
69-
v->type=T_String;
70-
v->val.str=str;
71-
returnv;
72-
}
73-
74-
75-
/*
76-
*makeBitString
77-
*
78-
* Caller is responsible for passing a palloc'd string.
79-
*/
80-
Value*
81-
makeBitString(char*str)
82-
{
83-
Value*v=makeNode(Value);
84-
85-
v->type=T_BitString;
86-
v->val.str=str;
87-
returnv;
88-
}
89-
90-
9120
/*
9221
*lcons
9322
*

‎src/backend/nodes/value.c

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* value.c
4+
* implementation of Value nodes
5+
*
6+
*
7+
* Copyright (c) 2003, PostgreSQL Global Development Group
8+
*
9+
*
10+
* IDENTIFICATION
11+
* $PostgreSQL: pgsql/src/backend/nodes/value.c,v 1.1 2004/01/07 18:43:36 neilc Exp $
12+
*
13+
*-------------------------------------------------------------------------
14+
*/
15+
#include"postgres.h"
16+
17+
#include"nodes/parsenodes.h"
18+
19+
/*
20+
*makeInteger
21+
*/
22+
Value*
23+
makeInteger(longi)
24+
{
25+
Value*v=makeNode(Value);
26+
27+
v->type=T_Integer;
28+
v->val.ival=i;
29+
returnv;
30+
}
31+
32+
/*
33+
*makeFloat
34+
*
35+
* Caller is responsible for passing a palloc'd string.
36+
*/
37+
Value*
38+
makeFloat(char*numericStr)
39+
{
40+
Value*v=makeNode(Value);
41+
42+
v->type=T_Float;
43+
v->val.str=numericStr;
44+
returnv;
45+
}
46+
47+
/*
48+
*makeString
49+
*
50+
* Caller is responsible for passing a palloc'd string.
51+
*/
52+
Value*
53+
makeString(char*str)
54+
{
55+
Value*v=makeNode(Value);
56+
57+
v->type=T_String;
58+
v->val.str=str;
59+
returnv;
60+
}
61+
62+
/*
63+
*makeBitString
64+
*
65+
* Caller is responsible for passing a palloc'd string.
66+
*/
67+
Value*
68+
makeBitString(char*str)
69+
{
70+
Value*v=makeNode(Value);
71+
72+
v->type=T_BitString;
73+
v->val.str=str;
74+
returnv;
75+
}

‎src/include/nodes/nodes.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.149 2004/01/06 23:55:19 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.150 2004/01/07 18:43:36 neilc Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -175,16 +175,20 @@ typedef enum NodeTag
175175
T_AllocSetContext,
176176

177177
/*
178-
* TAGS FOR VALUE NODES (pg_list.h)
178+
* TAGS FOR VALUE NODES (value.h)
179179
*/
180180
T_Value=650,
181-
T_List,
182181
T_Integer,
183182
T_Float,
184183
T_String,
185184
T_BitString,
186185
T_Null,
187186

187+
/*
188+
* TAGS FOR LIST NODES (pg_list.h)
189+
*/
190+
T_List,
191+
188192
/*
189193
* TAGS FOR PARSE TREE NODES (parsenodes.h)
190194
*/

‎src/include/nodes/pg_list.h

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*-------------------------------------------------------------------------
22
*
33
* pg_list.h
4-
*POSTGRESgeneric list package
4+
*interface for PostgreSQLgeneric linked list package
55
*
66
*
77
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/nodes/pg_list.h,v 1.42 2003/11/29 22:41:06 pgsql Exp $
10+
* $PostgreSQL: pgsql/src/include/nodes/pg_list.h,v 1.43 2004/01/07 18:43:36 neilc Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -21,44 +21,6 @@
2121
* ----------------------------------------------------------------
2222
*/
2323

24-
/*----------------------
25-
*Value node
26-
*
27-
* The same Value struct is used for five node types: T_Integer,
28-
* T_Float, T_String, T_BitString, T_Null.
29-
*
30-
* Integral values are actually represented by a machine integer,
31-
* but both floats and strings are represented as strings.
32-
* Using T_Float as the node type simply indicates that
33-
* the contents of the string look like a valid numeric literal.
34-
*
35-
* (Before Postgres 7.0, we used a double to represent T_Float,
36-
* but that creates loss-of-precision problems when the value is
37-
* ultimately destined to be converted to NUMERIC.Since Value nodes
38-
* are only used in the parsing process, not for runtime data, it's
39-
* better to use the more general representation.)
40-
*
41-
* Note that an integer-looking string will get lexed as T_Float if
42-
* the value is too large to fit in a 'long'.
43-
*
44-
* Nulls, of course, don't need the value part at all.
45-
*----------------------
46-
*/
47-
typedefstructValue
48-
{
49-
NodeTagtype;/* tag appropriately (eg. T_String) */
50-
unionValUnion
51-
{
52-
longival;/* machine integer */
53-
char*str;/* string */
54-
}val;
55-
}Value;
56-
57-
#defineintVal(v)(((Value *)(v))->val.ival)
58-
#definefloatVal(v)atof(((Value *)(v))->val.str)
59-
#definestrVal(v)(((Value *)(v))->val.str)
60-
61-
6224
/*----------------------
6325
*List node
6426
*
@@ -150,15 +112,6 @@ typedef struct FastList
150112
#definemakeFastList1(fl,x1) \
151113
( (fl)->head = (fl)->tail = makeList1(x1) )
152114

153-
154-
/*
155-
* function prototypes in nodes/list.c
156-
*/
157-
externValue*makeInteger(longi);
158-
externValue*makeFloat(char*numericStr);
159-
externValue*makeString(char*str);
160-
externValue*makeBitString(char*str);
161-
162115
externList*lcons(void*datum,List*list);
163116
externList*lconsi(intdatum,List*list);
164117
externList*lconso(Oiddatum,List*list);

‎src/include/nodes/primnodes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
1111
* Portions Copyright (c) 1994, Regents of the University of California
1212
*
13-
* $PostgreSQL: pgsql/src/include/nodes/primnodes.h,v 1.93 2003/11/29 22:41:06 pgsql Exp $
13+
* $PostgreSQL: pgsql/src/include/nodes/primnodes.h,v 1.94 2004/01/07 18:43:36 neilc Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -19,6 +19,7 @@
1919

2020
#include"access/attnum.h"
2121
#include"nodes/pg_list.h"
22+
#include"nodes/value.h"
2223

2324

2425
/* ----------------------------------------------------------------

‎src/include/nodes/value.h

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*-------------------------------------------------------------------------
2+
*
3+
* value.h
4+
* interface for Value nodes
5+
*
6+
*
7+
* Copyright (c) 2003, PostgreSQL Global Development Group
8+
*
9+
* $PostgreSQL: pgsql/src/include/nodes/value.h,v 1.1 2004/01/07 18:43:36 neilc Exp $
10+
*
11+
*-------------------------------------------------------------------------
12+
*/
13+
14+
#include"nodes/nodes.h"
15+
16+
/*----------------------
17+
*Value node
18+
*
19+
* The same Value struct is used for five node types: T_Integer,
20+
* T_Float, T_String, T_BitString, T_Null.
21+
*
22+
* Integral values are actually represented by a machine integer,
23+
* but both floats and strings are represented as strings.
24+
* Using T_Float as the node type simply indicates that
25+
* the contents of the string look like a valid numeric literal.
26+
*
27+
* (Before Postgres 7.0, we used a double to represent T_Float,
28+
* but that creates loss-of-precision problems when the value is
29+
* ultimately destined to be converted to NUMERIC.Since Value nodes
30+
* are only used in the parsing process, not for runtime data, it's
31+
* better to use the more general representation.)
32+
*
33+
* Note that an integer-looking string will get lexed as T_Float if
34+
* the value is too large to fit in a 'long'.
35+
*
36+
* Nulls, of course, don't need the value part at all.
37+
*----------------------
38+
*/
39+
typedefstructValue
40+
{
41+
NodeTagtype;/* tag appropriately (eg. T_String) */
42+
unionValUnion
43+
{
44+
longival;/* machine integer */
45+
char*str;/* string */
46+
}val;
47+
}Value;
48+
49+
#defineintVal(v)(((Value *)(v))->val.ival)
50+
#definefloatVal(v)atof(((Value *)(v))->val.str)
51+
#definestrVal(v)(((Value *)(v))->val.str)
52+
53+
externValue*makeInteger(longi);
54+
externValue*makeFloat(char*numericStr);
55+
externValue*makeString(char*str);
56+
externValue*makeBitString(char*str);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp