diff options
Diffstat (limited to 'src/backend/commands/copy.c')
-rw-r--r-- | src/backend/commands/copy.c | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index f56b2ac49b0..1fd21627948 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -287,13 +287,13 @@ static const char BinarySignature[11] = "PGCOPY\n\377\r\n\0"; /* non-export function prototypes */ -static CopyState BeginCopy(ParseState *pstate, bool is_from, Relation rel, Node *raw_query, - const Oid queryRelId, List *attnamelist, +static CopyState BeginCopy(ParseState *pstate, bool is_from, Relation rel, + RawStmt *raw_query, Oid queryRelId, List *attnamelist, List *options); static void EndCopy(CopyState cstate); static void ClosePipeToProgram(CopyState cstate); -static CopyState BeginCopyTo(ParseState *pstate, Relation rel, Node *query, - const Oid queryRelId, const char *filename, bool is_program, +static CopyState BeginCopyTo(ParseState *pstate, Relation rel, RawStmt *query, + Oid queryRelId, const char *filename, bool is_program, List *attnamelist, List *options); static void EndCopyTo(CopyState cstate); static uint64 DoCopyTo(CopyState cstate); @@ -770,15 +770,17 @@ CopyLoadRawBuf(CopyState cstate) * Do not allow the copy if user doesn't have proper permission to access * the table or the specifically requested columns. */ -Oid -DoCopy(ParseState *pstate, const CopyStmt *stmt, uint64 *processed) +void +DoCopy(ParseState *pstate, const CopyStmt *stmt, + int stmt_location, int stmt_len, + uint64 *processed) { CopyState cstate; bool is_from = stmt->is_from; bool pipe = (stmt->filename == NULL); Relation rel; Oid relid; - Node *query = NULL; + RawStmt *query = NULL; List *range_table = NIL; /* Disallow COPY to/from file or program except to superusers. */ @@ -929,7 +931,10 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt, uint64 *processed) select->targetList = targetList; select->fromClause = list_make1(from); - query = (Node *) select; + query = makeNode(RawStmt); + query->stmt = (Node *) select; + query->stmt_location = stmt_location; + query->stmt_len = stmt_len; /* * Close the relation for now, but keep the lock on it to prevent @@ -945,7 +950,11 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt, uint64 *processed) { Assert(stmt->query); - query = stmt->query; + query = makeNode(RawStmt); + query->stmt = stmt->query; + query->stmt_location = stmt_location; + query->stmt_len = stmt_len; + relid = InvalidOid; rel = NULL; } @@ -981,8 +990,6 @@ DoCopy(ParseState *pstate, const CopyStmt *stmt, uint64 *processed) */ if (rel != NULL) heap_close(rel, (is_from ? NoLock : AccessShareLock)); - - return relid; } /* @@ -1364,8 +1371,8 @@ static CopyState BeginCopy(ParseState *pstate, bool is_from, Relation rel, - Node *raw_query, - const Oid queryRelId, + RawStmt *raw_query, + Oid queryRelId, List *attnamelist, List *options) { @@ -1456,7 +1463,7 @@ BeginCopy(ParseState *pstate, * function and is executed repeatedly. (See also the same hack in * DECLARE CURSOR and PREPARE.) XXX FIXME someday. */ - rewritten = pg_analyze_and_rewrite((Node *) copyObject(raw_query), + rewritten = pg_analyze_and_rewrite((RawStmt *) copyObject(raw_query), pstate->p_sourcetext, NULL, 0); /* check that we got back something we can work with */ @@ -1747,8 +1754,8 @@ EndCopy(CopyState cstate) static CopyState BeginCopyTo(ParseState *pstate, Relation rel, - Node *query, - const Oid queryRelId, + RawStmt *query, + Oid queryRelId, const char *filename, bool is_program, List *attnamelist, |