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
c3a960ad
Commit
c3a960ad
authored
May 31, 1997
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for SELECT * INTO TABLE for char(), varchar() fields.
parent
ad01dd27
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
3 deletions
+79
-3
src/backend/executor/execMain.c
src/backend/executor/execMain.c
+6
-1
src/backend/executor/execUtils.c
src/backend/executor/execUtils.c
+69
-1
src/include/executor/executor.h
src/include/executor/executor.h
+4
-1
No files found.
src/backend/executor/execMain.c
View file @
c3a960ad
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.1
2 1997/04/02 04:04:11 vadim
Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.1
3 1997/05/31 16:52:00 momjian
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -531,12 +531,17 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate)
...
@@ -531,12 +531,17 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate)
intoName
=
parseTree
->
into
;
intoName
=
parseTree
->
into
;
archiveMode
=
'n'
;
archiveMode
=
'n'
;
/* fixup to prevent zero-length columns in create */
setVarAttrLenForCreateTable
(
tupType
,
targetList
,
rangeTable
);
intoRelationId
=
heap_create
(
intoName
,
intoRelationId
=
heap_create
(
intoName
,
intoName
,
/* not used */
intoName
,
/* not used */
archiveMode
,
archiveMode
,
DEFAULT_SMGR
,
DEFAULT_SMGR
,
tupType
);
tupType
);
resetVarAttrLenForCreateTable
(
tupType
);
/* ----------------
/* ----------------
* XXX rather than having to call setheapoverride(true)
* XXX rather than having to call setheapoverride(true)
* and then back to false, we should change the
* and then back to false, we should change the
...
...
src/backend/executor/execUtils.c
View file @
c3a960ad
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.
7 1997/01/10 09:58:53 vadim
Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.
8 1997/05/31 16:52:02 momjian
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -55,6 +55,8 @@
...
@@ -55,6 +55,8 @@
#include "catalog/index.h"
#include "catalog/index.h"
#include "catalog/catname.h"
#include "catalog/catname.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#include "parser/parsetree.h"
/* ----------------------------------------------------------------
/* ----------------------------------------------------------------
* global counters for number of tuples processed, retrieved,
* global counters for number of tuples processed, retrieved,
...
@@ -1122,3 +1124,69 @@ ExecInsertIndexTuples(TupleTableSlot *slot,
...
@@ -1122,3 +1124,69 @@ ExecInsertIndexTuples(TupleTableSlot *slot,
}
}
if
(
econtext
!=
NULL
)
pfree
(
econtext
);
if
(
econtext
!=
NULL
)
pfree
(
econtext
);
}
}
/* ----------------------------------------------------------------
* setVarAttrLenForCreateTable -
* called when we do a SELECT * INTO TABLE tab
* needed for attributes that have a defined length, like bpchar and
* varchar
* ----------------------------------------------------------------
*/
void
setVarAttrLenForCreateTable
(
TupleDesc
tupType
,
List
*
targetList
,
List
*
rangeTable
)
{
List
*
tl
;
TargetEntry
*
tle
;
Node
*
expr
;
int
varno
;
tl
=
targetList
;
for
(
varno
=
0
;
varno
<
tupType
->
natts
;
varno
++
)
{
tle
=
lfirst
(
tl
);
if
(
tupType
->
attrs
[
varno
]
->
atttypid
==
BPCHAROID
||
tupType
->
attrs
[
varno
]
->
atttypid
==
VARCHAROID
)
{
expr
=
tle
->
expr
;
if
(
expr
&&
IsA
(
expr
,
Var
))
{
Var
*
var
;
RangeTblEntry
*
rtentry
;
Relation
rd
;
var
=
(
Var
*
)
expr
;
rtentry
=
rt_fetch
(
var
->
varno
,
rangeTable
);
rd
=
heap_open
(
rtentry
->
relid
);
/* set length to that defined in relation */
tupType
->
attrs
[
varno
]
->
attlen
=
(
*
rd
->
rd_att
->
attrs
[
var
->
varattno
-
1
]).
attlen
;
heap_close
(
rd
);
}
else
elog
(
WARN
,
"setVarAttrLenForCreateTable: can't get length for variable-length field"
);
}
tl
=
lnext
(
tl
);
}
}
/* ----------------------------------------------------------------
* resetVarAttrLenForCreateTable -
* called when we do a SELECT * INTO TABLE tab
* needed for attributes that have a defined length, like bpchar and
* varchar
* resets length to -1 for those types
* ----------------------------------------------------------------
*/
void
resetVarAttrLenForCreateTable
(
TupleDesc
tupType
)
{
int
varno
;
for
(
varno
=
0
;
varno
<
tupType
->
natts
;
varno
++
)
{
if
(
tupType
->
attrs
[
varno
]
->
atttypid
==
BPCHAROID
||
tupType
->
attrs
[
varno
]
->
atttypid
==
VARCHAROID
)
/* set length to original -1 */
tupType
->
attrs
[
varno
]
->
attlen
=
-
1
;
}
}
src/include/executor/executor.h
View file @
c3a960ad
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
*
*
* Copyright (c) 1994, Regents of the University of California
* Copyright (c) 1994, Regents of the University of California
*
*
* $Id: executor.h,v 1.
7 1996/12/26 17:53:40
momjian Exp $
* $Id: executor.h,v 1.
8 1997/05/31 16:52:19
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -174,6 +174,9 @@ extern IndexTuple ExecFormIndexTuple(HeapTuple heapTuple,
...
@@ -174,6 +174,9 @@ extern IndexTuple ExecFormIndexTuple(HeapTuple heapTuple,
Relation
heapRelation
,
Relation
indexRelation
,
IndexInfo
*
indexInfo
);
Relation
heapRelation
,
Relation
indexRelation
,
IndexInfo
*
indexInfo
);
extern
void
ExecInsertIndexTuples
(
TupleTableSlot
*
slot
,
ItemPointer
tupleid
,
extern
void
ExecInsertIndexTuples
(
TupleTableSlot
*
slot
,
ItemPointer
tupleid
,
EState
*
estate
,
bool
is_update
);
EState
*
estate
,
bool
is_update
);
extern
void
resetVarAttrLenForCreateTable
(
TupleDesc
tupType
);
extern
void
setVarAttrLenForCreateTable
(
TupleDesc
tupType
,
List
*
targetList
,
List
*
rangeTable
);
/* ----------------------------------------------------------------
/* ----------------------------------------------------------------
...
...
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