我正在尝试使用COPY命令将数据库表导入Postgres 9.3.5数据库服务器,如下所示:
COPY comment (generatedid, id, "timestamp", message, bugreport_id, personcontainer_id) FROM stdin;
1 12840538 2010-03-03 09:50:46 How is that an error in HttpClient? Don't buffer large content in memory, or configure memory in your VM appropriately. HTTPCLIENT-922 102
2 12841503 2010-03-04 21:36:13 Thanks for having a look!<br/><br/>I explored and found problem is with org.apache.james.mime4j.util.CharsetUtil of mime4j jar. It tries to load all available charset classes present under JVM.<br/><br/>I know memory for Perm Gen can be increased but there would be limit. I have increased it and would be doing a round of load testing. If it still consumes whole allocated space I would be putting some fix on CharsetUtil.<br/><br/>Stack trace for reference:<br/>-----------------------------------------<br/>java.lang.OutOfMemoryError: PermGen space<br/> at sun.nio.cs.ext.IBM970$Encoder.<clinit>(IBM970.java:2688)<br/> at sun.nio.cs.ext.IBM970.newEncoder(IBM970.java:45)<br/> at java.lang.StringCoding$StringEncoder.<init>(StringCoding.java:215)<br/> at java.lang.StringCoding$StringEncoder.<init>(StringCoding.java:207)<br/> at java.lang.StringCoding.encode(StringCoding.java:266)<br/> at java.lang.String.getBytes(String.java:947)<br/> at org.apache.james.mime4j.util.CharsetUtil.<clinit>(CharsetUtil.java:1028)<br/> at org.apache.http.entity.mime.MIME.<clinit>(MIME.java:51)<br/> at org.apache.http.entity.mime.HttpMultipart.<clinit>(HttpMultipart.java:85)<br/> at org.apache.http.entity.mime.MultipartEntity.<init>(MultipartEntity.java:78)<br/> at org.apache.http.entity.mime.MultipartEntity.<init>(MultipartEntity.java:101)<br/><br/> HTTPCLIENT-922 103
但我导入的所有数据都有错误(我上面只显示了2行数据以显示所有错误),如:
ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "}" LINE 1: }<br/> ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "break" LINE 1: break; ^ ERROR: syntax error at or near "<" LINE 1: <br/><br/>Recompiling after this change and trying again the... ^ ERROR: syntax error at or near "ll" LINE 1: ll provide a fix for CVS<br/>HEAD tomorrow. My apologies.<br... ^ ERROR: syntax error at or near "Cookie" LINE 1: Cookie' ^ ERROR: syntax error at or near "headers" LINE 1: headers only.<br/><br/>Oleg HTTPCLIENT-292 28066 ^ ERROR: syntax error at or near "t" LINE 1: t had a chance to try this patch out, but if it works for yo... ^ ERROR: syntax error at or near "s" LINE 1: s<br/>good enough for me.<br/><br/>Mike HTTPCLIENT-292 28068 ^ ERROR: syntax error at or near "d" LINE 1: d feel better if someone else had a look.<br/><br/>Oleg HTTP... ^ ERROR: syntax error at or near "ll" LINE 1: ll try to come up with something more elegant for the 2.1 br... ^ ERROR: syntax error at or near "t" LINE 1: t think either<br/>patch 2 or 3 handles this case, unless (i... ^ ERROR: syntax error at or near "What" LINE 1: What we really need is a way to remove NTLM headers after th... ^ ERROR: syntax error at or near "authentication" LINE 1: authentication has succeeded.<br/>Agreed. However, that stil... ^ ERROR: syntax error at or near "<" LINE 1: <br/>if ("NTLM".equalsIgnoreCase(authscheme.getSch... ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "//" LINE 1: // clean up<br/>}<br/><br/>As far as HEAD CVS goes, there ar... ^ ERROR: syntax error at or near "t" LINE 1: t not<br/>pretty, but that appears to be the only option we ... ^ ERROR: syntax error at or near "ll" LINE 1: ll be working on a more elegant fix for the CVS HEAD<br/><br... ^ ERROR: syntax error at or near "s" LINE 1: s the only real choice for 2.0.<br/><br/>Mike HTTPCLIENT-292... ^ ERROR: syntax error at or near "m" LINE 1: m currently unable to test it and it could take a couple of ... ^ ERROR: syntax error at or near "Digest" LINE 1: Digest schemes still need to be refactored to take<br/>advan... ^ ERROR: syntax error at or near "code" LINE 1: code> ^ ERROR: syntax error at or near "public" LINE 1: public OutputStream getRequestOutputStream(boolean <br/>useC... ^ ERROR: syntax error at or near "/" LINE 1: /code> ^ ERROR: syntax error at or near "<" LINE 1: <br/><br/>The PutMethod does allow for chunking with the fun... ^ ERROR: syntax error at or near "code" LINE 1: code> ^ unrecognized boolean value; assuming "on". Showing only tuples. \t: extra argument "Jun" ignored \t: extra argument "02" ignored \t: extra argument "00:39:55" ignored \t: extra argument "GMT+00:00" ignored \t: extra argument "20090)" ignored \t: extra argument "seems" ignored \t: extra argument "broken.<br/><br/> [java]" ignored \t: extra argument "2009/06/02" ignored \t: extra argument "13:14:12:150" ignored \t: extra argument "CEST" ignored \t: extra argument "[DEBUG]" ignored \t: extra argument "SingleClientConnManager" ignored \t: extra argument "-" ignored \t: extra argument "Get" ignored \t: extra argument "connection" ignored \t: extra argument "for" ignored \t: extra argument "route" ignored \t: extra argument "HttpRoute[{}-><a" ignored \t: extra argument "href="http://www.seoconsultants.com">http://www.seoconsultants.com</a>]<br/> [java]" ignored \t: extra argument "2009/06/02" ignored \t: extra argument "13:14:12:334" ignored \t: extra argument "CEST" ignored \t: extra argument "[DEBUG]" ignored \t: extra argument "ClientParamsStack" ignored \t: extra argument "-" ignored \t: extra argument "'http.tcp.nodelay':" ignored \t: extra argument "true<br/> [java]" ignored \t: extra argument "2009/06/02" ignored \t: extra argument "13:14:12:335" ignored \t: extra argument "CEST" ignored \t: extra argument "[DEBUG]" ignored \t: extra argument "ClientParamsStack" ignored \t: extra argument "-" ignored \t: extra argument "'http.socket.buffer-size':" ignored \t: extra argument "8192<br/> [java]" ignored \t: extra argument "2009/06/02" ignored \t: extra argument "13:14:12:360" ignored \t: extra argument "CEST" ignored \t: extra argument "[DEBUG]" ignored \t: extra argument "ClientParamsStack" ignored \t: extra argument "-" ignored \t: extra argument "'http.protocol.version':" ignored \t: extra argument "HTTP/1.1<br/> [java]" ignored \t: extra argument "2009/06/02" ignored \t: extra argument "13:14:12:361" ignored \t: extra argument "CEST" ignored \t: extra argument "[DEBUG]" ignored \t: extra argument "ClientParamsStack" ignored \t: extra argument "-" ignored \t: extra argument "'http.useragent':" ignored \t: extra argument "Mozilla/5.0" ignored \t: extra argument "(Macintosh;" ignored \t: extra argument "U;" ignored \t: extra argument "Intel" ignored \t: extra argument "Mac" ignored \t: extra argument "OS" ignored \t: extra argument "X" ignored \t: extra argument "10.5;" ignored \t: extra argument "en-US;" ignored \t: extra argument "rv:1.9.0.10)" ignored \t: extra argument "Gecko/2009042315" ignored \t: extra argument "Firefox/3.0.10<br/> [java]" ignored \t: extra argument "2009/06/02" ignored \t: extra argument "13:14:12:362" ignored \t: extra argument "CEST" ignored \t: extra argument "[DEBUG]" ignored \t: extra argument "RequestAddCookies" ignored \t: extra argument "-" ignored \t: extra argument "CookieSpec" ignored \t: extra argument "selected:" ignored \t: extra argument "best-match<br/> [java]" ignored \t: extra argument "2009/06/02" ignored \t: extra argument "13:14:12:362" ignored \t: extra argument "CEST" ignored \t: extra argument "[DEBUG]" ignored \t: extra argument "DefaultClientConnection" ignored \t: extra argument "-" ignored \t: extra argument "Connection" ignored \t: extra argument "shut" ignored \t: extra argument "down<br/> [java]" ignored \t: extra argument "2009/06/02" ignored \t: extra argument "13:14:12:363" ignored \t: extra argument "CEST" ignored \t: extra argument "[DEBUG]" ignored \t: extra argument "SingleClientConnManager" ignored \t: extra argument "-" ignored \t: extra argument "Releasing" ignored \t: extra argument "connection" ignored \t: extra argument "org.apache.http.impl.conn.SingleClientConnManager$<a" ignored \t: extra argument "href='mailto:ConnAdapter@3136e5'>ConnAdapter@3136e5</a><br/> [java]" ignored \t: extra argument "Exception" ignored \t: extra argument "in" ignored \t: extra argument "thread" ignored \t: extra argument ""main"" ignored \t: extra argument "java.lang.ClassCastException:" ignored \t: extra argument "org.apache.http.auth.AuthSchemeRegistry<br/>   [java]" ignored invalid command \tat ERROR: syntax error at or near "conn" LINE 1: conn.getRequestOutputStream((isHttp11() && (null == ... ^ ERROR: syntax error at or near "ve" LINE 1: ve made something wrong in compilation process because the c... ^ ERROR: syntax error at or near "d" LINE 1: d attached successfully works in production nowadays. HTTPCL... ^ invalid command \ ERROR: syntax error at or near "ve" LINE 1: ve tried to use your code. I downloaded the source code of H... ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "Roland" LINE 1: Roland<br/> HTTPCLIENT-579 28761 ^ ERROR: syntax error at or near "s" LINE 1: s not a problem for me to provide a totally functioning exam... ^ ERROR: syntax error at or near "t" LINE 1: t attach example in this topic because it' ^ ERROR: syntax error at or near "s" LINE 1: s closed.<br/><br/>Just send me your emails in a private mes... ^ ERROR: syntax error at or near "ll" LINE 1: ll share the example.<br/> HTTPCLIENT-579 28762 ^ ERROR: syntax error at or near "ve" LINE 1: ve added a patch to the code you provided above to handle th... ^ ERROR: syntax error at or near "Require" LINE 1: Require NTLMv2 session security" ^ ERROR: syntax error at or near "is" LINE 1: is set as an option inside " ^ ERROR: syntax error at or near "Network" LINE 1: Network security: Minimum session security for NTLM SSP base... ^ ERROR: syntax error at or near "." LINE 1: .<br/><br/>The changes I made were a result of reading of: <... ^ ERROR: syntax error at or near "d" LINE 1: d happily licence my change under the Apache Licence, I don&... ^ ERROR: syntax error at or near "t" LINE 1: t believe it' ^ ERROR: syntax error at or near "s" LINE 1: s allowed as the original patch was under the LGPL.<br/><br/... ^ ERROR: syntax error at or near "s" LINE 1: s request that we can create an external project (on sourcef... ^ ERROR: syntax error at or near "m" LINE 1: m running the same issue like Zhao had. What was the resolu... ^ ERROR: syntax error at or near "s" LINE 1: s unclear about resolution ' ^ ERROR: syntax error at or near "Won" LINE 1: Won' ^ ERROR: syntax error at or near "t" LINE 1: t Fix ' ^ ERROR: syntax error at or near "?<" LINE 1: ?<br/><br/>However, HttpClient 4.0 is capable of supporting ... ^ ERROR: syntax error at or near "s" LINE 1: s not illegal. It' ^ ERROR: syntax error at or near "s" LINE 1: s just that you create a package that is probably no longer ... ^ ERROR: syntax error at or near "s" LINE 1: s the reason why we cannot provide this out of the box. What... ^ ERROR: syntax error at or near "s" LINE 1: s license terms you will need to check with a software licen... ^ ERROR: syntax error at or near "ve" LINE 1: ve decided to attach complete example of integration Axis, H... ^ ERROR: syntax error at or near "d" LINE 1: d recommend you before sending your requests to figure out h... ^ ERROR: syntax error at or near "s" LINE 1: s the problem? HTTPCLIENT-579 28773 ^ ERROR: syntax error at or near "project" LINE 1: project name=" ^ ERROR: syntax error at or near "casau" LINE 1: casau" ^ ERROR: syntax error at or near "default" LINE 1: default=" ^ ERROR: syntax error at or near "main" LINE 1: main" ^ ERROR: syntax error at or near "&" LINE 1: > ^ ERROR: syntax error at or near "<" LINE 1: <br/> ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: < ^ ERROR: syntax error at or near "target" LINE 1: target name=" ^ ERROR: syntax error at or near "main" LINE 1: main" ^ ERROR: syntax error at or near "&" LINE 1: > ^ ERROR: syntax error at or near "<" LINE 1: <br/> ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: < ^ ERROR: syntax error at or near "javac" LINE 1: javac srcdir=" ^ ERROR: syntax error at or near "." LINE 1: ." ^ ERROR: syntax error at or near "destdir" LINE 1: destdir=" ^ ERROR: syntax error at or near "." LINE 1: ." ^ ERROR: syntax error at or near "deprecation" LINE 1: deprecation=" ^ ERROR: syntax error at or near "yes" LINE 1: yes" ^ ERROR: syntax error at or near "debug" LINE 1: debug=" ^ ERROR: syntax error at or near "yes" LINE 1: yes" ^ ERROR: syntax error at or near "<" LINE 1: <br/> ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "classpath" LINE 1: classpath=" ^ ERROR: syntax error at or near ".." LINE 1: ../lib/commons-logging-1.0.4.jar; ^ ERROR: syntax error at or near ".." LINE 1: ../lib/commons-codec-1.3.jar; ^ ERROR: syntax error at or near ".." LINE 1: ../lib/commons-httpclient-3.0-ntlm-2.0.jar" ^ ERROR: syntax error at or near "&" LINE 1: > ^ ERROR: syntax error at or near "<" LINE 1: <br/> ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: ^ ERROR: syntax error at or near "&" LINE 1: < ^ ERROR: syntax error at or near "include" LINE 1: include name=" ^ ERROR: syntax error at or near "**" LINE 1: **/*.java"/><br/> </javac&... ^
如何避免这些错误?我可以在COPY命令或导入的数据中仅使用一种更改来解决所有错误吗?
答案 0 :(得分:0)
以下程序将清理输入数据。
#include <stdio.h>
#include <string.h>
/**
** cleantab.c: correct tab-separated dumpfile in which tabs have been expanded
** to spaces.
** input is from stdin; output goes to stdout.
** Note : space and tab in the input are seen as single whithespace,
** so multipe tabs *without* non whites betweesn them are merged into ones
** (for the Postgres .tsv file this could only happen on fields
** that originally were NULL)
** /
/** Test data
1 42 2015-03-13 12:12:13 wat the fuck &#sssdd hiero </html> nog-een-string 13
2 442 2015-03-13 13:13:13 wat the sia uck &#nss dd daaro </html>kut nog-een-string 13
*/
char bigbuff[1024*1024];
struct witje {
size_t off;
size_t len;
} witjes[16*1024];
size_t parse_line( char *str, struct witje *arr);
void dump_chunks(char *str, struct witje *arr, size_t nwit);
void dump_nchar(char *str, size_t nchar);
void dump_nchar_notab(char *str, size_t nchar);
int main(void)
{
size_t nwit,iwit;
for ( ; fgets(bigbuff, sizeof bigbuff, stdin); ) {
nwit = parse_line(bigbuff, witjes);
#if 0
for (iwit = 0; iwit < nwit; iwit++ ) {
fprintf(stderr,"[%zu] %zu+%zu\n"
, iwit, witjes[iwit].off , witjes[iwit].len );
}
#endif
dump_chunks(bigbuff, witjes , nwit);
}
return 0;
}
size_t parse_line( char *str, struct witje *arr)
{
size_t len, pos, idx;
for(len= pos= idx=0; str[pos]; pos += len) {
arr[idx].off = pos; /* position of whitespace */
len = strspn(str+pos, " \t\n\r" );
pos += len;
arr[idx++].len = len; /* length of whitespace */
len = strcspn(str+pos, " \t\n\r" );
}
return idx;
}
void dump_chunks(char *str, struct witje *arr, size_t nwit)
{
size_t iwit, pos;
for ( pos= iwit = 0; iwit < nwit; iwit++ ) {
// if (iwit ==0 && arr[iwit].off == 0 && arr[iwit].len ==0) { iwit++; nwit--; continue; }
if (arr[iwit].off >pos) dump_nchar(str+pos, arr[iwit].off -pos); /* payload */
pos = arr[iwit].off ;
if (arr[iwit].len) switch (iwit) {
case 0:
case 1:
case 2:
dump_nchar("\t", 1); /* tab */
break;
case 3:
dump_nchar(" ", 1); /* the space between date and time*/
break;
default:
if (iwit == nwit -1) dump_nchar("\n", 1); /* nl */
else if (iwit >= nwit -3) dump_nchar("\t", 1); /* tab */
else dump_nchar_notab(str+pos, arr[iwit].len) ; /* whitespace */
break;
}
pos += arr[iwit].len ;
}
}
void dump_nchar(char *str, size_t nchar) {
while (nchar--) putc(*str++, stdout);
}
void dump_nchar_notab(char *str, size_t nchar) {
for ( ;nchar--; str++) putc(*str == '\t' ? ' ' : *str, stdout);
}
答案 1 :(得分:0)
我不知道但是我用一个奇怪的命令解决了这种情况:GRANT ALL ON SCHEMA schema_name到psql_roler_name。我输入恢复命令后工作正常。有人能解释一下吗?