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
Show 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 @@
...
@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* 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)
...
@@ -1639,8 +1639,6 @@ _copyAConst(A_Const *from)
break
;
break
;
}
}
COPY_NODE_FIELD
(
typename
);
return
newnode
;
return
newnode
;
}
}
...
...
src/backend/nodes/equalfuncs.c
View file @
6fff5c3b
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* IDENTIFICATION
* 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)
...
@@ -1693,7 +1693,6 @@ _equalAConst(A_Const *a, A_Const *b)
{
{
if
(
!
equal
(
&
a
->
val
,
&
b
->
val
))
/* hack for in-line Value field */
if
(
!
equal
(
&
a
->
val
,
&
b
->
val
))
/* hack for in-line Value field */
return
false
;
return
false
;
COMPARE_NODE_FIELD
(
typename
);
return
true
;
return
true
;
}
}
...
...
src/backend/nodes/outfuncs.c
View file @
6fff5c3b
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* 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
* NOTES
* Every node type that can appear in stored rules' parsetrees *must*
* Every node type that can appear in stored rules' parsetrees *must*
...
@@ -1945,7 +1945,6 @@ _outAConst(StringInfo str, A_Const *node)
...
@@ -1945,7 +1945,6 @@ _outAConst(StringInfo str, A_Const *node)
appendStringInfo
(
str
,
" :val "
);
appendStringInfo
(
str
,
" :val "
);
_outValue
(
str
,
&
(
node
->
val
));
_outValue
(
str
,
&
(
node
->
val
));
WRITE_NODE_FIELD
(
typename
);
}
}
static
void
static
void
...
...
src/backend/parser/gram.y
View file @
6fff5c3b
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.61
2 2008/04/14 17:05:33 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.61
3 2008/04/29 14:59:16 alvherre
Exp $
*
*
* HISTORY
* HISTORY
* AUTHOR DATE MAJOR EVENT
* AUTHOR DATE MAJOR EVENT
...
@@ -91,11 +91,12 @@ static bool QueryIsRule = FALSE;
...
@@ -91,11 +91,12 @@ static bool QueryIsRule = FALSE;
static Node *makeColumnRef(char *relname, List *indirection, int location);
static Node *makeColumnRef(char *relname, List *indirection, int location);
static Node *makeTypeCast(Node *arg, TypeName *typename);
static Node *makeTypeCast(Node *arg, TypeName *typename);
static Node *makeStringConst(char *str, TypeName *typename);
static Node *makeStringConst(char *str);
static Node *makeStringConstCast(char *str, TypeName *typename);
static Node *makeIntConst(int val);
static Node *makeIntConst(int val);
static Node *makeFloatConst(char *str);
static Node *makeFloatConst(char *str);
static Node *makeAConst(Value *v);
static Node *makeAConst(Value *v);
static
A_Const
*makeBoolAConst(bool state);
static
Node
*makeBoolAConst(bool state);
static FuncCall *makeOverlaps(List *largs, List *rargs, int location);
static FuncCall *makeOverlaps(List *largs, List *rargs, int location);
static void check_qualified_name(List *names);
static void check_qualified_name(List *names);
static List *check_func_name(List *names);
static List *check_func_name(List *names);
...
@@ -1112,7 +1113,7 @@ set_rest: /* Generic SET syntaxes: */
...
@@ -1112,7 +1113,7 @@ set_rest: /* Generic SET syntaxes: */
n->kind = VAR_SET_VALUE;
n->kind = VAR_SET_VALUE;
n->name = "client_encoding";
n->name = "client_encoding";
if ($2 != NULL)
if ($2 != NULL)
n->args = list_make1(makeStringConst($2
, NULL
));
n->args = list_make1(makeStringConst($2));
else
else
n->kind = VAR_SET_DEFAULT;
n->kind = VAR_SET_DEFAULT;
$$ = n;
$$ = n;
...
@@ -1122,7 +1123,7 @@ set_rest: /* Generic SET syntaxes: */
...
@@ -1122,7 +1123,7 @@ set_rest: /* Generic SET syntaxes: */
VariableSetStmt *n = makeNode(VariableSetStmt);
VariableSetStmt *n = makeNode(VariableSetStmt);
n->kind = VAR_SET_VALUE;
n->kind = VAR_SET_VALUE;
n->name = "role";
n->name = "role";
n->args = list_make1(makeStringConst($2
, NULL
));
n->args = list_make1(makeStringConst($2));
$$ = n;
$$ = n;
}
}
| SESSION AUTHORIZATION ColId_or_Sconst
| SESSION AUTHORIZATION ColId_or_Sconst
...
@@ -1130,7 +1131,7 @@ set_rest: /* Generic SET syntaxes: */
...
@@ -1130,7 +1131,7 @@ set_rest: /* Generic SET syntaxes: */
VariableSetStmt *n = makeNode(VariableSetStmt);
VariableSetStmt *n = makeNode(VariableSetStmt);
n->kind = VAR_SET_VALUE;
n->kind = VAR_SET_VALUE;
n->name = "session_authorization";
n->name = "session_authorization";
n->args = list_make1(makeStringConst($3
, NULL
));
n->args = list_make1(makeStringConst($3));
$$ = n;
$$ = n;
}
}
| SESSION AUTHORIZATION DEFAULT
| SESSION AUTHORIZATION DEFAULT
...
@@ -1145,7 +1146,7 @@ set_rest: /* Generic SET syntaxes: */
...
@@ -1145,7 +1146,7 @@ set_rest: /* Generic SET syntaxes: */
VariableSetStmt *n = makeNode(VariableSetStmt);
VariableSetStmt *n = makeNode(VariableSetStmt);
n->kind = VAR_SET_VALUE;
n->kind = VAR_SET_VALUE;
n->name = "xmloption";
n->name = "xmloption";
n->args = list_make1(makeStringConst($3 == XMLOPTION_DOCUMENT ? "DOCUMENT" : "CONTENT"
, NULL
));
n->args = list_make1(makeStringConst($3 == XMLOPTION_DOCUMENT ? "DOCUMENT" : "CONTENT"));
$$ = n;
$$ = n;
}
}
;
;
...
@@ -1163,9 +1164,9 @@ var_list: var_value { $$ = list_make1($1); }
...
@@ -1163,9 +1164,9 @@ var_list: var_value { $$ = list_make1($1); }
;
;
var_value: opt_boolean
var_value: opt_boolean
{ $$ = makeStringConst($1
, NULL
); }
{ $$ = makeStringConst($1); }
| ColId_or_Sconst
| ColId_or_Sconst
{ $$ = makeStringConst($1
, NULL
); }
{ $$ = makeStringConst($1); }
| NumericOnly
| NumericOnly
{ $$ = makeAConst($1); }
{ $$ = makeAConst($1); }
;
;
...
@@ -1194,36 +1195,36 @@ opt_boolean:
...
@@ -1194,36 +1195,36 @@ opt_boolean:
zone_value:
zone_value:
Sconst
Sconst
{
{
$$ = makeStringConst($1
, NULL
);
$$ = makeStringConst($1);
}
}
| IDENT
| IDENT
{
{
$$ = makeStringConst($1
, NULL
);
$$ = makeStringConst($1);
}
}
| ConstInterval Sconst opt_interval
| ConstInterval Sconst opt_interval
{
{
A_Const *n = (A_Const *) makeStringConst($2, $1)
;
TypeName *t = $1
;
if ($3 != INTERVAL_FULL_RANGE)
if ($3 != INTERVAL_FULL_RANGE)
{
{
if (($3 & ~(INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE))) != 0)
if (($3 & ~(INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE))) != 0)
ereport(ERROR,
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("time zone interval must be HOUR or HOUR TO MINUTE")));
errmsg("time zone interval must be HOUR or HOUR TO MINUTE")));
n->typename
->typmods = list_make1(makeIntConst($3));
t
->typmods = list_make1(makeIntConst($3));
}
}
$$ =
(Node *)n
;
$$ =
makeStringConstCast($2, t)
;
}
}
| ConstInterval '(' Iconst ')' Sconst opt_interval
| ConstInterval '(' Iconst ')' Sconst opt_interval
{
{
A_Const *n = (A_Const *) makeStringConst($5, $1)
;
TypeName *t = $1
;
if (($6 != INTERVAL_FULL_RANGE)
if (($6 != INTERVAL_FULL_RANGE)
&& (($6 & ~(INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE))) != 0))
&& (($6 & ~(INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE))) != 0))
ereport(ERROR,
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("time zone interval must be HOUR or HOUR TO MINUTE")));
errmsg("time zone interval must be HOUR or HOUR TO MINUTE")));
n->typename->typmods = list_make2(makeIntConst($6),
t->typmods = list_make2(makeIntConst($6),
makeIntConst($3));
makeIntConst($3));
$$ =
(Node *)n
;
$$ =
makeStringConstCast($5, t)
;
}
}
| NumericOnly { $$ = makeAConst($1); }
| NumericOnly { $$ = makeAConst($1); }
| DEFAULT { $$ = NULL; }
| DEFAULT { $$ = NULL; }
...
@@ -5207,7 +5208,7 @@ opt_transaction: WORK {}
...
@@ -5207,7 +5208,7 @@ opt_transaction: WORK {}
transaction_mode_item:
transaction_mode_item:
ISOLATION LEVEL iso_level
ISOLATION LEVEL iso_level
{ $$ = makeDefElem("transaction_isolation",
{ $$ = makeDefElem("transaction_isolation",
makeStringConst($3
, NULL
)); }
makeStringConst($3)); }
| READ ONLY
| READ ONLY
{ $$ = makeDefElem("transaction_read_only",
{ $$ = makeDefElem("transaction_read_only",
makeIntConst(TRUE)); }
makeIntConst(TRUE)); }
...
@@ -7912,16 +7913,9 @@ func_expr: func_name '(' ')'
...
@@ -7912,16 +7913,9 @@ func_expr: func_name '(' ')'
* that is actually possible, but not clear that we want
* that is actually possible, but not clear that we want
* to rely on it.)
* to rely on it.)
*/
*/
A_Const *s = makeNode(A_Const);
Node *n;
TypeName *d;
n = makeStringConstCast("now", SystemTypeName("text"));
$$ = makeTypeCast(n, SystemTypeName("date"));
s->val.type = T_String;
s->val.val.str = "now";
s->typename = SystemTypeName("text");
d = SystemTypeName("date");
$$ = (Node *)makeTypeCast((Node *)s, d);
}
}
| CURRENT_TIME
| CURRENT_TIME
{
{
...
@@ -7929,16 +7923,9 @@ func_expr: func_name '(' ')'
...
@@ -7929,16 +7923,9 @@ func_expr: func_name '(' ')'
* Translate as "'now'::text::timetz".
* Translate as "'now'::text::timetz".
* See comments for CURRENT_DATE.
* See comments for CURRENT_DATE.
*/
*/
A_Const *s = makeNode(A_Const);
Node *n;
TypeName *d;
n = makeStringConstCast("now", SystemTypeName("text"));
$$ = makeTypeCast(n, SystemTypeName("timetz"));
s->val.type = T_String;
s->val.val.str = "now";
s->typename = SystemTypeName("text");
d = SystemTypeName("timetz");
$$ = (Node *)makeTypeCast((Node *)s, d);
}
}
| CURRENT_TIME '(' Iconst ')'
| CURRENT_TIME '(' Iconst ')'
{
{
...
@@ -7946,16 +7933,12 @@ func_expr: func_name '(' ')'
...
@@ -7946,16 +7933,12 @@ func_expr: func_name '(' ')'
* Translate as "'now'::text::timetz(n)".
* Translate as "'now'::text::timetz(n)".
* See comments for CURRENT_DATE.
* See comments for CURRENT_DATE.
*/
*/
A_Const *s = makeNode(A_Const)
;
Node *n
;
TypeName *d;
TypeName *d;
n = makeStringConstCast("now", SystemTypeName("text"));
s->val.type = T_String;
s->val.val.str = "now";
s->typename = SystemTypeName("text");
d = SystemTypeName("timetz");
d = SystemTypeName("timetz");
d->typmods = list_make1(makeIntConst($3));
d->typmods = list_make1(makeIntConst($3));
$$ = makeTypeCast(n, d);
$$ = (Node *)makeTypeCast((Node *)s, d);
}
}
| CURRENT_TIMESTAMP
| CURRENT_TIMESTAMP
{
{
...
@@ -7977,17 +7960,12 @@ func_expr: func_name '(' ')'
...
@@ -7977,17 +7960,12 @@ func_expr: func_name '(' ')'
* Translate as "'now'::text::timestamptz(n)".
* Translate as "'now'::text::timestamptz(n)".
* See comments for CURRENT_DATE.
* See comments for CURRENT_DATE.
*/
*/
A_Const *s = makeNode(A_Const)
;
Node *n
;
TypeName *d;
TypeName *d;
n = makeStringConstCast("now", SystemTypeName("text"));
s->val.type = T_String;
s->val.val.str = "now";
s->typename = SystemTypeName("text");
d = SystemTypeName("timestamptz");
d = SystemTypeName("timestamptz");
d->typmods = list_make1(makeIntConst($3));
d->typmods = list_make1(makeIntConst($3));
$$ = makeTypeCast(n, d);
$$ = (Node *)makeTypeCast((Node *)s, d);
}
}
| LOCALTIME
| LOCALTIME
{
{
...
@@ -7995,16 +7973,9 @@ func_expr: func_name '(' ')'
...
@@ -7995,16 +7973,9 @@ func_expr: func_name '(' ')'
* Translate as "'now'::text::time".
* Translate as "'now'::text::time".
* See comments for CURRENT_DATE.
* See comments for CURRENT_DATE.
*/
*/
A_Const *s = makeNode(A_Const);
Node *n;
TypeName *d;
n = makeStringConstCast("now", SystemTypeName("text"));
$$ = makeTypeCast((Node *)n, SystemTypeName("time"));
s->val.type = T_String;
s->val.val.str = "now";
s->typename = SystemTypeName("text");
d = SystemTypeName("time");
$$ = (Node *)makeTypeCast((Node *)s, d);
}
}
| LOCALTIME '(' Iconst ')'
| LOCALTIME '(' Iconst ')'
{
{
...
@@ -8012,16 +7983,12 @@ func_expr: func_name '(' ')'
...
@@ -8012,16 +7983,12 @@ func_expr: func_name '(' ')'
* Translate as "'now'::text::time(n)".
* Translate as "'now'::text::time(n)".
* See comments for CURRENT_DATE.
* See comments for CURRENT_DATE.
*/
*/
A_Const *s = makeNode(A_Const)
;
Node *n
;
TypeName *d;
TypeName *d;
n = makeStringConstCast("now", SystemTypeName("text"));
s->val.type = T_String;
s->val.val.str = "now";
s->typename = SystemTypeName("text");
d = SystemTypeName("time");
d = SystemTypeName("time");
d->typmods = list_make1(makeIntConst($3));
d->typmods = list_make1(makeIntConst($3));
$$ = makeTypeCast((Node *)n, d);
$$ = (Node *)makeTypeCast((Node *)s, d);
}
}
| LOCALTIMESTAMP
| LOCALTIMESTAMP
{
{
...
@@ -8029,16 +7996,9 @@ func_expr: func_name '(' ')'
...
@@ -8029,16 +7996,9 @@ func_expr: func_name '(' ')'
* Translate as "'now'::text::timestamp".
* Translate as "'now'::text::timestamp".
* See comments for CURRENT_DATE.
* See comments for CURRENT_DATE.
*/
*/
A_Const *s = makeNode(A_Const);
Node *n;
TypeName *d;
n = makeStringConstCast("now", SystemTypeName("text"));
$$ = makeTypeCast(n, SystemTypeName("timestamp"));
s->val.type = T_String;
s->val.val.str = "now";
s->typename = SystemTypeName("text");
d = SystemTypeName("timestamp");
$$ = (Node *)makeTypeCast((Node *)s, d);
}
}
| LOCALTIMESTAMP '(' Iconst ')'
| LOCALTIMESTAMP '(' Iconst ')'
{
{
...
@@ -8046,17 +8006,12 @@ func_expr: func_name '(' ')'
...
@@ -8046,17 +8006,12 @@ func_expr: func_name '(' ')'
* Translate as "'now'::text::timestamp(n)".
* Translate as "'now'::text::timestamp(n)".
* See comments for CURRENT_DATE.
* See comments for CURRENT_DATE.
*/
*/
A_Const *s = makeNode(A_Const)
;
Node *n
;
TypeName *d;
TypeName *d;
n = makeStringConstCast("now", SystemTypeName("text"));
s->val.type = T_String;
s->val.val.str = "now";
s->typename = SystemTypeName("text");
d = SystemTypeName("timestamp");
d = SystemTypeName("timestamp");
d->typmods = list_make1(makeIntConst($3));
d->typmods = list_make1(makeIntConst($3));
$$ = makeTypeCast(n, d);
$$ = (Node *)makeTypeCast((Node *)s, d);
}
}
| CURRENT_ROLE
| CURRENT_ROLE
{
{
...
@@ -8304,13 +8259,13 @@ xml_root_version: VERSION_P a_expr
...
@@ -8304,13 +8259,13 @@ xml_root_version: VERSION_P a_expr
;
;
opt_xml_root_standalone: ',' STANDALONE_P YES_P
opt_xml_root_standalone: ',' STANDALONE_P YES_P
{ $$ =
(Node *)
makeIntConst(XML_STANDALONE_YES); }
{ $$ = makeIntConst(XML_STANDALONE_YES); }
| ',' STANDALONE_P NO
| ',' STANDALONE_P NO
{ $$ =
(Node *)
makeIntConst(XML_STANDALONE_NO); }
{ $$ = makeIntConst(XML_STANDALONE_NO); }
| ',' STANDALONE_P NO VALUE_P
| ',' STANDALONE_P NO VALUE_P
{ $$ =
(Node *)
makeIntConst(XML_STANDALONE_NO_VALUE); }
{ $$ = makeIntConst(XML_STANDALONE_NO_VALUE); }
| /*EMPTY*/
| /*EMPTY*/
{ $$ =
(Node *)
makeIntConst(XML_STANDALONE_OMITTED); }
{ $$ = makeIntConst(XML_STANDALONE_OMITTED); }
;
;
xml_attributes: XMLATTRIBUTES '(' xml_attribute_list ')' { $$ = $3; }
xml_attributes: XMLATTRIBUTES '(' xml_attribute_list ')' { $$ = $3; }
...
@@ -8897,60 +8852,44 @@ AexprConst: Iconst
...
@@ -8897,60 +8852,44 @@ AexprConst: Iconst
| func_name Sconst
| func_name Sconst
{
{
/* generic type 'literal' syntax */
/* generic type 'literal' syntax */
A_Const *n = makeNode(A_Const);
TypeName *t = makeTypeNameFromNameList($1);
n->typename = makeTypeNameFromNameList($1);
t->location = @1;
n->typename->location = @1;
$$ = makeStringConstCast($2, t);
n->val.type = T_String;
n->val.val.str = $2;
$$ = (Node *)n;
}
}
| func_name '(' expr_list ')' Sconst
| func_name '(' expr_list ')' Sconst
{
{
/* generic syntax with a type modifier */
/* generic syntax with a type modifier */
A_Const *n = makeNode(A_Const);
TypeName *t = makeTypeNameFromNameList($1);
n->typename = makeTypeNameFromNameList($1);
t->typmods = $3;
n->typename->typmods = $3;
t->location = @1;
n->typename->location = @1;
$$ = makeStringConstCast($5, t);
n->val.type = T_String;
n->val.val.str = $5;
$$ = (Node *)n;
}
}
| ConstTypename Sconst
| ConstTypename Sconst
{
{
A_Const *n = makeNode(A_Const);
$$ = makeStringConstCast($2, $1);
n->typename = $1;
n->val.type = T_String;
n->val.val.str = $2;
$$ = (Node *)n;
}
}
| ConstInterval Sconst opt_interval
| ConstInterval Sconst opt_interval
{
{
A_Const *n = makeNode(A_Const);
TypeName *t = $1;
n->typename = $1;
n->val.type = T_String;
n->val.val.str = $2;
/* precision is not specified, but fields may be... */
/* precision is not specified, but fields may be... */
if ($3 != INTERVAL_FULL_RANGE)
if ($3 != INTERVAL_FULL_RANGE)
n->typename
->typmods = list_make1(makeIntConst($3));
t
->typmods = list_make1(makeIntConst($3));
$$ =
(Node *)n
;
$$ =
makeStringConstCast($2, t)
;
}
}
| ConstInterval '(' Iconst ')' Sconst opt_interval
| ConstInterval '(' Iconst ')' Sconst opt_interval
{
{
A_Const *n = makeNode(A_Const);
TypeName *t = $1;
n->typename = $1;
t->typmods = list_make2(makeIntConst($6),
n->val.type = T_String;
n->val.val.str = $5;
n->typename->typmods = list_make2(makeIntConst($6),
makeIntConst($3));
makeIntConst($3));
$$ =
(Node *)n
;
$$ =
makeStringConstCast($5, t)
;
}
}
| TRUE_P
| TRUE_P
{
{
$$ =
(Node *)
makeBoolAConst(TRUE);
$$ = makeBoolAConst(TRUE);
}
}
| FALSE_P
| FALSE_P
{
{
$$ =
(Node *)
makeBoolAConst(FALSE);
$$ = makeBoolAConst(FALSE);
}
}
| NULL_P
| NULL_P
{
{
...
@@ -9506,24 +9445,31 @@ makeTypeCast(Node *arg, TypeName *typename)
...
@@ -9506,24 +9445,31 @@ makeTypeCast(Node *arg, TypeName *typename)
}
}
static Node *
static Node *
makeStringConst(char *str
, TypeName *typename
)
makeStringConst(char *str)
{
{
A_Const *n = makeNode(A_Const);
A_Const *n = makeNode(A_Const);
n->val.type = T_String;
n->val.type = T_String;
n->val.val.str = str;
n->val.val.str = str;
n->typename = typename;
return (Node *)n;
return (Node *)n;
}
}
static Node *
makeStringConstCast(char *str, TypeName *typename)
{
Node *s = makeStringConst(str);
return makeTypeCast(s, typename);
}
static Node *
static Node *
makeIntConst(int val)
makeIntConst(int val)
{
{
A_Const *n = makeNode(A_Const);
A_Const *n = makeNode(A_Const);
n->val.type = T_Integer;
n->val.type = T_Integer;
n->val.val.ival = val;
n->val.val.ival = val;
n->typename = SystemTypeName("int4");
return (Node *)n;
return (Node *)n;
}
}
...
@@ -9535,9 +9481,8 @@ makeFloatConst(char *str)
...
@@ -9535,9 +9481,8 @@ makeFloatConst(char *str)
n->val.type = T_Float;
n->val.type = T_Float;
n->val.val.str = str;
n->val.val.str = str;
n->typename = SystemTypeName("float8");
return
(Node *)n
;
return
makeTypeCast((Node *)n, SystemTypeName("float8"))
;
}
}
static Node *
static Node *
...
@@ -9557,7 +9502,7 @@ makeAConst(Value *v)
...
@@ -9557,7 +9502,7 @@ makeAConst(Value *v)
case T_String:
case T_String:
default:
default:
n = makeStringConst(v->val.str
, NULL
);
n = makeStringConst(v->val.str);
break;
break;
}
}
...
@@ -9565,16 +9510,17 @@ makeAConst(Value *v)
...
@@ -9565,16 +9510,17 @@ makeAConst(Value *v)
}
}
/* makeBoolAConst()
/* makeBoolAConst()
* Create an A_Const
node and initialize to a boolean constan
t.
* Create an A_Const
string node and put it inside a boolean cas
t.
*/
*/
static
A_Const
*
static
Node
*
makeBoolAConst(bool state)
makeBoolAConst(bool state)
{
{
A_Const *n = makeNode(A_Const);
A_Const *n = makeNode(A_Const);
n->val.type = T_String;
n->val.type = T_String;
n->val.val.str = (state ? "t" : "f");
n->val.val.str = (state ? "t" : "f");
n->typename = SystemTypeName("bool");
return
n
;
return
makeTypeCast((Node *)n, SystemTypeName("bool"))
;
}
}
/* makeOverlaps()
/* makeOverlaps()
...
...
src/backend/parser/parse_expr.c
View file @
6fff5c3b
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* 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)
...
@@ -127,9 +127,6 @@ transformExpr(ParseState *pstate, Node *expr)
Value
*
val
=
&
con
->
val
;
Value
*
val
=
&
con
->
val
;
result
=
(
Node
*
)
make_const
(
val
);
result
=
(
Node
*
)
make_const
(
val
);
if
(
con
->
typename
!=
NULL
)
result
=
typecast_expression
(
pstate
,
result
,
con
->
typename
);
break
;
break
;
}
}
...
@@ -649,8 +646,7 @@ exprIsNullConstant(Node *arg)
...
@@ -649,8 +646,7 @@ exprIsNullConstant(Node *arg)
{
{
A_Const
*
con
=
(
A_Const
*
)
arg
;
A_Const
*
con
=
(
A_Const
*
)
arg
;
if
(
con
->
val
.
type
==
T_Null
&&
if
(
con
->
val
.
type
==
T_Null
)
con
->
typename
==
NULL
)
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
...
src/backend/parser/parse_target.c
View file @
6fff5c3b
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* 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)
...
@@ -1266,13 +1266,6 @@ FigureColnameInternal(Node *node, char **name)
return
2
;
return
2
;
}
}
break
;
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
:
case
T_TypeCast
:
strength
=
FigureColnameInternal
(((
TypeCast
*
)
node
)
->
arg
,
strength
=
FigureColnameInternal
(((
TypeCast
*
)
node
)
->
arg
,
name
);
name
);
...
...
src/backend/parser/parse_type.c
View file @
6fff5c3b
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* 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)
...
@@ -289,20 +289,33 @@ typenameTypeMod(ParseState *pstate, const TypeName *typename, Type typ)
{
{
A_Const
*
ac
=
(
A_Const
*
)
tm
;
A_Const
*
ac
=
(
A_Const
*
)
tm
;
if
(
IsA
(
&
ac
->
val
,
Integer
))
{
cstr
=
(
char
*
)
palloc
(
32
);
snprintf
(
cstr
,
32
,
"%ld"
,
(
long
)
ac
->
val
.
val
.
ival
);
}
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
* The grammar hands back some integers with ::int4 attached, so
* allow a cast decoration if it's an Integer value, but not
* allow a cast decoration if it's an Integer value, but not
* otherwise.
* otherwise.
*/
*/
TypeCast
*
tc
=
(
TypeCast
*
)
tm
;
if
(
IsA
(
tc
->
arg
,
A_Const
))
{
A_Const
*
ac
=
(
A_Const
*
)
tc
->
arg
;
if
(
IsA
(
&
ac
->
val
,
Integer
))
if
(
IsA
(
&
ac
->
val
,
Integer
))
{
{
cstr
=
(
char
*
)
palloc
(
32
);
cstr
=
(
char
*
)
palloc
(
32
);
snprintf
(
cstr
,
32
,
"%ld"
,
(
long
)
ac
->
val
.
val
.
ival
);
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. */
cstr
=
ac
->
val
.
val
.
str
;
}
}
}
}
else
if
(
IsA
(
tm
,
ColumnRef
))
else
if
(
IsA
(
tm
,
ColumnRef
))
...
...
src/backend/parser/parse_utilcmd.c
View file @
6fff5c3b
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* 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,
...
@@ -308,6 +308,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
char
*
sname
;
char
*
sname
;
char
*
qstring
;
char
*
qstring
;
A_Const
*
snamenode
;
A_Const
*
snamenode
;
TypeCast
*
castnode
;
FuncCall
*
funccallnode
;
FuncCall
*
funccallnode
;
CreateSeqStmt
*
seqstmt
;
CreateSeqStmt
*
seqstmt
;
AlterSeqStmt
*
altseqstmt
;
AlterSeqStmt
*
altseqstmt
;
...
@@ -379,10 +380,12 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
...
@@ -379,10 +380,12 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
snamenode
=
makeNode
(
A_Const
);
snamenode
=
makeNode
(
A_Const
);
snamenode
->
val
.
type
=
T_String
;
snamenode
->
val
.
type
=
T_String
;
snamenode
->
val
.
val
.
str
=
qstring
;
snamenode
->
val
.
val
.
str
=
qstring
;
snamenode
->
typename
=
SystemTypeName
(
"regclass"
);
castnode
=
makeNode
(
TypeCast
);
castnode
->
typename
=
SystemTypeName
(
"regclass"
);
castnode
->
arg
=
(
Node
*
)
snamenode
;
funccallnode
=
makeNode
(
FuncCall
);
funccallnode
=
makeNode
(
FuncCall
);
funccallnode
->
funcname
=
SystemFuncName
(
"nextval"
);
funccallnode
->
funcname
=
SystemFuncName
(
"nextval"
);
funccallnode
->
args
=
list_make1
(
sname
node
);
funccallnode
->
args
=
list_make1
(
cast
node
);
funccallnode
->
agg_star
=
false
;
funccallnode
->
agg_star
=
false
;
funccallnode
->
agg_distinct
=
false
;
funccallnode
->
agg_distinct
=
false
;
funccallnode
->
location
=
-
1
;
funccallnode
->
location
=
-
1
;
...
...
src/backend/utils/misc/guc.c
View file @
6fff5c3b
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>.
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
*
* IDENTIFICATION
* 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)
...
@@ -5207,29 +5207,48 @@ flatten_set_variable_args(const char *name, List *args)
initStringInfo
(
&
buf
);
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
)
foreach
(
l
,
args
)
{
{
A_Const
*
arg
=
(
A_Const
*
)
lfirst
(
l
);
Node
*
arg
=
(
Node
*
)
lfirst
(
l
);
char
*
val
;
char
*
val
;
TypeName
*
typename
=
NULL
;
A_Const
*
con
;
if
(
l
!=
list_head
(
args
))
if
(
l
!=
list_head
(
args
))
appendStringInfo
(
&
buf
,
", "
);
appendStringInfo
(
&
buf
,
", "
);
if
(
IsA
(
arg
,
TypeCast
))
{
TypeCast
*
tc
=
(
TypeCast
*
)
arg
;
arg
=
tc
->
arg
;
typename
=
tc
->
typename
;
}
if
(
!
IsA
(
arg
,
A_Const
))
if
(
!
IsA
(
arg
,
A_Const
))
elog
(
ERROR
,
"unrecognized node type: %d"
,
(
int
)
nodeTag
(
arg
));
elog
(
ERROR
,
"unrecognized node type: %d"
,
(
int
)
nodeTag
(
arg
));
switch
(
nodeTag
(
&
arg
->
val
))
con
=
(
A_Const
*
)
arg
;
switch
(
nodeTag
(
&
con
->
val
))
{
{
case
T_Integer
:
case
T_Integer
:
appendStringInfo
(
&
buf
,
"%ld"
,
intVal
(
&
arg
->
val
));
appendStringInfo
(
&
buf
,
"%ld"
,
intVal
(
&
con
->
val
));
break
;
break
;
case
T_Float
:
case
T_Float
:
/* represented as a string, so just copy it */
/* represented as a string, so just copy it */
appendStringInfoString
(
&
buf
,
strVal
(
&
arg
->
val
));
appendStringInfoString
(
&
buf
,
strVal
(
&
con
->
val
));
break
;
break
;
case
T_String
:
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
* Must be a ConstInterval argument for TIME ZONE. Coerce
...
@@ -5241,7 +5260,7 @@ flatten_set_variable_args(const char *name, List *args)
...
@@ -5241,7 +5260,7 @@ flatten_set_variable_args(const char *name, List *args)
Datum
interval
;
Datum
interval
;
char
*
intervalout
;
char
*
intervalout
;
typoid
=
typenameTypeId
(
NULL
,
arg
->
typename
,
&
typmod
);
typoid
=
typenameTypeId
(
NULL
,
typename
,
&
typmod
);
Assert
(
typoid
==
INTERVALOID
);
Assert
(
typoid
==
INTERVALOID
);
interval
=
interval
=
...
@@ -5254,13 +5273,12 @@ flatten_set_variable_args(const char *name, List *args)
...
@@ -5254,13 +5273,12 @@ flatten_set_variable_args(const char *name, List *args)
DatumGetCString
(
DirectFunctionCall1
(
interval_out
,
DatumGetCString
(
DirectFunctionCall1
(
interval_out
,
interval
));
interval
));
appendStringInfo
(
&
buf
,
"INTERVAL '%s'"
,
intervalout
);
appendStringInfo
(
&
buf
,
"INTERVAL '%s'"
,
intervalout
);
/* don't leave this set */
typename
=
NULL
;
}
}
else
else
{
{
/*
* Plain string literal or identifier. For quote mode,
* quote it if it's not a vanilla identifier.
*/
if
(
flags
&
GUC_LIST_QUOTE
)
if
(
flags
&
GUC_LIST_QUOTE
)
appendStringInfoString
(
&
buf
,
quote_identifier
(
val
));
appendStringInfoString
(
&
buf
,
quote_identifier
(
val
));
else
else
...
@@ -5269,7 +5287,7 @@ flatten_set_variable_args(const char *name, List *args)
...
@@ -5269,7 +5287,7 @@ flatten_set_variable_args(const char *name, List *args)
break
;
break
;
default:
default:
elog
(
ERROR
,
"unrecognized node type: %d"
,
elog
(
ERROR
,
"unrecognized node type: %d"
,
(
int
)
nodeTag
(
&
arg
->
val
));
(
int
)
nodeTag
(
&
con
->
val
));
break
;
break
;
}
}
}
}
...
...
src/include/catalog/catversion.h
View file @
6fff5c3b
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* 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 @@
...
@@ -53,6 +53,6 @@
*/
*/
/* yyyymmddN */
/* yyyymmddN */
#define CATALOG_VERSION_NO 20080429
1
#define CATALOG_VERSION_NO 20080429
2
#endif
#endif
src/include/nodes/parsenodes.h
View file @
6fff5c3b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
* 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
...
@@ -234,17 +234,10 @@ typedef struct A_Const
{
{
NodeTag
type
;
NodeTag
type
;
Value
val
;
/* the value (with the tag) */
Value
val
;
/* the value (with the tag) */
TypeName
*
typename
;
/* typecast, or NULL if none */
}
A_Const
;
}
A_Const
;
/*
/*
* TypeCast - a CAST expression
* 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
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