Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
6fff5c3b
Commit
6fff5c3b
authored
Apr 29, 2008
by
Alvaro Herrera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove typename from A_Const.
Brendan Jurd, minor editorialization by me.
parent
339570fd
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
150 additions
and
192 deletions
+150
-192
src/backend/nodes/copyfuncs.c
src/backend/nodes/copyfuncs.c
+1
-3
src/backend/nodes/equalfuncs.c
src/backend/nodes/equalfuncs.c
+1
-2
src/backend/nodes/outfuncs.c
src/backend/nodes/outfuncs.c
+1
-2
src/backend/parser/gram.y
src/backend/parser/gram.y
+82
-136
src/backend/parser/parse_expr.c
src/backend/parser/parse_expr.c
+2
-6
src/backend/parser/parse_target.c
src/backend/parser/parse_target.c
+1
-8
src/backend/parser/parse_type.c
src/backend/parser/parse_type.c
+22
-9
src/backend/parser/parse_utilcmd.c
src/backend/parser/parse_utilcmd.c
+6
-3
src/backend/utils/misc/guc.c
src/backend/utils/misc/guc.c
+31
-13
src/include/catalog/catversion.h
src/include/catalog/catversion.h
+2
-2
src/include/nodes/parsenodes.h
src/include/nodes/parsenodes.h
+1
-8
No files found.
src/backend/nodes/copyfuncs.c
View file @
6fff5c3b
...
...
@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.39
2 2008/04/14 17:05:33 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.39
3 2008/04/29 14:59:16 alvherre
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1639,8 +1639,6 @@ _copyAConst(A_Const *from)
break
;
}
COPY_NODE_FIELD
(
typename
);
return
newnode
;
}
...
...
src/backend/nodes/equalfuncs.c
View file @
6fff5c3b
...
...
@@ -18,7 +18,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.32
1 2008/04/14 17:05:33 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/nodes/equalfuncs.c,v 1.32
2 2008/04/29 14:59:16 alvherre
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1693,7 +1693,6 @@ _equalAConst(A_Const *a, A_Const *b)
{
if
(
!
equal
(
&
a
->
val
,
&
b
->
val
))
/* hack for in-line Value field */
return
false
;
COMPARE_NODE_FIELD
(
typename
);
return
true
;
}
...
...
src/backend/nodes/outfuncs.c
View file @
6fff5c3b
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.32
5 2008/04/13 20:51:20 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.32
6 2008/04/29 14:59:16 alvherre
Exp $
*
* NOTES
* Every node type that can appear in stored rules' parsetrees *must*
...
...
@@ -1945,7 +1945,6 @@ _outAConst(StringInfo str, A_Const *node)
appendStringInfo
(
str
,
" :val "
);
_outValue
(
str
,
&
(
node
->
val
));
WRITE_NODE_FIELD
(
typename
);
}
static
void
...
...
src/backend/parser/gram.y
View file @
6fff5c3b
This diff is collapsed.
Click to expand it.
src/backend/parser/parse_expr.c
View file @
6fff5c3b
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.22
7 2008/03/20 21:42:48 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.22
8 2008/04/29 14:59:16 alvherre
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -127,9 +127,6 @@ transformExpr(ParseState *pstate, Node *expr)
Value
*
val
=
&
con
->
val
;
result
=
(
Node
*
)
make_const
(
val
);
if
(
con
->
typename
!=
NULL
)
result
=
typecast_expression
(
pstate
,
result
,
con
->
typename
);
break
;
}
...
...
@@ -649,8 +646,7 @@ exprIsNullConstant(Node *arg)
{
A_Const
*
con
=
(
A_Const
*
)
arg
;
if
(
con
->
val
.
type
==
T_Null
&&
con
->
typename
==
NULL
)
if
(
con
->
val
.
type
==
T_Null
)
return
true
;
}
return
false
;
...
...
src/backend/parser/parse_target.c
View file @
6fff5c3b
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.1
59 2008/03/20 21:42:48 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.1
60 2008/04/29 14:59:17 alvherre
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1266,13 +1266,6 @@ FigureColnameInternal(Node *node, char **name)
return
2
;
}
break
;
case
T_A_Const
:
if
(((
A_Const
*
)
node
)
->
typename
!=
NULL
)
{
*
name
=
strVal
(
llast
(((
A_Const
*
)
node
)
->
typename
->
names
));
return
1
;
}
break
;
case
T_TypeCast
:
strength
=
FigureColnameInternal
(((
TypeCast
*
)
node
)
->
arg
,
name
);
...
...
src/backend/parser/parse_type.c
View file @
6fff5c3b
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.9
5 2008/04/11 22:54:23 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.9
6 2008/04/29 14:59:17 alvherre
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -289,20 +289,33 @@ typenameTypeMod(ParseState *pstate, const TypeName *typename, Type typ)
{
A_Const
*
ac
=
(
A_Const
*
)
tm
;
/*
* The grammar hands back some integers with ::int4 attached, so
* allow a cast decoration if it's an Integer value, but not
* otherwise.
*/
if
(
IsA
(
&
ac
->
val
,
Integer
))
{
cstr
=
(
char
*
)
palloc
(
32
);
snprintf
(
cstr
,
32
,
"%ld"
,
(
long
)
ac
->
val
.
val
.
ival
);
}
else
if
(
ac
->
typename
==
NULL
)
/* no casts allowed */
{
/* otherwise we can just use the str field directly. */
else
/* we can just use the str field directly. */
cstr
=
ac
->
val
.
val
.
str
;
}
else
if
(
IsA
(
tm
,
TypeCast
))
{
/*
* The grammar hands back some integers with ::int4 attached, so
* allow a cast decoration if it's an Integer value, but not
* otherwise.
*/
TypeCast
*
tc
=
(
TypeCast
*
)
tm
;
if
(
IsA
(
tc
->
arg
,
A_Const
))
{
A_Const
*
ac
=
(
A_Const
*
)
tc
->
arg
;
if
(
IsA
(
&
ac
->
val
,
Integer
))
{
cstr
=
(
char
*
)
palloc
(
32
);
snprintf
(
cstr
,
32
,
"%ld"
,
(
long
)
ac
->
val
.
val
.
ival
);
}
}
}
else
if
(
IsA
(
tm
,
ColumnRef
))
...
...
src/backend/parser/parse_utilcmd.c
View file @
6fff5c3b
...
...
@@ -19,7 +19,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/backend/parser/parse_utilcmd.c,v 2.1
2 2008/04/24 20:46:49 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_utilcmd.c,v 2.1
3 2008/04/29 14:59:17 alvherre
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -308,6 +308,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
char
*
sname
;
char
*
qstring
;
A_Const
*
snamenode
;
TypeCast
*
castnode
;
FuncCall
*
funccallnode
;
CreateSeqStmt
*
seqstmt
;
AlterSeqStmt
*
altseqstmt
;
...
...
@@ -379,10 +380,12 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
snamenode
=
makeNode
(
A_Const
);
snamenode
->
val
.
type
=
T_String
;
snamenode
->
val
.
val
.
str
=
qstring
;
snamenode
->
typename
=
SystemTypeName
(
"regclass"
);
castnode
=
makeNode
(
TypeCast
);
castnode
->
typename
=
SystemTypeName
(
"regclass"
);
castnode
->
arg
=
(
Node
*
)
snamenode
;
funccallnode
=
makeNode
(
FuncCall
);
funccallnode
->
funcname
=
SystemFuncName
(
"nextval"
);
funccallnode
->
args
=
list_make1
(
sname
node
);
funccallnode
->
args
=
list_make1
(
cast
node
);
funccallnode
->
agg_star
=
false
;
funccallnode
->
agg_distinct
=
false
;
funccallnode
->
location
=
-
1
;
...
...
src/backend/utils/misc/guc.c
View file @
6fff5c3b
...
...
@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.44
7 2008/04/18 01:42:17 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.44
8 2008/04/29 14:59:17 alvherre
Exp $
*
*--------------------------------------------------------------------
*/
...
...
@@ -5207,29 +5207,48 @@ flatten_set_variable_args(const char *name, List *args)
initStringInfo
(
&
buf
);
/*
* Each list member may be a plain A_Const node, or an A_Const within a
* TypeCast, as produced by makeFloatConst() et al in gram.y.
*/
foreach
(
l
,
args
)
{
A_Const
*
arg
=
(
A_Const
*
)
lfirst
(
l
);
Node
*
arg
=
(
Node
*
)
lfirst
(
l
);
char
*
val
;
TypeName
*
typename
=
NULL
;
A_Const
*
con
;
if
(
l
!=
list_head
(
args
))
appendStringInfo
(
&
buf
,
", "
);
if
(
IsA
(
arg
,
TypeCast
))
{
TypeCast
*
tc
=
(
TypeCast
*
)
arg
;
arg
=
tc
->
arg
;
typename
=
tc
->
typename
;
}
if
(
!
IsA
(
arg
,
A_Const
))
elog
(
ERROR
,
"unrecognized node type: %d"
,
(
int
)
nodeTag
(
arg
));
switch
(
nodeTag
(
&
arg
->
val
))
con
=
(
A_Const
*
)
arg
;
switch
(
nodeTag
(
&
con
->
val
))
{
case
T_Integer
:
appendStringInfo
(
&
buf
,
"%ld"
,
intVal
(
&
arg
->
val
));
appendStringInfo
(
&
buf
,
"%ld"
,
intVal
(
&
con
->
val
));
break
;
case
T_Float
:
/* represented as a string, so just copy it */
appendStringInfoString
(
&
buf
,
strVal
(
&
arg
->
val
));
appendStringInfoString
(
&
buf
,
strVal
(
&
con
->
val
));
break
;
case
T_String
:
val
=
strVal
(
&
arg
->
val
);
if
(
arg
->
typename
!=
NULL
)
/*
* Plain string literal or identifier. For quote mode,
* quote it if it's not a vanilla identifier.
*/
val
=
strVal
(
&
con
->
val
);
if
(
typename
!=
NULL
)
{
/*
* Must be a ConstInterval argument for TIME ZONE. Coerce
...
...
@@ -5241,7 +5260,7 @@ flatten_set_variable_args(const char *name, List *args)
Datum
interval
;
char
*
intervalout
;
typoid
=
typenameTypeId
(
NULL
,
arg
->
typename
,
&
typmod
);
typoid
=
typenameTypeId
(
NULL
,
typename
,
&
typmod
);
Assert
(
typoid
==
INTERVALOID
);
interval
=
...
...
@@ -5254,13 +5273,12 @@ flatten_set_variable_args(const char *name, List *args)
DatumGetCString
(
DirectFunctionCall1
(
interval_out
,
interval
));
appendStringInfo
(
&
buf
,
"INTERVAL '%s'"
,
intervalout
);
/* don't leave this set */
typename
=
NULL
;
}
else
{
/*
* Plain string literal or identifier. For quote mode,
* quote it if it's not a vanilla identifier.
*/
if
(
flags
&
GUC_LIST_QUOTE
)
appendStringInfoString
(
&
buf
,
quote_identifier
(
val
));
else
...
...
@@ -5269,7 +5287,7 @@ flatten_set_variable_args(const char *name, List *args)
break
;
default:
elog
(
ERROR
,
"unrecognized node type: %d"
,
(
int
)
nodeTag
(
&
arg
->
val
));
(
int
)
nodeTag
(
&
con
->
val
));
break
;
}
}
...
...
src/include/catalog/catversion.h
View file @
6fff5c3b
...
...
@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.45
2 2008/04/29 13:00:22
alvherre Exp $
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.45
3 2008/04/29 14:59:17
alvherre Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
#define CATALOG_VERSION_NO 20080429
1
#define CATALOG_VERSION_NO 20080429
2
#endif
src/include/nodes/parsenodes.h
View file @
6fff5c3b
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.36
2 2008/04/14 17:05:34 tgl
Exp $
* $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.36
3 2008/04/29 14:59:17 alvherre
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -234,17 +234,10 @@ typedef struct A_Const
{
NodeTag
type
;
Value
val
;
/* the value (with the tag) */
TypeName
*
typename
;
/* typecast, or NULL if none */
}
A_Const
;
/*
* TypeCast - a CAST expression
*
* NOTE: for mostly historical reasons, A_Const parsenodes contain
* room for a TypeName, allowing a constant to be marked as being of a given
* type without a separate TypeCast node. Either representation will work,
* but the combined representation saves a bit of code in many
* productions in gram.y.
*/
typedef
struct
TypeCast
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment