copy.c revision c5c4113dfcabb1eed3d4bdf7609de5170027a794
#pragma ident "%Z%%M% %I% %E% SMI"
/*
** 2003 April 6
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains code used to implement the COPY command.
**
** $Id: copy.c,v 1.9 2004/02/25 13:47:31 drh Exp $
*/
#include "sqliteInt.h"
/*
** The COPY command is for compatibility with PostgreSQL and specificially
** for the ability to read the output of pg_dump. The format is as
** follows:
**
** COPY table FROM file [USING DELIMITERS string]
**
** "table" is an existing table name. We will read lines of code from
** file to fill this table with data. File might be "stdin". The optional
** delimiter string identifies the field separators. The default is a tab.
*/
void sqliteCopy(
int onError /* What to do if a constraint fails */
){
int i;
Vdbe *v;
char *zFile = 0;
const char *zDb;
if( sqlite_malloc_failed ) goto copy_cleanup;
goto copy_cleanup;
}
v = sqliteGetVdbe(pParse);
if( v ){
sqliteVdbeDequoteP3(v, addr);
}
end = sqliteVdbeMakeLabel(v);
if( pDelimiter ){
sqliteVdbeDequoteP3(v, addr);
}else{
}
sqliteVdbeAddOp(v, OP_MustBeInt, 0, 0);
}else{
sqliteVdbeAddOp(v, OP_NewRecno, 0, 0);
}
/* The integer primary key column is filled with NULL since its
** value is always pulled from the record number */
sqliteVdbeAddOp(v, OP_String, 0, 0);
}else{
sqliteVdbeAddOp(v, OP_FileColumn, i, 0);
}
}
}
sqliteVdbeAddOp(v, OP_Noop, 0, 0);
}
}
return;
}