This patch separates the 'Value' and 'List' nodes: now the Value node
has its own interface (i.e. header) and implementation files. This is
just house-keeping, in preparation for the list rewrite.

I renumbered a NodeTag: does that require a catalog version number
bump?

Unless anyone objects, I intend to apply this patch in about 24 hours.

-Neil

Index: src/backend/nodes/Makefile
===================================================================
RCS file: /Users/neilc/local/cvs/pgsql-server/src/backend/nodes/Makefile,v
retrieving revision 1.15
diff -c -r1.15 Makefile
*** src/backend/nodes/Makefile	29 Nov 2003 19:51:49 -0000	1.15
--- src/backend/nodes/Makefile	4 Jan 2004 00:03:54 -0000
***************
*** 14,20 ****
  
  OBJS = nodeFuncs.o nodes.o list.o bitmapset.o \
         copyfuncs.o equalfuncs.o makefuncs.o \
!        outfuncs.o readfuncs.o print.o read.o
  
  all: SUBSYS.o
  
--- 14,20 ----
  
  OBJS = nodeFuncs.o nodes.o list.o bitmapset.o \
         copyfuncs.o equalfuncs.o makefuncs.o \
!        outfuncs.o readfuncs.o print.o read.o value.o
  
  all: SUBSYS.o
  
Index: src/backend/nodes/list.c
===================================================================
RCS file: /Users/neilc/local/cvs/pgsql-server/src/backend/nodes/list.c,v
retrieving revision 1.55
diff -c -r1.55 list.c
*** src/backend/nodes/list.c	29 Nov 2003 19:51:49 -0000	1.55
--- src/backend/nodes/list.c	3 Jan 2004 23:59:19 -0000
***************
*** 1,7 ****
  /*-------------------------------------------------------------------------
   *
   * list.c
!  *	  POSTGRES generic list package
   *
   *
   * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
--- 1,7 ----
  /*-------------------------------------------------------------------------
   *
   * list.c
!  *	  implementation for PostgreSQL generic linked list package
   *
   *
   * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
***************
*** 11,92 ****
   * IDENTIFICATION
   *	  $PostgreSQL: /cvsroot/pgsql-server/src/backend/nodes/list.c,v 1.54 2003/08/08 21:41:44 momjian Exp $
   *
-  * NOTES
-  *	  XXX a few of the following functions are duplicated to handle
-  *		  List of pointers and List of integers separately. Some day,
-  *		  someone should unify them.			- ay 11/2/94
-  *	  This file needs cleanup.
-  *
-  * HISTORY
-  *	  AUTHOR			DATE			MAJOR EVENT
-  *	  Andrew Yu			Oct, 1994		file creation
-  *
   *-------------------------------------------------------------------------
   */
  #include "postgres.h"
  
  #include "nodes/parsenodes.h"
- 
- 
- /*
-  *	makeInteger
-  */
- Value *
- makeInteger(long i)
- {
- 	Value	   *v = makeNode(Value);
- 
- 	v->type = T_Integer;
- 	v->val.ival = i;
- 	return v;
- }
- 
- /*
-  *	makeFloat
-  *
-  * Caller is responsible for passing a palloc'd string.
-  */
- Value *
- makeFloat(char *numericStr)
- {
- 	Value	   *v = makeNode(Value);
- 
- 	v->type = T_Float;
- 	v->val.str = numericStr;
- 	return v;
- }
- 
- /*
-  *	makeString
-  *
-  * Caller is responsible for passing a palloc'd string.
-  */
- Value *
- makeString(char *str)
- {
- 	Value	   *v = makeNode(Value);
- 
- 	v->type = T_String;
- 	v->val.str = str;
- 	return v;
- }
- 
- 
- /*
-  *	makeBitString
-  *
-  * Caller is responsible for passing a palloc'd string.
-  */
- Value *
- makeBitString(char *str)
- {
- 	Value	   *v = makeNode(Value);
- 
- 	v->type = T_BitString;
- 	v->val.str = str;
- 	return v;
- }
- 
  
  /*
   *	lcons
--- 11,21 ----
Index: src/backend/nodes/value.c
===================================================================
RCS file: src/backend/nodes/value.c
diff -N src/backend/nodes/value.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- src/backend/nodes/value.c	4 Jan 2004 00:03:19 -0000
***************
*** 0 ****
--- 1,75 ----
+ /*-------------------------------------------------------------------------
+  *
+  * list.c
+  *	  implementation of Value nodes
+  *
+  *
+  * Copyright (c) 2003, PostgreSQL Global Development Group
+  *
+  *
+  * IDENTIFICATION
+  *	  $PostgreSQL$
+  *
+  *-------------------------------------------------------------------------
+  */
+ #include "postgres.h"
+ 
+ #include "nodes/parsenodes.h"
+ 
+ /*
+  *	makeInteger
+  */
+ Value *
+ makeInteger(long i)
+ {
+ 	Value	   *v = makeNode(Value);
+ 
+ 	v->type = T_Integer;
+ 	v->val.ival = i;
+ 	return v;
+ }
+ 
+ /*
+  *	makeFloat
+  *
+  * Caller is responsible for passing a palloc'd string.
+  */
+ Value *
+ makeFloat(char *numericStr)
+ {
+ 	Value	   *v = makeNode(Value);
+ 
+ 	v->type = T_Float;
+ 	v->val.str = numericStr;
+ 	return v;
+ }
+ 
+ /*
+  *	makeString
+  *
+  * Caller is responsible for passing a palloc'd string.
+  */
+ Value *
+ makeString(char *str)
+ {
+ 	Value	   *v = makeNode(Value);
+ 
+ 	v->type = T_String;
+ 	v->val.str = str;
+ 	return v;
+ }
+ 
+ /*
+  *	makeBitString
+  *
+  * Caller is responsible for passing a palloc'd string.
+  */
+ Value *
+ makeBitString(char *str)
+ {
+ 	Value	   *v = makeNode(Value);
+ 
+ 	v->type = T_BitString;
+ 	v->val.str = str;
+ 	return v;
+ }
Index: src/include/nodes/nodes.h
===================================================================
RCS file: /Users/neilc/local/cvs/pgsql-server/src/include/nodes/nodes.h,v
retrieving revision 1.148
diff -c -r1.148 nodes.h
*** src/include/nodes/nodes.h	29 Nov 2003 22:41:06 -0000	1.148
--- src/include/nodes/nodes.h	4 Jan 2004 00:05:05 -0000
***************
*** 175,189 ****
  	T_AllocSetContext,
  
  	/*
! 	 * TAGS FOR VALUE NODES (pg_list.h)
  	 */
  	T_Value = 650,
- 	T_List,
  	T_Integer,
  	T_Float,
  	T_String,
  	T_BitString,
  	T_Null,
  
  	/*
  	 * TAGS FOR PARSE TREE NODES (parsenodes.h)
--- 175,193 ----
  	T_AllocSetContext,
  
  	/*
! 	 * TAGS FOR VALUE NODES (value.h)
  	 */
  	T_Value = 650,
  	T_Integer,
  	T_Float,
  	T_String,
  	T_BitString,
  	T_Null,
+ 
+ 	/*
+ 	 * TAGS FOR LIST NODES (pg_list.h)
+ 	 */
+ 	T_List,
  
  	/*
  	 * TAGS FOR PARSE TREE NODES (parsenodes.h)
Index: src/include/nodes/pg_list.h
===================================================================
RCS file: /Users/neilc/local/cvs/pgsql-server/src/include/nodes/pg_list.h,v
retrieving revision 1.42
diff -c -r1.42 pg_list.h
*** src/include/nodes/pg_list.h	29 Nov 2003 22:41:06 -0000	1.42
--- src/include/nodes/pg_list.h	4 Jan 2004 00:09:23 -0000
***************
*** 1,7 ****
  /*-------------------------------------------------------------------------
   *
   * pg_list.h
!  *	  POSTGRES generic list package
   *
   *
   * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
--- 1,7 ----
  /*-------------------------------------------------------------------------
   *
   * pg_list.h
!  *	  interface for PostgreSQL generic linked list package
   *
   *
   * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
***************
*** 22,65 ****
   */
  
  /*----------------------
-  *		Value node
-  *
-  * The same Value struct is used for five node types: T_Integer,
-  * T_Float, T_String, T_BitString, T_Null.
-  *
-  * Integral values are actually represented by a machine integer,
-  * but both floats and strings are represented as strings.
-  * Using T_Float as the node type simply indicates that
-  * the contents of the string look like a valid numeric literal.
-  *
-  * (Before Postgres 7.0, we used a double to represent T_Float,
-  * but that creates loss-of-precision problems when the value is
-  * ultimately destined to be converted to NUMERIC.	Since Value nodes
-  * are only used in the parsing process, not for runtime data, it's
-  * better to use the more general representation.)
-  *
-  * Note that an integer-looking string will get lexed as T_Float if
-  * the value is too large to fit in a 'long'.
-  *
-  * Nulls, of course, don't need the value part at all.
-  *----------------------
-  */
- typedef struct Value
- {
- 	NodeTag		type;			/* tag appropriately (eg. T_String) */
- 	union ValUnion
- 	{
- 		long		ival;		/* machine integer */
- 		char	   *str;		/* string */
- 	}			val;
- } Value;
- 
- #define intVal(v)		(((Value *)(v))->val.ival)
- #define floatVal(v)		atof(((Value *)(v))->val.str)
- #define strVal(v)		(((Value *)(v))->val.str)
- 
- 
- /*----------------------
   *		List node
   *
   * We support three types of lists:
--- 22,27 ----
***************
*** 149,163 ****
  
  #define makeFastList1(fl, x1)  \
  	( (fl)->head = (fl)->tail = makeList1(x1) )
- 
- 
- /*
-  * function prototypes in nodes/list.c
-  */
- extern Value *makeInteger(long i);
- extern Value *makeFloat(char *numericStr);
- extern Value *makeString(char *str);
- extern Value *makeBitString(char *str);
  
  extern List *lcons(void *datum, List *list);
  extern List *lconsi(int datum, List *list);
--- 111,116 ----
Index: src/include/nodes/primnodes.h
===================================================================
RCS file: /Users/neilc/local/cvs/pgsql-server/src/include/nodes/primnodes.h,v
retrieving revision 1.93
diff -c -r1.93 primnodes.h
*** src/include/nodes/primnodes.h	29 Nov 2003 22:41:06 -0000	1.93
--- src/include/nodes/primnodes.h	4 Jan 2004 00:06:34 -0000
***************
*** 19,24 ****
--- 19,25 ----
  
  #include "access/attnum.h"
  #include "nodes/pg_list.h"
+ #include "nodes/value.h"
  
  
  /* ----------------------------------------------------------------
Index: src/include/nodes/value.h
===================================================================
RCS file: src/include/nodes/value.h
diff -N src/include/nodes/value.h
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- src/include/nodes/value.h	4 Jan 2004 00:09:04 -0000
***************
*** 0 ****
--- 1,56 ----
+ /*-------------------------------------------------------------------------
+  *
+  * value.h
+  *	  interface for Value nodes
+  *
+  *
+  * Copyright (c) 2003, PostgreSQL Global Development Group
+  *
+  * $PostgreSQL$
+  *
+  *-------------------------------------------------------------------------
+  */
+ 
+ #include "nodes/nodes.h"
+ 
+ /*----------------------
+  *		Value node
+  *
+  * The same Value struct is used for five node types: T_Integer,
+  * T_Float, T_String, T_BitString, T_Null.
+  *
+  * Integral values are actually represented by a machine integer,
+  * but both floats and strings are represented as strings.
+  * Using T_Float as the node type simply indicates that
+  * the contents of the string look like a valid numeric literal.
+  *
+  * (Before Postgres 7.0, we used a double to represent T_Float,
+  * but that creates loss-of-precision problems when the value is
+  * ultimately destined to be converted to NUMERIC.	Since Value nodes
+  * are only used in the parsing process, not for runtime data, it's
+  * better to use the more general representation.)
+  *
+  * Note that an integer-looking string will get lexed as T_Float if
+  * the value is too large to fit in a 'long'.
+  *
+  * Nulls, of course, don't need the value part at all.
+  *----------------------
+  */
+ typedef struct Value
+ {
+ 	NodeTag		type;			/* tag appropriately (eg. T_String) */
+ 	union ValUnion
+ 	{
+ 		long		ival;		/* machine integer */
+ 		char	   *str;		/* string */
+ 	}			val;
+ } Value;
+ 
+ #define intVal(v)		(((Value *)(v))->val.ival)
+ #define floatVal(v)		atof(((Value *)(v))->val.str)
+ #define strVal(v)		(((Value *)(v))->val.str)
+ 
+ extern Value *makeInteger(long i);
+ extern Value *makeFloat(char *numericStr);
+ extern Value *makeString(char *str);
+ extern Value *makeBitString(char *str);
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faqs/FAQ.html

Reply via email to