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
a8d2820e
Commit
a8d2820e
authored
May 22, 1999
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for DEFAULT ''.
parent
9710995f
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
40 additions
and
45 deletions
+40
-45
src/backend/catalog/heap.c
src/backend/catalog/heap.c
+4
-19
src/backend/parser/parse_coerce.c
src/backend/parser/parse_coerce.c
+12
-6
src/backend/parser/parse_expr.c
src/backend/parser/parse_expr.c
+5
-3
src/backend/parser/parse_func.c
src/backend/parser/parse_func.c
+4
-5
src/backend/parser/parse_node.c
src/backend/parser/parse_node.c
+2
-4
src/backend/parser/parse_relation.c
src/backend/parser/parse_relation.c
+4
-2
src/backend/parser/parse_target.c
src/backend/parser/parse_target.c
+6
-4
src/include/parser/parse_coerce.h
src/include/parser/parse_coerce.h
+3
-2
No files found.
src/backend/catalog/heap.c
View file @
a8d2820e
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.8
3 1999/05/21 18:33:12
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.8
4 1999/05/22 04:12:24
momjian Exp $
*
*
* INTERFACE ROUTINES
...
...
@@ -1538,26 +1538,11 @@ start:
if
(
type
!=
atp
->
atttypid
)
{
/*
* Though these types are binary compatible, bpchar has a fixed
* length on the disk, requiring non-bpchar types to be padded
* before storage in the default table. bjm 1999/05/18
*/
if
(
1
==
0
&&
atp
->
atttypid
==
BPCHAROID
&&
(
type
==
TEXTOID
||
type
==
BPCHAROID
||
type
==
UNKNOWNOID
))
{
FuncCall
*
n
=
makeNode
(
FuncCall
);
n
->
funcname
=
typeidTypeName
(
atp
->
atttypid
);
n
->
args
=
lcons
((
Node
*
)
expr
,
NIL
);
expr
=
transformExpr
(
NULL
,
(
Node
*
)
n
,
EXPR_COLUMN_FIRST
);
}
else
if
(
IS_BINARY_COMPATIBLE
(
type
,
atp
->
atttypid
))
if
(
IS_BINARY_COMPATIBLE
(
type
,
atp
->
atttypid
))
;
/* use without change */
else
if
(
can_coerce_type
(
1
,
&
(
type
),
&
(
atp
->
atttypid
)))
expr
=
coerce_type
(
NULL
,
(
Node
*
)
expr
,
type
,
atp
->
atttypid
);
expr
=
coerce_type
(
NULL
,
(
Node
*
)
expr
,
type
,
atp
->
atttypid
,
atp
->
atttypmod
);
else
if
(
IsA
(
expr
,
Const
))
{
if
(
*
cast
!=
0
)
...
...
src/backend/parser/parse_coerce.c
View file @
a8d2820e
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.1
4 1999/05/22 02:55:57
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.1
5 1999/05/22 04:12:26
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -35,7 +35,8 @@ static Oid PreferredType(CATEGORY category, Oid type);
* Convert a function argument to a different type.
*/
Node
*
coerce_type
(
ParseState
*
pstate
,
Node
*
node
,
Oid
inputTypeId
,
Oid
targetTypeId
)
coerce_type
(
ParseState
*
pstate
,
Node
*
node
,
Oid
inputTypeId
,
Oid
targetTypeId
,
int32
atttypmod
)
{
Node
*
result
=
NULL
;
Oid
infunc
;
...
...
@@ -82,11 +83,16 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId)
con
->
consttype
=
targetTypeId
;
con
->
constlen
=
typeLen
(
typeidType
(
targetTypeId
));
/* use "-1" for varchar() type */
/*
* Use "-1" for varchar() type.
* For char(), we need to pad out the type with the proper
* number of spaces. This was a major problem for
* DEFAULT string constants to char() types.
*/
con
->
constvalue
=
(
Datum
)
fmgr
(
infunc
,
val
,
typeidTypElem
(
targetTypeId
),
-
1
);
(
targetTypeId
!=
BPCHAROID
)
?
-
1
:
atttypmod
);
con
->
constisnull
=
false
;
con
->
constbyval
=
typeByVal
(
typeidType
(
targetTypeId
));
con
->
constisset
=
false
;
...
...
@@ -100,7 +106,7 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, Oid targetTypeId)
result
=
node
;
return
result
;
}
/* coerce_type() */
}
/* can_coerce_type()
...
...
@@ -178,7 +184,7 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids)
}
return
true
;
}
/* can_coerce_type() */
}
/* TypeCategory()
...
...
src/backend/parser/parse_expr.c
View file @
a8d2820e
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.4
6 1999/05/18 23:40:05 tgl
Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.4
7 1999/05/22 04:12:26 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -417,7 +417,8 @@ transformExpr(ParseState *pstate, Node *expr, int precedence)
}
else
if
(
can_coerce_type
(
1
,
&
c
->
casetype
,
&
ptype
))
{
c
->
defresult
=
coerce_type
(
pstate
,
c
->
defresult
,
c
->
casetype
,
ptype
);
c
->
defresult
=
coerce_type
(
pstate
,
c
->
defresult
,
c
->
casetype
,
ptype
,
-
1
);
c
->
casetype
=
ptype
;
}
else
...
...
@@ -439,7 +440,8 @@ transformExpr(ParseState *pstate, Node *expr, int precedence)
{
if
(
can_coerce_type
(
1
,
&
wtype
,
&
ptype
))
{
w
->
result
=
coerce_type
(
pstate
,
w
->
result
,
wtype
,
ptype
);
w
->
result
=
coerce_type
(
pstate
,
w
->
result
,
wtype
,
ptype
,
-
1
);
}
else
{
...
...
src/backend/parser/parse_func.c
View file @
a8d2820e
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.4
4 1999/05/17 17:03:33
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.4
5 1999/05/22 04:12:27
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -352,7 +352,6 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
}
else
{
/*
* Parsing aggregates.
*/
...
...
@@ -361,7 +360,6 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
int
ncandidates
;
CandidateList
candidates
;
/*
* the aggregate COUNT is a special case, ignore its base
* type. Treat it as zero
...
...
@@ -392,7 +390,8 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
type
=
agg_select_candidate
(
basetype
,
candidates
);
if
(
OidIsValid
(
type
))
{
lfirst
(
fargs
)
=
coerce_type
(
pstate
,
lfirst
(
fargs
),
basetype
,
type
);
lfirst
(
fargs
)
=
coerce_type
(
pstate
,
lfirst
(
fargs
),
basetype
,
type
,
-
1
);
basetype
=
type
;
return
(
Node
*
)
ParseAgg
(
pstate
,
funcname
,
basetype
,
...
...
@@ -1316,7 +1315,7 @@ make_arguments(ParseState *pstate,
lfirst
(
current_fargs
)
=
coerce_type
(
pstate
,
lfirst
(
current_fargs
),
input_typeids
[
i
],
function_typeids
[
i
]);
function_typeids
[
i
]
,
-
1
);
}
}
}
...
...
src/backend/parser/parse_node.c
View file @
a8d2820e
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.2
5 1999/05/10 00:45:28
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.2
6 1999/05/22 04:12:27
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -75,9 +75,7 @@ make_operand(char *opname,
/* must coerce? */
if
(
true_typeId
!=
orig_typeId
)
{
result
=
coerce_type
(
NULL
,
tree
,
orig_typeId
,
true_typeId
);
}
result
=
coerce_type
(
NULL
,
tree
,
orig_typeId
,
true_typeId
,
-
1
);
}
/* otherwise, this is a NULL value */
else
...
...
src/backend/parser/parse_relation.c
View file @
a8d2820e
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.2
0 1999/05/17 17:03:34
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.2
1 1999/05/22 04:12:28
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -445,7 +445,9 @@ checkTargetTypes(ParseState *pstate, char *target_colname,
{
if
(
can_coerce_type
(
1
,
&
attrtype_id
,
&
attrtype_target
))
{
Node
*
expr
=
coerce_type
(
pstate
,
expr
,
attrtype_id
,
attrtype_target
);
Node
*
expr
=
coerce_type
(
pstate
,
expr
,
attrtype_id
,
attrtype_target
,
get_atttypmod
(
pstate
->
p_target_relation
->
rd_id
,
resdomno_target
));
elog
(
ERROR
,
"Type %s(%d) can be coerced to match target column %s(%d)"
,
colname
,
get_atttypmod
(
rte
->
relid
,
resdomno_id
),
...
...
src/backend/parser/parse_target.c
View file @
a8d2820e
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.3
7 1999/05/17 17:03:35
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.3
8 1999/05/22 04:12:28
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -121,7 +121,9 @@ MakeTargetEntryIdent(ParseState *pstate,
{
if
(
can_coerce_type
(
1
,
&
attrtype_id
,
&
attrtype_target
))
{
expr
=
coerce_type
(
pstate
,
node
,
attrtype_id
,
attrtype_target
);
expr
=
coerce_type
(
pstate
,
node
,
attrtype_id
,
attrtype_target
,
get_atttypmod
(
pstate
->
p_target_relation
->
rd_id
,
resdomno_target
));
expr
=
transformExpr
(
pstate
,
expr
,
EXPR_COLUMN_FIRST
);
tent
=
MakeTargetEntryExpr
(
pstate
,
*
resname
,
expr
,
false
,
false
);
expr
=
tent
->
expr
;
...
...
@@ -666,7 +668,7 @@ CoerceTargetExpr(ParseState *pstate,
{
if
(
can_coerce_type
(
1
,
&
type_id
,
&
attrtype
))
{
expr
=
coerce_type
(
pstate
,
expr
,
type_id
,
attrtype
);
expr
=
coerce_type
(
pstate
,
expr
,
type_id
,
attrtype
,
-
1
);
}
#ifndef DISABLE_STRING_HACKS
...
...
@@ -683,7 +685,7 @@ CoerceTargetExpr(ParseState *pstate,
{
}
else
if
(
can_coerce_type
(
1
,
&
type_id
,
&
text_id
))
expr
=
coerce_type
(
pstate
,
expr
,
type_id
,
text_id
);
expr
=
coerce_type
(
pstate
,
expr
,
type_id
,
text_id
,
-
1
);
else
expr
=
NULL
;
}
...
...
src/include/parser/parse_coerce.h
View file @
a8d2820e
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: parse_coerce.h,v 1.
9 1999/03/10 05:05:58 tgl
Exp $
* $Id: parse_coerce.h,v 1.
10 1999/05/22 04:12:29 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -121,6 +121,7 @@ extern bool IsPreferredType(CATEGORY category, Oid type);
extern
CATEGORY
TypeCategory
(
Oid
type
);
extern
bool
can_coerce_type
(
int
nargs
,
Oid
*
input_typeids
,
Oid
*
func_typeids
);
extern
Node
*
coerce_type
(
ParseState
*
pstate
,
Node
*
node
,
Oid
inputTypeId
,
Oid
targetTypeId
);
extern
Node
*
coerce_type
(
ParseState
*
pstate
,
Node
*
node
,
Oid
inputTypeId
,
Oid
targetTypeId
,
int32
atttypmod
);
#endif
/* PARSE_COERCE_H */
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