From: john guthrie <jguthrie@psynapsetech.net>
To: john guthrie <jguthrie@psynapsetech.net>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: problem with 'copy binary' file format
Date: Wed, 22 Jan 2003 12:10:18 -0500
Message-ID: <3E2ED07A.6090703@psynapsetech.net> (raw)
In-Reply-To: <3E2DB3A2.7020503@psynapsetech.net>
References: <3E2DB3A2.7020503@psynapsetech.net>
moron alert - i forgot the 'binary' in the sql i sent to postgresql,
i.e. i used:
copy my_table from 'somefile.bin';
instead of:
copy binary my_table from 'somefile.bin';
only took me a whole day to find this. sheesh!
john
john guthrie wrote:
> i am having a problem creating a 'copy binary' input file in c
> on my linux box running postgresql 7.2.2. the error message i get is:
> ERROR: copy: line 1, pg_atoi: error in "PGBCOPY": can't parse "PGBCOPY"
>
> so it looks to me like the header doesn't match what it should. my
> code creates/writes the header like this:
>
> char *bchead = "PGBCOPY\n\377\r\n\0";
> unsigned int bcsig = 0x01020304;
> unsigned int bcflags = 0x0;
> unsigned int bcext = 0x0;
>
> outFile = fopen(tmpfile, "w");
> fwrite(bchead,1,12,outFile);
> fwrite(&bcsig,1,4,outFile);
> fwrite(&bcflags,1,4,outFile);
> fwrite(&bcext,1,4,outFile);
>
> when i 'od -c' the created file, i see:
> local jguthrie> od -c /tmp/packets.bin
> 0000000 P G B C O P Y \n 377 \r \n \0 004 003 002 001
> 0000020 \0 \0 \0 \0 \0 \0 \0 \0 004 \0 377 377
> 0000034
>
> (this for a 4-field tuple with no rows in the data file).
>
> this all seems to match up with the documentation online:
> http://www.postgresql.org/idocs/index.php?sql-copy.html
>
> any help much appreciated.
>
> thanks. john.
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: jguthrie@psynapsetech.net
Subject: Re: problem with 'copy binary' file format
In-Reply-To: <3E2ED07A.6090703@psynapsetech.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox