Thread: COPY error

COPY error

From
"Nupur Pande"
Date:
Hi,
I'm trying to copy data from an excel file into a postgres table. I saved
the file in .txt format (tab delimited) from Excel (running on Windows XP
machine) and then ran the d2u utility on the .txt file to convert it into
unix format on cygwin. The command I executed was COPY [table_name] from
[full path of file name].
I get the following error message:
ERROR:  copy: line 1520, Extra data after last expected column
ERROR:  copy: line 1520, Extra data after last expected column

Could someone please tell me what I did wrong? I checked the excel table and
I can't see any extra information on that line.

Thanks a lot..
Nupur


Re: COPY error

From
Bruce Momjian
Date:
My guess is that the file is carriage-return/newline terminated.  Change
it to newline-only.  This is fixed in 7.4beta5.

---------------------------------------------------------------------------

Nupur Pande wrote:
> Hi,
> I'm trying to copy data from an excel file into a postgres table. I saved
> the file in .txt format (tab delimited) from Excel (running on Windows XP
> machine) and then ran the d2u utility on the .txt file to convert it into
> unix format on cygwin. The command I executed was COPY [table_name] from
> [full path of file name].
> I get the following error message:
> ERROR:  copy: line 1520, Extra data after last expected column
> ERROR:  copy: line 1520, Extra data after last expected column
>
> Could someone please tell me what I did wrong? I checked the excel table and
> I can't see any extra information on that line.
>
> Thanks a lot..
> Nupur
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
>                http://archives.postgresql.org
>

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: COPY error

From
"Nupur Pande"
Date:
Hi,
I'm using 7.3.2.. I tried to find 7.4beta5 but couldn't find it on any of
the cywin mirror sites, only on postgresql.org. Also, I ran d2u again on the
file to generate a new text file and now I get a new error when I try to
copy the data to the database:

ERROR:  parser: parse error at or near "'/home/Nupur/Pine2_Results'" at
character 20
ERROR:  parser: parse error at or near "'/home/Nupur/Pine2_Results'" at
character 20

I haven't changed anything in the file from the previous time except running
d2u on it again..

Also, I'm not sure how to change the file to newline-only.

Thanks for your help,
Nupur

----- Original Message -----
From: "Bruce Momjian" <pgman@candle.pha.pa.us>
To: "Nupur Pande" <npande@vt.edu>
Cc: <pgsql-cygwin@postgresql.org>
Sent: Thursday, October 30, 2003 1:26 PM
Subject: Re: [CYGWIN] COPY error


>
> My guess is that the file is carriage-return/newline terminated.  Change
> it to newline-only.  This is fixed in 7.4beta5.
>
> --------------------------------------------------------------------------
-
>
> Nupur Pande wrote:
> > Hi,
> > I'm trying to copy data from an excel file into a postgres table. I
saved
> > the file in .txt format (tab delimited) from Excel (running on Windows
XP
> > machine) and then ran the d2u utility on the .txt file to convert it
into
> > unix format on cygwin. The command I executed was COPY [table_name] from
> > [full path of file name].
> > I get the following error message:
> > ERROR:  copy: line 1520, Extra data after last expected column
> > ERROR:  copy: line 1520, Extra data after last expected column
> >
> > Could someone please tell me what I did wrong? I checked the excel table
and
> > I can't see any extra information on that line.
> >
> > Thanks a lot..
> > Nupur
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 6: Have you searched our list archives?
> >
> >                http://archives.postgresql.org
> >
>
> --
>   Bruce Momjian                        |  http://candle.pha.pa.us
>   pgman@candle.pha.pa.us               |  (610) 359-1001
>   +  If your life is a hard drive,     |  13 Roberts Road
>   +  Christ can be your backup.        |  Newtown Square, Pennsylvania
19073
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
>       subscribe-nomail command to majordomo@postgresql.org so that your
>       message can get through to the mailing list cleanly


Re: COPY error

From
"Nupur Pande"
Date:
Sorry about the last email. I made a dumb mistake. I'm still getting the
copy error though
ERROR:  copy: line 1520, Extra data after last expected column
ERROR:  copy: line 1520, Extra data after last expected column

Also, line 1520 is not the last line in the file, it's in the middle. Does
postgresql have a limit on the number of rows in a table? What did you mean
by changing the file to newline-only?

Thanks again..

----- Original Message -----
From: "Nupur Pande" <npande@vt.edu>
To: "Bruce Momjian" <pgman@candle.pha.pa.us>
Cc: <pgsql-cygwin@postgresql.org>
Sent: Thursday, October 30, 2003 2:53 PM
Subject: Re: [CYGWIN] COPY error


> Hi,
> I'm using 7.3.2.. I tried to find 7.4beta5 but couldn't find it on any of
> the cywin mirror sites, only on postgresql.org. Also, I ran d2u again on
the
> file to generate a new text file and now I get a new error when I try to
> copy the data to the database:
>
> ERROR:  parser: parse error at or near "'/home/Nupur/Pine2_Results'" at
> character 20
> ERROR:  parser: parse error at or near "'/home/Nupur/Pine2_Results'" at
> character 20
>
> I haven't changed anything in the file from the previous time except
running
> d2u on it again..
>
> Also, I'm not sure how to change the file to newline-only.
>
> Thanks for your help,
> Nupur
>
> ----- Original Message -----
> From: "Bruce Momjian" <pgman@candle.pha.pa.us>
> To: "Nupur Pande" <npande@vt.edu>
> Cc: <pgsql-cygwin@postgresql.org>
> Sent: Thursday, October 30, 2003 1:26 PM
> Subject: Re: [CYGWIN] COPY error
>
>
> >
> > My guess is that the file is carriage-return/newline terminated.  Change
> > it to newline-only.  This is fixed in 7.4beta5.
> >
>
> --------------------------------------------------------------------------
> -
> >
> > Nupur Pande wrote:
> > > Hi,
> > > I'm trying to copy data from an excel file into a postgres table. I
> saved
> > > the file in .txt format (tab delimited) from Excel (running on Windows
> XP
> > > machine) and then ran the d2u utility on the .txt file to convert it
> into
> > > unix format on cygwin. The command I executed was COPY [table_name]
from
> > > [full path of file name].
> > > I get the following error message:
> > > ERROR:  copy: line 1520, Extra data after last expected column
> > > ERROR:  copy: line 1520, Extra data after last expected column
> > >
> > > Could someone please tell me what I did wrong? I checked the excel
table
> and
> > > I can't see any extra information on that line.
> > >
> > > Thanks a lot..
> > > Nupur
> > >
> > >
> > > ---------------------------(end of
broadcast)---------------------------
> > > TIP 6: Have you searched our list archives?
> > >
> > >                http://archives.postgresql.org
> > >
> >
> > --
> >   Bruce Momjian                        |  http://candle.pha.pa.us
> >   pgman@candle.pha.pa.us               |  (610) 359-1001
> >   +  If your life is a hard drive,     |  13 Roberts Road
> >   +  Christ can be your backup.        |  Newtown Square, Pennsylvania
> 19073
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 3: if posting/reading through Usenet, please send an appropriate
> >       subscribe-nomail command to majordomo@postgresql.org so that your
> >       message can get through to the mailing list cleanly
>


Re: COPY error

From
Claudio Natoli
Date:
You might have an additional tab in one of the fields in that row?

Cheers,
Claudio


-----Original Message-----
From: Nupur Pande
To: pgsql-cygwin@postgresql.org
Sent: 10/31/03 3:37 AM
Subject: [CYGWIN] COPY error

Hi,
I'm trying to copy data from an excel file into a postgres table. I
saved
the file in .txt format (tab delimited) from Excel (running on Windows
XP
machine) and then ran the d2u utility on the .txt file to convert it
into
unix format on cygwin. The command I executed was COPY [table_name] from
[full path of file name].
I get the following error message:
ERROR:  copy: line 1520, Extra data after last expected column
ERROR:  copy: line 1520, Extra data after last expected column

Could someone please tell me what I did wrong? I checked the excel table
and
I can't see any extra information on that line.

Thanks a lot..
Nupur


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org

---
WE HAVE MOVED - PLEASE NOTE OUR NEW CONTACT DETAILS:
THE BASEMENT, 33 EWELL STREET, BALMAIN NSW 2041
TEL: +61 2 9555 1544 FAX: +61 2 9555 6911
Certain disclaimers and policies apply to all email sent from Memetrics.
For the full text of these disclaimers and policies see
http://www.memetrics.com/emailpolicy.html

postgres.h

From
"Nupur Pande"
Date:
Hi,
I'm trying to compile and run some external functions on postgres. The code
seems to compile and run fine on linux machine. But on cygwin, it gave me
errors saying it couldn't find some files such as "postgres.h",
"server/executor/executor.h", "server/executor/spi.h"

Could someone please tell me where to find these files. My
/usr/include/postgresql/ only includes 1 folder called internal. I checked
google for these files and it seems they should be in a folder
../postgresql/server
But I don't see that in my directories. I have postgresql 7.3.4 installed.

Thanks,
Nupur


Re: postgres.h

From
Jason Tishler
Date:
Nupur,

On Mon, Nov 03, 2003 at 04:12:37PM -0500, Nupur Pande wrote:
> I'm trying to compile and run some external functions on postgres. The
> code seems to compile and run fine on linux machine. But on cygwin, it
> gave me errors saying it couldn't find some files such as
> "postgres.h", "server/executor/executor.h", "server/executor/spi.h"
>
> Could someone please tell me where to find these files. My
> /usr/include/postgresql/ only includes 1 folder called internal. I
> checked google for these files and it seems they should be in a folder
> ../postgresql/server But I don't see that in my directories. I have
> postgresql 7.3.4 installed.

When I package Cygwin PostgreSQL, I only do a "make install".  From
src/include/Makefile, we have the following:

    # 'make install' installs only those headers needed for client-side
    # programming.  'make install-all-headers' installs the whole
    # contents of src/include.

Hence, the short-term workaround is to download and unpack the source
tarball.

For the long-term, does anyone having any opinions on whether or not I
should include the "install-all-headers" headers too?

Thanks,
Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6

Re: postgres.h

From
Peter Eisentraut
Date:
Jason Tishler writes:

> For the long-term, does anyone having any opinions on whether or not I
> should include the "install-all-headers" headers too?

You should.  The only reason not to install them is if you are keeping the
source tree around.  In a package for general distribution, you definitely
need to include them.

--
Peter Eisentraut   peter_e@gmx.net


Re: postgres.h

From
"Nupur Pande"
Date:
Is there any specific location where I should untar the files?

Thanks,
Nupur

----- Original Message -----
From: "Jason Tishler" <jason@tishler.net>
To: "Nupur Pande" <npande@vt.edu>
Cc: <pgsql-cygwin@postgresql.org>
Sent: Monday, November 03, 2003 4:41 PM
Subject: Re: [CYGWIN] postgres.h


> Nupur,
>
> On Mon, Nov 03, 2003 at 04:12:37PM -0500, Nupur Pande wrote:
> > I'm trying to compile and run some external functions on postgres. The
> > code seems to compile and run fine on linux machine. But on cygwin, it
> > gave me errors saying it couldn't find some files such as
> > "postgres.h", "server/executor/executor.h", "server/executor/spi.h"
> >
> > Could someone please tell me where to find these files. My
> > /usr/include/postgresql/ only includes 1 folder called internal. I
> > checked google for these files and it seems they should be in a folder
> > ../postgresql/server But I don't see that in my directories. I have
> > postgresql 7.3.4 installed.
>
> When I package Cygwin PostgreSQL, I only do a "make install".  From
> src/include/Makefile, we have the following:
>
>     # 'make install' installs only those headers needed for client-side
>     # programming.  'make install-all-headers' installs the whole
>     # contents of src/include.
>
> Hence, the short-term workaround is to download and unpack the source
> tarball.
>
> For the long-term, does anyone having any opinions on whether or not I
> should include the "install-all-headers" headers too?
>
> Thanks,
> Jason
>
> --
> PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
> Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6

Re: postgres.h

From
Jason Tishler
Date:
Peter,

On Mon, Nov 03, 2003 at 10:45:54PM +0100, Peter Eisentraut wrote:
> Jason Tishler writes:
> > For the long-term, does anyone having any opinions on whether or not
> > I should include the "install-all-headers" headers too?
>
> You should.  The only reason not to install them is if you are keeping
> the source tree around.  In a package for general distribution, you
> definitely need to include them.

Thanks for the above.  I will include them the next time I release the
Cygwin PostgreSQL package.  In the meantime, I will upload a separate
"install-all-headers" package to my web site.

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6

Re: postgres.h

From
Jason Tishler
Date:
Nupur,

On Mon, Nov 03, 2003 at 05:24:48PM -0500, Nupur Pande wrote:
> Is there any specific location where I should untar the files?

Use the following to install the missing headers:

    $ wget -P /tmp http://www.tishler.net/jason/software/postgresql/postgresql-7.3.4-2-install-all-headers.tar.bz2
    $ tar -C / -xjf /tmp/postgresql-7.3.4-2-install-all-headers.tar.bz2

Thanks for bring this issue to my attention.

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6

Re: postgres.h

From
"Nupur Pande"
Date:
How do I set path in postgres for it to find all the header files? Now that
everything is installed, I thought it would do that automatically.. but I'm
still getting compiler errors.. Do I have to save my C files in some
particular directory?

Thanks..

----- Original Message -----
From: "Jason Tishler" <jason@tishler.net>
To: "Nupur Pande" <npande@vt.edu>
Cc: <pgsql-cygwin@postgresql.org>
Sent: Tuesday, November 04, 2003 7:32 AM
Subject: Re: [CYGWIN] postgres.h


> Nupur,
>
> On Mon, Nov 03, 2003 at 05:24:48PM -0500, Nupur Pande wrote:
> > Is there any specific location where I should untar the files?
>
> Use the following to install the missing headers:
>
>     $ wget -P /tmp
http://www.tishler.net/jason/software/postgresql/postgresql-7.3.4-2-install-all-headers.tar.bz2
>     $ tar -C / -xjf /tmp/postgresql-7.3.4-2-install-all-headers.tar.bz2
>
> Thanks for bring this issue to my attention.
>
> Jason
>
> --
> PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
> Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)


Re: postgres.h

From
Jason Tishler
Date:
Nupur,

On Tue, Nov 04, 2003 at 10:31:28AM -0500, Nupur Pande wrote:
> How do I set path in postgres for it to find all the header files? Now
> that everything is installed, I thought it would do that
> automatically.. but I'm still getting compiler errors.. Do I have to
> save my C files in some particular directory?

I presume you would have to do something like the following:

    gcc -I/usr/include/postgresql/server ...

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6

Re: postgres.h

From
"Nupur Pande"
Date:
Thanks a lot.. that did work.
One last question (hopefully)
I'm trying to create a .so file. My makefile looks like this:

all: RuleFinder.so

RuleFinder.so: RuleFinder.o
        gcc -shared -o RuleFinder.so RuleFinder.o

RuleFinder.o: <files>
        gcc -I /usr/include/postgresql/server -fpic -c RuleFinder.c

When I run make, the .o file gets created but not the .so. I get the
following errors:

gcc -I /usr/include/postgresql/server -fpic -c RuleFinder.c
cc1: warning: -fpic ignored for target (all code is position independent)
gcc -shared -o RuleFinder.so RuleFinder.o
RuleFinder.o(.text+0x16c1):RuleFinder.c: undefined reference to `_SPI_exec'
RuleFinder.o(.text+0x1cf2):RuleFinder.c: undefined reference to
`_pg_detoast_datum'
RuleFinder.o(.text+0x1d06):RuleFinder.c: undefined reference to
`_pg_detoast_datum'
RuleFinder.o(.text+0x2152):RuleFinder.c: undefined reference to
`_GetAttributeByName'
RuleFinder.o(.text+0x2438):RuleFinder.c: undefined reference to
`_GetAttributeByName'

Did I do something wrong?

Thanks,
Nupur

----- Original Message -----
From: "Jason Tishler" <jason@tishler.net>
To: "Nupur Pande" <npande@vt.edu>
Cc: <pgsql-cygwin@postgresql.org>
Sent: Tuesday, November 04, 2003 11:26 AM
Subject: Re: [CYGWIN] postgres.h


> Nupur,
>
> On Tue, Nov 04, 2003 at 10:31:28AM -0500, Nupur Pande wrote:
> > How do I set path in postgres for it to find all the header files? Now
> > that everything is installed, I thought it would do that
> > automatically.. but I'm still getting compiler errors.. Do I have to
> > save my C files in some particular directory?
>
> I presume you would have to do something like the following:
>
>     gcc -I/usr/include/postgresql/server ...
>
> Jason


Re: postgres.h

From
Frank Seesink
Date:
Nupur,

No, you didn't do anything wrong.  The problem is that you have stumbled
into one of the areas where compiling/developing under Cygwin is
different than most forms of *nix.  You may find the following
information helpful in general (taken from a README I wrote up for the
Cygwin version of Jabberd v1.4.3 recently; apologies for being lazy):

______________________________________________________________________
COMMENTS ABOUT BUILDING *NIX APPS UNDER CYGWIN

With the modifications made since Jabberd v1.4.2, you should now be able
to build Jabberd under Cygwin just as you would under *nix, with a few
exceptions.  For those interested, note that building *nix applications
under Cygwin tends to run into problems in the following areas:

    * dynamic libraries
    * DNS (Domain Name System) resolution/functionality
    * the use of fork()

Unfortunately, Jabberd touches on ALL of these capabilities to some
extent.

Dynamic libraries are an OS-specific feature, requiring the OS to play
its role in loading/unloading libraries.  In *nix, dynamic libraries
have filenames ending in .so, whereas in Windows they end in .dll.  This
is more cosmetic in nature, but it requires changing all modules such as
JUD or MU-Conference so that their filenames end in .dll (see setup.sh).

More importantly, however, is the fact that *nix and Windows compile
their libraries differently, and in order to make a *nix library
build/work under Cygwin, it requires using certain Cygwin tools to build
a list of EXPORTed functions/variables and then building the libraries
as Windows would expect.  See the various Makefiles for details on the
commands used under Cygwin vs. typical *nix builds.  Basically it
involves building an EXPORT list via 'nm' and then building the libary
using 'dllwrap'.

DNS is another area where compiling *nix apps under Cygwin falls down
hard.  In *nix, you can expect to find BIND (Berkeley Internet Name
Domain) or something like it.  This provides you not only with a DNS
server, but also as a programmer with all the functions you might
need for DNS resolution, via libraries like libresolv
(/usr/lib/libresolv.a) and their matching header files like
/usr/include/resolv.h, /usr/include/arpa/nameser.h, etc.

Unfortunately, BIND does not build cleanly under Cygwin (so far one can
only Google for hacks), and there is no BIND package available via
Cygwin's setup.exe.  This means that as a programmer, you do not get the
header files or necessary libraries for doing DNS functions.  Since
Jabberd does DNS resolution for its 'dialback' feature, this required a
rewrite of that portion of Jabberd for Cygwin.  This is the ugliest part
of the Cygwin build, as you will find setup.sh simply overwrites the
standard ./dnsrv subdirectory with the Cygwin-specific version.  Thanks
go to whoever did this rewrite, however, as it does work.

Recently I found a handy utility called 'minires' (v0.9.7 as I write
this) which implements the more common BIND libresolv functions,
allowing you to build against it as if you had libresolv.
Unfortunately, in my tests, compilation and linking against minires went
fine, but attempts to run the DNSRV portion (dnsrv.dll) of Jabberd blew
up, kicking up rather nasty errors.  Though it did not die, it did not
do DNS resolution either.  So for now, we'll stick to the rewrite from
Jabberd v1.4.2.

Finally, fork().  Cygwin is fork()ing hell (pun intended) compared to a
proper *nix environment.  Applications which use fork() either directly
or indirectly--as Jabberd does since it uses GNU Pth, which in turn uses
fork()--often have difficulty under Cygwin.  As mentioned above, when
attempting to run a version of Jabberd compiled against minires
(basically attempting to build Jabberd under Cygwin as you would do
under *nix), I ran into trouble.  The trouble involved fork().  I do not
have a resolution at this time.
______________________________________________________________________


Basically, you cannot use .so files under Cygwin.  Dynamic Link
Libraries, or DLLs, in Windows end with .DLL, and the way in which they
are built is different than under *nix.

In most cases you CAN take *nix type source code and, by modifying the
Makefile, compile yourself a .DLL file that will work under Windows.  I
would suggest doing a

    $ man nm
    $ dllwrap --help
    $ man dlltool

to learn more.  Yes it's a pain, but it can be done.  I would give you a
modified version of your Makefile here if it were that simple, but there
are too many assumptions I would have to make, and compiling a .so file
as a .dll requires both a modified Makefile and a wrapper/stub file, an
example of which can be had here (taken from Jabberd project):

http://www.jabberstudio.org/cgi-bin/viewcvs.cgi/*checkout*/jabberd14/cygwin/dllinit.c?rev=1.1&content-type=text/plain

To give you at least some direction in this, look at the following
Makefile (again taken from Jabberd project) for a basic idea of what's
involved:


http://www.jabberstudio.org/cgi-bin/viewcvs.cgi/jabberd14/dialback/Makefile?rev=1.5&content-type=text/vnd.viewcvs-markup

Ignore the actual filenames and just note the general structure.  Note
the line at the top "include ../platform-settings" refers to including a
simple shell script file containing compiler flags and such, including
one line that reads "__CYGWIN__=1", which is what the conditionals in
the above Makefile look for to see if you're running under Cygwin.  This
platform-settings file was generated by a ./configure script provided
with Jabberd, available here:

http://www.jabberstudio.org/cgi-bin/viewcvs.cgi/jabberd14/configure?rev=1.43&content-type=text/vnd.viewcvs-markup

I realize that saying "Go look at this other code" isn't the prettiest
way to learn, but hopefully it will be of use to you.  Best of luck to you.

______________________________________________________________________
DISCLAIMER:  I am not a professional coder (i.e., "sitting at desk,
coding for my paycheck"), nor do I play one on TV.  So if any of the
above is a little off, an apology is the best I can offer.


Nupur Pande wrote:

> Thanks a lot.. that did work.
> One last question (hopefully)
> I'm trying to create a .so file. My makefile looks like this:
>
> all: RuleFinder.so
>
> RuleFinder.so: RuleFinder.o
>         gcc -shared -o RuleFinder.so RuleFinder.o
>
> RuleFinder.o: <files>
>         gcc -I /usr/include/postgresql/server -fpic -c RuleFinder.c
>
> When I run make, the .o file gets created but not the .so. I get the
> following errors:
>
> gcc -I /usr/include/postgresql/server -fpic -c RuleFinder.c
> cc1: warning: -fpic ignored for target (all code is position independent)
> gcc -shared -o RuleFinder.so RuleFinder.o
> RuleFinder.o(.text+0x16c1):RuleFinder.c: undefined reference to `_SPI_exec'
> RuleFinder.o(.text+0x1cf2):RuleFinder.c: undefined reference to
> `_pg_detoast_datum'
> RuleFinder.o(.text+0x1d06):RuleFinder.c: undefined reference to
> `_pg_detoast_datum'
> RuleFinder.o(.text+0x2152):RuleFinder.c: undefined reference to
> `_GetAttributeByName'
> RuleFinder.o(.text+0x2438):RuleFinder.c: undefined reference to
> `_GetAttributeByName'
>
> Did I do something wrong?
>
> Thanks,
> Nupur
*snip*


Re: postgres.h

From
Jason Tishler
Date:
Nupar,

On Tue, Nov 04, 2003 at 01:28:06PM -0500, Nupur Pande wrote:
> Thanks a lot..

You are welcome.

> that did work.

Good.

> Did I do something wrong?

Yes and no.

> I'm trying to create a .so file. My makefile looks like this:
                         ^^^

Under Cygwin (i.e., Windows), you should create .dll files instead.

> all: RuleFinder.so
>
> RuleFinder.so: RuleFinder.o
>         gcc -shared -o RuleFinder.so RuleFinder.o
>
> RuleFinder.o: <files>
>         gcc -I /usr/include/postgresql/server -fpic -c RuleFinder.c
                                                ^^^^^

The -fpic options is unnecessary under Cygwin.

> gcc -shared -o RuleFinder.so RuleFinder.o
> RuleFinder.o(.text+0x16c1):RuleFinder.c: undefined reference to `_SPI_exec'
> [snip]

You are missing the "-lpostgres" option (and possibly the associated
"-L" option too) on the link command line.  Unfortunately, the binary
package does *not* contain libpostgres.a.  This is because the other
Unix platforms do not have such a file.  Sigh...

The short-term workaround is to download the PostgreSQL source and build
libpostgres.a yourself.  I need to think about the long-term solution...

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6

Re: postgres.h

From
Jason Tishler
Date:
Frank,

On Tue, Nov 04, 2003 at 07:12:52PM -0500, Frank Seesink wrote:
> Basically it involves building an EXPORT list via 'nm' and then
> building the libary using 'dllwrap'.

Please recommend using "gcc -shared" instead of "dllwrap".

> Finally, fork().  Cygwin is fork()ing hell (pun intended) compared to
> a proper *nix environment.  Applications which use fork() either
> directly or indirectly--as Jabberd does since it uses GNU Pth, which
> in turn uses fork()--often have difficulty under Cygwin.  As mentioned
> above, when attempting to run a version of Jabberd compiled against
> minires (basically attempting to build Jabberd under Cygwin as you
> would do under *nix), I ran into trouble.  The trouble involved
> fork().  I do not have a resolution at this time.

<WAG>
Try rebasing your system:

    http://sources.redhat.com/ml/cygwin-announce/2003-09/msg00039.html
</WAG>

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6

Re: postgres.h

From
"Nupur Pande"
Date:
> The short-term workaround is to download the PostgreSQL source and build
> libpostgres.a yourself.  I need to think about the long-term solution...

Are there any instructions posted for that?

Nupur


Re: postgres.h

From
Jason Tishler
Date:
Nupur,

On Wed, Nov 05, 2003 at 03:56:28PM -0500, Nupur Pande wrote:
> > The short-term workaround is to download the PostgreSQL source and build
> > libpostgres.a yourself.  I need to think about the long-term solution...
>
> Are there any instructions posted for that?

The README states the following:


    See CYGWIN-PATCHES/build.sh in the source archive for my exact build
    recipe for configuring, making, and packaging this distribution.

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6

Re: postgres.h

From
"Nupur Pande"
Date:
I ran the build.sh file under CYGWIN-PATCHES, but I'm getting some errors
like
configure: No such file or directory
etc etc..
The only configure file I found was in the directory above it. So it seems
that I have to build postgres from scratch. I was assuming that I don't have
to rebuild postgres.. just the library for libpostgres.a, or do I?

Could you please give me precise directions?

Thanks a lot,
Nupur


Re: postgres.h

From
Jason Tishler
Date:
Nupur,

On Wed, Nov 05, 2003 at 05:12:04PM -0500, Nupur Pande wrote:
> Could you please give me precise directions?

Use the following (after installing all necessary Cygwin packages):

    $ wget -P /tmp http://mirrors.rcn.net/pub/sourceware/cygwin/release/postgresql/postgresql-7.3.4-2-src.tar.bz2
    $ tar -xjf /tmp/postgresql-7.3.4-2-src.tar.bz2
    $ cd postgresql-7.3.4-2
    $ configure --enable-multibyte --prefix=/usr
    $ make
    $ cp src/backend/libpostgres.a /usr/lib

Now you can just add -lpostgres to your link command line.

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6

Re: postgres.h

From
"Nupur Pande"
Date:
I did exactly that, but it still doesn't work. I don't think -lpostgres is
not working even though my /usr/lib contains libpostgres.a now. I have also
changed libpostgres.a's permission to reflect those of other .a files. The
only difference is the + at the end of the permissions of libpostgres.a
which I'm not sure how to change..

$ ls -Al /usr/lib/libp*
-rwxr-xr--    1 Nupur    Users    2445312 Nov  6 00:06
/usr/lib/libpostgres.a
-rwxr-x---+   1 Nupur    Users      111176 Aug  5 09:31 /usr/lib/libpq.a
-rwxr-x---+   1 Nupur    Users       56086 Sep 20 16:32
/usr/lib/libpthread.a

My makefile looks like this:

RuleFinder.so: RuleFinder.o
    gcc -shared -lpostgres -L /usr/lib -o RuleFinder.so RuleFinder.o

RuleFinder.o: <files>
    gcc -I /usr/include/postgresql/server -c RuleFinder.c

Thanks for the help!

Nupur

----- Original Message -----
From: "Jason Tishler" <jason@tishler.net>
To: "Nupur Pande" <npande@vt.edu>
Cc: <pgsql-cygwin@postgresql.org>
Sent: Wednesday, November 05, 2003 10:24 PM
Subject: Re: [CYGWIN] postgres.h


> Nupur,
>
> On Wed, Nov 05, 2003 at 05:12:04PM -0500, Nupur Pande wrote:
> > Could you please give me precise directions?
>
> Use the following (after installing all necessary Cygwin packages):
>
>     $ wget -P /tmp
http://mirrors.rcn.net/pub/sourceware/cygwin/release/postgresql/postgresql-7.3.4-2-src.tar.bz2
>     $ tar -xjf /tmp/postgresql-7.3.4-2-src.tar.bz2
>     $ cd postgresql-7.3.4-2
>     $ configure --enable-multibyte --prefix=/usr
>     $ make
>     $ cp src/backend/libpostgres.a /usr/lib
>
> Now you can just add -lpostgres to your link command line.
>
> Jason


Re: postgres.h

From
Jason Tishler
Date:
Nupur,

On Thu, Nov 06, 2003 at 11:37:23AM -0500, Nupur Pande wrote:
> My makefile looks like this:
>
> RuleFinder.so: RuleFinder.o
>     gcc -shared -lpostgres -L /usr/lib -o RuleFinder.so RuleFinder.o

Under Cygwin, the order of link command line arguments is important.
Does the following work?

    gcc -shared -o RuleFinder.dll RuleFinder.o -lpostgres -L/usr/lib

Note you should use ".dll" not ".so" under Cygwin (i.e., Windows).

> Thanks for the help!

You are welcome, but next please include error messages.

Jason

--
PGP/GPG Key: http://www.tishler.net/jason/pubkey.asc or key servers
Fingerprint: 7A73 1405 7F2B E669 C19D  8784 1AFD E4CC ECF4 8EF6