Skip to content

Commit 9fa8379

Browse files
committed
Fix usage of new copy api
1 parent de4487b commit 9fa8379

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

contrib/pg_pathman/src/copy_stmt_hooking.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ PathmanDoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
341341
{
342342
bool is_old_protocol = PG_PROTOCOL_MAJOR(FrontendProtocol) < 3 &&
343343
stmt->filename == NULL;
344+
ParseState *pstate;
344345

345346
/* There should be relation */
346347
if (!rel) elog(FATAL, "No relation for PATHMAN COPY FROM");
@@ -350,15 +351,19 @@ PathmanDoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
350351
PreventCommandIfReadOnly("PATHMAN COPY FROM");
351352
PreventCommandIfParallelMode("PATHMAN COPY FROM");
352353

353-
cstate = BeginCopyFrom(NULL,rel, stmt->filename, stmt->is_program,
354+
pstate = make_parsestate(NULL);
355+
pstate->p_sourcetext = queryString;
356+
cstate = BeginCopyFrom(pstate,rel, stmt->filename, stmt->is_program,
354357
stmt->attlist, stmt->options);
355358
*processed = PathmanCopyFrom(cstate, rel, range_table, is_old_protocol);
356359
EndCopyFrom(cstate);
360+
free_parsestate(pstate);
357361
}
358362
/* COPY ... TO ... */
359363
else
360364
{
361365
CopyStmt modified_copy_stmt;
366+
ParseState *pstate;
362367

363368
/* We should've created a query */
364369
Assert(query);
@@ -367,9 +372,13 @@ PathmanDoCopy(const CopyStmt *stmt, const char *queryString, uint64 *processed)
367372
modified_copy_stmt = *stmt;
368373
modified_copy_stmt.relation = NULL;
369374
modified_copy_stmt.query = query;
375+
pstate = make_parsestate(NULL);
376+
pstate->p_sourcetext = queryString;
377+
370378

371379
/* Call standard DoCopy using a new CopyStmt */
372-
DoCopy(NULL,&modified_copy_stmt, processed);
380+
DoCopy(pstate,&modified_copy_stmt, processed);
381+
free_parsestate(pstate);
373382
}
374383

375384
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy