/* these are just for error messages, see CopyFromErrorCallback */
const char *cur_relname; /* table name for error messages */
- int cur_lineno; /* line number for error messages */
+ uint64 cur_lineno; /* line number for error messages */
const char *cur_attname; /* current att for error messages */
const char *cur_attval; /* current att value for error messages */
ResultRelInfo *resultRelInfo, TupleTableSlot *myslot,
BulkInsertState bistate,
int nBufferedTuples, HeapTuple *bufferedTuples,
- int firstBufferedLineNo);
+ uint64 firstBufferedLineNo);
static bool CopyReadLine(CopyState cstate);
static bool CopyReadLineText(CopyState cstate);
static int CopyReadAttributesText(CopyState cstate);
CopyFromErrorCallback(void *arg)
{
CopyState cstate = (CopyState) arg;
+ char curlineno_str[32];
+
+ snprintf(curlineno_str, sizeof(curlineno_str), UINT64_FORMAT,
+ cstate->cur_lineno);
if (cstate->binary)
{
/* can't usefully display the data */
if (cstate->cur_attname)
- errcontext("COPY %s, line %d, column %s",
- cstate->cur_relname, cstate->cur_lineno,
+ errcontext("COPY %s, line %s, column %s",
+ cstate->cur_relname, curlineno_str,
cstate->cur_attname);
else
- errcontext("COPY %s, line %d",
- cstate->cur_relname, cstate->cur_lineno);
+ errcontext("COPY %s, line %s",
+ cstate->cur_relname, curlineno_str);
}
else
{
char *attval;
attval = limit_printout_length(cstate->cur_attval);
- errcontext("COPY %s, line %d, column %s: \"%s\"",
- cstate->cur_relname, cstate->cur_lineno,
+ errcontext("COPY %s, line %s, column %s: \"%s\"",
+ cstate->cur_relname, curlineno_str,
cstate->cur_attname, attval);
pfree(attval);
}
else if (cstate->cur_attname)
{
/* error is relevant to a particular column, value is NULL */
- errcontext("COPY %s, line %d, column %s: null input",
- cstate->cur_relname, cstate->cur_lineno,
+ errcontext("COPY %s, line %s, column %s: null input",
+ cstate->cur_relname, curlineno_str,
cstate->cur_attname);
}
else
char *lineval;
lineval = limit_printout_length(cstate->line_buf.data);
- errcontext("COPY %s, line %d: \"%s\"",
- cstate->cur_relname, cstate->cur_lineno, lineval);
+ errcontext("COPY %s, line %s: \"%s\"",
+ cstate->cur_relname, curlineno_str, lineval);
pfree(lineval);
}
else
{
- errcontext("COPY %s, line %d",
- cstate->cur_relname, cstate->cur_lineno);
+ errcontext("COPY %s, line %s",
+ cstate->cur_relname, curlineno_str);
}
}
}
#define MAX_BUFFERED_TUPLES 1000
HeapTuple *bufferedTuples = NULL; /* initialize to silence warning */
Size bufferedTuplesSize = 0;
- int firstBufferedLineNo = 0;
+ uint64 firstBufferedLineNo = 0;
Assert(cstate->rel);
int hi_options, ResultRelInfo *resultRelInfo,
TupleTableSlot *myslot, BulkInsertState bistate,
int nBufferedTuples, HeapTuple *bufferedTuples,
- int firstBufferedLineNo)
+ uint64 firstBufferedLineNo)
{
MemoryContext oldcontext;
int i;
- int save_cur_lineno;
+ uint64 save_cur_lineno;
/*
* Print error context information correctly, if one of the operations