CommitFest 2009-09, two weeks on

Started by Robert Haasover 16 years ago114 messages
#1Robert Haas
robertmhaas@gmail.com

It's now been two weeks since we started this CommitFest, so it seems
like a good time to review where we are. Here are my thoughts, for
what that's worth.

Our overall rate of progress is significantly slower than it was last
time around. At a similar point in the July CommitFest, 19 patches
had been committed (not counting 3 that were committed before the
start of the CommitFest), 11 had been returned with feedback (again,
not counting 2 from before the start of the CommitFest), and 3 had
been rejected. The corresponding numbers for this CommitFest are 8,
7, and 3, which means that the rate of returning patches with feedback
and/or rejecting them is only modestly lower, but the rate of
committing is much lower. I'm not sure whether this is because the
patches are more complex, because the committers have been busy with
other issues, or some other reason.

We also have fewer patches than we did last time around. I believe we
started the last CommitFest with a bit more than 75 patches (there are
fewer now, as some were moved to this CommitFest) and we started this
one with just 48. This somewhat balances out the slower rate of
grinding through the patch queue, but I'm still a bit worried about
the rate at which we're making progress. It would be nice to be done
on time, and I'm not sure we're going to make it.

With respect to individual patches:

- There are three ECPG patches for which it's been difficult to find a
reviewer. It seems we don't have any reviewers familiar with ECPG.
If anyone is able to help review these, it would be much appreciated.
- There is one dblink pach left over from last CommitFest. Joe Conway
was going to review it the weekend of July 18th-19th, but that didn't
end up happening and so that patch is still waiting. We might be able
to find someone else to review it, but I'm not sure whether that will
help unless there is a committer other than Joe with bandwidth to do
the final review and commit.
- Hot Standby and Streaming Replication are both huge new features in
this CommitFest, and there seems to be a fair amount of activity
around both patches. Heikki previously expressed optimism about
getting Hot Standby done this CommitFest, but I am not sure whether he
is still feeling optimistic, or what his feelings are about Streaming
Replication, which is currently waiting on Fujii Masao for a new
version.

On the whole, it seems like patch authors have done a better job than
last time of responding to feedback in a timely fashion - very little
is falling out due to submitter inattention. That is good, although
it also means that the percentage of patches that will require
substantive action (rather than, say, summary rejection for
non-communication) is apt to be higher. I am also generally under the
impression that we have a larger number of complex patches this time
around. Some of that may be because much good feedback was given in
the last CommitFest, and previously half-baked ideas are coming back a
little more well done.

...Robert

#2Heikki Linnakangas
heikki.linnakangas@enterprisedb.com
In reply to: Robert Haas (#1)
Re: CommitFest 2009-09, two weeks on

Robert Haas wrote:

- Hot Standby and Streaming Replication are both huge new features in
this CommitFest, and there seems to be a fair amount of activity
around both patches. Heikki previously expressed optimism about
getting Hot Standby done this CommitFest, but I am not sure whether he
is still feeling optimistic,

There's a lot of small things that need fixing, but nothing major. I'm
not so much optimistic, but I think we should spend the extra effort
required on hot standby to force it in in this commitfest. It's a big
feature and it really could use some alpha-testing earlier rather than
later. It would also leave time for any extra features or tweaks to be
made in the later commitfests.

OTOH, I'd hate to hold the commitfest hostage for that. Perhaps it
should be returned to author at this point, I should move on to other
patches to get the commitfest closed ASAP, and continue reviewing and
polishing that right after the commitfest.

or what his feelings are about Streaming
Replication, which is currently waiting on Fujii Masao for a new
version.

I'm undecided on whether walreceiver should be a subprocess of the
startup process, or of postmaster as it was submitted. I'd appreciate if
others would take a look into that too and give opinions. And then
there's the small list of things I asked Fujii-san to work on.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Heikki Linnakangas (#2)
Re: CommitFest 2009-09, two weeks on

Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:

OTOH, I'd hate to hold the commitfest hostage for that. Perhaps it
should be returned to author at this point, I should move on to other
patches to get the commitfest closed ASAP, and continue reviewing and
polishing that right after the commitfest.

FWIW, I'd rather you kept focusing on those two patches while other
committers work on the rest. From what I've seen you're finding a
whole lot of broken or at least questionable stuff, and even if they're
individually minor issues, that adds up to a lot of instability.

I agree that these patches need special attention and should not be
treated exactly the same as we'd treat smaller patches.

regards, tom lane

#4Robert Haas
robertmhaas@gmail.com
In reply to: Tom Lane (#3)
Re: CommitFest 2009-09, two weeks on

On Wed, Sep 30, 2009 at 11:36 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:

OTOH, I'd hate to hold the commitfest hostage for that. Perhaps it
should be returned to author at this point, I should move on to other
patches to get the commitfest closed ASAP, and continue reviewing and
polishing that right after the commitfest.

FWIW, I'd rather you kept focusing on those two patches while other
committers work on the rest.  From what I've seen you're finding a
whole lot of broken or at least questionable stuff, and even if they're
individually minor issues, that adds up to a lot of instability.

I agree that these patches need special attention and should not be
treated exactly the same as we'd treat smaller patches.

I tend to agree. I think it's reasonable for you (meaning Heikki) to
devote far more time and effort to those patches than you would to
other patches implementing more run-of-the-mill features, and it seems
like there is no shortage of things to find and fix. I don't think
that having you take a break to work on other patches is going to be
to the overall benefit of the project (and many of the more
significant remaining patches look like they are right up Tom's alley
anyway).

That having been said, if Hot Standby is still closer to commit than
Streaming Replication, it might make sense to push Streaming
Replication off until November, or at least post-CommitFest. Do you
have any sense of how soon you'll feel confident to commit either
patch?

...Robert

#5Joe Conway
mail@joeconway.com
In reply to: Robert Haas (#1)
Re: CommitFest 2009-09, two weeks on

Robert Haas wrote:

- There is one dblink pach left over from last CommitFest. Joe Conway
was going to review it the weekend of July 18th-19th, but that didn't
end up happening and so that patch is still waiting. We might be able
to find someone else to review it, but I'm not sure whether that will
help unless there is a committer other than Joe with bandwidth to do
the final review and commit.

I will get to it before the end of this commitfest, but I have to admit
I'm not all that excited about this patch in the first place. I don't
know that I agree with the need.

Joe

#6Heikki Linnakangas
heikki.linnakangas@enterprisedb.com
In reply to: Robert Haas (#4)
Re: CommitFest 2009-09, two weeks on

Robert Haas wrote:

On Wed, Sep 30, 2009 at 11:36 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:

OTOH, I'd hate to hold the commitfest hostage for that. Perhaps it
should be returned to author at this point, I should move on to other
patches to get the commitfest closed ASAP, and continue reviewing and
polishing that right after the commitfest.

FWIW, I'd rather you kept focusing on those two patches while other
committers work on the rest. From what I've seen you're finding a
whole lot of broken or at least questionable stuff, and even if they're
individually minor issues, that adds up to a lot of instability.

I agree that these patches need special attention and should not be
treated exactly the same as we'd treat smaller patches.

I tend to agree. I think it's reasonable for you (meaning Heikki) to
devote far more time and effort to those patches than you would to
other patches implementing more run-of-the-mill features, and it seems
like there is no shortage of things to find and fix. I don't think
that having you take a break to work on other patches is going to be
to the overall benefit of the project (and many of the more
significant remaining patches look like they are right up Tom's alley
anyway).

Ok, good, I'm more than happy to continue fine-combing hot standby.

That having been said, if Hot Standby is still closer to commit than
Streaming Replication, it might make sense to push Streaming
Replication off until November, or at least post-CommitFest.

Commitfest or no-commitfest, I'm planning to continue working on the
streaming replication patch in any case until it's committed.

Do you
have any sense of how soon you'll feel confident to commit either
patch?

I'm bad at estimating. Not this week for sure, and next week I'm
traveling and won't be able to spend as much time on it as I am right
now. If no new major issues are found, and all the outstanding issues
are resolved by me or Simon by then, maybe the week after that.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

#7Tom Lane
tgl@sss.pgh.pa.us
In reply to: Joe Conway (#5)
Re: CommitFest 2009-09, two weeks on

Joe Conway <mail@joeconway.com> writes:

Robert Haas wrote:

- There is one dblink pach left over from last CommitFest. Joe Conway
was going to review it the weekend of July 18th-19th, but that didn't
end up happening and so that patch is still waiting. We might be able
to find someone else to review it, but I'm not sure whether that will
help unless there is a committer other than Joe with bandwidth to do
the final review and commit.

I will get to it before the end of this commitfest, but I have to admit
I'm not all that excited about this patch in the first place. I don't
know that I agree with the need.

Well, you're the dblink expert. If you think it should be rejected
I doubt many of us will argue with you.

regards, tom lane

#8Tom Lane
tgl@sss.pgh.pa.us
In reply to: Robert Haas (#4)
Re: CommitFest 2009-09, two weeks on

Robert Haas <robertmhaas@gmail.com> writes:

... (and many of the more
significant remaining patches look like they are right up Tom's alley
anyway).

FWIW, if left to my own devices I will eventually get to everything
except the dblink, ecpg, and encoding/win32 patches. I don't intend
to touch any of those because there are other committers better
qualified to review them. (I don't actually think we have anybody
except Michael who's really familiar with ecpg.)

However, if no other committers are working on it it's going to be
a long commitfest ...

The other problem is that most of the patches are not Ready for
Committer anyway.

regards, tom lane

#9Robert Haas
robertmhaas@gmail.com
In reply to: Tom Lane (#7)
Re: CommitFest 2009-09, two weeks on

On Wed, Sep 30, 2009 at 12:27 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Joe Conway <mail@joeconway.com> writes:

Robert Haas wrote:

- There is one dblink pach left over from last CommitFest.  Joe Conway
was going to review it the weekend of July 18th-19th, but that didn't
end up happening and so that patch is still waiting.  We might be able
to find someone else to review it, but I'm not sure whether that will
help unless there is a committer other than Joe with bandwidth to do
the final review and commit.

I will get to it before the end of this commitfest, but I have to admit
I'm not all that excited about this patch in the first place. I don't
know that I agree with the need.

Well, you're the dblink expert.  If you think it should be rejected
I doubt many of us will argue with you.

Yep. CommitFest doesn't mean "commit it"; it means "decide whether to
commit it". Things being rejected or returned with feedback for
further improvement is fine; we're just trying to avoid long periods
with no response at all.

...Robert

#10Robert Haas
robertmhaas@gmail.com
In reply to: Tom Lane (#8)
Re: CommitFest 2009-09, two weeks on

On Wed, Sep 30, 2009 at 12:34 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Robert Haas <robertmhaas@gmail.com> writes:

... (and many of the more
significant remaining patches look like they are right up Tom's alley
anyway).

FWIW, if left to my own devices I will eventually get to everything
except the dblink, ecpg, and encoding/win32 patches.  I don't intend
to touch any of those because there are other committers better
qualified to review them.  (I don't actually think we have anybody
except Michael who's really familiar with ecpg.)

Thanks, I think that's helpful information.

However, if no other committers are working on it it's going to be
a long commitfest ...

That is my concern as well.

The other problem is that most of the patches are not Ready for
Committer anyway.

I (and hopefully the people who agreed to help with patch-chasing) can
work on this, but given that there are 5 that are Ready for Committer
and probably as many more that are close, and further given that in
the past 7 days exactly 1 patch from the CommitFest has been
committed, I'm not sure there's a real problem here. If you
commit/bounce all 5 of those afternoon I will spend the evening making
sure you have a few more to tackle tomorrow.

...Robert

#11Andrew Dunstan
andrew@dunslane.net
In reply to: Robert Haas (#10)
Re: CommitFest 2009-09, two weeks on

Robert Haas wrote:

On Wed, Sep 30, 2009 at 12:34 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Robert Haas <robertmhaas@gmail.com> writes:

... (and many of the more
significant remaining patches look like they are right up Tom's alley
anyway).

FWIW, if left to my own devices I will eventually get to everything
except the dblink, ecpg, and encoding/win32 patches. I don't intend
to touch any of those because there are other committers better
qualified to review them. (I don't actually think we have anybody
except Michael who's really familiar with ecpg.)

Thanks, I think that's helpful information.

However, if no other committers are working on it it's going to be
a long commitfest ...

That is my concern as well.

I have been (and still am somewhat) slammed, but I can probably make
space to work on "Encoding issues in console and eventlog on win32
<https://commitfest.postgresql.org/action/patch_view?id=148&gt;&quot; some time
in the next day or three. After that, if I still have time and nobody
else has grabbed it, I'll move on to "CREATE LIKE INCLUDING COMMENTS and
STORAGE <https://commitfest.postgresql.org/action/patch_view?id=172&gt;&quot;.

cheers

andrew

#12Joe Conway
mail@joeconway.com
In reply to: Robert Haas (#9)
Re: CommitFest 2009-09, two weeks on

Robert Haas wrote:

On Wed, Sep 30, 2009 at 12:27 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Joe Conway <mail@joeconway.com> writes:

Robert Haas wrote:

- There is one dblink pach left over from last CommitFest. Joe Conway
was going to review it the weekend of July 18th-19th, but that didn't
end up happening and so that patch is still waiting. We might be able
to find someone else to review it, but I'm not sure whether that will
help unless there is a committer other than Joe with bandwidth to do
the final review and commit.

I will get to it before the end of this commitfest, but I have to admit
I'm not all that excited about this patch in the first place. I don't
know that I agree with the need.

Well, you're the dblink expert. If you think it should be rejected
I doubt many of us will argue with you.

Yep. CommitFest doesn't mean "commit it"; it means "decide whether to
commit it". Things being rejected or returned with feedback for
further improvement is fine; we're just trying to avoid long periods
with no response at all.

The issue is not so much technical as it is philosophical.

The patch basically forces all use of libpq by dblink to be asynchronous
(internally) so that a cancel can be sensed and passed down to the
remote side and everything cleaned up. Possibly the right thing to do,
but dblink already allows the use of async queries, and the current
synchronous method uses standard libpq calls. If all of this is really
necessary, doesn't every libpq client have the same issue? If so why
have the synchronous libpq functions at all?

So while I can vet the patch technically, and spend more time
understanding the use case, and maybe explaining it better, I think
other people should weigh in on the change as it is significant and
points to other potential issues.

Joe

#13Magnus Hagander
magnus@hagander.net
In reply to: Tom Lane (#8)
Re: CommitFest 2009-09, two weeks on

On Wed, Sep 30, 2009 at 18:34, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Robert Haas <robertmhaas@gmail.com> writes:

... (and many of the more
significant remaining patches look like they are right up Tom's alley
anyway).

FWIW, if left to my own devices I will eventually get to everything
except the dblink, ecpg, and encoding/win32 patches.  I don't intend
to touch any of those because there are other committers better
qualified to review them.  (I don't actually think we have anybody
except Michael who's really familiar with ecpg.)

I can certainly review the win32 encoding patch, but I was rather
hoping for some comments from others on if we're interested in a win32
only solution, or if we want something more generic. Should we just go
with the win32-only one for now?

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/

#14Alvaro Herrera
alvherre@commandprompt.com
In reply to: Magnus Hagander (#13)
Re: CommitFest 2009-09, two weeks on

Magnus Hagander escribi�:

On Wed, Sep 30, 2009 at 18:34, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Robert Haas <robertmhaas@gmail.com> writes:

... (and many of the more
significant remaining patches look like they are right up Tom's alley
anyway).

FWIW, if left to my own devices I will eventually get to everything
except the dblink, ecpg, and encoding/win32 patches. �I don't intend
to touch any of those because there are other committers better
qualified to review them. �(I don't actually think we have anybody
except Michael who's really familiar with ecpg.)

I can certainly review the win32 encoding patch, but I was rather
hoping for some comments from others on if we're interested in a win32
only solution, or if we want something more generic. Should we just go
with the win32-only one for now?

Just a couple of days ago a question came on the spanish list because
someone was getting mixed UTF8 and Latin1 output in a log file. This
was in Fedora IIRC, so maybe we do want something more general.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

#15Tom Lane
tgl@sss.pgh.pa.us
In reply to: Magnus Hagander (#13)
Re: CommitFest 2009-09, two weeks on

Magnus Hagander <magnus@hagander.net> writes:

I can certainly review the win32 encoding patch, but I was rather
hoping for some comments from others on if we're interested in a win32
only solution, or if we want something more generic. Should we just go
with the win32-only one for now?

That was actually the only substantive comment I had about it. I don't
see why it's a win32-only problem or why a win32-only solution is a good
approach.

regards, tom lane

#16Magnus Hagander
magnus@hagander.net
In reply to: Tom Lane (#15)
Re: CommitFest 2009-09, two weeks on

On Wed, Sep 30, 2009 at 21:38, Tom Lane <tgl@sss.pgh.pa.us> wrote:

Magnus Hagander <magnus@hagander.net> writes:

I can certainly review the win32 encoding patch, but I was rather
hoping for some comments from others on if we're interested in a win32
only solution, or if we want something more generic. Should we just go
with the win32-only one for now?

That was actually the only substantive comment I had about it.  I don't
see why it's a win32-only problem or why a win32-only solution is a good
approach.

Yeah, that's my thought as well.

If we want a complete one, we should reject this patch and ask for one
that does that.

If we are fine with a win32 only one, I can review this one and get it in.

I'm leaning towards us wanting a general one, but I'm unsure how much
work that will take.

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/

#17Tom Lane
tgl@sss.pgh.pa.us
In reply to: Joe Conway (#12)
Re: CommitFest 2009-09, two weeks on

Joe Conway <mail@joeconway.com> writes:

The issue is not so much technical as it is philosophical.

The patch basically forces all use of libpq by dblink to be asynchronous
(internally) so that a cancel can be sensed and passed down to the
remote side and everything cleaned up. Possibly the right thing to do,
but dblink already allows the use of async queries, and the current
synchronous method uses standard libpq calls. If all of this is really
necessary, doesn't every libpq client have the same issue?

Well, only the ones that want to implement cancel and don't have access
to the app's own signal handling functions. (Which suggests that a
possible answer is to allow dblink to hook into the SIGINT catcher,
but frankly hooks in that location scare me ...)

I would argue that it's not necessarily a good idea at all: one of the
typical uses for dblink is to fake "autonomous transactions", and in
that application I don't think you *want* a cancel to propagate to the
other session. If we did put this behavior into all dblink operations,
we'd need a way to turn it off.

Since dblink_cancel_query is already available, people who do want
cancels to propagate have the ability to do that. I'm inclined to
think that this is complexity we don't need.

regards, tom lane

#18Itagaki Takahiro
itagaki.takahiro@oss.ntt.co.jp
In reply to: Joe Conway (#12)
Re: CommitFest 2009-09, two weeks on

Joe Conway <mail@joeconway.com> wrote:

The patch basically forces all use of libpq by dblink to be asynchronous
(internally) so that a cancel can be sensed and passed down to the
remote side and everything cleaned up. Possibly the right thing to do,
but dblink already allows the use of async queries, and the current
synchronous method uses standard libpq calls.

The point is *memory leak* in dblink when a query is canceled or
become time-out. I think it is a bug, and my patch could fix it.

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center

#19Itagaki Takahiro
itagaki.takahiro@oss.ntt.co.jp
In reply to: Magnus Hagander (#13)
Re: CommitFest 2009-09, two weeks on

Magnus Hagander <magnus@hagander.net> wrote:

I can certainly review the win32 encoding patch, but I was rather
hoping for some comments from others on if we're interested in a win32
only solution, or if we want something more generic. Should we just go
with the win32-only one for now?

Yes, because Windows is only platform that supports UTF-16 encoding natively.
I believe my patch is the best solution for Windows even if we have another
approach for other platforms.

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center

#20Magnus Hagander
magnus@hagander.net
In reply to: Itagaki Takahiro (#19)
Re: CommitFest 2009-09, two weeks on

On Thu, Oct 1, 2009 at 04:11, Itagaki Takahiro
<itagaki.takahiro@oss.ntt.co.jp> wrote:

Magnus Hagander <magnus@hagander.net> wrote:

I can certainly review the win32 encoding patch, but I was rather
hoping for some comments from others on if we're interested in a win32
only solution, or if we want something more generic. Should we just go
with the win32-only one for now?

Yes, because Windows is only platform that supports UTF-16 encoding natively.
I believe my patch is the best solution for Windows even if we have another
approach for other platforms.

Actually, I think a better argument is that since Windows will *never*
accept UTF8 logging, and that's what most databases will be in, much
of this patch will be required anyway. So I should probably review and
get this part in while we think about other solutions *as well* for
other platforms.

--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/

#21Michael Meskes
meskes@postgresql.org
In reply to: Tom Lane (#8)
Re: CommitFest 2009-09, two weeks on

On Wed, Sep 30, 2009 at 12:34:23PM -0400, Tom Lane wrote:

qualified to review them. (I don't actually think we have anybody
except Michael who's really familiar with ecpg.)

I'm afraid I'm simply not able to spend much time on this in the near future as
I'm simply too busy atm. I spend some time on these the last time, but wasn't
even able to see how Zoltan changed the points we mentioned back then, but I'm
sure he has.

As already noted the patches stack on each other. There doesn't seem to be a
technical reason for this at least not for some of those dependencies. With the
first patch changing the grammar file and thus taking quite some reviewing
effort this slows things down even more because one needs more effort to review
for instance the sqlda addition, although that one seems to be quite easy to
review.

All of this is written from the top of my head, so please bear with me if I
missed any changes in the patches.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ: 179140304, AIM/Yahoo/Skype: michaelmeskes, Jabber: meskes@jabber.org
Go VfL Borussia! Go SF 49ers! Use Debian GNU/Linux! Use PostgreSQL!

#22Boszormenyi Zoltan
zb@cybertec.at
In reply to: Michael Meskes (#21)
Re: CommitFest 2009-09, two weeks on

Michael Meskes �rta:

On Wed, Sep 30, 2009 at 12:34:23PM -0400, Tom Lane wrote:

qualified to review them. (I don't actually think we have anybody
except Michael who's really familiar with ecpg.)

I'm afraid I'm simply not able to spend much time on this in the near future as
I'm simply too busy atm. I spend some time on these the last time, but wasn't
even able to see how Zoltan changed the points we mentioned back then, but I'm
sure he has.

As already noted the patches stack on each other. There doesn't seem to be a
technical reason for this at least not for some of those dependencies. With the
first patch changing the grammar file and thus taking quite some reviewing
effort this slows things down even more because one needs more effort to review
for instance the sqlda addition, although that one seems to be quite easy to
review.

You're not being fair with me. The dependencies are quite
technical.

First, Tom Lane suggested to unify core and ecpg FETCH
syntaxes so both will accept optional FROM/IN, which I did.
SQLDA support adds new FETCH forms (Informix-specific
ones) so naturally these patches clash. There's no simple way
to make they separately applicable. With the first version,
the same technical dependency were also there, because of
the (already explained) grammar problem, I got 2 shift/reduce
problems in the FETCH/MOVE stmts unless I de-factorized
FORWARD and BACKWARD out of fetch_direction.
The new FETCH forms with SQLDA touched the same areas
in ecpg.addon.

Second, DESCRIBE support and SQLDA support also overlap,
because SQLDA is a new descriptor form, and DESCRIBE has to
support both SQL descriptors and SQLDA. Well, I can split the
DESCRIBE patch in half, so it will be usable on SQL descriptors
but the other part would depend on both SQLDA and basic
DESCRIBE support. Technical dependency again.

What non-technical dependencies are you talking about?
Please explain, so I may fix them. Saying it vaguely doesn't help.

When I first posted the split patchset, you didn't tell me that
the split is no good. I tried everything help I could to explain
why I did what.

Also, the current reviewer (Dan Colish) haven't contacted me despite
I offered help privately. I can't review my own patches, that's clear.
But I can't do anything else to speed review up but to offer my help
and wait for the help/explanation request that didn't arrive.

Also, I have sent some independent very small patches, that don't
even need much review. One of them (the typo in pgc.l) was already
applied and I thank you Michael, but the memory leak fix for two
improperly freed numerics is still behind. Please, look at that patch,
it should be really obvious.

All of this is written from the top of my head, so please bear with me if I
missed any changes in the patches.

Michael

Best regards,
Zolt�n B�sz�rm�nyi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

#23Alvaro Herrera
alvherre@commandprompt.com
In reply to: Boszormenyi Zoltan (#22)
Re: CommitFest 2009-09, two weeks on

Boszormenyi Zoltan escribi�:

First, Tom Lane suggested to unify core and ecpg FETCH
syntaxes so both will accept optional FROM/IN, which I did.
SQLDA support adds new FETCH forms (Informix-specific
ones) so naturally these patches clash. There's no simple way
to make they separately applicable. With the first version,
the same technical dependency were also there, because of
the (already explained) grammar problem, I got 2 shift/reduce
problems in the FETCH/MOVE stmts unless I de-factorized
FORWARD and BACKWARD out of fetch_direction.
The new FETCH forms with SQLDA touched the same areas
in ecpg.addon.

Probably the parts that touch the core grammar can be reviewed and
applied separately.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

#24Michael Meskes
meskes@postgresql.org
In reply to: Boszormenyi Zoltan (#22)
Re: CommitFest 2009-09, two weeks on

On Thu, Oct 01, 2009 at 03:47:07PM +0200, Boszormenyi Zoltan wrote:

You're not being fair with me. The dependencies are quite
technical.

I'm sorry that you interpreted my email this way, it wasn't at all meant to
offend you.

First, Tom Lane suggested to unify core and ecpg FETCH
syntaxes so both will accept optional FROM/IN, which I did.
SQLDA support adds new FETCH forms (Informix-specific

This is actually one I was talking about. Adding SQLDA *only* seems like an
easy one, as soon as it also hits the parser it becomes more complicated. This
is not to say that it is not doable, but it wasn't for me with my time
constraints. I was just explaining why I didn't delve into these any more so
far.

When I first posted the split patchset, you didn't tell me that
the split is no good. I tried everything help I could to explain
why I did what.

Well actually I did, but that's not the problem here. I have no idea why you
are ranting like this just because of me excusing myself for a lack of time.

Also, the current reviewer (Dan Colish) haven't contacted me despite
I offered help privately. I can't review my own patches, that's clear.
But I can't do anything else to speed review up but to offer my help
and wait for the help/explanation request that didn't arrive.

Okay, so it's all my fault. Do you feel better now?

Also, I have sent some independent very small patches, that don't
even need much review. One of them (the typo in pgc.l) was already
applied and I thank you Michael, but the memory leak fix for two
improperly freed numerics is still behind. Please, look at that patch,
it should be really obvious.

My last commit was one of your patches, obviously I didn't do anything on ecpg
since. I'm not sure what you are trying to tell me, you might want to explain
the last two sentences. But keep in mind you are *not* the one to decide how I
spend my spare time.

Michael

--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ: 179140304, AIM/Yahoo/Skype: michaelmeskes, Jabber: meskes@jabber.org
Go VfL Borussia! Go SF 49ers! Use Debian GNU/Linux! Use PostgreSQL!

#25Boszormenyi Zoltan
zb@cybertec.at
In reply to: Michael Meskes (#24)
Re: CommitFest 2009-09, two weeks on

Michael Meskes �rta:

On Thu, Oct 01, 2009 at 03:47:07PM +0200, Boszormenyi Zoltan wrote:

You're not being fair with me. The dependencies are quite
technical.

I'm sorry that you interpreted my email this way, it wasn't at all meant to
offend you.

Please, accept my apologies, I only tried to express my
frustration, this is not a good situation for either of us.
You were busy with your job and other occupations.
We have a serious project going on that depend on
ECPG being more compatible to Informix.

First, Tom Lane suggested to unify core and ecpg FETCH
syntaxes so both will accept optional FROM/IN, which I did.
SQLDA support adds new FETCH forms (Informix-specific

This is actually one I was talking about. Adding SQLDA *only* seems like an
easy one, as soon as it also hits the parser it becomes more complicated. This
is not to say that it is not doable, but it wasn't for me with my time
constraints. I was just explaining why I didn't delve into these any more so
far.

This is now clear, I will separate that part out and post it.
But this means that the same core grammar parts will be touched
twice because two basic things are done there:
- optional FROM/IN in core grammar, ECPG grammar updated
- "name" -> "cursor_name" transition in cursor-related statements
in the core grammar and the dynamic cursorname patch
So, technically dependant patches again, but maybe easier on the reviewer.
Would this be accepted this way? Or the two modification washed into one?

When I first posted the split patchset, you didn't tell me that
the split is no good. I tried everything help I could to explain
why I did what.

Well actually I did, but that's not the problem here. I have no idea why you
are ranting like this just because of me excusing myself for a lack of time.

I am very sorry, under stress sometimes I get like a steam
engine overloaded. Not a good behaviour at 37, I know.
I am very sorry.

Also, the current reviewer (Dan Colish) haven't contacted me despite
I offered help privately. I can't review my own patches, that's clear.
But I can't do anything else to speed review up but to offer my help
and wait for the help/explanation request that didn't arrive.

Okay, so it's all my fault. Do you feel better now?

It's not your fault at all, it's a difficult situation and I had to
express it somehow. My tone was not proper.

BTW, thanks for adding my small collected knowledge
about the ECPG grammar as official documentation.

Also, I have sent some independent very small patches, that don't
even need much review. One of them (the typo in pgc.l) was already
applied and I thank you Michael, but the memory leak fix for two
improperly freed numerics is still behind. Please, look at that patch,
it should be really obvious.

My last commit was one of your patches,

Yes, the pgc.l one-liner. Thanks again for committing that.

obviously I didn't do anything on ecpg
since. I'm not sure what you are trying to tell me, you might want to explain
the last two sentences.

I thought you forgot that patch, the "please, look at that patch"
was an (I thought) polite request, it's really two one-liners.

But keep in mind you are *not* the one to decide how I
spend my spare time.

Obviously. Please, accept my apologies.

Best regards,
Zolt�n B�sz�rm�nyi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

#26Michael Meskes
meskes@postgresql.org
In reply to: Boszormenyi Zoltan (#25)
Re: CommitFest 2009-09, two weeks on

On Thu, Oct 01, 2009 at 07:21:54PM +0200, Boszormenyi Zoltan wrote:

Please, accept my apologies, I only tried to express my
frustration, this is not a good situation for either of us.

Apologies accepted, email is a difficult means of communication anyway. It
leads to misunderstanding IMO.

You were busy with your job and other occupations.
We have a serious project going on that depend on
ECPG being more compatible to Informix.

Please keep in mind that the needs of your business project cannot and will not
influence the way PostgreSQL as on OSS project will work.

Would this be accepted this way? Or the two modification washed into one?

It is accepted either way. I was just pointing out that it might be easier to
review/commit at least parts of your patches if they can be applied seperately.

I thought you forgot that patch, the "please, look at that patch"
was an (I thought) polite request, it's really two one-liners.

Well, this is true as the patch was buried in the long thread containing all
the other ones. And yes, now that you brought it into my memory again, I
already committed it. Sorry for missing it.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ: 179140304, AIM/Yahoo/Skype: michaelmeskes, Jabber: meskes@jabber.org
Go VfL Borussia! Go SF 49ers! Use Debian GNU/Linux! Use PostgreSQL!

#27Boszormenyi Zoltan
zb@cybertec.at
In reply to: Michael Meskes (#26)
Re: CommitFest 2009-09, two weeks on

Michael Meskes �rta:

On Thu, Oct 01, 2009 at 07:21:54PM +0200, Boszormenyi Zoltan wrote:

Please, accept my apologies, I only tried to express my
frustration, this is not a good situation for either of us.

Apologies accepted, email is a difficult means of communication anyway. It
leads to misunderstanding IMO.

You were busy with your job and other occupations.
We have a serious project going on that depend on
ECPG being more compatible to Informix.

Please keep in mind that the needs of your business project cannot and will not
influence the way PostgreSQL as on OSS project will work.

Yes, but technical problems and solutions do. ECPG claims
to be ESQL/C compatible, but at places it's only half compatible.
For our project to succeed, we need more compatibility in ECPG.
It's easier to solve these problems in ECPG than to code around it
in literally thousands of little programs.

BTW, a thought about the comment in ecpg.header about adjust_informix():

/* Informix accepts DECLARE with variables that are out of scope
when OPEN is called.
* for instance you can declare variables in a function, and
then subsequently use them
* {
* declare_vars();
* exec sql ... which uses vars declared in the above function
*
* This breaks standard and leads to some very dangerous
programming.

This comment is misleading and reflects quite a narrow POV.
Not only OPEN and DECLARE may be out of scope,
but FETCH and CLOSE as well. The reason why ESQL/C
allows this construct is that this ultimately allows using
embedded SQL in event-driven code in a straightforward way.
For this purpose, native ECPG code is not usable currently,
or you need programming tricks, like tracking whether the
cursor is open and protecting DECLARE and OPEN under
some conditional branch to avoid double open, etc. A straight
DECLARE, OPEN, FETCH(s) and CLOSE series in
the same function is only good for batch programming.

Would this be accepted this way? Or the two modification washed into one?

It is accepted either way. I was just pointing out that it might be easier to
review/commit at least parts of your patches if they can be applied seperately.

Okay, I will split the remaining patches into more little pieces
that can reviewed more easily. Some patches will still build
on earlier ones in the series, that's unavoidable.

I thought you forgot that patch, the "please, look at that patch"
was an (I thought) polite request, it's really two one-liners.

Well, this is true as the patch was buried in the long thread containing all
the other ones. And yes, now that you brought it into my memory again, I
already committed it. Sorry for missing it.

Thank you very much for committing it.

Best regards,
Zolt�n B�sz�rm�nyi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

#28Michael Meskes
meskes@postgresql.org
In reply to: Boszormenyi Zoltan (#27)
Re: CommitFest 2009-09, two weeks on

On Thu, Oct 01, 2009 at 09:05:55PM +0200, Boszormenyi Zoltan wrote:

Yes, but technical problems and solutions do. ECPG claims
to be ESQL/C compatible, but at places it's only half compatible.

Where does it claim to be fully compatible?

This comment is misleading and reflects quite a narrow POV.
Not only OPEN and DECLARE may be out of scope,
but FETCH and CLOSE as well. The reason why ESQL/C
allows this construct is that this ultimately allows using
embedded SQL in event-driven code in a straightforward way.
For this purpose, native ECPG code is not usable currently,
or you need programming tricks, like tracking whether the
cursor is open and protecting DECLARE and OPEN under
some conditional branch to avoid double open, etc. A straight
DECLARE, OPEN, FETCH(s) and CLOSE series in
the same function is only good for batch programming.

Examples?

Michael

--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ: 179140304, AIM/Yahoo/Skype: michaelmeskes, Jabber: meskes@jabber.org
Go VfL Borussia! Go SF 49ers! Use Debian GNU/Linux! Use PostgreSQL!

#29Boszormenyi Zoltan
zb@cybertec.at
In reply to: Michael Meskes (#28)
5 attachment(s)
Re: CommitFest 2009-09, two weeks on

Michael Meskes �rta:

On Thu, Oct 01, 2009 at 09:05:55PM +0200, Boszormenyi Zoltan wrote:

Yes, but technical problems and solutions do. ECPG claims
to be ESQL/C compatible, but at places it's only half compatible.

Where does it claim to be fully compatible?

I didn't say it claims to be fully compatible, but it's
a "hint" that "ecpg -C INFORMIX[_SE]" exists. :-)

This comment is misleading and reflects quite a narrow POV.
Not only OPEN and DECLARE may be out of scope,
but FETCH and CLOSE as well. The reason why ESQL/C
allows this construct is that this ultimately allows using
embedded SQL in event-driven code in a straightforward way.
For this purpose, native ECPG code is not usable currently,
or you need programming tricks, like tracking whether the
cursor is open and protecting DECLARE and OPEN under
some conditional branch to avoid double open, etc. A straight
DECLARE, OPEN, FETCH(s) and CLOSE series in
the same function is only good for batch programming.

Examples?

I took my outofscope.pgc example from our "out of
scope" patch and shortened it. Compare the ecpg-native and
compat outputs and the esql output of the same file. The ecpg
outputs are generated with 8.4.1 plus out patches added, the
native output differs only from 8.3.7's ecpg in the amount of
whitespaces emitted between literals. The get_record1()
function can be called from a button-handler, e.g. when pressing
PgDn, or similar... No tricks needed, straightforward code.

Best regards,
Zolt�n B�sz�rm�nyi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

Attachments:

outofscope.ectext/plain; name=outofscope.ecDownload
struct.htext/x-chdr; name=struct.hDownload
outofscope.c-nativetext/plain; name=outofscope.c-nativeDownload
outofscope.c-compattext/plain; name=outofscope.c-compatDownload
outofscope.c-esqltext/plain; name=outofscope.c-esqlDownload
#30Boszormenyi Zoltan
zb@cybertec.at
In reply to: Michael Meskes (#26)
8 attachment(s)
Re: CommitFest 2009-09, two weeks on

Hi,

Michael Meskes �rta:

It is accepted either way. I was just pointing out that it might be easier to
review/commit at least parts of your patches if they can be applied seperately.

I have split up (and cleaned up a little) the dynamic
cursorname patch into smaller logical, easier-to-review
pieces. Descriptions below.

1) 1a-unified-optfromin-fetch-ctxdiff.patch

ecpg supports optional FROM/IN in FETCH and
MOVE statements (mainly because it's required by
Informix-compatibility). Unify core and ecpg grammar
as per Tom Lane's suggestion.

2) 1b-cursor_name-ctxdiff.patch

"name" -> "cursor_name" transition in core grammar
and ecpg grammar. Currently it does nothing, it's a
preparation phase. Depends on patch 1.

3) 1c-remove-var-from-list.patch

Introduce function remove_variable_from_list().
It is used by the dynamic cursor, SQLDA and DESCRIBE
patches for different reasons. Applicable separately.

4) 1d-dynamiccur-ctxdiff.patch

The real point of the whole series in this email.
Extend "cursor_name" in the ecpg grammar to actually
accept a character variable. The cursorname-as-variable
is replaced in the final SQL script with a $0 placeholder.
Doesn't compile as-is, requires patch 5 to get the
two shift/reduce conflicts fixed. Depends on patches
1, 2 and 3.

5) 1e-fix-shiftreduce-ctxdiff.patch

De-factorize "BACKWARD opt_from_in cursor_name"
and "FORWARD opt_from_in cursor_name" out of
fetch_args and pull them up into FetchStmt in the ecpg
grammar. Depends on patch 4.
One line in parse.pl is not clear for me:
$replace_line{'fetch_args'} = 'ignore';
The genarated preproc.y is the same with or without
this line. But as the previous version had it with
"fetch_direction", I left it in.

6) 1f-cursorname-in-varchar-ctxdiff.patch

Allow that varchar can be used as cursorname as well.
Other character variable types were already supported.
Depends on patch 4.

7) 1g-regressiontests-ctxdiff.patch

Introduce cursor.pgc regression test for both native
and compat mode. Depends on all patches.

8) 1h-fix-parse.pl-ctxdiff.patch

Now useless patch, in the previous dynamic cursorname
patch the following scenario occured: the same rule
had both an "addon" and a "rule" extension. Without
this fix, the following code was generated in preproc.y:
ruleA: <accepted syntax>
{
<addon code block>
{
<automatic code block>
}
With the cleanup I did during this splitup, this scenario
doesn't happen, but this fix may be considered useful.
Applicable separately.

After every patch (except 4) both the core and ecpg
"make check" are successful.

Best regards,
Zolt�n B�sz�rm�nyi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

Attachments:

1a-unified-optfromin-fetch-ctxdiff.patchtext/x-patch; name=1a-unified-optfromin-fetch-ctxdiff.patchDownload
diff -dcrpN pgsql.orig/src/backend/parser/gram.y pgsql.ufd-opt-fromin-fetch/src/backend/parser/gram.y
*** pgsql.orig/src/backend/parser/gram.y	2009-09-23 19:25:40.000000000 +0200
--- pgsql.ufd-opt-fromin-fetch/src/backend/parser/gram.y	2009-10-02 23:57:32.000000000 +0200
*************** static TypeName *TableFuncTypeName(List 
*** 330,336 ****
  %type <ival>	opt_column event cursor_options opt_hold opt_set_data
  %type <objtype>	reindex_type drop_type comment_type
  
! %type <node>	fetch_direction limit_clause select_limit_value
  				offset_clause select_offset_value
  				select_offset_value2 opt_select_fetch_first_value
  %type <ival>	row_or_rows first_or_next
--- 330,336 ----
  %type <ival>	opt_column event cursor_options opt_hold opt_set_data
  %type <objtype>	reindex_type drop_type comment_type
  
! %type <node>	fetch_args limit_clause select_limit_value
  				offset_clause select_offset_value
  				select_offset_value2 opt_select_fetch_first_value
  %type <ival>	row_or_rows first_or_next
*************** comment_text:
*** 4137,4278 ****
   *
   *****************************************************************************/
  
! FetchStmt:	FETCH fetch_direction from_in name
  				{
  					FetchStmt *n = (FetchStmt *) $2;
- 					n->portalname = $4;
- 					n->ismove = FALSE;
- 					$$ = (Node *)n;
- 				}
- 			| FETCH name
- 				{
- 					FetchStmt *n = makeNode(FetchStmt);
- 					n->direction = FETCH_FORWARD;
- 					n->howMany = 1;
- 					n->portalname = $2;
  					n->ismove = FALSE;
  					$$ = (Node *)n;
  				}
! 			| MOVE fetch_direction from_in name
  				{
  					FetchStmt *n = (FetchStmt *) $2;
- 					n->portalname = $4;
  					n->ismove = TRUE;
  					$$ = (Node *)n;
  				}
! 			| MOVE name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->direction = FETCH_FORWARD;
  					n->howMany = 1;
- 					n->portalname = $2;
- 					n->ismove = TRUE;
  					$$ = (Node *)n;
  				}
! 		;
! 
! fetch_direction:
! 			/*EMPTY*/
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->direction = FETCH_FORWARD;
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| NEXT
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->direction = FETCH_FORWARD;
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| PRIOR
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->direction = FETCH_BACKWARD;
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| FIRST_P
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->direction = FETCH_ABSOLUTE;
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| LAST_P
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->direction = FETCH_ABSOLUTE;
  					n->howMany = -1;
  					$$ = (Node *)n;
  				}
! 			| ABSOLUTE_P SignedIconst
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->direction = FETCH_ABSOLUTE;
  					n->howMany = $2;
  					$$ = (Node *)n;
  				}
! 			| RELATIVE_P SignedIconst
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->direction = FETCH_RELATIVE;
  					n->howMany = $2;
  					$$ = (Node *)n;
  				}
! 			| SignedIconst
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->direction = FETCH_FORWARD;
  					n->howMany = $1;
  					$$ = (Node *)n;
  				}
! 			| ALL
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->direction = FETCH_FORWARD;
  					n->howMany = FETCH_ALL;
  					$$ = (Node *)n;
  				}
! 			| FORWARD
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->direction = FETCH_FORWARD;
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| FORWARD SignedIconst
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->direction = FETCH_FORWARD;
  					n->howMany = $2;
  					$$ = (Node *)n;
  				}
! 			| FORWARD ALL
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->direction = FETCH_FORWARD;
  					n->howMany = FETCH_ALL;
  					$$ = (Node *)n;
  				}
! 			| BACKWARD
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->direction = FETCH_BACKWARD;
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| BACKWARD SignedIconst
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->direction = FETCH_BACKWARD;
  					n->howMany = $2;
  					$$ = (Node *)n;
  				}
! 			| BACKWARD ALL
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->direction = FETCH_BACKWARD;
  					n->howMany = FETCH_ALL;
  					$$ = (Node *)n;
--- 4137,4280 ----
   *
   *****************************************************************************/
  
! FetchStmt:	FETCH fetch_args
  				{
  					FetchStmt *n = (FetchStmt *) $2;
  					n->ismove = FALSE;
  					$$ = (Node *)n;
  				}
! 			| MOVE fetch_args
  				{
  					FetchStmt *n = (FetchStmt *) $2;
  					n->ismove = TRUE;
  					$$ = (Node *)n;
  				}
! 		;
! 
! fetch_args:	name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
+ 					n->portalname = $1;
  					n->direction = FETCH_FORWARD;
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
+ 					n->portalname = $2;
  					n->direction = FETCH_FORWARD;
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| NEXT opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
+ 					n->portalname = $3;
  					n->direction = FETCH_FORWARD;
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| PRIOR opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
+ 					n->portalname = $3;
  					n->direction = FETCH_BACKWARD;
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| FIRST_P opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
+ 					n->portalname = $3;
  					n->direction = FETCH_ABSOLUTE;
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| LAST_P opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
+ 					n->portalname = $3;
  					n->direction = FETCH_ABSOLUTE;
  					n->howMany = -1;
  					$$ = (Node *)n;
  				}
! 			| ABSOLUTE_P SignedIconst opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
+ 					n->portalname = $4;
  					n->direction = FETCH_ABSOLUTE;
  					n->howMany = $2;
  					$$ = (Node *)n;
  				}
! 			| RELATIVE_P SignedIconst opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
+ 					n->portalname = $4;
  					n->direction = FETCH_RELATIVE;
  					n->howMany = $2;
  					$$ = (Node *)n;
  				}
! 			| SignedIconst opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
+ 					n->portalname = $3;
  					n->direction = FETCH_FORWARD;
  					n->howMany = $1;
  					$$ = (Node *)n;
  				}
! 			| ALL opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
+ 					n->portalname = $3;
  					n->direction = FETCH_FORWARD;
  					n->howMany = FETCH_ALL;
  					$$ = (Node *)n;
  				}
! 			| FORWARD opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
+ 					n->portalname = $3;
  					n->direction = FETCH_FORWARD;
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| FORWARD SignedIconst opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
+ 					n->portalname = $4;
  					n->direction = FETCH_FORWARD;
  					n->howMany = $2;
  					$$ = (Node *)n;
  				}
! 			| FORWARD ALL opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
+ 					n->portalname = $4;
  					n->direction = FETCH_FORWARD;
  					n->howMany = FETCH_ALL;
  					$$ = (Node *)n;
  				}
! 			| BACKWARD opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
+ 					n->portalname = $3;
  					n->direction = FETCH_BACKWARD;
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| BACKWARD SignedIconst opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
+ 					n->portalname = $4;
  					n->direction = FETCH_BACKWARD;
  					n->howMany = $2;
  					$$ = (Node *)n;
  				}
! 			| BACKWARD ALL opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
+ 					n->portalname = $4;
  					n->direction = FETCH_BACKWARD;
  					n->howMany = FETCH_ALL;
  					$$ = (Node *)n;
*************** from_in:	FROM									{}
*** 4283,4288 ****
--- 4285,4295 ----
  			| IN_P									{}
  		;
  
+ opt_from_in:	FROM									{}
+ 			| IN_P									{}
+ 			| /* EMPTY */								{}
+ 		;
+ 
  
  /*****************************************************************************
   *
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.addons pgsql.ufd-opt-fromin-fetch/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.addons	2009-08-14 16:27:41.000000000 +0200
--- pgsql.ufd-opt-fromin-fetch/src/interfaces/ecpg/preproc/ecpg.addons	2009-10-03 00:50:37.000000000 +0200
*************** ECPG: ConstraintAttributeSpecConstraintT
*** 206,221 ****
  			if (strcmp($2, "deferrable") != 0 && strcmp($1, "initially deferrable") == 0 )
  				mmerror(PARSE_ERROR, ET_ERROR, "constraint declared INITIALLY DEFERRED must be DEFERRABLE");
  ECPG: var_valueNumericOnly addon
- ECPG: fetch_directionSignedIconst addon
  		if ($1[0] == '$')
  		{
  			free($1);
  			$1 = make_str("$0");
  		}
! ECPG: fetch_directionABSOLUTE_PSignedIconst addon
! ECPG: fetch_directionRELATIVE_PSignedIconst addon
! ECPG: fetch_directionFORWARDSignedIconst addon
! ECPG: fetch_directionBACKWARDSignedIconst addon
  		if ($2[0] == '$')
  		{
  			free($2);
--- 206,241 ----
  			if (strcmp($2, "deferrable") != 0 && strcmp($1, "initially deferrable") == 0 )
  				mmerror(PARSE_ERROR, ET_ERROR, "constraint declared INITIALLY DEFERRED must be DEFERRABLE");
  ECPG: var_valueNumericOnly addon
  		if ($1[0] == '$')
  		{
  			free($1);
  			$1 = make_str("$0");
  		}
! ECPG: fetch_argsname addon
! 		add_additional_variables($1, false);
! ECPG: fetch_argsfrom_inname addon
! 		add_additional_variables($2, false);
! ECPG: fetch_argsNEXTopt_from_inname addon
! ECPG: fetch_argsPRIORopt_from_inname addon
! ECPG: fetch_argsFIRST_Popt_from_inname addon
! ECPG: fetch_argsLAST_Popt_from_inname addon 
! ECPG: fetch_argsALLopt_from_inname addon    
! 		add_additional_variables($3, false);
! ECPG: fetch_argsSignedIconstopt_from_inname addon
! 		add_additional_variables($3, false);
! 		if ($1[0] == '$')
! 		{
! 			free($1);
! 			$1 = make_str("$0");
! 		}
! ECPG: fetch_argsFORWARDALLopt_from_inname addon
! ECPG: fetch_argsBACKWARDALLopt_from_inname addon
! 		add_additional_variables($4, false);
! ECPG: fetch_argsABSOLUTE_PSignedIconstopt_from_inname addon
! ECPG: fetch_argsRELATIVE_PSignedIconstopt_from_inname addon
! ECPG: fetch_argsFORWARDSignedIconstopt_from_inname addon
! ECPG: fetch_argsBACKWARDSignedIconstopt_from_inname addon
! 		add_additional_variables($4, false);
  		if ($2[0] == '$')
  		{
  			free($2);
*************** ECPG: VariableShowStmtSHOWALL block
*** 336,382 ****
  		mmerror(PARSE_ERROR, ET_ERROR, "SHOW ALL is not implemented");
  		$$ = EMPTY;
  	}
! ECPG: FetchStmtFETCHfetch_directionfrom_inname block 
! 	{
! 		add_additional_variables($4, false);
! 		$$ = cat_str(4, make_str("fetch"), $2, $3, $4);
! 	}
! ECPG: FetchStmtFETCHname block
  	{
! 		add_additional_variables($2, false);
! 		$$ = cat_str(2, make_str("fetch"), $2);
  	}
- ECPG: FetchStmtMOVEname rule
- 	| FETCH fetch_direction from_in name ecpg_into
- 		{
- 			add_additional_variables($4, false);
- 			$$ = cat_str(4, make_str("fetch"), $2, $3, $4);
- 		}
- 	| FETCH fetch_direction name ecpg_into
- 		{
- 			add_additional_variables($3, false);
- 			$$ = cat_str(4, make_str("fetch"), $2, make_str("from"), $3);
- 		}
- 	| FETCH from_in name ecpg_into
- 		{
- 			add_additional_variables($3, false);
- 			$$ = cat_str(3, make_str("fetch"), $2, $3);
- 		}
- 	| FETCH name ecpg_into
- 		{
- 			add_additional_variables($2, false);
- 			$$ = cat2_str(make_str("fetch"), $2);
- 		}
- 	| FETCH fetch_direction name
- 		{
- 			add_additional_variables($3, false);
- 			$$ = cat_str(4, make_str("fetch"), $2, make_str("from"), $3);
- 		}
- 	| FETCH from_in name
- 		{
- 			add_additional_variables($3, false);
- 			$$ = cat_str(3, make_str("fetch"), $2, $3);
- 		}
  ECPG: SpecialRuleRelationOLD addon
  		if (!QueryIsRule)
  			mmerror(PARSE_ERROR, ET_ERROR, "OLD used in query that is not in a rule");
--- 356,366 ----
  		mmerror(PARSE_ERROR, ET_ERROR, "SHOW ALL is not implemented");
  		$$ = EMPTY;
  	}
! ECPG: FetchStmtMOVEfetch_args rule
! 	| FETCH fetch_args ecpg_into
  	{
! 		$$ = cat2_str(make_str("fetch"), $2);
  	}
  ECPG: SpecialRuleRelationOLD addon
  		if (!QueryIsRule)
  			mmerror(PARSE_ERROR, ET_ERROR, "OLD used in query that is not in a rule");
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c pgsql.ufd-opt-fromin-fetch/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c	2009-08-14 16:27:41.000000000 +0200
--- pgsql.ufd-opt-fromin-fetch/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c	2009-10-03 00:33:14.000000000 +0200
*************** if (sqlca.sqlcode < 0) dosqlprint ( );}
*** 158,164 ****
  
  	while (1)
  	{
! 		{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch forward from c", ECPGt_EOIT, 
  	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
  	ECPGt_decimal,&(j),(long)1,(long)1,sizeof(decimal), 
--- 158,164 ----
  
  	while (1)
  	{
! 		{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch forward c", ECPGt_EOIT, 
  	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
  	ECPGt_decimal,&(j),(long)1,(long)1,sizeof(decimal), 
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-test_informix.stderr pgsql.ufd-opt-fromin-fetch/src/interfaces/ecpg/test/expected/compat_informix-test_informix.stderr
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-test_informix.stderr	2009-08-14 16:27:41.000000000 +0200
--- pgsql.ufd-opt-fromin-fetch/src/interfaces/ecpg/test/expected/compat_informix-test_informix.stderr	2009-10-03 00:33:15.000000000 +0200
*************** DETAIL:  Key (i)=(7) already exists.
*** 63,69 ****
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_execute on line 95: OK: DECLARE CURSOR
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 57: query: fetch forward from c; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_execute on line 57: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
--- 63,69 ----
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_execute on line 95: OK: DECLARE CURSOR
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 57: query: fetch forward c; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_execute on line 57: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
*************** DETAIL:  Key (i)=(7) already exists.
*** 75,81 ****
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_get_data on line 57: RESULT: test    offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 57: query: fetch forward from c; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_execute on line 57: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
--- 75,81 ----
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_get_data on line 57: RESULT: test    offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 57: query: fetch forward c; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_execute on line 57: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
*************** DETAIL:  Key (i)=(7) already exists.
*** 87,93 ****
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_get_data on line 57: RESULT: a       offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 57: query: fetch forward from c; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_execute on line 57: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
--- 87,93 ----
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_get_data on line 57: RESULT: a       offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 57: query: fetch forward c; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_execute on line 57: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
1b-cursor_name-ctxdiff.patchtext/x-patch; name=1b-cursor_name-ctxdiff.patchDownload
diff -dcrpN pgsql.ufd-opt-fromin-fetch/src/backend/parser/gram.y pgsql.cursor_name/src/backend/parser/gram.y
*** pgsql.ufd-opt-fromin-fetch/src/backend/parser/gram.y	2009-10-02 23:57:32.000000000 +0200
--- pgsql.cursor_name/src/backend/parser/gram.y	2009-10-03 00:47:53.000000000 +0200
*************** static TypeName *TableFuncTypeName(List 
*** 252,258 ****
  
  %type <str>		relation_name copy_file_name
  				database_name access_method_clause access_method attr_name
! 				index_name name file_name cluster_index_specification
  
  %type <list>	func_name handler_name qual_Op qual_all_Op subquery_Op
  				opt_class opt_inline_handler opt_validator validator_clause
--- 252,258 ----
  
  %type <str>		relation_name copy_file_name
  				database_name access_method_clause access_method attr_name
! 				index_name name cursor_name file_name cluster_index_specification
  
  %type <list>	func_name handler_name qual_Op qual_all_Op subquery_Op
  				opt_class opt_inline_handler opt_validator validator_clause
*************** reloption_elem:	
*** 1920,1926 ****
   *****************************************************************************/
  
  ClosePortalStmt:
! 			CLOSE name
  				{
  					ClosePortalStmt *n = makeNode(ClosePortalStmt);
  					n->portalname = $2;
--- 1920,1926 ----
   *****************************************************************************/
  
  ClosePortalStmt:
! 			CLOSE cursor_name
  				{
  					ClosePortalStmt *n = makeNode(ClosePortalStmt);
  					n->portalname = $2;
*************** FetchStmt:	FETCH fetch_args
*** 4151,4157 ****
  				}
  		;
  
! fetch_args:	name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $1;
--- 4151,4157 ----
  				}
  		;
  
! fetch_args:	cursor_name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $1;
*************** fetch_args:	name
*** 4159,4165 ****
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $2;
--- 4159,4165 ----
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| from_in cursor_name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $2;
*************** fetch_args:	name
*** 4167,4173 ****
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| NEXT opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $3;
--- 4167,4173 ----
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| NEXT opt_from_in cursor_name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $3;
*************** fetch_args:	name
*** 4175,4181 ****
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| PRIOR opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $3;
--- 4175,4181 ----
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| PRIOR opt_from_in cursor_name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $3;
*************** fetch_args:	name
*** 4183,4189 ****
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| FIRST_P opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $3;
--- 4183,4189 ----
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| FIRST_P opt_from_in cursor_name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $3;
*************** fetch_args:	name
*** 4191,4197 ****
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| LAST_P opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $3;
--- 4191,4197 ----
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| LAST_P opt_from_in cursor_name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $3;
*************** fetch_args:	name
*** 4199,4205 ****
  					n->howMany = -1;
  					$$ = (Node *)n;
  				}
! 			| ABSOLUTE_P SignedIconst opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $4;
--- 4199,4205 ----
  					n->howMany = -1;
  					$$ = (Node *)n;
  				}
! 			| ABSOLUTE_P SignedIconst opt_from_in cursor_name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $4;
*************** fetch_args:	name
*** 4207,4213 ****
  					n->howMany = $2;
  					$$ = (Node *)n;
  				}
! 			| RELATIVE_P SignedIconst opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $4;
--- 4207,4213 ----
  					n->howMany = $2;
  					$$ = (Node *)n;
  				}
! 			| RELATIVE_P SignedIconst opt_from_in cursor_name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $4;
*************** fetch_args:	name
*** 4215,4221 ****
  					n->howMany = $2;
  					$$ = (Node *)n;
  				}
! 			| SignedIconst opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $3;
--- 4215,4221 ----
  					n->howMany = $2;
  					$$ = (Node *)n;
  				}
! 			| SignedIconst opt_from_in cursor_name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $3;
*************** fetch_args:	name
*** 4223,4229 ****
  					n->howMany = $1;
  					$$ = (Node *)n;
  				}
! 			| ALL opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $3;
--- 4223,4229 ----
  					n->howMany = $1;
  					$$ = (Node *)n;
  				}
! 			| ALL opt_from_in cursor_name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $3;
*************** fetch_args:	name
*** 4231,4237 ****
  					n->howMany = FETCH_ALL;
  					$$ = (Node *)n;
  				}
! 			| FORWARD opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $3;
--- 4231,4237 ----
  					n->howMany = FETCH_ALL;
  					$$ = (Node *)n;
  				}
! 			| FORWARD opt_from_in cursor_name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $3;
*************** fetch_args:	name
*** 4239,4245 ****
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| FORWARD SignedIconst opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $4;
--- 4239,4245 ----
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| FORWARD SignedIconst opt_from_in cursor_name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $4;
*************** fetch_args:	name
*** 4247,4253 ****
  					n->howMany = $2;
  					$$ = (Node *)n;
  				}
! 			| FORWARD ALL opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $4;
--- 4247,4253 ----
  					n->howMany = $2;
  					$$ = (Node *)n;
  				}
! 			| FORWARD ALL opt_from_in cursor_name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $4;
*************** fetch_args:	name
*** 4255,4261 ****
  					n->howMany = FETCH_ALL;
  					$$ = (Node *)n;
  				}
! 			| BACKWARD opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $3;
--- 4255,4261 ----
  					n->howMany = FETCH_ALL;
  					$$ = (Node *)n;
  				}
! 			| BACKWARD opt_from_in cursor_name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $3;
*************** fetch_args:	name
*** 4263,4269 ****
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| BACKWARD SignedIconst opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $4;
--- 4263,4269 ----
  					n->howMany = 1;
  					$$ = (Node *)n;
  				}
! 			| BACKWARD SignedIconst opt_from_in cursor_name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $4;
*************** fetch_args:	name
*** 4271,4277 ****
  					n->howMany = $2;
  					$$ = (Node *)n;
  				}
! 			| BACKWARD ALL opt_from_in name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $4;
--- 4271,4277 ----
  					n->howMany = $2;
  					$$ = (Node *)n;
  				}
! 			| BACKWARD ALL opt_from_in cursor_name
  				{
  					FetchStmt *n = makeNode(FetchStmt);
  					n->portalname = $4;
*************** set_target_list:
*** 6941,6947 ****
   *				CURSOR STATEMENTS
   *
   *****************************************************************************/
! DeclareCursorStmt: DECLARE name cursor_options CURSOR opt_hold FOR SelectStmt
  				{
  					DeclareCursorStmt *n = makeNode(DeclareCursorStmt);
  					n->portalname = $2;
--- 6941,6947 ----
   *				CURSOR STATEMENTS
   *
   *****************************************************************************/
! DeclareCursorStmt: DECLARE cursor_name cursor_options CURSOR opt_hold FOR SelectStmt
  				{
  					DeclareCursorStmt *n = makeNode(DeclareCursorStmt);
  					n->portalname = $2;
*************** DeclareCursorStmt: DECLARE name cursor_o
*** 6952,6957 ****
--- 6952,6960 ----
  				}
  		;
  
+ cursor_name:	name						{ $$ = $1; }
+ 		;
+ 
  cursor_options: /*EMPTY*/					{ $$ = 0; }
  			| cursor_options NO SCROLL		{ $$ = $1 | CURSOR_OPT_NO_SCROLL; }
  			| cursor_options SCROLL			{ $$ = $1 | CURSOR_OPT_SCROLL; }
diff -dcrpN pgsql.ufd-opt-fromin-fetch/src/interfaces/ecpg/preproc/ecpg.addons pgsql.cursor_name/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.ufd-opt-fromin-fetch/src/interfaces/ecpg/preproc/ecpg.addons	2009-10-03 00:50:37.000000000 +0200
--- pgsql.cursor_name/src/interfaces/ecpg/preproc/ecpg.addons	2009-10-03 00:51:58.000000000 +0200
*************** ECPG: var_valueNumericOnly addon
*** 211,240 ****
  			free($1);
  			$1 = make_str("$0");
  		}
! ECPG: fetch_argsname addon
  		add_additional_variables($1, false);
! ECPG: fetch_argsfrom_inname addon
  		add_additional_variables($2, false);
! ECPG: fetch_argsNEXTopt_from_inname addon
! ECPG: fetch_argsPRIORopt_from_inname addon
! ECPG: fetch_argsFIRST_Popt_from_inname addon
! ECPG: fetch_argsLAST_Popt_from_inname addon 
! ECPG: fetch_argsALLopt_from_inname addon    
  		add_additional_variables($3, false);
! ECPG: fetch_argsSignedIconstopt_from_inname addon
  		add_additional_variables($3, false);
  		if ($1[0] == '$')
  		{
  			free($1);
  			$1 = make_str("$0");
  		}
! ECPG: fetch_argsFORWARDALLopt_from_inname addon
! ECPG: fetch_argsBACKWARDALLopt_from_inname addon
  		add_additional_variables($4, false);
! ECPG: fetch_argsABSOLUTE_PSignedIconstopt_from_inname addon
! ECPG: fetch_argsRELATIVE_PSignedIconstopt_from_inname addon
! ECPG: fetch_argsFORWARDSignedIconstopt_from_inname addon
! ECPG: fetch_argsBACKWARDSignedIconstopt_from_inname addon
  		add_additional_variables($4, false);
  		if ($2[0] == '$')
  		{
--- 211,240 ----
  			free($1);
  			$1 = make_str("$0");
  		}
! ECPG: fetch_argscursor_name addon
  		add_additional_variables($1, false);
! ECPG: fetch_argsfrom_incursor_name addon
  		add_additional_variables($2, false);
! ECPG: fetch_argsNEXTopt_from_incursor_name addon
! ECPG: fetch_argsPRIORopt_from_incursor_name addon
! ECPG: fetch_argsFIRST_Popt_from_incursor_name addon
! ECPG: fetch_argsLAST_Popt_from_incursor_name addon 
! ECPG: fetch_argsALLopt_from_incursor_name addon    
  		add_additional_variables($3, false);
! ECPG: fetch_argsSignedIconstopt_from_incursor_name addon
  		add_additional_variables($3, false);
  		if ($1[0] == '$')
  		{
  			free($1);
  			$1 = make_str("$0");
  		}
! ECPG: fetch_argsFORWARDALLopt_from_incursor_name addon
! ECPG: fetch_argsBACKWARDALLopt_from_incursor_name addon
  		add_additional_variables($4, false);
! ECPG: fetch_argsABSOLUTE_PSignedIconstopt_from_incursor_name addon
! ECPG: fetch_argsRELATIVE_PSignedIconstopt_from_incursor_name addon
! ECPG: fetch_argsFORWARDSignedIconstopt_from_incursor_name addon
! ECPG: fetch_argsBACKWARDSignedIconstopt_from_incursor_name addon
  		add_additional_variables($4, false);
  		if ($2[0] == '$')
  		{
*************** ECPG: PrepareStmtPREPAREprepared_namepre
*** 255,261 ****
  	}
  ECPG: ExecuteStmtEXECUTEprepared_nameexecute_param_clauseexecute_rest block
  	{ $$ = $2; }
! ECPG: DeclareCursorStmtDECLAREnamecursor_optionsCURSORopt_holdFORSelectStmt block
  	{
  		struct cursor *ptr, *this;
  		char *comment;
--- 255,261 ----
  	}
  ECPG: ExecuteStmtEXECUTEprepared_nameexecute_param_clauseexecute_rest block
  	{ $$ = $2; }
! ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectStmt block
  	{
  		struct cursor *ptr, *this;
  		char *comment;
diff -dcrpN pgsql.ufd-opt-fromin-fetch/src/interfaces/ecpg/preproc/ecpg.trailer pgsql.cursor_name/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.ufd-opt-fromin-fetch/src/interfaces/ecpg/preproc/ecpg.trailer	2009-09-23 19:25:46.000000000 +0200
--- pgsql.cursor_name/src/interfaces/ecpg/preproc/ecpg.trailer	2009-10-03 00:55:00.000000000 +0200
*************** prepared_name: name             {
*** 285,291 ****
   * Declare a prepared cursor. The syntax is different from the standard
   * declare statement, so we create a new rule.
   */
! ECPGCursorStmt:  DECLARE name cursor_options CURSOR opt_hold FOR prepared_name
  		{
  			struct cursor *ptr, *this;
  			struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable));
--- 285,291 ----
   * Declare a prepared cursor. The syntax is different from the standard
   * declare statement, so we create a new rule.
   */
! ECPGCursorStmt:  DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared_name
  		{
  			struct cursor *ptr, *this;
  			struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable));
*************** ECPGFree:	SQL_FREE name	{ $$ = $2; }
*** 957,963 ****
  /*
   * open is an open cursor, at the moment this has to be removed
   */
! ECPGOpen: SQL_OPEN name opt_ecpg_using { $$ = $2; };
  
  opt_ecpg_using: /*EMPTY*/	{ $$ = EMPTY; }
  		| ecpg_using		{ $$ = $1; }
--- 957,963 ----
  /*
   * open is an open cursor, at the moment this has to be removed
   */
! ECPGOpen: SQL_OPEN cursor_name opt_ecpg_using { $$ = $2; };
  
  opt_ecpg_using: /*EMPTY*/	{ $$ = EMPTY; }
  		| ecpg_using		{ $$ = $1; }
1c-remove-var-from-list-ctxdiff.patchtext/x-patch; name=1c-remove-var-from-list-ctxdiff.patchDownload
diff -dcrpN pgsql.cursor_name/src/interfaces/ecpg/preproc/extern.h pgsql.removevarlist/src/interfaces/ecpg/preproc/extern.h
*** pgsql.cursor_name/src/interfaces/ecpg/preproc/extern.h	2009-09-08 10:12:40.000000000 +0200
--- pgsql.removevarlist/src/interfaces/ecpg/preproc/extern.h	2009-10-03 01:07:54.000000000 +0200
*************** extern struct descriptor *lookup_descrip
*** 90,95 ****
--- 90,96 ----
  extern struct variable *descriptor_variable(const char *name, int input);
  extern void add_variable_to_head(struct arguments **, struct variable *, struct variable *);
  extern void add_variable_to_tail(struct arguments **, struct variable *, struct variable *);
+ extern void remove_variable_from_list(struct arguments ** list, struct variable * var);
  extern void dump_variables(struct arguments *, int);
  extern struct typedefs *get_typedef(char *);
  extern void adjust_array(enum ECPGttype, char **, char **, char *, char *, int, bool);
diff -dcrpN pgsql.cursor_name/src/interfaces/ecpg/preproc/variable.c pgsql.removevarlist/src/interfaces/ecpg/preproc/variable.c
*** pgsql.cursor_name/src/interfaces/ecpg/preproc/variable.c	2009-08-07 13:06:28.000000000 +0200
--- pgsql.removevarlist/src/interfaces/ecpg/preproc/variable.c	2009-10-03 01:09:32.000000000 +0200
*************** add_variable_to_tail(struct arguments **
*** 401,406 ****
--- 401,430 ----
  		*list = new;
  }
  
+ void
+ remove_variable_from_list(struct arguments ** list, struct variable * var)
+ {
+ 	struct arguments *p, *prev = NULL;
+ 	bool found = false;
+ 
+ 	for (p = *list; p; p = p->next)
+ 	{
+ 		if (p->variable == var)
+ 		{
+ 			found = true;
+ 			break;
+ 		}
+ 		prev = p;
+ 	}
+ 	if (found)
+ 	{
+ 		if (prev)
+ 			prev->next = p->next;
+ 		else
+ 			*list = p->next;
+ 	}
+ }
+ 
  /* Dump out a list of all the variable on this list.
     This is a recursive function that works from the end of the list and
     deletes the list as we go on.
1d-dynamiccur-ctxdiff.patchtext/x-patch; name=1d-dynamiccur-ctxdiff.patchDownload
diff -dcrpN pgsql.removevarlist/src/interfaces/ecpg/preproc/ecpg.addons pgsql.dynamiccur/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.removevarlist/src/interfaces/ecpg/preproc/ecpg.addons	2009-10-03 00:51:58.000000000 +0200
--- pgsql.dynamiccur/src/interfaces/ecpg/preproc/ecpg.addons	2009-10-03 01:24:46.000000000 +0200
*************** ECPG: var_valueNumericOnly addon
*** 213,228 ****
--- 213,248 ----
  		}
  ECPG: fetch_argscursor_name addon
  		add_additional_variables($1, false);
+ 		if ($1[0] == ':')
+ 		{
+ 			free($1);
+ 			$1 = make_str("$0");
+ 		}
  ECPG: fetch_argsfrom_incursor_name addon
  		add_additional_variables($2, false);
+ 		if ($2[0] == ':')
+ 		{
+ 			free($2);
+ 			$2 = make_str("$0");
+ 		}
  ECPG: fetch_argsNEXTopt_from_incursor_name addon
  ECPG: fetch_argsPRIORopt_from_incursor_name addon
  ECPG: fetch_argsFIRST_Popt_from_incursor_name addon
  ECPG: fetch_argsLAST_Popt_from_incursor_name addon 
  ECPG: fetch_argsALLopt_from_incursor_name addon    
  		add_additional_variables($3, false);
+ 		if ($3[0] == ':')
+ 		{
+ 			free($3);
+ 			$3 = make_str("$0");
+ 		}
  ECPG: fetch_argsSignedIconstopt_from_incursor_name addon
  		add_additional_variables($3, false);
+ 		if ($3[0] == ':')
+ 		{
+ 			free($3);
+ 			$3 = make_str("$0");
+ 		}
  		if ($1[0] == '$')
  		{
  			free($1);
*************** ECPG: fetch_argsSignedIconstopt_from_inc
*** 231,246 ****
--- 251,285 ----
  ECPG: fetch_argsFORWARDALLopt_from_incursor_name addon
  ECPG: fetch_argsBACKWARDALLopt_from_incursor_name addon
  		add_additional_variables($4, false);
+ 		if ($4[0] == ':')
+ 		{
+ 			free($4);
+ 			$4 = make_str("$0");
+ 		}
  ECPG: fetch_argsABSOLUTE_PSignedIconstopt_from_incursor_name addon
  ECPG: fetch_argsRELATIVE_PSignedIconstopt_from_incursor_name addon
  ECPG: fetch_argsFORWARDSignedIconstopt_from_incursor_name addon
  ECPG: fetch_argsBACKWARDSignedIconstopt_from_incursor_name addon
  		add_additional_variables($4, false);
+ 		if ($4[0] == ':')
+ 		{
+ 			free($4);
+ 			$4 = make_str("$0");
+ 		}
  		if ($2[0] == '$')
  		{
  			free($2);
  			$2 = make_str("$0");
  		}
+ ECPG: cursor_namename rule
+ 	| char_civar
+ 		{
+ 			char *curname = mm_alloc(strlen($1) + 2);
+ 			sprintf(curname, ":%s", $1);
+ 			free($1);
+ 			$1 = curname;
+ 			$$ = $1;
+ 		}
  ECPG: PrepareStmtPREPAREprepared_nameprep_type_clauseASPreparableStmt block
  	{
  		$$.name = $2;
*************** ECPG: ExecuteStmtEXECUTEprepared_nameexe
*** 258,263 ****
--- 297,303 ----
  ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectStmt block
  	{
  		struct cursor *ptr, *this;
+ 		char *cursor_marker = $2[0] == ':' ? make_str("$0") : mm_strdup($2);
  		char *comment;
  
  		for (ptr = cur; ptr != NULL; ptr = ptr->next)
*************** ECPG: DeclareCursorStmtDECLAREcursor_nam
*** 272,278 ****
  		this->name = $2;
  		this->connection = connection;
  		this->opened = false;
! 		this->command =  cat_str(7, make_str("declare"), mm_strdup($2), $3, make_str("cursor"), $5, make_str("for"), $7);
  		this->argsinsert = argsinsert;
  		this->argsresult = argsresult;
  		argsinsert = argsresult = NULL;
--- 312,318 ----
  		this->name = $2;
  		this->connection = connection;
  		this->opened = false;
! 		this->command =  cat_str(7, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for"), $7);
  		this->argsinsert = argsinsert;
  		this->argsresult = argsresult;
  		argsinsert = argsresult = NULL;
*************** ECPG: DeclareCursorStmtDECLAREcursor_nam
*** 292,297 ****
--- 332,342 ----
  		else
  			$$ = comment;
  	}
+ ECPG: ClosePortalStmtCLOSEcursor_name block
+ 	{
+ 		char *cursor_marker = $2[0] == ':' ? make_str("$0") : $2;
+ 		$$ = cat2_str(make_str("close"), cursor_marker);
+ 	}
  ECPG: opt_hold block
  	{
  		if (compat == ECPG_COMPAT_INFORMIX_SE && autocommit == true)
diff -dcrpN pgsql.removevarlist/src/interfaces/ecpg/preproc/ecpg.trailer pgsql.dynamiccur/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.removevarlist/src/interfaces/ecpg/preproc/ecpg.trailer	2009-10-03 00:55:00.000000000 +0200
--- pgsql.dynamiccur/src/interfaces/ecpg/preproc/ecpg.trailer	2009-10-03 01:36:36.000000000 +0200
*************** prepared_name: name             {
*** 288,293 ****
--- 288,294 ----
  ECPGCursorStmt:  DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared_name
  		{
  			struct cursor *ptr, *this;
+ 			char *cursor_marker = $2[0] == ':' ? make_str("$0") : mm_strdup($2);
  			struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable));
  			const char *con = connection ? connection : "NULL";
  
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 304,310 ****
  			this->next = cur;
  			this->name = $2;
  			this->connection = connection;
! 			this->command =  cat_str(6, make_str("declare"), mm_strdup($2), $3, make_str("cursor"), $5, make_str("for $1"));
  			this->argsresult = NULL;
  
  			thisquery->type = &ecpg_query;
--- 305,311 ----
  			this->next = cur;
  			this->name = $2;
  			this->connection = connection;
! 			this->command =  cat_str(6, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for $1"));
  			this->argsresult = NULL;
  
  			thisquery->type = &ecpg_query;
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 314,319 ****
--- 315,326 ----
  			sprintf(thisquery->name, "ECPGprepared_statement(%s, %s, __LINE__)", con, $7);
  
  			this->argsinsert = NULL;
+ 			if ($2[0] == ':')
+ 			{
+ 				struct variable *var = find_variable($2 + 1);
+ 				remove_variable_from_list(&argsinsert, var);
+ 				add_variable_to_head(&(this->argsinsert), var, &no_indicator);
+ 			}
  			add_variable_to_head(&(this->argsinsert), thisquery, &no_indicator);
  
  			cur = this;
*************** ECPGFree:	SQL_FREE name	{ $$ = $2; }
*** 957,963 ****
  /*
   * open is an open cursor, at the moment this has to be removed
   */
! ECPGOpen: SQL_OPEN cursor_name opt_ecpg_using { $$ = $2; };
  
  opt_ecpg_using: /*EMPTY*/	{ $$ = EMPTY; }
  		| ecpg_using		{ $$ = $1; }
--- 964,979 ----
  /*
   * open is an open cursor, at the moment this has to be removed
   */
! ECPGOpen: SQL_OPEN cursor_name opt_ecpg_using
! 		{
! 			if ($2[0] == ':')
! 			{
! 				struct variable *var = find_variable($2 + 1);
! 				remove_variable_from_list(&argsinsert, var);
! 			}
! 			$$ = $2;
! 		}
! 		;
  
  opt_ecpg_using: /*EMPTY*/	{ $$ = EMPTY; }
  		| ecpg_using		{ $$ = $1; }
*************** civarind: cvariable indicator
*** 1782,1787 ****
--- 1798,1810 ----
  		}
  		;
  
+ char_civar: char_variable
+ 		{
+ 			add_variable_to_head(&argsinsert, find_variable($1), &no_indicator);
+ 			$$ = $1;
+ 		}
+ 		;
+ 
  civar: cvariable
  		{
  			add_variable_to_head(&argsinsert, find_variable($1), &no_indicator);
diff -dcrpN pgsql.removevarlist/src/interfaces/ecpg/preproc/ecpg.type pgsql.dynamiccur/src/interfaces/ecpg/preproc/ecpg.type
*** pgsql.removevarlist/src/interfaces/ecpg/preproc/ecpg.type	2008-11-14 11:03:33.000000000 +0100
--- pgsql.dynamiccur/src/interfaces/ecpg/preproc/ecpg.type	2009-10-03 01:36:11.000000000 +0200
***************
*** 43,48 ****
--- 43,49 ----
  %type <str> c_term
  %type <str> c_thing
  %type <str> char_variable
+ %type <str> char_civar
  %type <str> civar
  %type <str> civarind
  %type <str> ColLabel
1e-fix-shiftreduce-ctxdiff.patchtext/x-patch; name=1e-fix-shiftreduce-ctxdiff.patchDownload
diff -dcrpN pgsql.dynamiccur/src/interfaces/ecpg/preproc/ecpg.addons pgsql.fixshred/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.dynamiccur/src/interfaces/ecpg/preproc/ecpg.addons	2009-10-03 01:24:46.000000000 +0200
--- pgsql.fixshred/src/interfaces/ecpg/preproc/ecpg.addons	2009-10-03 01:54:43.000000000 +0200
*************** ECPG: FetchStmtMOVEfetch_args rule
*** 406,411 ****
--- 406,459 ----
  	{
  		$$ = cat2_str(make_str("fetch"), $2);
  	}
+ 	| FETCH FORWARD cursor_name opt_ecpg_into
+ 	{
+ 		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
+ 		add_additional_variables($3, false);
+ 		$$ = cat_str(2, make_str("fetch forward"), cursor_marker);
+ 	}
+ 	| FETCH FORWARD from_in cursor_name opt_ecpg_into
+ 	{
+ 		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
+ 		add_additional_variables($4, false);
+ 		$$ = cat_str(2, make_str("fetch forward from"), cursor_marker);
+ 	}
+ 	| FETCH BACKWARD cursor_name opt_ecpg_into
+ 	{
+ 		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
+ 		add_additional_variables($3, false);
+ 		$$ = cat_str(2, make_str("fetch backward"), cursor_marker);
+ 	}
+ 	| FETCH BACKWARD from_in cursor_name opt_ecpg_into
+ 	{
+ 		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
+ 		add_additional_variables($4, false);
+ 		$$ = cat_str(2, make_str("fetch backward from"), cursor_marker);
+ 	}
+ 	| MOVE FORWARD cursor_name
+ 	{
+ 		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
+ 		add_additional_variables($3, false);
+ 		$$ = cat_str(2, make_str("move forward"), cursor_marker);
+ 	}
+ 	| MOVE FORWARD from_in cursor_name
+ 	{
+ 		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
+ 		add_additional_variables($4, false);
+ 		$$ = cat_str(2, make_str("move forward from"), cursor_marker);
+ 	}
+ 	| MOVE BACKWARD cursor_name
+ 	{
+ 		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
+ 		add_additional_variables($3, false);
+ 		$$ = cat_str(2, make_str("move backward"), cursor_marker);
+ 	}
+ 	| MOVE BACKWARD from_in cursor_name
+ 	{
+ 		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
+ 		add_additional_variables($4, false);
+ 		$$ = cat_str(2, make_str("move backward from"), cursor_marker);
+ 	}
  ECPG: SpecialRuleRelationOLD addon
  		if (!QueryIsRule)
  			mmerror(PARSE_ERROR, ET_ERROR, "OLD used in query that is not in a rule");
diff -dcrpN pgsql.dynamiccur/src/interfaces/ecpg/preproc/ecpg.trailer pgsql.fixshred/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.dynamiccur/src/interfaces/ecpg/preproc/ecpg.trailer	2009-10-03 01:36:36.000000000 +0200
--- pgsql.fixshred/src/interfaces/ecpg/preproc/ecpg.trailer	2009-10-03 01:42:17.000000000 +0200
*************** ecpg_into: INTO into_list	{ $$ = EMPTY; 
*** 2020,2025 ****
--- 2020,2029 ----
          | into_descriptor	{ $$ = $1; }
  	;
  
+ opt_ecpg_into:	/* EMPTY */	{ $$ = EMPTY; }
+ 	| ecpg_into		{ $$ = $1; }
+ 	;
+ 
  %%
  
  void base_yyerror(const char *error)
diff -dcrpN pgsql.dynamiccur/src/interfaces/ecpg/preproc/ecpg.type pgsql.fixshred/src/interfaces/ecpg/preproc/ecpg.type
*** pgsql.dynamiccur/src/interfaces/ecpg/preproc/ecpg.type	2009-10-03 01:36:11.000000000 +0200
--- pgsql.fixshred/src/interfaces/ecpg/preproc/ecpg.type	2009-10-03 01:41:51.000000000 +0200
***************
*** 76,81 ****
--- 76,82 ----
  %type <str> opt_bit_field
  %type <str> opt_connection_name
  %type <str> opt_database_name
+ %type <str> opt_ecpg_into
  %type <str> opt_ecpg_using
  %type <str> opt_initializer
  %type <str> opt_options
diff -dcrpN pgsql.dynamiccur/src/interfaces/ecpg/preproc/parse.pl pgsql.fixshred/src/interfaces/ecpg/preproc/parse.pl
*** pgsql.dynamiccur/src/interfaces/ecpg/preproc/parse.pl	2009-01-30 17:28:46.000000000 +0100
--- pgsql.fixshred/src/interfaces/ecpg/preproc/parse.pl	2009-10-03 01:54:56.000000000 +0200
*************** $replace_types{'unreserved_keyword'} = '
*** 57,63 ****
  $replace_types{'Sconst'} = 'ignore';
  
  # some production rules have to be ignored or replaced
! $replace_line{'fetch_direction'} = 'ignore';
  $replace_line{"opt_array_boundsopt_array_bounds'['Iconst']'"} = 'ignore';
  $replace_line{'col_name_keywordCHAR_P'} = 'ignore';
  $replace_line{'col_name_keywordINT_P'} = 'ignore';
--- 57,65 ----
  $replace_types{'Sconst'} = 'ignore';
  
  # some production rules have to be ignored or replaced
! $replace_line{'fetch_args'} = 'ignore';
! $replace_line{'fetch_argsFORWARDopt_from_incursor_name'} = 'ignore';
! $replace_line{'fetch_argsBACKWARDopt_from_incursor_name'} = 'ignore';
  $replace_line{"opt_array_boundsopt_array_bounds'['Iconst']'"} = 'ignore';
  $replace_line{'col_name_keywordCHAR_P'} = 'ignore';
  $replace_line{'col_name_keywordINT_P'} = 'ignore';
1f-cursorname-in-varchar-ctxdiff.patchtext/x-patch; name=1f-cursorname-in-varchar-ctxdiff.patchDownload
diff -dcrpN pgsql.fixshred/src/interfaces/ecpg/preproc/ecpg.trailer pgsql.cname_in_varchar/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.fixshred/src/interfaces/ecpg/preproc/ecpg.trailer	2009-10-03 01:42:17.000000000 +0200
--- pgsql.cname_in_varchar/src/interfaces/ecpg/preproc/ecpg.trailer	2009-10-03 02:05:58.000000000 +0200
*************** char_variable: cvariable
*** 228,233 ****
--- 228,265 ----
  		}
  		;
  
+ cursor_char_variable: cvariable
+ 		{
+ 			/* check if we have a string variable */
+ 			struct variable *p = find_variable($1);
+ 			enum ECPGttype type = p->type->type;
+ 
+ 			/* If we have just one character this is not a string */
+ 			if (atol(p->type->size) == 1)
+ 					mmerror(PARSE_ERROR, ET_ERROR, "invalid data type");
+ 			else
+ 			{
+ 				/* if array see what's inside */
+ 				if (type == ECPGt_array)
+ 					type = p->type->u.element->type;
+ 
+ 				switch (type)
+ 				{
+ 					case ECPGt_char:
+ 					case ECPGt_unsigned_char:
+ 					case ECPGt_string:
+ 					case ECPGt_varchar:
+ 						$$ = $1;
+ 						break;
+ 					default:
+ 						mmerror(PARSE_ERROR, ET_ERROR, "invalid data type");
+ 						$$ = $1;
+ 						break;
+ 				}
+ 			}
+ 		}
+ 		;
+ 
  opt_options: Op connect_options
  		{
  			if (strlen($1) == 0)
*************** civarind: cvariable indicator
*** 1798,1804 ****
  		}
  		;
  
! char_civar: char_variable
  		{
  			add_variable_to_head(&argsinsert, find_variable($1), &no_indicator);
  			$$ = $1;
--- 1830,1836 ----
  		}
  		;
  
! char_civar: cursor_char_variable
  		{
  			add_variable_to_head(&argsinsert, find_variable($1), &no_indicator);
  			$$ = $1;
diff -dcrpN pgsql.fixshred/src/interfaces/ecpg/preproc/ecpg.type pgsql.cname_in_varchar/src/interfaces/ecpg/preproc/ecpg.type
*** pgsql.fixshred/src/interfaces/ecpg/preproc/ecpg.type	2009-10-03 01:41:51.000000000 +0200
--- pgsql.cname_in_varchar/src/interfaces/ecpg/preproc/ecpg.type	2009-10-03 02:03:31.000000000 +0200
***************
*** 46,51 ****
--- 46,52 ----
  %type <str> char_civar
  %type <str> civar
  %type <str> civarind
+ %type <str> cursor_char_variable
  %type <str> ColLabel
  %type <str> connect_options
  %type <str> connection_object
1g-regressiontests-ctxdiff.patchtext/x-patch; name=1g-regressiontests-ctxdiff.patchDownload
diff -dcrpN pgsql.cname_in_varchar/src/interfaces/ecpg/test/compat_informix/cursor.pgc pgsql.regressiontests/src/interfaces/ecpg/test/compat_informix/cursor.pgc
*** pgsql.cname_in_varchar/src/interfaces/ecpg/test/compat_informix/cursor.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.regressiontests/src/interfaces/ecpg/test/compat_informix/cursor.pgc	2009-10-03 02:11:20.000000000 +0200
***************
*** 0 ****
--- 1,245 ----
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ exec sql type c is char reference;
+ typedef char* c;
+ 
+ exec sql type ind is union { int integer; short smallint; };
+ typedef union { int integer; short smallint; } ind;
+ 
+ #define BUFFERSIZ 8
+ exec sql type str is varchar[BUFFERSIZ];
+ 
+ #define CURNAME "mycur"
+ 
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ 	char	*stmt1 = "SELECT id, t FROM t1";
+ 	char	*curname1 = CURNAME;
+ 	char	*curname2 = CURNAME;
+ 	char	*curname3 = CURNAME;
+ 	varchar	curname4[50];
+ 	int	count;
+ 	int	id;
+ 	char	t[64];
+ exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table t1(id serial primary key, t text);
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into t1(id, t) values (default, 'a');
+ 	exec sql insert into t1(id, t) values (default, 'b');
+ 	exec sql insert into t1(id, t) values (default, 'c');
+ 	exec sql insert into t1(id, t) values (default, 'd');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* Dynamic cursorname test with INTO list in FETCH stmts */
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare :curname1 cursor for
+ 		select id, t from t1;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open :curname1;
+ 
+ 	strcpy(msg, "fetch from");
+ 	exec sql fetch from :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	exec sql fetch :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	exec sql fetch 1 from :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	exec sql fetch :count from :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move in");
+ 	exec sql move absolute 0 in :curname1;
+ 
+ 	strcpy(msg, "fetch 1");
+ 	exec sql fetch 1 :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	exec sql fetch :count :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close :curname1;
+ 
+ 	/* Dynamic cursorname test with INTO list in DECLARE stmt */
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare :curname2 cursor for
+ 		select id, t into :id, :t from t1;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open :curname2;
+ 
+ 	strcpy(msg, "fetch from");
+ 	exec sql fetch from :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	exec sql fetch :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	exec sql fetch 1 from :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	exec sql fetch :count from :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	exec sql move absolute 0 :curname2;
+ 
+ 	strcpy(msg, "fetch 1");
+ 	exec sql fetch 1 :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	exec sql fetch :count :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close :curname2;
+ 
+ 	/* Dynamic cursorname test with PREPARED stmt */
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id1 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare :curname3 cursor for st_id1;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open :curname3;
+ 
+ 	strcpy(msg, "fetch from");
+ 	exec sql fetch from :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	exec sql fetch :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	exec sql fetch 1 from :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	exec sql fetch :count from :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	exec sql move absolute 0 :curname3;
+ 
+ 	strcpy(msg, "fetch 1");
+ 	exec sql fetch 1 :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	exec sql fetch :count :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close :curname3;
+ 
+ 	strcpy(msg, "deallocate prepare");
+ 	exec sql deallocate prepare st_id1;
+ 
+ 	/* Dynamic cursorname test with PREPARED stmt,
+ 	   cursor name in varchar */
+ 
+ 	curname4.len = strlen(CURNAME);
+ 	strcpy(curname4.arr, CURNAME);
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id2 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare :curname4 cursor for st_id2;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open :curname4;
+ 
+ 	strcpy(msg, "fetch from");
+ 	exec sql fetch from :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	exec sql fetch :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	exec sql fetch 1 from :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	exec sql fetch :count from :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	exec sql move absolute 0 :curname4;
+ 
+ 	strcpy(msg, "fetch 1");
+ 	exec sql fetch 1 :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	exec sql fetch :count :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close :curname4;
+ 
+ 	strcpy(msg, "deallocate prepare");
+ 	exec sql deallocate prepare st_id2;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table t1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.cname_in_varchar/src/interfaces/ecpg/test/compat_informix/Makefile pgsql.regressiontests/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.cname_in_varchar/src/interfaces/ecpg/test/compat_informix/Makefile	2006-09-19 17:36:08.000000000 +0200
--- pgsql.regressiontests/src/interfaces/ecpg/test/compat_informix/Makefile	2009-10-03 02:11:20.000000000 +0200
*************** override LIBS := -lecpg_compat $(LIBS)
*** 12,17 ****
--- 12,18 ----
  
  TESTS = test_informix test_informix.c \
          test_informix2 test_informix2.c \
+         cursor cursor.c \
          dec_test dec_test.c \
          rfmtdate rfmtdate.c \
          rfmtlong rfmtlong.c \
*************** test_informix.c: test_informix.pgc ../re
*** 26,31 ****
--- 27,35 ----
  test_informix2.c: test_informix2.pgc ../regression.h
  	$(ECPG) -o $@ -I$(srcdir) $<
  
+ cursor.c: cursor.pgc ../regression.h
+ 	$(ECPG) -o $@ -I$(srcdir) $<
+ 
  dec_test.c: dec_test.pgc ../regression.h
  	$(ECPG) -o $@ -I$(srcdir) $<
  
diff -dcrpN pgsql.cname_in_varchar/src/interfaces/ecpg/test/ecpg_schedule pgsql.regressiontests/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.cname_in_varchar/src/interfaces/ecpg/test/ecpg_schedule	2008-10-29 11:40:29.000000000 +0100
--- pgsql.regressiontests/src/interfaces/ecpg/test/ecpg_schedule	2009-10-03 02:11:20.000000000 +0200
*************** test: compat_informix/charfuncs
*** 3,8 ****
--- 3,9 ----
  test: compat_informix/rfmtdate
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
+ test: compat_informix/cursor
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: pgtypeslib/num_test2
*** 16,21 ****
--- 17,23 ----
  test: preproc/array_of_struct
  test: preproc/autoprep
  test: preproc/comment
+ test: preproc/cursor
  test: preproc/define
  test: preproc/init
  test: preproc/strings
diff -dcrpN pgsql.cname_in_varchar/src/interfaces/ecpg/test/ecpg_schedule_tcp pgsql.regressiontests/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.cname_in_varchar/src/interfaces/ecpg/test/ecpg_schedule_tcp	2008-10-29 11:40:29.000000000 +0100
--- pgsql.regressiontests/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-10-03 02:11:20.000000000 +0200
*************** test: compat_informix/charfuncs
*** 3,8 ****
--- 3,9 ----
  test: compat_informix/rfmtdate
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
+ test: compat_informix/cursor
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: pgtypeslib/num_test2
*** 16,21 ****
--- 17,23 ----
  test: preproc/array_of_struct
  test: preproc/autoprep
  test: preproc/comment
+ test: preproc/cursor
  test: preproc/define
  test: preproc/init
  test: preproc/strings
diff -dcrpN pgsql.cname_in_varchar/src/interfaces/ecpg/test/expected/compat_informix-cursor.c pgsql.regressiontests/src/interfaces/ecpg/test/expected/compat_informix-cursor.c
*** pgsql.cname_in_varchar/src/interfaces/ecpg/test/expected/compat_informix-cursor.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.regressiontests/src/interfaces/ecpg/test/expected/compat_informix-cursor.c	2009-10-03 02:11:20.000000000 +0200
***************
*** 0 ****
--- 1,766 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "cursor.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 4 "cursor.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 6 "cursor.pgc"
+ 
+ 
+ /* exec sql type c is char reference */
+ #line 8 "cursor.pgc"
+ 
+ typedef char* c;
+ 
+ /* exec sql type ind is union { 
+ #line 11 "cursor.pgc"
+  int integer ;
+  
+ #line 11 "cursor.pgc"
+  short smallint ;
+  } */
+ #line 11 "cursor.pgc"
+ 
+ typedef union { int integer; short smallint; } ind;
+ 
+ #define BUFFERSIZ 8
+ /* exec sql type str is [ BUFFERSIZ ] */
+ #line 15 "cursor.pgc"
+ 
+ 
+ #define CURNAME "mycur"
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		  
+ 		  
+ 		
+ 		
+ 		
+ 		
+ 
+ #line 23 "cursor.pgc"
+  char * stmt1 = "SELECT id, t FROM t1" ;
+  
+ #line 24 "cursor.pgc"
+  char * curname1 = CURNAME ;
+  
+ #line 25 "cursor.pgc"
+  char * curname2 = CURNAME ;
+  
+ #line 26 "cursor.pgc"
+  char * curname3 = CURNAME ;
+  
+ #line 27 "cursor.pgc"
+   struct varchar_curname4_27  { int len; char arr[ 50 ]; }  curname4 ;
+  
+ #line 28 "cursor.pgc"
+  int count ;
+  
+ #line 29 "cursor.pgc"
+  int id ;
+  
+ #line 30 "cursor.pgc"
+  char t [ 64 ] ;
+ /* exec sql end declare section */
+ #line 31 "cursor.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0); 
+ #line 38 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 41 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
+ #line 44 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 44 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 47 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 47 "cursor.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 48 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 48 "cursor.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 49 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 49 "cursor.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 50 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 50 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 53 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 53 "cursor.pgc"
+ 
+ 
+ 	/* Dynamic cursorname test with INTO list in FETCH stmts */
+ 
+ 	strcpy(msg, "declare");
+ 	ECPG_informix_set_var( 0, &( curname1 ), __LINE__);\
+  ECPG_informix_reset_sqlca(); /* declare $0 cursor for select id , t from t1 */
+ #line 59 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
+ 	ECPGt_char,&(*( char  *)(ECPG_informix_get_var( 0))),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 62 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 62 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch from");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 65 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 65 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 69 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 69 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 73 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 73 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 78 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 78 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move in");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "move absolute 0 in $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 82 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 82 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch 1");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 85 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 85 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 90 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 90 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 94 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 94 "cursor.pgc"
+ 
+ 
+ 	/* Dynamic cursorname test with INTO list in DECLARE stmt */
+ 
+ 	strcpy(msg, "declare");
+ 	ECPG_informix_set_var( 3, &( curname2 ), __LINE__);\
+  ECPG_informix_set_var( 1, ( t ), __LINE__);\
+  ECPG_informix_set_var( 2, &( id ), __LINE__);\
+  ECPG_informix_reset_sqlca(); /* declare $0 cursor for select id , t from t1 */
+ #line 100 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
+ 	ECPGt_char,&(*( char  *)(ECPG_informix_get_var( 3))),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 103 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 103 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch from");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 106 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 106 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 110 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 110 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 114 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 114 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 119 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 119 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 123 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 123 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch 1");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 126 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 126 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 131 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 131 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 135 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 135 "cursor.pgc"
+ 
+ 
+ 	/* Dynamic cursorname test with PREPARED stmt */
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 140 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 140 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	ECPG_informix_reset_sqlca(); /* declare $0 cursor for $1 */
+ #line 143 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for $1", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 146 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 146 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch from");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 149 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 149 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 153 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 153 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 157 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 157 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 162 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 162 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 166 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 166 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch 1");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 169 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 169 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 174 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 174 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 178 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 178 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate prepare");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
+ #line 181 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 181 "cursor.pgc"
+ 
+ 
+ 	/* Dynamic cursorname test with PREPARED stmt,
+ 	   cursor name in varchar */
+ 
+ 	curname4.len = strlen(CURNAME);
+ 	strcpy(curname4.arr, CURNAME);
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
+ #line 190 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 190 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	ECPG_informix_reset_sqlca(); /* declare $0 cursor for $1 */
+ #line 193 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for $1", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 196 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 196 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch from");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 199 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 199 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 203 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 203 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 207 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 207 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 212 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 212 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 216 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 216 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch 1");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 219 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 219 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 224 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 224 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 228 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 228 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate prepare");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id2");
+ #line 231 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 231 "cursor.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 236 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 236 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 239 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 239 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 242 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 242 "cursor.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.cname_in_varchar/src/interfaces/ecpg/test/expected/compat_informix-cursor.stderr pgsql.regressiontests/src/interfaces/ecpg/test/expected/compat_informix-cursor.stderr
*** pgsql.cname_in_varchar/src/interfaces/ecpg/test/expected/compat_informix-cursor.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.regressiontests/src/interfaces/ecpg/test/expected/compat_informix-cursor.stderr	2009-10-03 02:11:20.000000000 +0200
***************
*** 0 ****
--- 1,372 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 47: query: insert into t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 47: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 47: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: query: insert into t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: query: insert into t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: query: insert into t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 53: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: query: declare mycur cursor for select id , t from t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 65: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 65: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 65: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 65: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 65: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 69: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 69: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 69: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 69: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 69: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 73: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 73: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 73: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 73: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 73: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 78: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 78: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 78: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 78: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 78: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: query: move absolute 0 in mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 85: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 85: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 90: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 90: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 94: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 94: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 94: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: query: declare mycur cursor for select id , t from t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 106: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 106: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 106: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 106: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 106: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 110: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 110: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 114: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 114: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 114: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 114: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 114: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 119: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 119: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 119: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 119: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 119: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 123: query: move absolute 0 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 123: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 123: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 126: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 126: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 126: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 126: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 126: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 131: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 131: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 131: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 131: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 131: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 140: name st_id1; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 146: query: declare mycur cursor for SELECT id, t FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 146: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 146: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 149: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 149: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 153: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 153: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 157: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 157: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 162: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 162: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 162: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 162: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 162: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 166: query: move absolute 0 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 166: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 166: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 169: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 169: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 169: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 169: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 169: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 174: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 174: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 174: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 174: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 174: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 178: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 178: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 178: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 181: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 190: name st_id2; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: query: declare mycur cursor for SELECT id, t FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 199: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 199: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 203: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 203: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 203: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 203: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 203: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 207: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 207: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 207: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 207: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 207: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 212: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 212: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 212: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 212: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 212: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 216: query: move absolute 0 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 216: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 216: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 224: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 224: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 224: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 224: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 224: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 231: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 236: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 236: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 236: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 239: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.cname_in_varchar/src/interfaces/ecpg/test/expected/compat_informix-cursor.stdout pgsql.regressiontests/src/interfaces/ecpg/test/expected/compat_informix-cursor.stdout
*** pgsql.cname_in_varchar/src/interfaces/ecpg/test/expected/compat_informix-cursor.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.regressiontests/src/interfaces/ecpg/test/expected/compat_informix-cursor.stdout	2009-10-03 02:11:20.000000000 +0200
***************
*** 0 ****
--- 1,24 ----
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
diff -dcrpN pgsql.cname_in_varchar/src/interfaces/ecpg/test/expected/preproc-cursor.c pgsql.regressiontests/src/interfaces/ecpg/test/expected/preproc-cursor.c
*** pgsql.cname_in_varchar/src/interfaces/ecpg/test/expected/preproc-cursor.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.regressiontests/src/interfaces/ecpg/test/expected/preproc-cursor.c	2009-10-03 02:11:20.000000000 +0200
***************
*** 0 ****
--- 1,760 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "cursor.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 4 "cursor.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 6 "cursor.pgc"
+ 
+ 
+ /* exec sql type c is char reference */
+ #line 8 "cursor.pgc"
+ 
+ typedef char* c;
+ 
+ /* exec sql type ind is union { 
+ #line 11 "cursor.pgc"
+  int integer ;
+  
+ #line 11 "cursor.pgc"
+  short smallint ;
+  } */
+ #line 11 "cursor.pgc"
+ 
+ typedef union { int integer; short smallint; } ind;
+ 
+ #define BUFFERSIZ 8
+ /* exec sql type str is [ BUFFERSIZ ] */
+ #line 15 "cursor.pgc"
+ 
+ 
+ #define CURNAME "mycur"
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		  
+ 		  
+ 		
+ 		
+ 		
+ 		
+ 
+ #line 23 "cursor.pgc"
+  char * stmt1 = "SELECT id, t FROM t1" ;
+  
+ #line 24 "cursor.pgc"
+  char * curname1 = CURNAME ;
+  
+ #line 25 "cursor.pgc"
+  char * curname2 = CURNAME ;
+  
+ #line 26 "cursor.pgc"
+  char * curname3 = CURNAME ;
+  
+ #line 27 "cursor.pgc"
+   struct varchar_curname4_27  { int len; char arr[ 50 ]; }  curname4 ;
+  
+ #line 28 "cursor.pgc"
+  int count ;
+  
+ #line 29 "cursor.pgc"
+  int id ;
+  
+ #line 30 "cursor.pgc"
+  char t [ 64 ] ;
+ /* exec sql end declare section */
+ #line 31 "cursor.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
+ #line 38 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 41 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
+ #line 44 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 44 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 47 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 47 "cursor.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 48 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 48 "cursor.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 49 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 49 "cursor.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 50 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 50 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 53 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 53 "cursor.pgc"
+ 
+ 
+ 	/* Dynamic cursorname test with INTO list in FETCH stmts */
+ 
+ 	strcpy(msg, "declare");
+ 	/* declare $0 cursor for select id , t from t1 */
+ #line 59 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 62 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 62 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch from");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 65 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 65 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 69 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 69 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 73 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 73 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 78 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 78 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move in");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move absolute 0 in $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 82 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 82 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch 1");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 85 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 85 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 90 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 90 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 94 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 94 "cursor.pgc"
+ 
+ 
+ 	/* Dynamic cursorname test with INTO list in DECLARE stmt */
+ 
+ 	strcpy(msg, "declare");
+ 	/* declare $0 cursor for select id , t from t1 */
+ #line 100 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 103 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 103 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch from");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 106 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 106 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 110 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 110 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 114 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 114 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 119 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 119 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 123 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 123 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch 1");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 126 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 126 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 131 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 131 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 135 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 135 "cursor.pgc"
+ 
+ 
+ 	/* Dynamic cursorname test with PREPARED stmt */
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 140 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 140 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	/* declare $0 cursor for $1 */
+ #line 143 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for $1", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 146 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 146 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch from");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 149 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 149 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 153 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 153 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 157 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 157 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 162 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 162 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 166 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 166 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch 1");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 169 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 169 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 174 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 174 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 178 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 178 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate prepare");
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
+ #line 181 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 181 "cursor.pgc"
+ 
+ 
+ 	/* Dynamic cursorname test with PREPARED stmt,
+ 	   cursor name in varchar */
+ 
+ 	curname4.len = strlen(CURNAME);
+ 	strcpy(curname4.arr, CURNAME);
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
+ #line 190 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 190 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	/* declare $0 cursor for $1 */
+ #line 193 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for $1", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 196 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 196 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch from");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 199 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 199 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 203 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 203 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 207 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 207 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 212 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 212 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 216 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 216 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch 1");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 219 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 219 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 224 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 224 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 228 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 228 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate prepare");
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
+ #line 231 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 231 "cursor.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 236 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 236 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 239 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 239 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 242 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 242 "cursor.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.cname_in_varchar/src/interfaces/ecpg/test/expected/preproc-cursor.stderr pgsql.regressiontests/src/interfaces/ecpg/test/expected/preproc-cursor.stderr
*** pgsql.cname_in_varchar/src/interfaces/ecpg/test/expected/preproc-cursor.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.regressiontests/src/interfaces/ecpg/test/expected/preproc-cursor.stderr	2009-10-03 02:11:20.000000000 +0200
***************
*** 0 ****
--- 1,372 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 47: query: insert into t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 47: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 47: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: query: insert into t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: query: insert into t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: query: insert into t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 53: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: query: declare mycur cursor for select id , t from t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 65: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 65: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 65: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 65: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 65: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 69: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 69: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 69: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 69: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 69: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 73: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 73: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 73: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 73: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 73: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 78: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 78: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 78: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 78: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 78: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: query: move absolute 0 in mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 85: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 85: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 90: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 90: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 94: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 94: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 94: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: query: declare mycur cursor for select id , t from t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 106: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 106: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 106: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 106: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 106: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 110: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 110: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 114: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 114: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 114: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 114: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 114: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 119: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 119: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 119: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 119: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 119: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 123: query: move absolute 0 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 123: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 123: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 126: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 126: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 126: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 126: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 126: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 131: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 131: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 131: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 131: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 131: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 140: name st_id1; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 146: query: declare mycur cursor for SELECT id, t FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 146: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 146: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 149: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 149: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 153: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 153: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 157: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 157: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 162: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 162: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 162: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 162: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 162: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 166: query: move absolute 0 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 166: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 166: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 169: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 169: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 169: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 169: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 169: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 174: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 174: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 174: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 174: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 174: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 178: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 178: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 178: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 181: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 190: name st_id2; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: query: declare mycur cursor for SELECT id, t FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 199: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 199: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 203: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 203: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 203: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 203: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 203: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 207: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 207: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 207: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 207: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 207: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 212: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 212: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 212: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 212: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 212: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 216: query: move absolute 0 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 216: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 216: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 224: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 224: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 224: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 224: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 224: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 231: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 236: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 236: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 236: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 239: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.cname_in_varchar/src/interfaces/ecpg/test/expected/preproc-cursor.stdout pgsql.regressiontests/src/interfaces/ecpg/test/expected/preproc-cursor.stdout
*** pgsql.cname_in_varchar/src/interfaces/ecpg/test/expected/preproc-cursor.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.regressiontests/src/interfaces/ecpg/test/expected/preproc-cursor.stdout	2009-10-03 02:11:20.000000000 +0200
***************
*** 0 ****
--- 1,24 ----
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
diff -dcrpN pgsql.cname_in_varchar/src/interfaces/ecpg/test/preproc/cursor.pgc pgsql.regressiontests/src/interfaces/ecpg/test/preproc/cursor.pgc
*** pgsql.cname_in_varchar/src/interfaces/ecpg/test/preproc/cursor.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.regressiontests/src/interfaces/ecpg/test/preproc/cursor.pgc	2009-10-03 02:11:20.000000000 +0200
***************
*** 0 ****
--- 1,245 ----
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ exec sql type c is char reference;
+ typedef char* c;
+ 
+ exec sql type ind is union { int integer; short smallint; };
+ typedef union { int integer; short smallint; } ind;
+ 
+ #define BUFFERSIZ 8
+ exec sql type str is varchar[BUFFERSIZ];
+ 
+ #define CURNAME "mycur"
+ 
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ 	char	*stmt1 = "SELECT id, t FROM t1";
+ 	char	*curname1 = CURNAME;
+ 	char	*curname2 = CURNAME;
+ 	char	*curname3 = CURNAME;
+ 	varchar	curname4[50];
+ 	int	count;
+ 	int	id;
+ 	char	t[64];
+ exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table t1(id serial primary key, t text);
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into t1(id, t) values (default, 'a');
+ 	exec sql insert into t1(id, t) values (default, 'b');
+ 	exec sql insert into t1(id, t) values (default, 'c');
+ 	exec sql insert into t1(id, t) values (default, 'd');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* Dynamic cursorname test with INTO list in FETCH stmts */
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare :curname1 cursor for
+ 		select id, t from t1;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open :curname1;
+ 
+ 	strcpy(msg, "fetch from");
+ 	exec sql fetch from :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	exec sql fetch :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	exec sql fetch 1 from :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	exec sql fetch :count from :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move in");
+ 	exec sql move absolute 0 in :curname1;
+ 
+ 	strcpy(msg, "fetch 1");
+ 	exec sql fetch 1 :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	exec sql fetch :count :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close :curname1;
+ 
+ 	/* Dynamic cursorname test with INTO list in DECLARE stmt */
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare :curname2 cursor for
+ 		select id, t into :id, :t from t1;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open :curname2;
+ 
+ 	strcpy(msg, "fetch from");
+ 	exec sql fetch from :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	exec sql fetch :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	exec sql fetch 1 from :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	exec sql fetch :count from :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	exec sql move absolute 0 :curname2;
+ 
+ 	strcpy(msg, "fetch 1");
+ 	exec sql fetch 1 :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	exec sql fetch :count :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close :curname2;
+ 
+ 	/* Dynamic cursorname test with PREPARED stmt */
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id1 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare :curname3 cursor for st_id1;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open :curname3;
+ 
+ 	strcpy(msg, "fetch from");
+ 	exec sql fetch from :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	exec sql fetch :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	exec sql fetch 1 from :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	exec sql fetch :count from :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	exec sql move absolute 0 :curname3;
+ 
+ 	strcpy(msg, "fetch 1");
+ 	exec sql fetch 1 :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	exec sql fetch :count :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close :curname3;
+ 
+ 	strcpy(msg, "deallocate prepare");
+ 	exec sql deallocate prepare st_id1;
+ 
+ 	/* Dynamic cursorname test with PREPARED stmt,
+ 	   cursor name in varchar */
+ 
+ 	curname4.len = strlen(CURNAME);
+ 	strcpy(curname4.arr, CURNAME);
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id2 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare :curname4 cursor for st_id2;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open :curname4;
+ 
+ 	strcpy(msg, "fetch from");
+ 	exec sql fetch from :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	exec sql fetch :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	exec sql fetch 1 from :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	exec sql fetch :count from :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	exec sql move absolute 0 :curname4;
+ 
+ 	strcpy(msg, "fetch 1");
+ 	exec sql fetch 1 :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	exec sql fetch :count :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close :curname4;
+ 
+ 	strcpy(msg, "deallocate prepare");
+ 	exec sql deallocate prepare st_id2;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table t1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.cname_in_varchar/src/interfaces/ecpg/test/preproc/Makefile pgsql.regressiontests/src/interfaces/ecpg/test/preproc/Makefile
*** pgsql.cname_in_varchar/src/interfaces/ecpg/test/preproc/Makefile	2008-10-29 11:40:29.000000000 +0100
--- pgsql.regressiontests/src/interfaces/ecpg/test/preproc/Makefile	2009-10-03 02:11:20.000000000 +0200
*************** include $(top_srcdir)/$(subdir)/../Makef
*** 7,12 ****
--- 7,13 ----
  TESTS = array_of_struct array_of_struct.c \
  	autoprep autoprep.c \
  	comment comment.c \
+ 	cursor cursor.c \
  	define define.c \
  	init init.c \
  	strings strings.c \
1h-fix-parse.pl-ctxdiff.patchtext/x-patch; name=1h-fix-parse.pl-ctxdiff.patchDownload
diff -dcrpN pgsql.regressiontests/src/interfaces/ecpg/preproc/parse.pl pgsql.fixparsepl/src/interfaces/ecpg/preproc/parse.pl
*** pgsql.regressiontests/src/interfaces/ecpg/preproc/parse.pl	2009-10-03 01:54:56.000000000 +0200
--- pgsql.fixparsepl/src/interfaces/ecpg/preproc/parse.pl	2009-10-03 02:18:47.000000000 +0200
*************** sub include_stuff {
*** 313,318 ****
--- 313,319 ----
      local($includestream, $includefilename, $includeblock, $copy, $field_count) = @_;
      $copied = 0;
      $inblock = 0;
+     $have_addon = 0;
      $filename = $path . "/" . $includefilename;
      while (($_ = &Getline2($filename),$getline_ok)) {
  	if ($includeblock ne '' && $Fld[1] eq 'ECPG:' && $inblock == 0) {
*************** sub include_stuff {
*** 321,329 ****
  		$inblock = 1;
  		$includetype = $Fld[3];
  		if ($includetype eq 'rule') {
! 		    &dump_fields($stmt_mode, *fields, $field_count, ' { ');
  		}
  		elsif ($includetype eq 'addon') {
  		    &add_to_buffer('rules', ' { ');
  		}
  	    }
--- 322,336 ----
  		$inblock = 1;
  		$includetype = $Fld[3];
  		if ($includetype eq 'rule') {
! 		    if ($have_addon == 0) {
! 			&dump_fields($stmt_mode, *fields, $field_count, ' { ');
! 		    }
! 		    else {
! 			&dump_fields($stmt_mode, *fields, $field_count, '');
! 		    }
  		}
  		elsif ($includetype eq 'addon') {
+ 		    $have_addon  = 1;
  		    &add_to_buffer('rules', ' { ');
  		}
  	    }
#31Robert Haas
robertmhaas@gmail.com
In reply to: Boszormenyi Zoltan (#30)
Re: CommitFest 2009-09, two weeks on

On Fri, Oct 2, 2009 at 9:01 PM, Boszormenyi Zoltan <zb@cybertec.at> wrote:

Hi,

Michael Meskes írta:

It is accepted either way. I was just pointing out that it might be easier to
review/commit at least parts of your patches if they can be applied seperately.

I have split up (and cleaned up a little) the dynamic
cursorname patch into smaller logical, easier-to-review
pieces. Descriptions below.

1) 1a-unified-optfromin-fetch-ctxdiff.patch

ecpg supports optional FROM/IN in FETCH and
MOVE statements (mainly because it's required by
Informix-compatibility). Unify core and ecpg grammar
as per Tom Lane's suggestion.

2) 1b-cursor_name-ctxdiff.patch

"name" -> "cursor_name" transition in core grammar
and ecpg grammar. Currently it does nothing, it's a
preparation phase. Depends on patch 1.

3) 1c-remove-var-from-list.patch

Introduce function remove_variable_from_list().
It is used by the dynamic cursor, SQLDA and DESCRIBE
patches for different reasons. Applicable separately.

4) 1d-dynamiccur-ctxdiff.patch

The real point of the whole series in this email.
Extend "cursor_name" in the ecpg grammar to actually
accept a character variable. The cursorname-as-variable
is replaced in the final SQL script with a $0 placeholder.
Doesn't compile as-is, requires patch 5 to get the
two shift/reduce conflicts fixed. Depends on patches
1, 2 and 3.

5) 1e-fix-shiftreduce-ctxdiff.patch

De-factorize "BACKWARD opt_from_in cursor_name"
and "FORWARD opt_from_in cursor_name" out of
fetch_args and pull them up into FetchStmt in the ecpg
grammar. Depends on patch 4.
One line in parse.pl is not clear for me:
   $replace_line{'fetch_args'} = 'ignore';
The genarated preproc.y is the same with or without
this line. But as the previous version had it with
"fetch_direction", I left it in.

6) 1f-cursorname-in-varchar-ctxdiff.patch

Allow that varchar can be used as cursorname as well.
Other character variable types were already supported.
Depends on patch 4.

7) 1g-regressiontests-ctxdiff.patch

Introduce cursor.pgc regression test for both native
and compat mode. Depends on all patches.

8) 1h-fix-parse.pl-ctxdiff.patch

Now useless patch, in the previous dynamic cursorname
patch the following scenario occured: the same rule
had both an "addon" and a "rule" extension. Without
this fix, the following code was generated in preproc.y:
   ruleA: <accepted syntax>
      {
            <addon code block>
      {
            <automatic code block>
      }
With the cleanup I did during this splitup, this scenario
doesn't happen, but this fix may be considered useful.
Applicable separately.

After every patch (except 4) both the core and ecpg
"make check" are successful.

It would've been nice if you'd changed the subject line before posting these.

Also, please update commitfest.postgresql.org appropriately.

...Robert

#32Boszormenyi Zoltan
zb@cybertec.at
In reply to: Robert Haas (#31)
ECPG dynamic cursorname patch revised and split Re: CommitFest 2009-09, two weeks on

Robert Haas �rta:

On Fri, Oct 2, 2009 at 9:01 PM, Boszormenyi Zoltan <zb@cybertec.at> wrote:

Hi,

Michael Meskes �rta:

It is accepted either way. I was just pointing out that it might be easier to
review/commit at least parts of your patches if they can be applied seperately.

I have split up (and cleaned up a little) the dynamic
cursorname patch into smaller logical, easier-to-review
pieces. Descriptions below.

...
After every patch (except 4) both the core and ecpg
"make check" are successful.

It would've been nice if you'd changed the subject line before posting these.

At 3am, I forgot this. :(
I hope the archive threading doesn't break and
my previous mail will be referenced by this one.

Also, please update commitfest.postgresql.org appropriately.

I just did, thanks for the reminder.

Best regards,
Zolt�n B�sz�rm�nyi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

#33Robert Haas
robertmhaas@gmail.com
In reply to: Magnus Hagander (#20)
Re: CommitFest 2009-09, two weeks on

On Thu, Oct 1, 2009 at 7:48 AM, Magnus Hagander <magnus@hagander.net> wrote:

On Thu, Oct 1, 2009 at 04:11, Itagaki Takahiro
<itagaki.takahiro@oss.ntt.co.jp> wrote:

Magnus Hagander <magnus@hagander.net> wrote:

I can certainly review the win32 encoding patch, but I was rather
hoping for some comments from others on if we're interested in a win32
only solution, or if we want something more generic. Should we just go
with the win32-only one for now?

Yes, because Windows is only platform that supports UTF-16 encoding natively.
I believe my patch is the best solution for Windows even if we have another
approach for other platforms.

Actually, I think a better argument is that since Windows will *never*
accept UTF8 logging, and that's what most databases will be in, much
of this patch will be required anyway. So I should probably review and
get this part in while we think about other solutions *as well* for
other platforms.

Given the above, it seems that perhaps we could go ahead and apply this?

...Robert

#34Joe Conway
mail@joeconway.com
In reply to: Itagaki Takahiro (#18)
1 attachment(s)
Re: CommitFest 2009-09, two weeks on

Itagaki Takahiro wrote:

The point is *memory leak* in dblink when a query is canceled or
become time-out. I think it is a bug, and my patch could fix it.

Please see if this works for you.

Joe

Attachments:

dblink-query-cancel-alt.difftext/x-patch; name=dblink-query-cancel-alt.diffDownload
Index: dblink.c
===================================================================
RCS file: /opt/src/cvs/pgsql/contrib/dblink/dblink.c,v
retrieving revision 1.84
diff -c -r1.84 dblink.c
*** dblink.c	12 Sep 2009 23:20:52 -0000	1.84
--- dblink.c	4 Oct 2009 02:19:17 -0000
***************
*** 97,109 ****
  static char *generate_relation_name(Oid relid);
  static void dblink_connstr_check(const char *connstr);
  static void dblink_security_check(PGconn *conn, remoteConn *rconn);
! static void dblink_res_error(const char *conname, PGresult *res, const char *dblink_context_msg, bool fail);
  static char *get_connect_string(const char *servername);
  static char *escape_param_str(const char *from);
  
  /* Global */
  static remoteConn *pconn = NULL;
  static HTAB *remoteConnHash = NULL;
  
  /*
   *	Following is list that holds multiple remote connections.
--- 97,111 ----
  static char *generate_relation_name(Oid relid);
  static void dblink_connstr_check(const char *connstr);
  static void dblink_security_check(PGconn *conn, remoteConn *rconn);
! static void dblink_res_error(const char *conname, const char *dblink_context_msg, bool fail);
  static char *get_connect_string(const char *servername);
  static char *escape_param_str(const char *from);
+ static void dblink_error_callback(void *arg);
  
  /* Global */
  static remoteConn *pconn = NULL;
  static HTAB *remoteConnHash = NULL;
+ static PGresult *res = NULL;
  
  /*
   *	Following is list that holds multiple remote connections.
***************
*** 143,149 ****
--- 145,154 ----
  	do { \
  			msg = pstrdup(PQerrorMessage(conn)); \
  			if (res) \
+ 			{ \
  				PQclear(res); \
+ 				res = NULL; \
+ 			} \
  			elog(ERROR, "%s: %s", p2, msg); \
  	} while (0)
  
***************
*** 212,217 ****
--- 217,238 ----
  			} \
  	} while (0)
  
+ #define ERRORCONTEXTCALLBACK \
+ 	ErrorContextCallback	dberrcontext
+ 
+ #define PUSH_DBERRCONTEXT(_error_callback_) \
+ 	do { \
+ 		dberrcontext.callback = _error_callback_; \
+ 		dberrcontext.arg = (void *) NULL; \
+ 		dberrcontext.previous = error_context_stack; \
+ 		error_context_stack = &dberrcontext; \
+ 	} while (0)
+ 
+ #define POP_DBERRCONTEXT \
+ 	do { \
+ 		error_context_stack = dberrcontext.previous; \
+ 	} while (0)
+ 
  /*
   * Create a persistent connection to another database
   */
***************
*** 325,331 ****
  dblink_open(PG_FUNCTION_ARGS)
  {
  	char	   *msg;
- 	PGresult   *res = NULL;
  	PGconn	   *conn = NULL;
  	char	   *curname = NULL;
  	char	   *sql = NULL;
--- 346,351 ----
***************
*** 333,339 ****
--- 353,361 ----
  	StringInfoData buf;
  	remoteConn *rconn = NULL;
  	bool		fail = true;	/* default to backward compatible behavior */
+ 	ERRORCONTEXTCALLBACK;
  
+ 	PUSH_DBERRCONTEXT(dblink_error_callback);
  	DBLINK_INIT;
  	initStringInfo(&buf);
  
***************
*** 381,389 ****
  	if (PQtransactionStatus(conn) == PQTRANS_IDLE)
  	{
  		res = PQexec(conn, "BEGIN");
! 		if (PQresultStatus(res) != PGRES_COMMAND_OK)
  			DBLINK_RES_INTERNALERROR("begin error");
  		PQclear(res);
  		rconn->newXactForCursor = TRUE;
  
  		/*
--- 403,412 ----
  	if (PQtransactionStatus(conn) == PQTRANS_IDLE)
  	{
  		res = PQexec(conn, "BEGIN");
! 		if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
  			DBLINK_RES_INTERNALERROR("begin error");
  		PQclear(res);
+ 		res = NULL;
  		rconn->newXactForCursor = TRUE;
  
  		/*
***************
*** 402,412 ****
  	res = PQexec(conn, buf.data);
  	if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
  	{
! 		dblink_res_error(conname, res, "could not open cursor", fail);
  		PG_RETURN_TEXT_P(cstring_to_text("ERROR"));
  	}
- 
  	PQclear(res);
  	PG_RETURN_TEXT_P(cstring_to_text("OK"));
  }
  
--- 425,437 ----
  	res = PQexec(conn, buf.data);
  	if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
  	{
! 		dblink_res_error(conname, "could not open cursor", fail);
  		PG_RETURN_TEXT_P(cstring_to_text("ERROR"));
  	}
  	PQclear(res);
+ 	res = NULL;
+ 
+ 	POP_DBERRCONTEXT;
  	PG_RETURN_TEXT_P(cstring_to_text("OK"));
  }
  
***************
*** 418,431 ****
  dblink_close(PG_FUNCTION_ARGS)
  {
  	PGconn	   *conn = NULL;
- 	PGresult   *res = NULL;
  	char	   *curname = NULL;
  	char	   *conname = NULL;
  	StringInfoData buf;
  	char	   *msg;
  	remoteConn *rconn = NULL;
  	bool		fail = true;	/* default to backward compatible behavior */
! 
  	DBLINK_INIT;
  	initStringInfo(&buf);
  
--- 443,457 ----
  dblink_close(PG_FUNCTION_ARGS)
  {
  	PGconn	   *conn = NULL;
  	char	   *curname = NULL;
  	char	   *conname = NULL;
  	StringInfoData buf;
  	char	   *msg;
  	remoteConn *rconn = NULL;
  	bool		fail = true;	/* default to backward compatible behavior */
! 	ERRORCONTEXTCALLBACK;
! 	
! 	PUSH_DBERRCONTEXT(dblink_error_callback);
  	DBLINK_INIT;
  	initStringInfo(&buf);
  
***************
*** 471,481 ****
  	res = PQexec(conn, buf.data);
  	if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
  	{
! 		dblink_res_error(conname, res, "could not close cursor", fail);
  		PG_RETURN_TEXT_P(cstring_to_text("ERROR"));
  	}
- 
  	PQclear(res);
  
  	/* if we started a transaction, decrement cursor count */
  	if (rconn->newXactForCursor)
--- 497,507 ----
  	res = PQexec(conn, buf.data);
  	if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
  	{
! 		dblink_res_error(conname, "could not close cursor", fail);
  		PG_RETURN_TEXT_P(cstring_to_text("ERROR"));
  	}
  	PQclear(res);
+ 	res = NULL;
  
  	/* if we started a transaction, decrement cursor count */
  	if (rconn->newXactForCursor)
***************
*** 488,499 ****
  			rconn->newXactForCursor = FALSE;
  
  			res = PQexec(conn, "COMMIT");
! 			if (PQresultStatus(res) != PGRES_COMMAND_OK)
  				DBLINK_RES_INTERNALERROR("commit error");
  			PQclear(res);
  		}
  	}
  
  	PG_RETURN_TEXT_P(cstring_to_text("OK"));
  }
  
--- 514,527 ----
  			rconn->newXactForCursor = FALSE;
  
  			res = PQexec(conn, "COMMIT");
! 			if (!res || PQresultStatus(res) != PGRES_COMMAND_OK)
  				DBLINK_RES_INTERNALERROR("commit error");
  			PQclear(res);
+ 			res = NULL;
  		}
  	}
  
+ 	POP_DBERRCONTEXT;
  	PG_RETURN_TEXT_P(cstring_to_text("OK"));
  }
  
***************
*** 509,519 ****
  	int			call_cntr;
  	int			max_calls;
  	AttInMetadata *attinmeta;
- 	PGresult   *res = NULL;
  	MemoryContext oldcontext;
  	char	   *conname = NULL;
  	remoteConn *rconn = NULL;
! 
  	DBLINK_INIT;
  
  	/* stuff done only on the first call of the function */
--- 537,548 ----
  	int			call_cntr;
  	int			max_calls;
  	AttInMetadata *attinmeta;
  	MemoryContext oldcontext;
  	char	   *conname = NULL;
  	remoteConn *rconn = NULL;
! 	ERRORCONTEXTCALLBACK;
! 	
! 	PUSH_DBERRCONTEXT(dblink_error_callback);
  	DBLINK_INIT;
  
  	/* stuff done only on the first call of the function */
***************
*** 585,597 ****
  			(PQresultStatus(res) != PGRES_COMMAND_OK &&
  			 PQresultStatus(res) != PGRES_TUPLES_OK))
  		{
! 			dblink_res_error(conname, res, "could not fetch from cursor", fail);
  			SRF_RETURN_DONE(funcctx);
  		}
  		else if (PQresultStatus(res) == PGRES_COMMAND_OK)
  		{
  			/* cursor does not exist - closed already or bad name */
  			PQclear(res);
  			ereport(ERROR,
  					(errcode(ERRCODE_INVALID_CURSOR_NAME),
  					 errmsg("cursor \"%s\" does not exist", curname)));
--- 614,627 ----
  			(PQresultStatus(res) != PGRES_COMMAND_OK &&
  			 PQresultStatus(res) != PGRES_TUPLES_OK))
  		{
! 			dblink_res_error(conname, "could not fetch from cursor", fail);
  			SRF_RETURN_DONE(funcctx);
  		}
  		else if (PQresultStatus(res) == PGRES_COMMAND_OK)
  		{
  			/* cursor does not exist - closed already or bad name */
  			PQclear(res);
+ 			res = NULL;
  			ereport(ERROR,
  					(errcode(ERRCODE_INVALID_CURSOR_NAME),
  					 errmsg("cursor \"%s\" does not exist", curname)));
***************
*** 635,640 ****
--- 665,671 ----
  		if (funcctx->max_calls < 1)
  		{
  			PQclear(res);
+ 			res = NULL;
  			SRF_RETURN_DONE(funcctx);
  		}
  
***************
*** 690,701 ****
--- 721,736 ----
  		/* make the tuple into a datum */
  		result = HeapTupleGetDatum(tuple);
  
+ 		POP_DBERRCONTEXT;
  		SRF_RETURN_NEXT(funcctx, result);
  	}
  	else
  	{
  		/* do when there is no more left */
  		PQclear(res);
+ 		res = NULL;
+ 
+ 		POP_DBERRCONTEXT;
  		SRF_RETURN_DONE(funcctx);
  	}
  }
***************
*** 755,766 ****
  	int			max_calls;
  	AttInMetadata *attinmeta;
  	char	   *msg;
- 	PGresult   *res = NULL;
  	bool		is_sql_cmd = false;
  	char	   *sql_cmd_status = NULL;
  	MemoryContext oldcontext;
  	bool		freeconn = false;
! 
  	DBLINK_INIT;
  
  	/* stuff done only on the first call of the function */
--- 790,802 ----
  	int			max_calls;
  	AttInMetadata *attinmeta;
  	char	   *msg;
  	bool		is_sql_cmd = false;
  	char	   *sql_cmd_status = NULL;
  	MemoryContext oldcontext;
  	bool		freeconn = false;
! 	ERRORCONTEXTCALLBACK;
! 	
! 	PUSH_DBERRCONTEXT(dblink_error_callback);
  	DBLINK_INIT;
  
  	/* stuff done only on the first call of the function */
***************
*** 857,863 ****
  		{
  			if (freeconn)
  				PQfinish(conn);
! 			dblink_res_error(conname, res, "could not execute query", fail);
  			MemoryContextSwitchTo(oldcontext);
  			SRF_RETURN_DONE(funcctx);
  		}
--- 893,899 ----
  		{
  			if (freeconn)
  				PQfinish(conn);
! 			dblink_res_error(conname, "could not execute query", fail);
  			MemoryContextSwitchTo(oldcontext);
  			SRF_RETURN_DONE(funcctx);
  		}
***************
*** 926,932 ****
--- 962,971 ----
  		if (funcctx->max_calls < 1)
  		{
  			if (res)
+ 			{
  				PQclear(res);
+ 				res = NULL;
+ 			}
  			MemoryContextSwitchTo(oldcontext);
  			SRF_RETURN_DONE(funcctx);
  		}
***************
*** 984,995 ****
--- 1023,1038 ----
  		/* make the tuple into a datum */
  		result = HeapTupleGetDatum(tuple);
  
+ 		POP_DBERRCONTEXT;
  		SRF_RETURN_NEXT(funcctx, result);
  	}
  	else
  	{
  		/* do when there is no more left */
  		PQclear(res);
+ 		res = NULL;
+ 
+ 		POP_DBERRCONTEXT;
  		SRF_RETURN_DONE(funcctx);
  	}
  }
***************
*** 1119,1125 ****
  dblink_exec(PG_FUNCTION_ARGS)
  {
  	char	   *msg;
- 	PGresult   *res = NULL;
  	text	   *sql_cmd_status = NULL;
  	TupleDesc	tupdesc = NULL;
  	PGconn	   *conn = NULL;
--- 1162,1167 ----
***************
*** 1129,1135 ****
  	remoteConn *rconn = NULL;
  	bool		freeconn = false;
  	bool		fail = true;	/* default to backward compatible behavior */
! 
  	DBLINK_INIT;
  
  	if (PG_NARGS() == 3)
--- 1171,1179 ----
  	remoteConn *rconn = NULL;
  	bool		freeconn = false;
  	bool		fail = true;	/* default to backward compatible behavior */
! 	ERRORCONTEXTCALLBACK;
! 	
! 	PUSH_DBERRCONTEXT(dblink_error_callback);
  	DBLINK_INIT;
  
  	if (PG_NARGS() == 3)
***************
*** 1172,1178 ****
  		(PQresultStatus(res) != PGRES_COMMAND_OK &&
  		 PQresultStatus(res) != PGRES_TUPLES_OK))
  	{
! 		dblink_res_error(conname, res, "could not execute command", fail);
  
  		/* need a tuple descriptor representing one TEXT column */
  		tupdesc = CreateTemplateTupleDesc(1, false);
--- 1216,1222 ----
  		(PQresultStatus(res) != PGRES_COMMAND_OK &&
  		 PQresultStatus(res) != PGRES_TUPLES_OK))
  	{
! 		dblink_res_error(conname, "could not execute command", fail);
  
  		/* need a tuple descriptor representing one TEXT column */
  		tupdesc = CreateTemplateTupleDesc(1, false);
***************
*** 1198,1207 ****
--- 1242,1253 ----
  		 */
  		sql_cmd_status = cstring_to_text(PQcmdStatus(res));
  		PQclear(res);
+ 		res = NULL;
  	}
  	else
  	{
  		PQclear(res);
+ 		res = NULL;
  		ereport(ERROR,
  				(errcode(ERRCODE_S_R_E_PROHIBITED_SQL_STATEMENT_ATTEMPTED),
  				 errmsg("statement returning results not allowed")));
***************
*** 1211,1216 ****
--- 1257,1263 ----
  	if (freeconn)
  		PQfinish(conn);
  
+ 	POP_DBERRCONTEXT;
  	PG_RETURN_TEXT_P(sql_cmd_status);
  }
  
***************
*** 2418,2424 ****
  }
  
  static void
! dblink_res_error(const char *conname, PGresult *res, const char *dblink_context_msg, bool fail)
  {
  	int			level;
  	char	   *pg_diag_sqlstate = PQresultErrorField(res, PG_DIAG_SQLSTATE);
--- 2465,2471 ----
  }
  
  static void
! dblink_res_error(const char *conname, const char *dblink_context_msg, bool fail)
  {
  	int			level;
  	char	   *pg_diag_sqlstate = PQresultErrorField(res, PG_DIAG_SQLSTATE);
***************
*** 2453,2459 ****
--- 2500,2509 ----
  	xpstrdup(message_context, pg_diag_context);
  
  	if (res)
+ 	{
  		PQclear(res);
+ 		res = NULL;
+ 	}
  
  	if (conname)
  		dblink_context_conname = conname;
***************
*** 2550,2552 ****
--- 2600,2615 ----
  
  	return buf->data;
  }
+ 
+ /*
+  * error context callback to let us free resources
+  */
+ static void
+ dblink_error_callback(void *arg)
+ {
+ 	if (res)
+ 	{
+ 		PQclear(res);
+ 		res = NULL;
+ 	}
+ }
#35Itagaki Takahiro
itagaki.takahiro@oss.ntt.co.jp
In reply to: Joe Conway (#34)
dblink memory leak

Joe Conway <mail@joeconway.com> wrote:

The point is *memory leak* in dblink when a query is canceled or
become time-out. I think it is a bug, and my patch could fix it.

Please see if this works for you.

It does not work because errors can occur in caller of dblink functions;
Error callback should be still registered after SRF_RETURN_NEXT, so we
cannot place callback context on stack of the function. More works needed.

RegisterExprContextCallback() might be good for this purpose,
but we need to modify callbacks are fired even if error.

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center

#36Tom Lane
tgl@sss.pgh.pa.us
In reply to: Itagaki Takahiro (#35)
Re: dblink memory leak

Itagaki Takahiro <itagaki.takahiro@oss.ntt.co.jp> writes:

Joe Conway <mail@joeconway.com> wrote:

Please see if this works for you.

It does not work because errors can occur in caller of dblink functions;
Error callback should be still registered after SRF_RETURN_NEXT, so we
cannot place callback context on stack of the function. More works needed.

Yeah, I meant to comment on that: it's an abuse of the error context
mechanism and will never be safe. (An example is that if someone
innocently did an elog(LOG) or something like that, the callback would
get triggered.) The global PGresult value seems awfully dangerous too.

I think what you want to do instead is use PG_TRY blocks to ensure that
transient results are cleaned up.

regards, tom lane

#37Itagaki Takahiro
itagaki.takahiro@oss.ntt.co.jp
In reply to: Tom Lane (#36)
Re: dblink memory leak

Tom Lane <tgl@sss.pgh.pa.us> wrote:

I think what you want to do instead is use PG_TRY blocks to ensure that
transient results are cleaned up.

I think PG_TRY blocks are not enough, too. PG_TRY requires a statement
block, but we need to return from dblink functions per tuple.
Error and interruption can occur at the caller:

ExecMakeTableFunctionResult()
{
for (;;)
{
*here* CHECK_FOR_INTERRUPTS();
result = FunctionCallInvoke(&fcinfo); => { PG_TRY ... END }
if (rsinfo.isDone == ExprEndResult)
break;
tuplestore_puttuple(tupstore, &tmptup);
}
}

Also, we should think SRF-functions might not be called repeatedly
until max_calls whether the transaction is committed or rollbacked
because we might have some optimization in FunctionScan in the future.
For example:
SELECT * FROM dblink() LIMIT 3
might call dblink() only 3 times if we optimize executor logic
(it should not occur for now, though).

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center

#38Tom Lane
tgl@sss.pgh.pa.us
In reply to: Itagaki Takahiro (#37)
Re: dblink memory leak

Itagaki Takahiro <itagaki.takahiro@oss.ntt.co.jp> writes:

I think PG_TRY blocks are not enough, too. PG_TRY requires a statement
block, but we need to return from dblink functions per tuple.

That bit will have to be undone. There is no reason for dblink not to
return a tuplestore.

regards, tom lane

#39Joe Conway
mail@joeconway.com
In reply to: Tom Lane (#38)
Re: dblink memory leak

Tom Lane wrote:

Itagaki Takahiro <itagaki.takahiro@oss.ntt.co.jp> writes:

I think PG_TRY blocks are not enough, too. PG_TRY requires a statement
block, but we need to return from dblink functions per tuple.

That bit will have to be undone. There is no reason for dblink not to
return a tuplestore.

That's a really good point. It was originally written thinking we would
eventually be able to stream tuples rather than materialize them, but
given that many years have passed and we are no closer (I believe) to a
true streaming mode for SRFs, a tuplestore would be much cleaner.

Given that change, is there even any leak to even worry about? As long
as the PGresult object is created in the correct memory context, it
ought to get cleaned up automatically, no?

I can't promise to make this change before 15 October, but I will get to
it before the end of CF3.

Joe

#40Tom Lane
tgl@sss.pgh.pa.us
In reply to: Joe Conway (#39)
Re: dblink memory leak

Joe Conway <mail@joeconway.com> writes:

Given that change, is there even any leak to even worry about? As long
as the PGresult object is created in the correct memory context, it
ought to get cleaned up automatically, no?

No, because libpq knows nothing of backend memory contexts; it just
allocates with malloc. You'll still need a PG_TRY block to ensure you
release PGresults during error cleanup. The change to using tuplestores
will just help you localize that requirement in well-defined places.

I can't promise to make this change before 15 October, but I will get to
it before the end of CF3.

No big hurry, I think, considering the leak has always been there.

regards, tom lane

#41Joe Conway
mail@joeconway.com
In reply to: Tom Lane (#40)
Re: dblink memory leak

Tom Lane wrote:

Joe Conway <mail@joeconway.com> writes:

Given that change, is there even any leak to even worry about? As long
as the PGresult object is created in the correct memory context, it
ought to get cleaned up automatically, no?

No, because libpq knows nothing of backend memory contexts; it just
allocates with malloc. You'll still need a PG_TRY block to ensure you
release PGresults during error cleanup. The change to using tuplestores
will just help you localize that requirement in well-defined places.

I should have known that! Thanks for the wack on the head...

I can't promise to make this change before 15 October, but I will get to
it before the end of CF3.

No big hurry, I think, considering the leak has always been there.

Great. It seems like this is too invasive a change to backport. My
feeling is that not enough people have complained about this specific
scenario to warrant the risk.

Joe

#42Tom Lane
tgl@sss.pgh.pa.us
In reply to: Joe Conway (#41)
Re: dblink memory leak

Joe Conway <mail@joeconway.com> writes:

Tom Lane wrote:

No big hurry, I think, considering the leak has always been there.

Great. It seems like this is too invasive a change to backport. My
feeling is that not enough people have complained about this specific
scenario to warrant the risk.

Agreed, the risk/reward ratio doesn't seem favorable for a backport.

regards, tom lane

#43Robert Haas
robertmhaas@gmail.com
In reply to: Joe Conway (#39)
Re: dblink memory leak

On Mon, Oct 5, 2009 at 1:46 PM, Joe Conway <mail@joeconway.com> wrote:

Tom Lane wrote:

Itagaki Takahiro <itagaki.takahiro@oss.ntt.co.jp> writes:

I think PG_TRY blocks are not enough, too. PG_TRY requires a statement
block, but we need to return from dblink functions per tuple.

That bit will have to be undone.  There is no reason for dblink not to
return a tuplestore.

That's a really good point. It was originally written thinking we would
eventually be able to stream tuples rather than materialize them, but
given that many years have passed and we are no closer (I believe) to a
true streaming mode for SRFs, a tuplestore would be much cleaner.

Given that change, is there even any leak to even worry about? As long
as the PGresult object is created in the correct memory context, it
ought to get cleaned up automatically, no?

I can't promise to make this change before 15 October, but I will get to
it before the end of CF3.

Another possibility is that Itagaki Takahiro, who developed the
original patch, might be willing to develop something along these
lines instead.

However, it does seem that that original patch will not be accepted,
for the reason that the committers prefer the approach discussed
upthread. Therefore, I am marking the "query cancel issues in dblink"
patch as "Returned with Feedback".

...Robert

#44Joe Conway
mail@joeconway.com
In reply to: Robert Haas (#43)
Re: dblink memory leak

Robert Haas wrote:

On Mon, Oct 5, 2009 at 1:46 PM, Joe Conway <mail@joeconway.com> wrote:

I can't promise to make this change before 15 October, but I will get to
it before the end of CF3.

Another possibility is that Itagaki Takahiro, who developed the
original patch, might be willing to develop something along these
lines instead.

Either way is fine -- good suggestion ;-)

However, it does seem that that original patch will not be accepted,
for the reason that the committers prefer the approach discussed
upthread. Therefore, I am marking the "query cancel issues in dblink"
patch as "Returned with Feedback".

Yes, thanks for doing that.

Joe

#45Robert Haas
robertmhaas@gmail.com
In reply to: Heikki Linnakangas (#6)
Re: CommitFest 2009-09, two weeks on

On Wed, Sep 30, 2009 at 12:24 PM, Heikki Linnakangas
<heikki.linnakangas@enterprisedb.com> wrote:

 Do you
have any sense of how soon you'll feel confident to commit either
patch?

I'm bad at estimating. Not this week for sure, and next week I'm
traveling and won't be able to spend as much time on it as I am right
now. If no new major issues are found, and all the outstanding issues
are resolved by me or Simon by then, maybe the week after that.

It's now the week after that, so unless you're in the process of
typing that 'cvs commit' command, I'm going to move HS + SR out to the
next CommitFest so that we can close this one out and stamp alpha2.

<brief pause for objections will now ensue>

...Robert

#46KaiGai Kohei
kaigai@ak.jp.nec.com
In reply to: Robert Haas (#45)
Re: CommitFest 2009-09, two weeks on

Robert Haas wrote:

On Wed, Sep 30, 2009 at 12:24 PM, Heikki Linnakangas
<heikki.linnakangas@enterprisedb.com> wrote:

Do you
have any sense of how soon you'll feel confident to commit either
patch?

I'm bad at estimating. Not this week for sure, and next week I'm
traveling and won't be able to spend as much time on it as I am right
now. If no new major issues are found, and all the outstanding issues
are resolved by me or Simon by then, maybe the week after that.

It's now the week after that, so unless you're in the process of
typing that 'cvs commit' command, I'm going to move HS + SR out to the
next CommitFest so that we can close this one out and stamp alpha2.

<brief pause for objections will now ensue>

I have a question.
When we register the postponed patches on the CF-Nov site again,
which tag should be choosen? "Needs Review"? or "Ready for Commiter"?

Thanks,
--
OSS Platform Development Division, NEC
KaiGai Kohei <kaigai@ak.jp.nec.com>

#47Robert Haas
robertmhaas@gmail.com
In reply to: KaiGai Kohei (#46)
Re: CommitFest 2009-09, two weeks on

2009/10/14 KaiGai Kohei <kaigai@ak.jp.nec.com>:

Robert Haas wrote:

On Wed, Sep 30, 2009 at 12:24 PM, Heikki Linnakangas
<heikki.linnakangas@enterprisedb.com> wrote:

 Do you
have any sense of how soon you'll feel confident to commit either
patch?

I'm bad at estimating. Not this week for sure, and next week I'm
traveling and won't be able to spend as much time on it as I am right
now. If no new major issues are found, and all the outstanding issues
are resolved by me or Simon by then, maybe the week after that.

It's now the week after that, so unless you're in the process of
typing that 'cvs commit' command, I'm going to move HS + SR out to the
next CommitFest so that we can close this one out and stamp alpha2.

<brief pause for objections will now ensue>

I have a question.
When we register the postponed patches on the CF-Nov site again,
which tag should be choosen? "Needs Review"? or "Ready for Commiter"?

Needs Review.

...Robert

#48Heikki Linnakangas
heikki.linnakangas@enterprisedb.com
In reply to: Robert Haas (#45)
Re: CommitFest 2009-09, two weeks on

Robert Haas wrote:

On Wed, Sep 30, 2009 at 12:24 PM, Heikki Linnakangas
<heikki.linnakangas@enterprisedb.com> wrote:

Do you
have any sense of how soon you'll feel confident to commit either
patch?

I'm bad at estimating. Not this week for sure, and next week I'm
traveling and won't be able to spend as much time on it as I am right
now. If no new major issues are found, and all the outstanding issues
are resolved by me or Simon by then, maybe the week after that.

It's now the week after that, so unless you're in the process of
typing that 'cvs commit' command, I'm going to move HS + SR out to the
next CommitFest so that we can close this one out and stamp alpha2.

No objections here.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

#49Robert Haas
robertmhaas@gmail.com
In reply to: Heikki Linnakangas (#48)
Re: CommitFest 2009-09, two weeks on

On Thu, Oct 15, 2009 at 2:27 AM, Heikki Linnakangas
<heikki.linnakangas@enterprisedb.com> wrote:

Robert Haas wrote:

On Wed, Sep 30, 2009 at 12:24 PM, Heikki Linnakangas
<heikki.linnakangas@enterprisedb.com> wrote:

 Do you
have any sense of how soon you'll feel confident to commit either
patch?

I'm bad at estimating. Not this week for sure, and next week I'm
traveling and won't be able to spend as much time on it as I am right
now. If no new major issues are found, and all the outstanding issues
are resolved by me or Simon by then, maybe the week after that.

It's now the week after that, so unless you're in the process of
typing that 'cvs commit' command, I'm going to move HS + SR out to the
next CommitFest so that we can close this one out and stamp alpha2.

No objections here.

OK, done.

...Robert

#50Alvaro Herrera
alvherre@commandprompt.com
In reply to: Boszormenyi Zoltan (#30)
Re: CommitFest 2009-09, two weeks on

Boszormenyi Zoltan escribi�:

I have split up (and cleaned up a little) the dynamic
cursorname patch into smaller logical, easier-to-review
pieces. Descriptions below.

1) 1a-unified-optfromin-fetch-ctxdiff.patch

ecpg supports optional FROM/IN in FETCH and
MOVE statements (mainly because it's required by
Informix-compatibility). Unify core and ecpg grammar
as per Tom Lane's suggestion.

I have applied this patch after some tinkering. I mainly added support
for "fetch_args: FORWARD opt_from_in name" and "BACKWARD opt_from_in
name" in ecpg.addons which apparently you forgot.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

#51Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alvaro Herrera (#50)
Re: CommitFest 2009-09, two weeks on

Alvaro Herrera <alvherre@commandprompt.com> writes:

I have applied this patch after some tinkering.

Shouldn't there be a docs change in that commit?

regards, tom lane

#52Alvaro Herrera
alvherre@commandprompt.com
In reply to: Tom Lane (#51)
Re: CommitFest 2009-09, two weeks on

Tom Lane escribi�:

Alvaro Herrera <alvherre@commandprompt.com> writes:

I have applied this patch after some tinkering.

Shouldn't there be a docs change in that commit?

True -- fixed.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

#53Alvaro Herrera
alvherre@commandprompt.com
In reply to: Boszormenyi Zoltan (#30)
Re: CommitFest 2009-09, two weeks on

Boszormenyi Zoltan escribi�:

2) 1b-cursor_name-ctxdiff.patch

"name" -> "cursor_name" transition in core grammar
and ecpg grammar. Currently it does nothing, it's a
preparation phase. Depends on patch 1.

Applied this part too.

I cannot apply the other ones -- they belong to the ECPG maintainer. I
hope I cleared his road a bit.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

#54Boszormenyi Zoltan
zb@cybertec.at
In reply to: Alvaro Herrera (#50)
Re: CommitFest 2009-09, two weeks on

Alvaro Herrera �rta:

Boszormenyi Zoltan escribi�:

I have split up (and cleaned up a little) the dynamic
cursorname patch into smaller logical, easier-to-review
pieces. Descriptions below.

1) 1a-unified-optfromin-fetch-ctxdiff.patch

ecpg supports optional FROM/IN in FETCH and
MOVE statements (mainly because it's required by
Informix-compatibility). Unify core and ecpg grammar
as per Tom Lane's suggestion.

I have applied this patch after some tinkering. I mainly added support
for "fetch_args: FORWARD opt_from_in name" and "BACKWARD opt_from_in
name" in ecpg.addons which apparently you forgot.

Thanks. Your fix is correct if this patch is considered
standalone. This means I have to re-post the later
patches to fix the reject this fix causes in them.

Best regards,
Zolt�n B�sz�rm�nyi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

#55Boszormenyi Zoltan
zb@cybertec.at
In reply to: Alvaro Herrera (#53)
Re: CommitFest 2009-09, two weeks on

Alvaro Herrera �rta:

Boszormenyi Zoltan escribi�:

2) 1b-cursor_name-ctxdiff.patch

"name" -> "cursor_name" transition in core grammar
and ecpg grammar. Currently it does nothing, it's a
preparation phase. Depends on patch 1.

Applied this part too.

I cannot apply the other ones -- they belong to the ECPG maintainer. I
hope I cleared his road a bit.

Thanks and best regards,
Zolt�n B�sz�rm�nyi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

#56Alvaro Herrera
alvherre@commandprompt.com
In reply to: Boszormenyi Zoltan (#54)
Re: CommitFest 2009-09, two weeks on

Boszormenyi Zoltan escribi�:

Alvaro Herrera �rta:

I have applied this patch after some tinkering. I mainly added support
for "fetch_args: FORWARD opt_from_in name" and "BACKWARD opt_from_in
name" in ecpg.addons which apparently you forgot.

Thanks. Your fix is correct if this patch is considered
standalone. This means I have to re-post the later
patches to fix the reject this fix causes in them.

Yeah. BTW I don't think the rest of the pieces in this series make
sense to apply separately, because they don't do anything useful by
themselves (one of them introduces an unused function, what good is in
that?). I think they should be submitted as a single patch.

If you want to submit patches in a series like this one, they need to be
considered standalone, I think. The Linux kernel devs work differently
than us here.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

#57Robert Haas
robertmhaas@gmail.com
In reply to: Alvaro Herrera (#56)
Re: CommitFest 2009-09, two weeks on

On Thu, Nov 12, 2009 at 2:49 PM, Alvaro Herrera
<alvherre@commandprompt.com> wrote:

Boszormenyi Zoltan escribió:

Alvaro Herrera írta:

I have applied this patch after some tinkering.  I mainly added support
for "fetch_args: FORWARD opt_from_in name" and "BACKWARD opt_from_in
name" in ecpg.addons which apparently you forgot.

Thanks. Your fix is correct if this patch is considered
standalone. This means I have to re-post the later
patches to fix the reject this fix causes in them.

Yeah.  BTW I don't think the rest of the pieces in this series make
sense to apply separately, because they don't do anything useful by
themselves (one of them introduces an unused function, what good is in
that?).  I think they should be submitted as a single patch.

If you want to submit patches in a series like this one, they need to be
considered standalone, I think.  The Linux kernel devs work differently
than us here.

Zoltan broke them up because Michael asked him to do so.

...Robert

#58Michael Meskes
meskes@postgresql.org
In reply to: Robert Haas (#57)
Re: CommitFest 2009-09, two weeks on

On Thu, Nov 12, 2009 at 03:07:27PM -0500, Robert Haas wrote:

If you want to submit patches in a series like this one, they need to be
considered standalone, I think.  The Linux kernel devs work differently
than us here.

Zoltan broke them up because Michael asked him to do so.

Actually these patchsets add different features. I see no reason why they
should be done as one patch. However, I haven't had the time to look into the
latest ones, but at least that was the situation when I asked Zoltan to split
the patch.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ: 179140304, AIM/Yahoo/Skype: michaelmeskes, Jabber: meskes@jabber.org
VfL Borussia! Forca Barca! Go SF 49ers! Use: Debian GNU/Linux, PostgreSQL

In reply to: Michael Meskes (#58)
Re: CommitFest 2009-09, two weeks on

On Nov 13, 2009, at 8:06 AM, Michael Meskes wrote:

On Thu, Nov 12, 2009 at 03:07:27PM -0500, Robert Haas wrote:

If you want to submit patches in a series like this one, they need
to be
considered standalone, I think. The Linux kernel devs work
differently
than us here.

Zoltan broke them up because Michael asked him to do so.

Actually these patchsets add different features. I see no reason why
they
should be done as one patch. However, I haven't had the time to look
into the
latest ones, but at least that was the situation when I asked Zoltan
to split
the patch.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ: 179140304, AIM/Yahoo/Skype: michaelmeskes, Jabber: meskes@jabber.org
VfL Borussia! Forca Barca! Go SF 49ers! Use: Debian GNU/Linux,
PostgreSQL

good morning,

are there some pending technical issues with those patches or can we
basically review and commit?

many thanks,

hans

--
Cybertec Schönig & Schönig GmbH
Reyergasse 9 / 2
A-2700 Wiener Neustadt
Web: www.postgresql-support.de

#60Robert Haas
robertmhaas@gmail.com
In reply to: Hans-Jürgen Schönig (#59)
Re: CommitFest 2009-09, two weeks on

2009/11/13 Hans-Jürgen Schönig <hs@cybertec.at>:

On Nov 13, 2009, at 8:06 AM, Michael Meskes wrote:

On Thu, Nov 12, 2009 at 03:07:27PM -0500, Robert Haas wrote:

If you want to submit patches in a series like this one, they need to be
considered standalone, I think.  The Linux kernel devs work differently
than us here.

Zoltan broke them up because Michael asked him to do so.

Actually these patchsets add different features. I see no reason why they
should be done as one patch. However, I haven't had the time to look into
the
latest ones, but at least that was the situation when I asked Zoltan to
split
the patch.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ: 179140304, AIM/Yahoo/Skype: michaelmeskes, Jabber: meskes@jabber.org
VfL Borussia! Forca Barca! Go SF 49ers! Use: Debian GNU/Linux, PostgreSQL

good morning,

are there some pending technical issues with those patches or can we
basically review and commit?

*scratches head*

How is anyone supposed to answer that question? It is in the process
of reviewing them that one decides whether there are any technical
issues...

...Robert

#61Boszormenyi Zoltan
zb@cybertec.at
In reply to: Alvaro Herrera (#56)
Re: CommitFest 2009-09, two weeks on

Alvaro Herrera �rta:

Boszormenyi Zoltan escribi�:

Alvaro Herrera �rta:

I have applied this patch after some tinkering. I mainly added support
for "fetch_args: FORWARD opt_from_in name" and "BACKWARD opt_from_in
name" in ecpg.addons which apparently you forgot.

Thanks. Your fix is correct if this patch is considered
standalone. This means I have to re-post the later
patches to fix the reject this fix causes in them.

Yeah. BTW I don't think the rest of the pieces in this series make
sense to apply separately, because they don't do anything useful by
themselves (one of them introduces an unused function, what good is in
that?). I think they should be submitted as a single patch.

If you want to submit patches in a series like this one, they need to be
considered standalone, I think. The Linux kernel devs work differently
than us here.

Dan started reviewing the dynamic cursorname patch.
He looked at it in the original form and he said that
he's not familiar with the ECPG code.

I have drafted the docs for the generated ECPG grammar
(it was applied mainstream by Michael shortly after
being posted) and have split this patch in question to help
Dan in the review. The patch pieces explain the various
problems about the implementation.

Is it really *that* apparent that I read too much LKML? :-D

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

#62Boszormenyi Zoltan
zb@cybertec.at
In reply to: Alvaro Herrera (#56)
1 attachment(s)
ECPG patch 1, dynamic cursorname

Hi,

I have rebased the ECPG patches to current CVS.
This mail contains the dynamic cursorname,
the fine-grained split-up was re-united as per
Alvaro's comment.

Best regards,
Zolt�n B�sz�rm�nyi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

Attachments:

1-dyncursor-ctxdiff.patchtext/x-patch; name=1-dyncursor-ctxdiff.patchDownload
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.addons pgsql.1/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.addons	2009-11-12 11:13:53.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/preproc/ecpg.addons	2009-11-16 10:51:38.000000000 +0100
*************** ECPG: var_valueNumericOnly addon
*** 213,230 ****
  		}
  ECPG: fetch_argscursor_name addon
  		add_additional_variables($1, false);
  ECPG: fetch_argsfrom_incursor_name addon
  		add_additional_variables($2, false);
  ECPG: fetch_argsNEXTopt_from_incursor_name addon
  ECPG: fetch_argsPRIORopt_from_incursor_name addon
  ECPG: fetch_argsFIRST_Popt_from_incursor_name addon
  ECPG: fetch_argsLAST_Popt_from_incursor_name addon
  ECPG: fetch_argsALLopt_from_incursor_name addon
- ECPG: fetch_argsFORWARDopt_from_incursor_name addon
- ECPG: fetch_argsBACKWARDopt_from_incursor_name addon
  		add_additional_variables($3, false);
  ECPG: fetch_argsSignedIconstopt_from_incursor_name addon
  		add_additional_variables($3, false);
  		if ($1[0] == '$')
  		{
  			free($1);
--- 213,248 ----
  		}
  ECPG: fetch_argscursor_name addon
  		add_additional_variables($1, false);
+ 		if ($1[0] == ':')
+ 		{
+ 			free($1);
+ 			$1 = make_str("$0");
+ 		}
  ECPG: fetch_argsfrom_incursor_name addon
  		add_additional_variables($2, false);
+ 		if ($2[0] == ':')
+ 		{
+ 			free($2);
+ 			$2 = make_str("$0");
+ 		}
  ECPG: fetch_argsNEXTopt_from_incursor_name addon
  ECPG: fetch_argsPRIORopt_from_incursor_name addon
  ECPG: fetch_argsFIRST_Popt_from_incursor_name addon
  ECPG: fetch_argsLAST_Popt_from_incursor_name addon
  ECPG: fetch_argsALLopt_from_incursor_name addon
  		add_additional_variables($3, false);
+ 		if ($3[0] == ':')
+ 		{
+ 			free($3);
+ 			$3 = make_str("$0");
+ 		}
  ECPG: fetch_argsSignedIconstopt_from_incursor_name addon
  		add_additional_variables($3, false);
+ 		if ($3[0] == ':')
+ 		{
+ 			free($3);
+ 			$3 = make_str("$0");
+ 		}
  		if ($1[0] == '$')
  		{
  			free($1);
*************** ECPG: fetch_argsSignedIconstopt_from_inc
*** 233,248 ****
--- 251,285 ----
  ECPG: fetch_argsFORWARDALLopt_from_incursor_name addon
  ECPG: fetch_argsBACKWARDALLopt_from_incursor_name addon
  		add_additional_variables($4, false);
+ 		if ($4[0] == ':')
+ 		{
+ 			free($4);
+ 			$4 = make_str("$0");
+ 		}
  ECPG: fetch_argsABSOLUTE_PSignedIconstopt_from_incursor_name addon
  ECPG: fetch_argsRELATIVE_PSignedIconstopt_from_incursor_name addon
  ECPG: fetch_argsFORWARDSignedIconstopt_from_incursor_name addon
  ECPG: fetch_argsBACKWARDSignedIconstopt_from_incursor_name addon
  		add_additional_variables($4, false);
+ 		if ($4[0] == ':')
+ 		{
+ 			free($4);
+ 			$4 = make_str("$0");
+ 		}
  		if ($2[0] == '$')
  		{
  			free($2);
  			$2 = make_str("$0");
  		}
+ ECPG: cursor_namename rule
+ 	| char_civar
+ 		{
+ 			char *curname = mm_alloc(strlen($1) + 2);
+ 			sprintf(curname, ":%s", $1);
+ 			free($1);
+ 			$1 = curname;
+ 			$$ = $1;
+ 		}
  ECPG: PrepareStmtPREPAREprepared_nameprep_type_clauseASPreparableStmt block
  	{
  		$$.name = $2;
*************** ECPG: ExecuteStmtEXECUTEprepared_nameexe
*** 260,265 ****
--- 297,303 ----
  ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectStmt block
  	{
  		struct cursor *ptr, *this;
+ 		char *cursor_marker = $2[0] == ':' ? make_str("$0") : mm_strdup($2);
  		char *comment;
  
  		for (ptr = cur; ptr != NULL; ptr = ptr->next)
*************** ECPG: DeclareCursorStmtDECLAREcursor_nam
*** 274,280 ****
  		this->name = $2;
  		this->connection = connection;
  		this->opened = false;
! 		this->command =  cat_str(7, make_str("declare"), mm_strdup($2), $3, make_str("cursor"), $5, make_str("for"), $7);
  		this->argsinsert = argsinsert;
  		this->argsresult = argsresult;
  		argsinsert = argsresult = NULL;
--- 312,318 ----
  		this->name = $2;
  		this->connection = connection;
  		this->opened = false;
! 		this->command =  cat_str(7, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for"), $7);
  		this->argsinsert = argsinsert;
  		this->argsresult = argsresult;
  		argsinsert = argsresult = NULL;
*************** ECPG: DeclareCursorStmtDECLAREcursor_nam
*** 294,299 ****
--- 332,342 ----
  		else
  			$$ = comment;
  	}
+ ECPG: ClosePortalStmtCLOSEcursor_name block
+ 	{
+ 		char *cursor_marker = $2[0] == ':' ? make_str("$0") : $2;
+ 		$$ = cat2_str(make_str("close"), cursor_marker);
+ 	}
  ECPG: opt_hold block
  	{
  		if (compat == ECPG_COMPAT_INFORMIX_SE && autocommit == true)
*************** ECPG: FetchStmtMOVEfetch_args rule
*** 363,368 ****
--- 406,459 ----
  	{
  		$$ = cat2_str(make_str("fetch"), $2);
  	}
+ 	| FETCH FORWARD cursor_name opt_ecpg_into
+ 	{
+ 		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
+ 		add_additional_variables($3, false);
+ 		$$ = cat_str(2, make_str("fetch forward"), cursor_marker);
+ 	}
+ 	| FETCH FORWARD from_in cursor_name opt_ecpg_into
+ 	{
+ 		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
+ 		add_additional_variables($4, false);
+ 		$$ = cat_str(2, make_str("fetch forward from"), cursor_marker);
+ 	}
+ 	| FETCH BACKWARD cursor_name opt_ecpg_into
+ 	{
+ 		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
+ 		add_additional_variables($3, false);
+ 		$$ = cat_str(2, make_str("fetch backward"), cursor_marker);
+ 	}
+ 	| FETCH BACKWARD from_in cursor_name opt_ecpg_into
+ 	{
+ 		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
+ 		add_additional_variables($4, false);
+ 		$$ = cat_str(2, make_str("fetch backward from"), cursor_marker);
+ 	}
+ 	| MOVE FORWARD cursor_name
+ 	{
+ 		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
+ 		add_additional_variables($3, false);
+ 		$$ = cat_str(2, make_str("move forward"), cursor_marker);
+ 	}
+ 	| MOVE FORWARD from_in cursor_name
+ 	{
+ 		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
+ 		add_additional_variables($4, false);
+ 		$$ = cat_str(2, make_str("move forward from"), cursor_marker);
+ 	}
+ 	| MOVE BACKWARD cursor_name
+ 	{
+ 		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
+ 		add_additional_variables($3, false);
+ 		$$ = cat_str(2, make_str("move backward"), cursor_marker);
+ 	}
+ 	| MOVE BACKWARD from_in cursor_name
+ 	{
+ 		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
+ 		add_additional_variables($4, false);
+ 		$$ = cat_str(2, make_str("move backward from"), cursor_marker);
+ 	}
  ECPG: select_limitLIMITselect_limit_value','select_offset_value block
          {
                  mmerror(PARSE_ERROR, ET_WARNING, "no longer supported LIMIT #,# syntax passed to server");
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.trailer pgsql.1/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.trailer	2009-11-12 11:13:54.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/preproc/ecpg.trailer	2009-11-16 10:52:12.000000000 +0100
*************** char_variable: cvariable
*** 218,223 ****
--- 218,255 ----
  		}
  		;
  
+ cursor_char_variable: cvariable
+ 		{
+ 			/* check if we have a string variable */
+ 			struct variable *p = find_variable($1);
+ 			enum ECPGttype type = p->type->type;
+ 
+ 			/* If we have just one character this is not a string */
+ 			if (atol(p->type->size) == 1)
+ 					mmerror(PARSE_ERROR, ET_ERROR, "invalid data type");
+ 			else
+ 			{
+ 				/* if array see what's inside */
+ 				if (type == ECPGt_array)
+ 					type = p->type->u.element->type;
+ 
+ 				switch (type)
+ 				{
+ 					case ECPGt_char:
+ 					case ECPGt_unsigned_char:
+ 					case ECPGt_string:
+ 					case ECPGt_varchar:
+ 						$$ = $1;
+ 						break;
+ 					default:
+ 						mmerror(PARSE_ERROR, ET_ERROR, "invalid data type");
+ 						$$ = $1;
+ 						break;
+ 				}
+ 			}
+ 		}
+ 		;
+ 
  opt_options: Op connect_options
  		{
  			if (strlen($1) == 0)
*************** prepared_name: name             {
*** 278,283 ****
--- 310,316 ----
  ECPGCursorStmt:  DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared_name
  		{
  			struct cursor *ptr, *this;
+ 			char *cursor_marker = $2[0] == ':' ? make_str("$0") : mm_strdup($2);
  			struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable));
  			const char *con = connection ? connection : "NULL";
  
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 294,300 ****
  			this->next = cur;
  			this->name = $2;
  			this->connection = connection;
! 			this->command =  cat_str(6, make_str("declare"), mm_strdup($2), $3, make_str("cursor"), $5, make_str("for $1"));
  			this->argsresult = NULL;
  
  			thisquery->type = &ecpg_query;
--- 327,333 ----
  			this->next = cur;
  			this->name = $2;
  			this->connection = connection;
! 			this->command =  cat_str(6, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for $1"));
  			this->argsresult = NULL;
  
  			thisquery->type = &ecpg_query;
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 304,309 ****
--- 337,348 ----
  			sprintf(thisquery->name, "ECPGprepared_statement(%s, %s, __LINE__)", con, $7);
  
  			this->argsinsert = NULL;
+ 			if ($2[0] == ':')
+ 			{
+ 				struct variable *var = find_variable($2 + 1);
+ 				remove_variable_from_list(&argsinsert, var);
+ 				add_variable_to_head(&(this->argsinsert), var, &no_indicator);
+ 			}
  			add_variable_to_head(&(this->argsinsert), thisquery, &no_indicator);
  
  			cur = this;
*************** ECPGFree:	SQL_FREE name	{ $$ = $2; }
*** 947,953 ****
  /*
   * open is an open cursor, at the moment this has to be removed
   */
! ECPGOpen: SQL_OPEN cursor_name opt_ecpg_using { $$ = $2; };
  
  opt_ecpg_using: /*EMPTY*/	{ $$ = EMPTY; }
  		| ecpg_using		{ $$ = $1; }
--- 986,1001 ----
  /*
   * open is an open cursor, at the moment this has to be removed
   */
! ECPGOpen: SQL_OPEN cursor_name opt_ecpg_using
! 		{
! 			if ($2[0] == ':')
! 			{
! 				struct variable *var = find_variable($2 + 1);
! 				remove_variable_from_list(&argsinsert, var);
! 			}
! 			$$ = $2;
! 		}
! 		;
  
  opt_ecpg_using: /*EMPTY*/	{ $$ = EMPTY; }
  		| ecpg_using		{ $$ = $1; }
*************** civarind: cvariable indicator
*** 1772,1777 ****
--- 1820,1832 ----
  		}
  		;
  
+ char_civar: cursor_char_variable
+ 		{
+ 			add_variable_to_head(&argsinsert, find_variable($1), &no_indicator);
+ 			$$ = $1;
+ 		}
+ 		;
+ 
  civar: cvariable
  		{
  			add_variable_to_head(&argsinsert, find_variable($1), &no_indicator);
*************** ecpg_into: INTO into_list	{ $$ = EMPTY; 
*** 1987,1992 ****
--- 2042,2051 ----
          | into_descriptor	{ $$ = $1; }
  	;
  
+ opt_ecpg_into:	/* EMPTY */	{ $$ = EMPTY; }
+ 	| ecpg_into		{ $$ = $1; }
+ 	;
+ 
  %%
  
  void base_yyerror(const char *error)
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.type pgsql.1/src/interfaces/ecpg/preproc/ecpg.type
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.type	2009-11-06 11:06:24.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/preproc/ecpg.type	2009-11-16 10:52:12.000000000 +0100
***************
*** 43,50 ****
--- 43,52 ----
  %type <str> c_term
  %type <str> c_thing
  %type <str> char_variable
+ %type <str> char_civar
  %type <str> civar
  %type <str> civarind
+ %type <str> cursor_char_variable
  %type <str> ColLabel
  %type <str> connect_options
  %type <str> connection_object
***************
*** 75,80 ****
--- 77,83 ----
  %type <str> opt_bit_field
  %type <str> opt_connection_name
  %type <str> opt_database_name
+ %type <str> opt_ecpg_into
  %type <str> opt_ecpg_using
  %type <str> opt_initializer
  %type <str> opt_options
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/extern.h pgsql.1/src/interfaces/ecpg/preproc/extern.h
*** pgsql.orig/src/interfaces/ecpg/preproc/extern.h	2009-09-08 10:12:40.000000000 +0200
--- pgsql.1/src/interfaces/ecpg/preproc/extern.h	2009-11-16 10:44:18.000000000 +0100
*************** extern struct descriptor *lookup_descrip
*** 90,95 ****
--- 90,96 ----
  extern struct variable *descriptor_variable(const char *name, int input);
  extern void add_variable_to_head(struct arguments **, struct variable *, struct variable *);
  extern void add_variable_to_tail(struct arguments **, struct variable *, struct variable *);
+ extern void remove_variable_from_list(struct arguments ** list, struct variable * var);
  extern void dump_variables(struct arguments *, int);
  extern struct typedefs *get_typedef(char *);
  extern void adjust_array(enum ECPGttype, char **, char **, char *, char *, int, bool);
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/parse.pl pgsql.1/src/interfaces/ecpg/preproc/parse.pl
*** pgsql.orig/src/interfaces/ecpg/preproc/parse.pl	2009-11-06 11:06:25.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/preproc/parse.pl	2009-11-16 11:02:50.000000000 +0100
*************** $replace_types{'unreserved_keyword'} = '
*** 56,62 ****
  $replace_types{'Sconst'} = 'ignore';
  
  # some production rules have to be ignored or replaced
! $replace_line{'fetch_direction'} = 'ignore';
  $replace_line{"opt_array_boundsopt_array_bounds'['Iconst']'"} = 'ignore';
  $replace_line{'col_name_keywordCHAR_P'} = 'ignore';
  $replace_line{'col_name_keywordINT_P'} = 'ignore';
--- 56,63 ----
  $replace_types{'Sconst'} = 'ignore';
  
  # some production rules have to be ignored or replaced
! $replace_line{'fetch_argsFORWARDopt_from_incursor_name'} = 'ignore';
! $replace_line{'fetch_argsBACKWARDopt_from_incursor_name'} = 'ignore';
  $replace_line{"opt_array_boundsopt_array_bounds'['Iconst']'"} = 'ignore';
  $replace_line{'col_name_keywordCHAR_P'} = 'ignore';
  $replace_line{'col_name_keywordINT_P'} = 'ignore';
*************** sub include_stuff {
*** 310,315 ****
--- 311,317 ----
      local($includestream, $includefilename, $includeblock, $copy, $field_count) = @_;
      $copied = 0;
      $inblock = 0;
+     $have_addon = 0;
      $filename = $path . "/" . $includefilename;
      while (($_ = &Getline2($filename),$getline_ok)) {
  	if ($includeblock ne '' && $Fld[1] eq 'ECPG:' && $inblock == 0) {
*************** sub include_stuff {
*** 318,326 ****
  		$inblock = 1;
  		$includetype = $Fld[3];
  		if ($includetype eq 'rule') {
! 		    &dump_fields($stmt_mode, *fields, $field_count, ' { ');
  		}
  		elsif ($includetype eq 'addon') {
  		    &add_to_buffer('rules', ' { ');
  		}
  	    }
--- 320,334 ----
  		$inblock = 1;
  		$includetype = $Fld[3];
  		if ($includetype eq 'rule') {
! 		    if ($have_addon == 0) {
! 			&dump_fields($stmt_mode, *fields, $field_count, ' { ');
! 		    }
! 		    else {
! 			&dump_fields($stmt_mode, *fields, $field_count, '');
! 		    }
  		}
  		elsif ($includetype eq 'addon') {
+ 		    $have_addon  = 1;
  		    &add_to_buffer('rules', ' { ');
  		}
  	    }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/variable.c pgsql.1/src/interfaces/ecpg/preproc/variable.c
*** pgsql.orig/src/interfaces/ecpg/preproc/variable.c	2009-08-07 13:06:28.000000000 +0200
--- pgsql.1/src/interfaces/ecpg/preproc/variable.c	2009-11-16 10:44:18.000000000 +0100
*************** add_variable_to_tail(struct arguments **
*** 401,406 ****
--- 401,430 ----
  		*list = new;
  }
  
+ void
+ remove_variable_from_list(struct arguments ** list, struct variable * var)
+ {
+ 	struct arguments *p, *prev = NULL;
+ 	bool found = false;
+ 
+ 	for (p = *list; p; p = p->next)
+ 	{
+ 		if (p->variable == var)
+ 		{
+ 			found = true;
+ 			break;
+ 		}
+ 		prev = p;
+ 	}
+ 	if (found)
+ 	{
+ 		if (prev)
+ 			prev->next = p->next;
+ 		else
+ 			*list = p->next;
+ 	}
+ }
+ 
  /* Dump out a list of all the variable on this list.
     This is a recursive function that works from the end of the list and
     deletes the list as we go on.
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/compat_informix/cursor.pgc pgsql.1/src/interfaces/ecpg/test/compat_informix/cursor.pgc
*** pgsql.orig/src/interfaces/ecpg/test/compat_informix/cursor.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/test/compat_informix/cursor.pgc	2009-11-16 10:52:22.000000000 +0100
***************
*** 0 ****
--- 1,245 ----
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ exec sql type c is char reference;
+ typedef char* c;
+ 
+ exec sql type ind is union { int integer; short smallint; };
+ typedef union { int integer; short smallint; } ind;
+ 
+ #define BUFFERSIZ 8
+ exec sql type str is varchar[BUFFERSIZ];
+ 
+ #define CURNAME "mycur"
+ 
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ 	char	*stmt1 = "SELECT id, t FROM t1";
+ 	char	*curname1 = CURNAME;
+ 	char	*curname2 = CURNAME;
+ 	char	*curname3 = CURNAME;
+ 	varchar	curname4[50];
+ 	int	count;
+ 	int	id;
+ 	char	t[64];
+ exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table t1(id serial primary key, t text);
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into t1(id, t) values (default, 'a');
+ 	exec sql insert into t1(id, t) values (default, 'b');
+ 	exec sql insert into t1(id, t) values (default, 'c');
+ 	exec sql insert into t1(id, t) values (default, 'd');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* Dynamic cursorname test with INTO list in FETCH stmts */
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare :curname1 cursor for
+ 		select id, t from t1;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open :curname1;
+ 
+ 	strcpy(msg, "fetch from");
+ 	exec sql fetch from :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	exec sql fetch :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	exec sql fetch 1 from :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	exec sql fetch :count from :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move in");
+ 	exec sql move absolute 0 in :curname1;
+ 
+ 	strcpy(msg, "fetch 1");
+ 	exec sql fetch 1 :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	exec sql fetch :count :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close :curname1;
+ 
+ 	/* Dynamic cursorname test with INTO list in DECLARE stmt */
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare :curname2 cursor for
+ 		select id, t into :id, :t from t1;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open :curname2;
+ 
+ 	strcpy(msg, "fetch from");
+ 	exec sql fetch from :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	exec sql fetch :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	exec sql fetch 1 from :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	exec sql fetch :count from :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	exec sql move absolute 0 :curname2;
+ 
+ 	strcpy(msg, "fetch 1");
+ 	exec sql fetch 1 :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	exec sql fetch :count :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close :curname2;
+ 
+ 	/* Dynamic cursorname test with PREPARED stmt */
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id1 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare :curname3 cursor for st_id1;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open :curname3;
+ 
+ 	strcpy(msg, "fetch from");
+ 	exec sql fetch from :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	exec sql fetch :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	exec sql fetch 1 from :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	exec sql fetch :count from :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	exec sql move absolute 0 :curname3;
+ 
+ 	strcpy(msg, "fetch 1");
+ 	exec sql fetch 1 :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	exec sql fetch :count :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close :curname3;
+ 
+ 	strcpy(msg, "deallocate prepare");
+ 	exec sql deallocate prepare st_id1;
+ 
+ 	/* Dynamic cursorname test with PREPARED stmt,
+ 	   cursor name in varchar */
+ 
+ 	curname4.len = strlen(CURNAME);
+ 	strcpy(curname4.arr, CURNAME);
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id2 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare :curname4 cursor for st_id2;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open :curname4;
+ 
+ 	strcpy(msg, "fetch from");
+ 	exec sql fetch from :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	exec sql fetch :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	exec sql fetch 1 from :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	exec sql fetch :count from :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	exec sql move absolute 0 :curname4;
+ 
+ 	strcpy(msg, "fetch 1");
+ 	exec sql fetch 1 :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	exec sql fetch :count :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close :curname4;
+ 
+ 	strcpy(msg, "deallocate prepare");
+ 	exec sql deallocate prepare st_id2;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table t1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/compat_informix/Makefile pgsql.1/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.orig/src/interfaces/ecpg/test/compat_informix/Makefile	2006-09-19 17:36:08.000000000 +0200
--- pgsql.1/src/interfaces/ecpg/test/compat_informix/Makefile	2009-11-16 10:52:22.000000000 +0100
*************** override LIBS := -lecpg_compat $(LIBS)
*** 12,17 ****
--- 12,18 ----
  
  TESTS = test_informix test_informix.c \
          test_informix2 test_informix2.c \
+         cursor cursor.c \
          dec_test dec_test.c \
          rfmtdate rfmtdate.c \
          rfmtlong rfmtlong.c \
*************** test_informix.c: test_informix.pgc ../re
*** 26,31 ****
--- 27,35 ----
  test_informix2.c: test_informix2.pgc ../regression.h
  	$(ECPG) -o $@ -I$(srcdir) $<
  
+ cursor.c: cursor.pgc ../regression.h
+ 	$(ECPG) -o $@ -I$(srcdir) $<
+ 
  dec_test.c: dec_test.pgc ../regression.h
  	$(ECPG) -o $@ -I$(srcdir) $<
  
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule pgsql.1/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule	2008-10-29 11:40:29.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/test/ecpg_schedule	2009-11-16 10:52:22.000000000 +0100
*************** test: compat_informix/charfuncs
*** 3,8 ****
--- 3,9 ----
  test: compat_informix/rfmtdate
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
+ test: compat_informix/cursor
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: pgtypeslib/num_test2
*** 16,21 ****
--- 17,23 ----
  test: preproc/array_of_struct
  test: preproc/autoprep
  test: preproc/comment
+ test: preproc/cursor
  test: preproc/define
  test: preproc/init
  test: preproc/strings
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule_tcp pgsql.1/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule_tcp	2008-10-29 11:40:29.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-11-16 10:52:22.000000000 +0100
*************** test: compat_informix/charfuncs
*** 3,8 ****
--- 3,9 ----
  test: compat_informix/rfmtdate
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
+ test: compat_informix/cursor
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: pgtypeslib/num_test2
*** 16,21 ****
--- 17,23 ----
  test: preproc/array_of_struct
  test: preproc/autoprep
  test: preproc/comment
+ test: preproc/cursor
  test: preproc/define
  test: preproc/init
  test: preproc/strings
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-cursor.c pgsql.1/src/interfaces/ecpg/test/expected/compat_informix-cursor.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-cursor.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/test/expected/compat_informix-cursor.c	2009-11-16 10:52:22.000000000 +0100
***************
*** 0 ****
--- 1,766 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "cursor.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 4 "cursor.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 6 "cursor.pgc"
+ 
+ 
+ /* exec sql type c is char reference */
+ #line 8 "cursor.pgc"
+ 
+ typedef char* c;
+ 
+ /* exec sql type ind is union { 
+ #line 11 "cursor.pgc"
+  int integer ;
+  
+ #line 11 "cursor.pgc"
+  short smallint ;
+  } */
+ #line 11 "cursor.pgc"
+ 
+ typedef union { int integer; short smallint; } ind;
+ 
+ #define BUFFERSIZ 8
+ /* exec sql type str is [ BUFFERSIZ ] */
+ #line 15 "cursor.pgc"
+ 
+ 
+ #define CURNAME "mycur"
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		  
+ 		  
+ 		
+ 		
+ 		
+ 		
+ 
+ #line 23 "cursor.pgc"
+  char * stmt1 = "SELECT id, t FROM t1" ;
+  
+ #line 24 "cursor.pgc"
+  char * curname1 = CURNAME ;
+  
+ #line 25 "cursor.pgc"
+  char * curname2 = CURNAME ;
+  
+ #line 26 "cursor.pgc"
+  char * curname3 = CURNAME ;
+  
+ #line 27 "cursor.pgc"
+   struct varchar_curname4_27  { int len; char arr[ 50 ]; }  curname4 ;
+  
+ #line 28 "cursor.pgc"
+  int count ;
+  
+ #line 29 "cursor.pgc"
+  int id ;
+  
+ #line 30 "cursor.pgc"
+  char t [ 64 ] ;
+ /* exec sql end declare section */
+ #line 31 "cursor.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0); 
+ #line 38 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 41 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
+ #line 44 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 44 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 47 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 47 "cursor.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 48 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 48 "cursor.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 49 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 49 "cursor.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 50 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 50 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 53 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 53 "cursor.pgc"
+ 
+ 
+ 	/* Dynamic cursorname test with INTO list in FETCH stmts */
+ 
+ 	strcpy(msg, "declare");
+ 	ECPG_informix_set_var( 0, &( curname1 ), __LINE__);\
+  ECPG_informix_reset_sqlca(); /* declare $0 cursor for select id , t from t1 */
+ #line 59 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
+ 	ECPGt_char,&(*( char  *)(ECPG_informix_get_var( 0))),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 62 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 62 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch from");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 65 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 65 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 69 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 69 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 73 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 73 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 78 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 78 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move in");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "move absolute 0 in $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 82 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 82 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch 1");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 85 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 85 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 90 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 90 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 94 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 94 "cursor.pgc"
+ 
+ 
+ 	/* Dynamic cursorname test with INTO list in DECLARE stmt */
+ 
+ 	strcpy(msg, "declare");
+ 	ECPG_informix_set_var( 3, &( curname2 ), __LINE__);\
+  ECPG_informix_set_var( 1, ( t ), __LINE__);\
+  ECPG_informix_set_var( 2, &( id ), __LINE__);\
+  ECPG_informix_reset_sqlca(); /* declare $0 cursor for select id , t from t1 */
+ #line 100 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
+ 	ECPGt_char,&(*( char  *)(ECPG_informix_get_var( 3))),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 103 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 103 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch from");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 106 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 106 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 110 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 110 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 114 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 114 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 119 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 119 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 123 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 123 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch 1");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 126 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 126 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 131 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 131 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 135 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 135 "cursor.pgc"
+ 
+ 
+ 	/* Dynamic cursorname test with PREPARED stmt */
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 140 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 140 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	ECPG_informix_reset_sqlca(); /* declare $0 cursor for $1 */
+ #line 143 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for $1", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 146 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 146 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch from");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 149 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 149 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 153 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 153 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 157 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 157 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 162 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 162 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 166 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 166 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch 1");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 169 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 169 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 174 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 174 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 178 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 178 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate prepare");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
+ #line 181 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 181 "cursor.pgc"
+ 
+ 
+ 	/* Dynamic cursorname test with PREPARED stmt,
+ 	   cursor name in varchar */
+ 
+ 	curname4.len = strlen(CURNAME);
+ 	strcpy(curname4.arr, CURNAME);
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
+ #line 190 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 190 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	ECPG_informix_reset_sqlca(); /* declare $0 cursor for $1 */
+ #line 193 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for $1", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 196 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 196 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch from");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 199 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 199 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 203 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 203 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 207 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 207 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 212 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 212 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 216 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 216 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch 1");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 219 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 219 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0 $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 224 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 224 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 228 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 228 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate prepare");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id2");
+ #line 231 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 231 "cursor.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 236 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 236 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 239 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 239 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 242 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 242 "cursor.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-cursor.stderr pgsql.1/src/interfaces/ecpg/test/expected/compat_informix-cursor.stderr
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-cursor.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/test/expected/compat_informix-cursor.stderr	2009-11-16 10:52:22.000000000 +0100
***************
*** 0 ****
--- 1,372 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 47: query: insert into t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 47: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 47: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: query: insert into t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: query: insert into t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: query: insert into t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 53: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: query: declare mycur cursor for select id , t from t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 65: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 65: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 65: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 65: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 65: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 69: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 69: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 69: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 69: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 69: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 73: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 73: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 73: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 73: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 73: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 78: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 78: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 78: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 78: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 78: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: query: move absolute 0 in mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 85: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 85: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 90: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 90: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 94: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 94: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 94: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: query: declare mycur cursor for select id , t from t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 106: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 106: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 106: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 106: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 106: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 110: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 110: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 114: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 114: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 114: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 114: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 114: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 119: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 119: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 119: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 119: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 119: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 123: query: move absolute 0 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 123: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 123: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 126: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 126: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 126: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 126: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 126: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 131: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 131: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 131: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 131: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 131: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 140: name st_id1; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 146: query: declare mycur cursor for SELECT id, t FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 146: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 146: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 149: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 149: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 153: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 153: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 157: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 157: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 162: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 162: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 162: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 162: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 162: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 166: query: move absolute 0 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 166: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 166: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 169: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 169: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 169: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 169: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 169: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 174: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 174: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 174: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 174: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 174: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 178: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 178: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 178: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 181: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 190: name st_id2; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: query: declare mycur cursor for SELECT id, t FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 199: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 199: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 203: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 203: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 203: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 203: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 203: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 207: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 207: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 207: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 207: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 207: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 212: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 212: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 212: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 212: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 212: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 216: query: move absolute 0 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 216: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 216: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 224: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 224: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 224: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 224: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 224: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 231: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 236: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 236: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 236: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 239: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-cursor.stdout pgsql.1/src/interfaces/ecpg/test/expected/compat_informix-cursor.stdout
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-cursor.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/test/expected/compat_informix-cursor.stdout	2009-11-16 10:52:22.000000000 +0100
***************
*** 0 ****
--- 1,24 ----
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/preproc-cursor.c pgsql.1/src/interfaces/ecpg/test/expected/preproc-cursor.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/preproc-cursor.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/test/expected/preproc-cursor.c	2009-11-16 10:52:22.000000000 +0100
***************
*** 0 ****
--- 1,760 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "cursor.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 4 "cursor.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 6 "cursor.pgc"
+ 
+ 
+ /* exec sql type c is char reference */
+ #line 8 "cursor.pgc"
+ 
+ typedef char* c;
+ 
+ /* exec sql type ind is union { 
+ #line 11 "cursor.pgc"
+  int integer ;
+  
+ #line 11 "cursor.pgc"
+  short smallint ;
+  } */
+ #line 11 "cursor.pgc"
+ 
+ typedef union { int integer; short smallint; } ind;
+ 
+ #define BUFFERSIZ 8
+ /* exec sql type str is [ BUFFERSIZ ] */
+ #line 15 "cursor.pgc"
+ 
+ 
+ #define CURNAME "mycur"
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		  
+ 		  
+ 		
+ 		
+ 		
+ 		
+ 
+ #line 23 "cursor.pgc"
+  char * stmt1 = "SELECT id, t FROM t1" ;
+  
+ #line 24 "cursor.pgc"
+  char * curname1 = CURNAME ;
+  
+ #line 25 "cursor.pgc"
+  char * curname2 = CURNAME ;
+  
+ #line 26 "cursor.pgc"
+  char * curname3 = CURNAME ;
+  
+ #line 27 "cursor.pgc"
+   struct varchar_curname4_27  { int len; char arr[ 50 ]; }  curname4 ;
+  
+ #line 28 "cursor.pgc"
+  int count ;
+  
+ #line 29 "cursor.pgc"
+  int id ;
+  
+ #line 30 "cursor.pgc"
+  char t [ 64 ] ;
+ /* exec sql end declare section */
+ #line 31 "cursor.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
+ #line 38 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 41 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
+ #line 44 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 44 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 47 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 47 "cursor.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 48 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 48 "cursor.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 49 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 49 "cursor.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 50 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 50 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 53 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 53 "cursor.pgc"
+ 
+ 
+ 	/* Dynamic cursorname test with INTO list in FETCH stmts */
+ 
+ 	strcpy(msg, "declare");
+ 	/* declare $0 cursor for select id , t from t1 */
+ #line 59 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 62 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 62 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch from");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 65 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 65 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 69 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 69 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 73 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 73 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 78 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 78 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move in");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move absolute 0 in $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 82 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 82 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch 1");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 85 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 85 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 90 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 90 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close $0", 
+ 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 94 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 94 "cursor.pgc"
+ 
+ 
+ 	/* Dynamic cursorname test with INTO list in DECLARE stmt */
+ 
+ 	strcpy(msg, "declare");
+ 	/* declare $0 cursor for select id , t from t1 */
+ #line 100 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 103 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 103 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch from");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 106 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 106 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 110 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 110 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 114 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 114 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 119 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 119 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 123 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 123 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch 1");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 126 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 126 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 131 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 131 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 135 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 135 "cursor.pgc"
+ 
+ 
+ 	/* Dynamic cursorname test with PREPARED stmt */
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 140 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 140 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	/* declare $0 cursor for $1 */
+ #line 143 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for $1", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 146 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 146 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch from");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 149 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 149 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 153 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 153 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 157 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 157 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 162 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 162 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 166 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 166 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch 1");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 169 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 169 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 174 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 174 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close $0", 
+ 	ECPGt_char,&(curname3),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 178 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 178 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate prepare");
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
+ #line 181 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 181 "cursor.pgc"
+ 
+ 
+ 	/* Dynamic cursorname test with PREPARED stmt,
+ 	   cursor name in varchar */
+ 
+ 	curname4.len = strlen(CURNAME);
+ 	strcpy(curname4.arr, CURNAME);
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
+ #line 190 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 190 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	/* declare $0 cursor for $1 */
+ #line 193 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for $1", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 196 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 196 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch from");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch from $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 199 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 199 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 203 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 203 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 207 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 207 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 from $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 212 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 212 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 216 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 216 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch 1");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 219 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 219 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0 $0", 
+ 	ECPGt_int,&(count),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 224 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 224 "cursor.pgc"
+ 
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close $0", 
+ 	ECPGt_varchar,&(curname4),(long)50,(long)1,sizeof(struct varchar_curname4_27), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 228 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 228 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate prepare");
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
+ #line 231 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 231 "cursor.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 236 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 236 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 239 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 239 "cursor.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 242 "cursor.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 242 "cursor.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/preproc-cursor.stderr pgsql.1/src/interfaces/ecpg/test/expected/preproc-cursor.stderr
*** pgsql.orig/src/interfaces/ecpg/test/expected/preproc-cursor.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/test/expected/preproc-cursor.stderr	2009-11-16 10:52:22.000000000 +0100
***************
*** 0 ****
--- 1,372 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 44: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 47: query: insert into t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 47: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 47: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: query: insert into t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: query: insert into t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: query: insert into t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 53: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: query: declare mycur cursor for select id , t from t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 65: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 65: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 65: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 65: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 65: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 69: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 69: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 69: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 69: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 69: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 73: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 73: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 73: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 73: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 73: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 78: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 78: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 78: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 78: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 78: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: query: move absolute 0 in mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 85: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 85: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 90: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 90: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 94: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 94: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 94: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: query: declare mycur cursor for select id , t from t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 106: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 106: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 106: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 106: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 106: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 110: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 110: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 114: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 114: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 114: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 114: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 114: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 119: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 119: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 119: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 119: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 119: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 123: query: move absolute 0 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 123: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 123: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 126: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 126: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 126: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 126: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 126: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 131: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 131: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 131: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 131: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 131: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 140: name st_id1; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 146: query: declare mycur cursor for SELECT id, t FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 146: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 146: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 149: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 149: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 153: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 153: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 157: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 157: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 162: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 162: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 162: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 162: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 162: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 166: query: move absolute 0 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 166: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 166: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 169: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 169: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 169: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 169: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 169: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 174: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 174: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 174: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 174: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 174: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 178: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 178: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 178: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 181: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 190: name st_id2; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: query: declare mycur cursor for SELECT id, t FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: query: fetch from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 199: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 199: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 203: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 203: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 203: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 203: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 203: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 207: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 207: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 207: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 207: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 207: RESULT: c offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 212: query: fetch 1 from mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 212: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 212: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 212: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 212: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 216: query: move absolute 0 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 216: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 216: OK: MOVE 0
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 224: query: fetch 1 mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 224: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 224: correctly got 1 tuples with 2 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 224: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 224: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 231: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 236: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 236: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 236: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 239: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/preproc-cursor.stdout pgsql.1/src/interfaces/ecpg/test/expected/preproc-cursor.stdout
*** pgsql.orig/src/interfaces/ecpg/test/expected/preproc-cursor.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/test/expected/preproc-cursor.stdout	2009-11-16 10:52:22.000000000 +0100
***************
*** 0 ****
--- 1,24 ----
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
+ 1 a
+ 2 b
+ 3 c
+ 4 d
+ 1 a
+ 2 b
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/preproc/cursor.pgc pgsql.1/src/interfaces/ecpg/test/preproc/cursor.pgc
*** pgsql.orig/src/interfaces/ecpg/test/preproc/cursor.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/test/preproc/cursor.pgc	2009-11-16 10:52:22.000000000 +0100
***************
*** 0 ****
--- 1,245 ----
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ exec sql type c is char reference;
+ typedef char* c;
+ 
+ exec sql type ind is union { int integer; short smallint; };
+ typedef union { int integer; short smallint; } ind;
+ 
+ #define BUFFERSIZ 8
+ exec sql type str is varchar[BUFFERSIZ];
+ 
+ #define CURNAME "mycur"
+ 
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ 	char	*stmt1 = "SELECT id, t FROM t1";
+ 	char	*curname1 = CURNAME;
+ 	char	*curname2 = CURNAME;
+ 	char	*curname3 = CURNAME;
+ 	varchar	curname4[50];
+ 	int	count;
+ 	int	id;
+ 	char	t[64];
+ exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table t1(id serial primary key, t text);
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into t1(id, t) values (default, 'a');
+ 	exec sql insert into t1(id, t) values (default, 'b');
+ 	exec sql insert into t1(id, t) values (default, 'c');
+ 	exec sql insert into t1(id, t) values (default, 'd');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* Dynamic cursorname test with INTO list in FETCH stmts */
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare :curname1 cursor for
+ 		select id, t from t1;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open :curname1;
+ 
+ 	strcpy(msg, "fetch from");
+ 	exec sql fetch from :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	exec sql fetch :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	exec sql fetch 1 from :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	exec sql fetch :count from :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move in");
+ 	exec sql move absolute 0 in :curname1;
+ 
+ 	strcpy(msg, "fetch 1");
+ 	exec sql fetch 1 :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	exec sql fetch :count :curname1 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close :curname1;
+ 
+ 	/* Dynamic cursorname test with INTO list in DECLARE stmt */
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare :curname2 cursor for
+ 		select id, t into :id, :t from t1;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open :curname2;
+ 
+ 	strcpy(msg, "fetch from");
+ 	exec sql fetch from :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	exec sql fetch :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	exec sql fetch 1 from :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	exec sql fetch :count from :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	exec sql move absolute 0 :curname2;
+ 
+ 	strcpy(msg, "fetch 1");
+ 	exec sql fetch 1 :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	exec sql fetch :count :curname2;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close :curname2;
+ 
+ 	/* Dynamic cursorname test with PREPARED stmt */
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id1 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare :curname3 cursor for st_id1;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open :curname3;
+ 
+ 	strcpy(msg, "fetch from");
+ 	exec sql fetch from :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	exec sql fetch :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	exec sql fetch 1 from :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	exec sql fetch :count from :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	exec sql move absolute 0 :curname3;
+ 
+ 	strcpy(msg, "fetch 1");
+ 	exec sql fetch 1 :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	exec sql fetch :count :curname3 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close :curname3;
+ 
+ 	strcpy(msg, "deallocate prepare");
+ 	exec sql deallocate prepare st_id1;
+ 
+ 	/* Dynamic cursorname test with PREPARED stmt,
+ 	   cursor name in varchar */
+ 
+ 	curname4.len = strlen(CURNAME);
+ 	strcpy(curname4.arr, CURNAME);
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id2 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare :curname4 cursor for st_id2;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open :curname4;
+ 
+ 	strcpy(msg, "fetch from");
+ 	exec sql fetch from :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch");
+ 	exec sql fetch :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch 1 from");
+ 	exec sql fetch 1 from :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count from");
+ 	count = 1;
+ 	exec sql fetch :count from :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "move");
+ 	exec sql move absolute 0 :curname4;
+ 
+ 	strcpy(msg, "fetch 1");
+ 	exec sql fetch 1 :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "fetch :count");
+ 	count = 1;
+ 	exec sql fetch :count :curname4 into :id, :t;
+ 	printf("%d %s\n", id, t);
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close :curname4;
+ 
+ 	strcpy(msg, "deallocate prepare");
+ 	exec sql deallocate prepare st_id2;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table t1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/preproc/Makefile pgsql.1/src/interfaces/ecpg/test/preproc/Makefile
*** pgsql.orig/src/interfaces/ecpg/test/preproc/Makefile	2008-10-29 11:40:29.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/test/preproc/Makefile	2009-11-16 10:52:22.000000000 +0100
*************** include $(top_srcdir)/$(subdir)/../Makef
*** 7,12 ****
--- 7,13 ----
  TESTS = array_of_struct array_of_struct.c \
  	autoprep autoprep.c \
  	comment comment.c \
+ 	cursor cursor.c \
  	define define.c \
  	init init.c \
  	strings strings.c \
#63Boszormenyi Zoltan
zb@cybertec.at
In reply to: Boszormenyi Zoltan (#62)
1 attachment(s)
ECPG patch 2, SQLDA support

New version: rebased to current CVS.

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

Attachments:

2-pg85-sqlda-14-ctxdiff.patchtext/x-patch; name=2-pg85-sqlda-14-ctxdiff.patchDownload
diff -dcrpN pgsql.1/src/interfaces/ecpg/ecpglib/execute.c pgsql.2/src/interfaces/ecpg/ecpglib/execute.c
*** pgsql.1/src/interfaces/ecpg/ecpglib/execute.c	2009-09-03 14:37:34.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/ecpglib/execute.c	2009-11-16 11:07:02.000000000 +0100
***************
*** 25,30 ****
--- 25,31 ----
  #include "ecpgerrno.h"
  #include "extern.h"
  #include "sqlca.h"
+ #include "sqlda.h"
  #include "sql3types.h"
  #include "pgtypes_numeric.h"
  #include "pgtypes_date.h"
*************** ecpg_store_input(const int lineno, const
*** 1033,1038 ****
--- 1034,1040 ----
  				break;
  
  			case ECPGt_descriptor:
+ 			case ECPGt_sqlda:
  				break;
  
  			default:
*************** ecpg_execute(struct statement * stmt)
*** 1172,1177 ****
--- 1174,1235 ----
  			if (desc->count == desc_counter)
  				desc_counter = 0;
  		}
+ 		else if (var->type == ECPGt_sqlda)
+ 		{
+ 			pg_sqlda_t	  **_sqlda = (pg_sqlda_t **)var->pointer;
+ 			pg_sqlda_t	   *sqlda = *_sqlda;
+ 			struct variable	desc_inlist;
+ 			int		i;
+ 
+ 			if (sqlda == NULL)
+ 				return false;
+ 
+ 			desc_counter++;
+ 			for (i = 0; i < sqlda->sqld; i++)
+ 			{
+ 				if (i + 1 == desc_counter)
+ 				{
+ 					desc_inlist.type = ecpg_sqlda_type(sqlda->sqlvar[i].sqltype);
+ 					desc_inlist.value = sqlda->sqlvar[i].sqldata;
+ 					desc_inlist.pointer = &(sqlda->sqlvar[i].sqldata);
+ 					switch (desc_inlist.type)
+ 					{
+ 						case ECPGt_char:
+ 						case ECPGt_varchar:
+ 							desc_inlist.varcharsize = strlen(sqlda->sqlvar[i].sqldata);
+ 							break;
+ 						default:
+ 							desc_inlist.varcharsize = 0;
+ 							break;
+ 					}
+ 					desc_inlist.arrsize = 1;
+ 					desc_inlist.offset = 0;
+ 					if (sqlda->sqlvar[i].sqlind)
+ 					{
+ 						desc_inlist.ind_type = ECPGt_short;
+ 						/* ECPG expects indicator value < 0 */
+ 						if (*(sqlda->sqlvar[i].sqlind))
+ 							*(sqlda->sqlvar[i].sqlind) = -1;
+ 						desc_inlist.ind_value = sqlda->sqlvar[i].sqlind;
+ 						desc_inlist.ind_pointer = &(sqlda->sqlvar[i].sqlind);
+ 						desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = 1;
+ 						desc_inlist.ind_offset = 0;
+ 					}
+ 					else
+ 					{
+ 						desc_inlist.ind_type = ECPGt_NO_INDICATOR;
+ 						desc_inlist.ind_value = desc_inlist.ind_pointer = NULL;
+ 						desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = desc_inlist.ind_offset = 0;
+ 					}
+ 					if (!ecpg_store_input(stmt->lineno, stmt->force_indicator, &desc_inlist, &tobeinserted, false))
+ 						return false;
+ 
+ 					break;
+ 				}
+ 			}
+ 			if (sqlda->sqld == desc_counter)
+ 				desc_counter = 0;
+ 		}
  		else
  		{
  			if (!ecpg_store_input(stmt->lineno, stmt->force_indicator, var, &tobeinserted, false))
*************** ecpg_execute(struct statement * stmt)
*** 1353,1358 ****
--- 1411,1452 ----
  				}
  				var = var->next;
  			}
+ 			else if (var != NULL && var->type == ECPGt_sqlda)
+ 			{
+ 				pg_sqlda_t	  **_sqlda = (pg_sqlda_t **)var->pointer;
+ 				pg_sqlda_t	   *sqlda = *_sqlda;
+ 				pg_sqlda_t	   *sqlda_new;
+ 
+ 				/* Build a new sqlda structure. Note that only fetching 1 record is supported */
+ 				sqlda_new = ecpg_build_sqlda_for_PGresult(stmt->lineno, results, 0);
+ 
+ 				if (!sqlda_new)
+ 				{
+ 					ecpg_log("ecpg_execute on line %d: out of memory allocating a new sqlda\n", stmt->lineno);
+ 					status = false;
+ 				}
+ 				else
+ 				{
+ 					ecpg_log("ecpg_execute on line %d: new sqlda was built\n", stmt->lineno);
+ 
+ 					/* If we are passed in a previously existing sqlda then free it. */
+ 					if (sqlda)
+ 					{
+ 						if (sqlda->sqlvar != (pg_sqlvar_t *)(sqlda + 1))
+ 							free(sqlda->sqlvar);
+ 						free(sqlda);
+ 						sqlda = NULL;
+ 					}
+ 
+ 					*_sqlda = sqlda_new;
+ 
+ 					ecpg_set_sqlda_from_PGresult(stmt->lineno, _sqlda, results, 0);
+ 					ecpg_log("ecpg_execute on line %d: putting result (1 tuple %d fields) into sqlda descriptor\n",
+ 							stmt->lineno, PQnfields(results));
+ 				}
+ 
+ 				var = var->next;
+ 			}
  			else
  				for (act_field = 0; act_field < nfields && status; act_field++)
  				{
diff -dcrpN pgsql.1/src/interfaces/ecpg/ecpglib/extern.h pgsql.2/src/interfaces/ecpg/ecpglib/extern.h
*** pgsql.1/src/interfaces/ecpg/ecpglib/extern.h	2009-05-25 12:08:48.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/ecpglib/extern.h	2009-11-16 11:07:02.000000000 +0100
***************
*** 6,11 ****
--- 6,12 ----
  #include "postgres_fe.h"
  #include "libpq-fe.h"
  #include "sqlca.h"
+ #include "sqlda.h"
  #include "ecpg_config.h"
  #ifndef CHAR_BIT
  #include <limits.h>
*************** bool		ecpg_init(const struct connection 
*** 129,134 ****
--- 130,137 ----
  char	   *ecpg_strdup(const char *, int);
  const char *ecpg_type_name(enum ECPGttype);
  int			ecpg_dynamic_type(Oid);
+ int			ecpg_sqlda_type(int);
+ int			ecpg_to_sqlda_type(Oid);
  void		ecpg_free_auto_mem(void);
  void		ecpg_clear_auto_mem(void);
  
*************** void		ecpg_log(const char *format,...);
*** 149,154 ****
--- 152,160 ----
  bool		ecpg_auto_prepare(int, const char *, const int, char **, const char *);
  void		ecpg_init_sqlca(struct sqlca_t * sqlca);
  
+ pg_sqlda_t *ecpg_build_sqlda_for_PGresult(int, PGresult *, int);
+ void		ecpg_set_sqlda_from_PGresult(int, pg_sqlda_t **, const PGresult *, int);
+ 
  /* SQLSTATE values generated or processed by ecpglib (intentionally
   * not exported -- users should refer to the codes directly) */
  
diff -dcrpN pgsql.1/src/interfaces/ecpg/ecpglib/Makefile pgsql.2/src/interfaces/ecpg/ecpglib/Makefile
*** pgsql.1/src/interfaces/ecpg/ecpglib/Makefile	2009-07-13 11:16:41.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/ecpglib/Makefile	2009-11-16 11:07:02.000000000 +0100
*************** override CFLAGS += $(PTHREAD_CFLAGS)
*** 24,30 ****
  # Need to recompile any libpgport object files
  LIBS := $(filter-out -lpgport, $(LIBS))
  
! OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
  	connect.o misc.o path.o pgstrcasecmp.o \
  	$(filter snprintf.o strlcpy.o, $(LIBOBJS))
  
--- 24,30 ----
  # Need to recompile any libpgport object files
  LIBS := $(filter-out -lpgport, $(LIBS))
  
! OBJS= execute.o typename.o descriptor.o sqlda.o data.o error.o prepare.o memory.o \
  	connect.o misc.o path.o pgstrcasecmp.o \
  	$(filter snprintf.o strlcpy.o, $(LIBOBJS))
  
diff -dcrpN pgsql.1/src/interfaces/ecpg/ecpglib/sqlda.c pgsql.2/src/interfaces/ecpg/ecpglib/sqlda.c
*** pgsql.1/src/interfaces/ecpg/ecpglib/sqlda.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/ecpglib/sqlda.c	2009-11-16 11:16:38.000000000 +0100
***************
*** 0 ****
--- 1,293 ----
+ /*
+  * SQLDA support routines
+  * Only supports fetching 1 record at a time
+  *
+  * The allocated memory area pointed by an sqlda pointer
+  * contains both the metadata and the data, so freeing up
+  * is a simple free(sqlda) as expected by the ESQL/C examples.
+  */
+ 
+ #define POSTGRES_ECPG_INTERNAL
+ #include "postgres_fe.h"
+ #include "pg_type.h"
+ 
+ #include <inttypes.h>
+ #include <dlfcn.h>
+ 
+ #include "ecpg-pthread-win32.h"
+ #include "decimal.h"
+ #include "ecpgtype.h"
+ #include "ecpglib.h"
+ #include "ecpgerrno.h"
+ #include "extern.h"
+ #include "sqlca.h"
+ #include "sqlda.h"
+ #include "sqltypes.h"
+ 
+ /*
+  * Compute the next variable's offset with
+  * the current variable's size and alignment.
+  */
+ static long
+ ecpg_sqlda_size_round_align(long offset, int alignment, int size)
+ {
+ 	if (offset % alignment)
+ 		offset += alignment - (offset % alignment);
+ 	offset += size;
+ 	return offset;
+ }
+ 
+ /*
+  * Compute the current variable's offset with alignment.
+  */
+ static long
+ ecpg_sqlda_size_align(long offset, int alignment)
+ {
+ 	if (offset % alignment)
+ 		offset += alignment - (offset % alignment);
+ 	return offset;
+ }
+ 
+ static long
+ ecpg_sqlda_empty_size(const PGresult *res)
+ {
+ 	long	size;
+ 	int	i;
+ 	int	sqld = PQnfields(res);
+ 
+ 	/* Initial size to store main structure and field structures */
+ 	size = sizeof(pg_sqlda_t) + sqld * sizeof(pg_sqlvar_t);
+ 
+ 	/* Add space for field names */
+ 	for (i = 0; i < sqld; i++)
+ 		size += strlen(PQfname(res, i)) + 1;
+ 
+ 	/* Add padding to the first field value */
+ 	size = ecpg_sqlda_size_align(size, sizeof(int));
+ 
+ 	return size;
+ }
+ 
+ static long
+ ecpg_sqlda_total_size(const PGresult *res, int row)
+ {
+ 	int	i;
+ 	int	sqld = PQnfields(res);
+ 	long	size;
+ 
+ 	size = ecpg_sqlda_empty_size(res);
+ 
+ 	if (row < 0)
+ 		return size;
+ 
+ 	/* Add space for the field values */
+ 	for (i = 0; i < sqld; i++)
+ 	{
+ 		switch (ecpg_to_sqlda_type(PQftype(res, i)))
+ 		{
+ 			case SQLSMINT:
+ 				size = ecpg_sqlda_size_round_align(size, sizeof(short), sizeof(short));
+ 				break;
+ 			case SQLINT:
+ 			case SQLSERIAL:
+ 				size = ecpg_sqlda_size_round_align(size, sizeof(int), sizeof(int));
+ 				break;
+ 			case SQLFLOAT:
+ 				size = ecpg_sqlda_size_round_align(size, sizeof(double), sizeof(double));
+ 				break;
+ 			case SQLSMFLOAT:
+ 				size = ecpg_sqlda_size_round_align(size, sizeof(float), sizeof(float));
+ 				break;
+ 			case SQLDECIMAL:
+ 				size = ecpg_sqlda_size_round_align(size, sizeof(int), sizeof(decimal));
+ 				break;
+ 			case SQLINT8:
+ 			case SQLSERIAL8:
+ 				size = ecpg_sqlda_size_round_align(size, sizeof(int64_t), sizeof(int64_t));
+ 				break;
+ 
+ 			/*
+ 			 * These types will be passed as character strings
+ 			 * copied as is from the PGresult until we know
+ 			 * what to do with them.
+ 			 */
+ 			case SQLCHAR:
+ 			case SQLTEXT:
+ 			case SQLVCHAR:
+ 			case SQLNCHAR:
+ 			case SQLNVCHAR:
+ 			case SQLMONEY:
+ 			case SQLDATE:
+ 			case SQLDTIME:
+ 			case SQLINTERVAL:
+ 			default:
+ 				size += strlen(PQgetvalue(res, row, i)) + 1;
+ 				break;
+ 		}
+ 	}
+ 	return size;
+ }
+ 
+ /*
+  * Build pg_sqlda_t (metadata only) from PGresult
+  * leaving enough space for the field values in
+  * the given row number
+  */
+ pg_sqlda_t *
+ ecpg_build_sqlda_for_PGresult(int line, PGresult *res, int row)
+ {
+ 	pg_sqlda_t *sqlda;
+ 	pg_sqlvar_t*sqlvar;
+ 	char	   *fname;
+ 	long		size;
+ 	int		sqld;
+ 	int		i;
+ 
+ 	size = ecpg_sqlda_total_size(res, row);
+ 	sqlda = (pg_sqlda_t *)ecpg_alloc(size, line);
+ 	if (!sqlda)
+ 		return NULL;
+ 
+ 	memset(sqlda, 0, size);
+ 	sqlvar = (pg_sqlvar_t *)(sqlda + 1);
+ 	sqld = PQnfields(res);
+ 	fname = (char *)(sqlvar + sqld);
+ 
+ 	sqlda->sqld = sqld;
+ 	sqlda->desc_occ = size; /* cheat here, keep the full allocated size */
+ 	sqlda->sqlvar = sqlvar;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		sqlda->sqlvar[i].sqltype = ecpg_to_sqlda_type(PQftype(res, i));
+ 		strcpy(fname, PQfname(res, i));
+ 		sqlda->sqlvar[i].sqlname = fname;
+ 		fname += strlen(sqlda->sqlvar[i].sqlname) + 1;
+ 		sqlda->sqlvar[i].sqlformat = (char *)(long)PQfformat(res, i);
+ 		sqlda->sqlvar[i].sqlxid = PQftype(res, i);
+ 		sqlda->sqlvar[i].sqltypelen = PQfsize(res, i);
+ 	}
+ 
+ 	return sqlda;
+ }
+ 
+ /*
+  * Sets values from PGresult.
+  */
+ void
+ ecpg_set_sqlda_from_PGresult(int lineno, pg_sqlda_t **_sqlda, const PGresult *res, int row)
+ {
+ 	pg_sqlda_t *sqlda = (*_sqlda);
+ 	int		i;
+ 	long		size;
+ 	static	int2	value_is_null = -1;
+ 	static	int2	value_is_not_null = 0;
+ 
+ 	/* Offset for the first field value */
+ 	size = ecpg_sqlda_empty_size(res);
+ 
+ 	/*
+ 	 * Set sqlvar[i]->sqldata pointers and convert values to correct format
+ 	 */
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		int type = -1, isnull;
+ 		int use_getdata = true;
+ 		int datalen;
+ 
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 			case SQLSMINT:
+ 				size = ecpg_sqlda_size_align(size, sizeof(short));
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + size;
+ 				sqlda->sqlvar[i].sqllen = sizeof(short);
+ 				size += sizeof(short);
+ 				type = ECPGt_short;
+ 				break;
+ 			case SQLINT:
+ 			case SQLSERIAL:
+ 				size = ecpg_sqlda_size_align(size, sizeof(int));
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + size;
+ 				sqlda->sqlvar[i].sqllen = sizeof(int);
+ 				size += sizeof(int);
+ 				type = ECPGt_int;
+ 				break;
+ 			case SQLFLOAT:
+ 				size = ecpg_sqlda_size_align(size, sizeof(double));
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + size;
+ 				sqlda->sqlvar[i].sqllen = sizeof(double);
+ 				size += sizeof(double);
+ 				type = ECPGt_double;
+ 				break;
+ 			case SQLSMFLOAT:
+ 				size = ecpg_sqlda_size_align(size, sizeof(float));
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + size;
+ 				sqlda->sqlvar[i].sqllen = sizeof(float);
+ 				size += sizeof(float);
+ 				type = ECPGt_float;
+ 				break;
+ 			case SQLDECIMAL:
+ 			{
+ 				size = ecpg_sqlda_size_align(size, sizeof(int));
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + size;
+ 				sqlda->sqlvar[i].sqllen = sizeof(decimal);
+ 				size += sizeof(decimal);
+ 				type = ECPGt_decimal;
+ 				break;
+ 			}
+ 			case SQLINT8:
+ 			case SQLSERIAL8:
+ 				size = ecpg_sqlda_size_align(size, sizeof(int64_t));
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + size;
+ 				sqlda->sqlvar[i].sqllen = sizeof(int64_t);
+ 				size += sizeof(int64_t);
+ #ifdef HAVE_LONG_LONG_INT_64
+ 				type = ECPGt_long_long;
+ #else
+ 				type = ECPGt_long;
+ #endif
+ 				break;
+ 
+ 			/*
+ 			 * These types will be passed as character strings until
+ 			 * it's known what to do with them. We use sqlvar->sqldata
+ 			 * in all cases regardless of length, don't care about
+ 			 * sqlvar->sqlilongdata.
+ 			 */
+ 			case SQLCHAR:
+ 			case SQLTEXT:
+ 			case SQLVCHAR:
+ 			case SQLNCHAR:
+ 			case SQLNVCHAR:
+ 			case SQLMONEY:
+ 			case SQLDATE:
+ 			case SQLDTIME:
+ 			case SQLINTERVAL:
+ 			default:
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + size;
+ 				datalen = strlen(PQgetvalue(res, row, i)) + 1;
+ 				sqlda->sqlvar[i].sqllen = datalen;
+ 				size += datalen;
+ 				if (datalen > 32768)
+ 					sqlda->sqlvar[i].sqlilongdata = sqlda->sqlvar[i].sqldata;
+ 				use_getdata = false;
+ 				break;
+ 		}
+ 
+ 		isnull = PQgetisnull(res, 0, i);
+ 		sqlda->sqlvar[i].sqlind = isnull ? &value_is_null : &value_is_not_null;
+ 		sqlda->sqlvar[i].sqlitype = SQLSMINT;
+ 		sqlda->sqlvar[i].sqlilen = sizeof(short);
+ 		if (!isnull)
+ 		{
+ 			if (use_getdata)
+ 				ecpg_get_data(res, row, i, lineno,
+ 						type, ECPGt_NO_INDICATOR,
+ 						sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
+ 						ECPG_ARRAY_NONE, ECPG_COMPAT_INFORMIX, false);
+ 			else
+ 				strcpy(sqlda->sqlvar[i].sqldata, PQgetvalue(res, row, i));
+ 		}
+ 	}
+ }
+ 
diff -dcrpN pgsql.1/src/interfaces/ecpg/ecpglib/typename.c pgsql.2/src/interfaces/ecpg/ecpglib/typename.c
*** pgsql.1/src/interfaces/ecpg/ecpglib/typename.c	2009-08-07 13:06:28.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/ecpglib/typename.c	2009-11-16 11:07:02.000000000 +0100
***************
*** 7,12 ****
--- 7,13 ----
  #include "ecpgtype.h"
  #include "ecpglib.h"
  #include "extern.h"
+ #include "sqltypes.h"
  #include "sql3types.h"
  #include "pg_type.h"
  
*************** ecpg_dynamic_type(Oid type)
*** 100,102 ****
--- 101,194 ----
  			return -(int) type;
  	}
  }
+ 
+ int
+ ecpg_sqlda_type(int type)
+ {
+ 	switch (type)
+ 	{
+ 		case SQLCHAR:
+ 		case SQLNCHAR:
+ 			return ECPGt_char;
+ 		case SQLSMINT:
+ 			return ECPGt_short;
+ 		case SQLINT:
+ 			return ECPGt_int;
+ 		case SQLFLOAT:
+ 			return ECPGt_double;
+ 		case SQLSMFLOAT:
+ 			return ECPGt_float;
+ 		case SQLDECIMAL:
+ 			return ECPGt_decimal;
+ 		case SQLSERIAL:
+ 			return ECPGt_int;
+ 		case SQLDATE:
+ 			return ECPGt_date;
+ #if 0
+ 		case SQLMONEY:
+ 			return ???;
+ 		case SQLNULL:
+ 			return ???;
+ #endif
+ 		case SQLDTIME:
+ 			return ECPGt_timestamp;
+ #if 0
+ 		case SQLBYTES:
+ 			return ???;
+ #endif
+ 		case SQLTEXT:
+ 			return ECPGt_char;
+ 		case SQLVCHAR:
+ 		case SQLNVCHAR:
+ 			return ECPGt_varchar;
+ 		case SQLINTERVAL:
+ 			return ECPGt_interval;
+ 		case SQLINT8:
+ 		case SQLSERIAL8:
+ #ifdef HAVE_LONG_LONG_INT_64
+ 			return ECPGt_long_long;
+ #else
+ 			return ECPGt_long;
+ #endif
+ 		default:
+ 			return (-type);
+ 	}
+ }
+ 
+ int
+ ecpg_to_sqlda_type(Oid type)
+ {
+ 	switch (type)
+ 	{
+ 		case CHAROID:
+ 		case BPCHAROID:
+ 			return SQLCHAR;
+ 		case INT2OID:
+ 			return SQLSMINT;
+ 		case INT4OID:
+ 			return SQLINT;
+ 		case FLOAT8OID:
+ 			return SQLFLOAT;
+ 		case FLOAT4OID:
+ 			return SQLSMFLOAT;
+ 		case NUMERICOID:
+ 			return SQLDECIMAL;
+ 		case DATEOID:
+ 			return SQLDATE;
+ 		case CASHOID:
+ 			return SQLMONEY;
+ 		case TIMESTAMPOID:
+ 		case TIMESTAMPTZOID:
+ 			return SQLDTIME;
+ 		case TEXTOID:
+ 			return SQLTEXT;
+ 		case VARCHAROID:
+ 			return SQLVCHAR;
+ 		case INTERVALOID:
+ 			return SQLINTERVAL;
+ 		case INT8OID:
+ 			return SQLINT8;
+ 		default:
+ 			return (-type);
+ 	}
+ }
diff -dcrpN pgsql.1/src/interfaces/ecpg/include/ecpgtype.h pgsql.2/src/interfaces/ecpg/include/ecpgtype.h
*** pgsql.1/src/interfaces/ecpg/include/ecpgtype.h	2009-08-07 13:06:28.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/include/ecpgtype.h	2009-11-16 11:07:02.000000000 +0100
*************** enum ECPGttype
*** 62,68 ****
  	ECPGt_EOIT,					/* End of insert types. */
  	ECPGt_EORT,					/* End of result types. */
  	ECPGt_NO_INDICATOR,			/* no indicator */
! 	ECPGt_string                            /* trimmed (char *) type */
  };
  
   /* descriptor items */
--- 62,69 ----
  	ECPGt_EOIT,					/* End of insert types. */
  	ECPGt_EORT,					/* End of result types. */
  	ECPGt_NO_INDICATOR,			/* no indicator */
! 	ECPGt_string,				/* trimmed (char *) type */
! 	ECPGt_sqlda				/* C struct descriptor */
  };
  
   /* descriptor items */
diff -dcrpN pgsql.1/src/interfaces/ecpg/include/sqlda.h pgsql.2/src/interfaces/ecpg/include/sqlda.h
*** pgsql.1/src/interfaces/ecpg/include/sqlda.h	2009-06-13 18:25:05.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/include/sqlda.h	2009-11-16 11:07:02.000000000 +0100
***************
*** 1,3 ****
--- 1,74 ----
  /*
   * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
   */
+ 
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+ 
+ /* Define Informix "standard" types */
+ #ifndef C_H
+ typedef int		int4;
+ typedef	short		int2;
+ #endif
+ typedef	char		int1;
+ 
+ typedef	int		mint;
+ typedef	long		mlong;
+ 
+ typedef	short		MSHORT;
+ typedef	char		MCHAR; 
+ 
+ typedef	unsigned int	uint4;
+ typedef	unsigned short	uint2;
+ typedef	unsigned char	uint1;
+ 
+ typedef	unsigned int	muint;
+ typedef	unsigned long	mulong;
+ 
+ typedef	unsigned short	MUSHORT;
+ typedef	unsigned char	MUCHAR; 
+ 
+ #define MI_INT_SIZE     (sizeof(int)    * 8)
+ #define MI_LONG_SIZE    (sizeof(long)   * 8)
+ #define MI_PTR_SIZE     (sizeof(char *) * 8)
+ 
+ typedef struct sqlvar_struct
+ {
+ 	int2	sqltype;		/* variable type                */
+ 	int4	sqllen;			/* length in bytes              */
+ 	char	   *sqldata;		/* pointer to data              */
+ 	int2	   *sqlind;		/* pointer to indicator         */
+ 	char	   *sqlname;		/* variable name                */
+ 	char	   *sqlformat;		/* reserved for future use      */
+ 	int2	sqlitype;		/* ind variable type            */
+ 	int2	sqlilen;		/* ind length in bytes          */
+ 	char	   *sqlidata;		/* ind data pointer             */
+ 	int4	sqlxid;			/* extended id type             */
+ 	char	   *sqltypename;	/* extended type name           */
+ 	int2	sqltypelen;		/* length of extended type name */
+ 	int2	sqlownerlen;		/* length of owner name         */
+ 	int2	sqlsourcetype;		/* source type for distinct of built-ins */
+ 	char	   *sqlownername;	/* owner name                   */
+ 	int4	sqlsourceid;		/* extended id of source type   */
+ 
+ 	/*
+ 	 * sqlilongdata is new.  It supports data that exceeds the 32k
+ 	 * limit.  sqlilen and sqlidata are for backward compatibility
+ 	 * and they have maximum value of <32K.
+ 	 */
+ 	char	   *sqlilongdata;	/* for data field beyond 32K    */
+ 	int4	sqlflags;		/* for internal use only        */
+ 	void	   *sqlreserved;	/* reserved for future use      */
+ } pg_sqlvar_t;
+ 
+ typedef struct sqlda
+ {
+ 	int2		sqld;
+ 	pg_sqlvar_t	   *sqlvar;
+ 	char		desc_name[19];	/* descriptor name              */
+ 	int2		desc_occ;	/* size of sqlda structure      */
+ 	struct sqlda	   *desc_next;	/* pointer to next sqlda struct */
+ 	void		   *reserved;	/* reserved for future use */
+ } pg_sqlda_t;
+ 
+ #endif /* POSTGRES_SQLDA_H */
diff -dcrpN pgsql.1/src/interfaces/ecpg/include/sqltypes.h pgsql.2/src/interfaces/ecpg/include/sqltypes.h
*** pgsql.1/src/interfaces/ecpg/include/sqltypes.h	2009-06-13 18:25:05.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/include/sqltypes.h	2009-11-16 11:07:02.000000000 +0100
***************
*** 30,33 ****
--- 30,55 ----
  #define CLVCHARPTRTYPE	124
  #define CTYPEMAX	25
  
+ /*
+  * Values used in sqlda->sqlvar[i]->sqltype
+  */
+ #define	SQLCHAR		0
+ #define	SQLSMINT	1
+ #define	SQLINT		2
+ #define	SQLFLOAT	3
+ #define	SQLSMFLOAT	4
+ #define	SQLDECIMAL	5
+ #define	SQLSERIAL	6
+ #define	SQLDATE		7
+ #define	SQLMONEY	8
+ #define	SQLDTIME	10
+ #define	SQLBYTES	11
+ #define	SQLTEXT		12
+ #define	SQLVCHAR	13
+ #define	SQLINTERVAL	14
+ #define	SQLNCHAR	15
+ #define	SQLNVCHAR	16
+ #define	SQLINT8		17
+ #define	SQLSERIAL8	18
+ 
  #endif   /* ndef ECPG_SQLTYPES_H */
diff -dcrpN pgsql.1/src/interfaces/ecpg/preproc/descriptor.c pgsql.2/src/interfaces/ecpg/preproc/descriptor.c
*** pgsql.1/src/interfaces/ecpg/preproc/descriptor.c	2009-01-30 17:28:46.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/preproc/descriptor.c	2009-11-16 11:07:02.000000000 +0100
*************** descriptor_variable(const char *name, in
*** 326,328 ****
--- 326,347 ----
  	strlcpy(descriptor_names[input], name, sizeof(descriptor_names[input]));
  	return (struct variable *) & varspace[input];
  }
+ 
+ struct variable *
+ sqlda_variable(const char *name)
+ {
+ 	struct variable *p = (struct variable *) mm_alloc(sizeof(struct variable));
+ 
+ 	p->name = mm_strdup(name);
+ 	p->type = (struct ECPGtype *) mm_alloc(sizeof(struct ECPGtype));
+ 	p->type->type = ECPGt_sqlda;
+ 	p->type->size = NULL;
+ 	p->type->struct_sizeof = NULL;
+ 	p->type->u.element = NULL;
+ 	p->type->lineno = 0;
+ 	p->brace_level = 0;
+ 	p->next = NULL;
+ 
+ 	return p;
+ }
+ 
diff -dcrpN pgsql.1/src/interfaces/ecpg/preproc/ecpg.addons pgsql.2/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.1/src/interfaces/ecpg/preproc/ecpg.addons	2009-11-16 10:51:38.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/preproc/ecpg.addons	2009-11-16 11:07:02.000000000 +0100
*************** ECPG: VariableShowStmtSHOWALL block
*** 402,430 ****
  		$$ = EMPTY;
  	}
  ECPG: FetchStmtMOVEfetch_args rule
! 	| FETCH fetch_args ecpg_into
  	{
  		$$ = cat2_str(make_str("fetch"), $2);
  	}
! 	| FETCH FORWARD cursor_name opt_ecpg_into
  	{
  		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
  		add_additional_variables($3, false);
  		$$ = cat_str(2, make_str("fetch forward"), cursor_marker);
  	}
! 	| FETCH FORWARD from_in cursor_name opt_ecpg_into
  	{
  		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
  		add_additional_variables($4, false);
  		$$ = cat_str(2, make_str("fetch forward from"), cursor_marker);
  	}
! 	| FETCH BACKWARD cursor_name opt_ecpg_into
  	{
  		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
  		add_additional_variables($3, false);
  		$$ = cat_str(2, make_str("fetch backward"), cursor_marker);
  	}
! 	| FETCH BACKWARD from_in cursor_name opt_ecpg_into
  	{
  		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
  		add_additional_variables($4, false);
--- 402,430 ----
  		$$ = EMPTY;
  	}
  ECPG: FetchStmtMOVEfetch_args rule
! 	| FETCH fetch_args ecpg_fetch_into
  	{
  		$$ = cat2_str(make_str("fetch"), $2);
  	}
! 	| FETCH FORWARD cursor_name opt_ecpg_fetch_into
  	{
  		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
  		add_additional_variables($3, false);
  		$$ = cat_str(2, make_str("fetch forward"), cursor_marker);
  	}
! 	| FETCH FORWARD from_in cursor_name opt_ecpg_fetch_into
  	{
  		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
  		add_additional_variables($4, false);
  		$$ = cat_str(2, make_str("fetch forward from"), cursor_marker);
  	}
! 	| FETCH BACKWARD cursor_name opt_ecpg_fetch_into
  	{
  		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
  		add_additional_variables($3, false);
  		$$ = cat_str(2, make_str("fetch backward"), cursor_marker);
  	}
! 	| FETCH BACKWARD from_in cursor_name opt_ecpg_fetch_into
  	{
  		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
  		add_additional_variables($4, false);
diff -dcrpN pgsql.1/src/interfaces/ecpg/preproc/ecpg.trailer pgsql.2/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.1/src/interfaces/ecpg/preproc/ecpg.trailer	2009-11-16 10:52:12.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/preproc/ecpg.trailer	2009-11-16 11:07:02.000000000 +0100
*************** ecpg_using:	USING using_list 	{ $$ = EMP
*** 1007,1025 ****
  
  using_descriptor: USING opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
  		{
! 			add_variable_to_head(&argsinsert, descriptor_variable($4,0), &no_indicator);
  			$$ = EMPTY;
  		}
  		;
  
  into_descriptor: INTO opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
  		{
! 			add_variable_to_head(&argsresult, descriptor_variable($4,1), &no_indicator);
  			$$ = EMPTY;
  		}
  		;
  
! opt_sql: /*EMPTY*/ | SQL_SQL;
  
  using_list: UsingValue | UsingValue ',' using_list;
  
--- 1007,1055 ----
  
  using_descriptor: USING opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
  		{
! 			if (strlen($2) || !(INFORMIX_MODE))
! 				add_variable_to_head(&argsinsert, descriptor_variable($4,0), &no_indicator);
! 			else
! 			{
! 				if ($4[0] == '\"')
! 				{
! 					char *pos;
! 
! 					$4[0] = ' ';
! 					for (pos = $4; *pos; pos++)
! 						if (*pos == '\"')
! 							*pos = ' ';
! 				}
! 				add_variable_to_head(&argsinsert, sqlda_variable($4), &no_indicator);
! 			}
  			$$ = EMPTY;
  		}
  		;
  
  into_descriptor: INTO opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
  		{
! 			if (strlen($2) || !(INFORMIX_MODE))
! 				add_variable_to_head(&argsresult, descriptor_variable($4,1), &no_indicator);
! 			else
! 			{
! 				if ($4[0] == '\"')
! 				{
! 					char *pos;
! 
! 					$4[0] = ' ';
! 					for (pos = $4; *pos; pos++)
! 						if (*pos == '\"')
! 							*pos = ' ';
! 				}
! 				add_variable_to_head(&argsresult, sqlda_variable($4), &no_indicator);
! 			}
  			$$ = EMPTY;
  		}
  		;
  
! opt_sql: /*EMPTY*/		{ $$ = EMPTY; }
! 		| SQL_SQL	{ $$ = make_str("sql"); }
! 		;
  
  using_list: UsingValue | UsingValue ',' using_list;
  
*************** ecpg_into: INTO into_list	{ $$ = EMPTY; 
*** 2042,2048 ****
          | into_descriptor	{ $$ = $1; }
  	;
  
! opt_ecpg_into:	/* EMPTY */	{ $$ = EMPTY; }
  	| ecpg_into		{ $$ = $1; }
  	;
  
--- 2072,2093 ----
          | into_descriptor	{ $$ = $1; }
  	;
  
! ecpg_fetch_into: ecpg_into	{ $$ = $1; }
! 	| using_descriptor
! 	{
! 		struct variable *var;
! 
! 		if (!INFORMIX_MODE)
! 			mmerror(PARSE_ERROR, ET_ERROR, "Not in Informix compatibility mode");
! 
! 		var = argsinsert->variable;
! 		remove_variable_from_list(&argsinsert, var);
! 		add_variable_to_head(&argsresult, var, &no_indicator);
! 		$$ = $1;
! 	}
! 	;
! 
! opt_ecpg_fetch_into:	/* EMPTY */	{ $$ = EMPTY; }
  	| ecpg_into		{ $$ = $1; }
  	;
  
diff -dcrpN pgsql.1/src/interfaces/ecpg/preproc/ecpg.type pgsql.2/src/interfaces/ecpg/preproc/ecpg.type
*** pgsql.1/src/interfaces/ecpg/preproc/ecpg.type	2009-11-16 10:52:12.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/preproc/ecpg.type	2009-11-16 11:07:02.000000000 +0100
***************
*** 62,67 ****
--- 62,68 ----
  %type <str> ecpg_ident
  %type <str> ecpg_interval
  %type <str> ecpg_into
+ %type <str> ecpg_fetch_into
  %type <str> ecpg_param
  %type <str> ecpg_sconst
  %type <str> ecpg_using
***************
*** 77,83 ****
  %type <str> opt_bit_field
  %type <str> opt_connection_name
  %type <str> opt_database_name
! %type <str> opt_ecpg_into
  %type <str> opt_ecpg_using
  %type <str> opt_initializer
  %type <str> opt_options
--- 78,84 ----
  %type <str> opt_bit_field
  %type <str> opt_connection_name
  %type <str> opt_database_name
! %type <str> opt_ecpg_fetch_into
  %type <str> opt_ecpg_using
  %type <str> opt_initializer
  %type <str> opt_options
***************
*** 87,92 ****
--- 88,94 ----
  %type <str> opt_reference
  %type <str> opt_scale
  %type <str> opt_server
+ %type <str> opt_sql   
  %type <str> opt_user
  %type <str> opt_opt_value
  %type <str> ora_user
diff -dcrpN pgsql.1/src/interfaces/ecpg/preproc/extern.h pgsql.2/src/interfaces/ecpg/preproc/extern.h
*** pgsql.1/src/interfaces/ecpg/preproc/extern.h	2009-11-16 10:44:18.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/preproc/extern.h	2009-11-16 11:07:02.000000000 +0100
*************** extern void add_descriptor(char *, char 
*** 88,93 ****
--- 88,94 ----
  extern void drop_descriptor(char *, char *);
  extern struct descriptor *lookup_descriptor(char *, char *);
  extern struct variable *descriptor_variable(const char *name, int input);
+ extern struct variable *sqlda_variable(const char *name);
  extern void add_variable_to_head(struct arguments **, struct variable *, struct variable *);
  extern void add_variable_to_tail(struct arguments **, struct variable *, struct variable *);
  extern void remove_variable_from_list(struct arguments ** list, struct variable * var);
diff -dcrpN pgsql.1/src/interfaces/ecpg/preproc/type.c pgsql.2/src/interfaces/ecpg/preproc/type.c
*** pgsql.1/src/interfaces/ecpg/preproc/type.c	2009-09-03 12:25:47.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/preproc/type.c	2009-11-16 11:07:02.000000000 +0100
*************** get_type(enum ECPGttype type)
*** 194,199 ****
--- 194,202 ----
  		case ECPGt_descriptor:
  			return ("ECPGt_descriptor");
  			break;
+ 		case ECPGt_sqlda:
+ 			return ("ECPGt_sqlda");
+ 			break;
  		case ECPGt_date:
  			return ("ECPGt_date");
  			break;
*************** ECPGdump_a_simple(FILE *o, const char *n
*** 328,333 ****
--- 331,338 ----
  	else if (type == ECPGt_descriptor)
  		/* remember that name here already contains quotes (if needed) */
  		fprintf(o, "\n\tECPGt_descriptor, %s, 0L, 0L, 0L, ", name);
+ 	else if (type == ECPGt_sqlda)
+ 		fprintf(o, "\n\tECPGt_sqlda, &%s, 0L, 0L, 0L, ", name);
  	else
  	{
  		char	   *variable = (char *) mm_alloc(strlen(name) + ((prefix == NULL) ? 0 : strlen(prefix)) + 4);
diff -dcrpN pgsql.1/src/interfaces/ecpg/test/compat_informix/Makefile pgsql.2/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.1/src/interfaces/ecpg/test/compat_informix/Makefile	2009-11-16 10:52:22.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/compat_informix/Makefile	2009-11-16 11:07:02.000000000 +0100
*************** TESTS = test_informix test_informix.c \
*** 17,22 ****
--- 17,23 ----
          rfmtdate rfmtdate.c \
          rfmtlong rfmtlong.c \
          rnull rnull.c \
+         sqlda sqlda.c \
          charfuncs charfuncs.c
  
  all: $(TESTS)
*************** test_informix2.c: test_informix2.pgc ../
*** 30,35 ****
--- 31,39 ----
  cursor.c: cursor.pgc ../regression.h
  	$(ECPG) -o $@ -I$(srcdir) $<
  
+ sqlda.c: sqlda.pgc ../regression.h
+ 	$(ECPG) -o $@ -I$(srcdir) $<
+ 
  dec_test.c: dec_test.pgc ../regression.h
  	$(ECPG) -o $@ -I$(srcdir) $<
  
diff -dcrpN pgsql.1/src/interfaces/ecpg/test/compat_informix/sqlda.pgc pgsql.2/src/interfaces/ecpg/test/compat_informix/sqlda.pgc
*** pgsql.1/src/interfaces/ecpg/test/compat_informix/sqlda.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/compat_informix/sqlda.pgc	2009-11-16 11:07:02.000000000 +0100
***************
*** 0 ****
--- 1,252 ----
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql include sqlda.h;
+ exec sql include sqltypes.h;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ /* These shouldn't be under DECLARE SECTION */
+ pg_sqlda_t	*inp_sqlda, *outp_sqlda;
+ 
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (outp_sqlda->sqlvar[i].sqlind && *(outp_sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", outp_sqlda->sqlvar[i].sqlname);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case SQLCHAR:
+ 		case SQLVCHAR:
+ 		case SQLTEXT:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLSERIAL:
+ 		case SQLINT:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLSERIAL8:
+ 		case SQLINT8:
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLFLOAT:
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLDECIMAL:
+ 			{
+ 				char    val[64];
+ 				dectoasc((dec_t *)sqlda->sqlvar[i].sqldata, val, 64, -1);
+ 				printf("name sqlda descriptor: '%s' value DECIMAL '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ 	char	*stmt1 = "SELECT * FROM t1";
+ 	char	*stmt2 = "SELECT * FROM t1 WHERE id = ?";
+ 	int	rec;
+ 	int	id;
+ exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1 as regress1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table t1(
+ 		id integer,
+ 		t text,
+ 		d1 numeric,
+ 		d2 float8,
+ 		c char(10));
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into t1 values
+ 		(1, 'a', 1.0, 1, 'a'),
+ 		(2, null, null, null, null),
+ 		(3, '"c"', -3, 'nan'::float8, 'c'),
+ 		(4, 'd', 4.0, 4, 'd');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* SQLDA test for getting all records from a table */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id1 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare mycur1 cursor for st_id1;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open mycur1;
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		exec sql fetch 1 from mycur1 into descriptor outp_sqlda; 
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	exec sql whenever not found continue;
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close mycur1;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id1;
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting all records from a table
+ 	   using the Informix-specific FETCH ... USING DESCRIPTOR
+ 	 */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id2 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare mycur2 cursor for st_id2;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open mycur2;
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		exec sql fetch from mycur2 using descriptor outp_sqlda;
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	exec sql whenever not found continue;
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close mycur2;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id2;
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor */
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id3 FROM :stmt2;
+ 
+ 	strcpy(msg, "execute");
+ 	exec sql execute st_id3 using descriptor inp_sqlda into descriptor outp_sqlda;
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id3;
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor
+ 	 * on a named connection
+ 	 */
+ 
+ 	exec sql connect to REGRESSDB1 as con2;
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql at con2 prepare st_id4 FROM :stmt2;
+ 
+ 	strcpy(msg, "execute");
+ 	exec sql at con2 execute st_id4 using descriptor inp_sqlda into descriptor outp_sqlda;
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql at con2 commit;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id4;
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	strcpy(msg, "disconnect");
+ 	exec sql disconnect con2;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table t1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect");
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.1/src/interfaces/ecpg/test/ecpg_schedule pgsql.2/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.1/src/interfaces/ecpg/test/ecpg_schedule	2009-11-16 10:52:22.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/ecpg_schedule	2009-11-16 11:07:02.000000000 +0100
*************** test: compat_informix/rfmtdate
*** 4,9 ****
--- 4,10 ----
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
  test: compat_informix/cursor
+ test: compat_informix/sqlda
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
diff -dcrpN pgsql.1/src/interfaces/ecpg/test/ecpg_schedule_tcp pgsql.2/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.1/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-11-16 10:52:22.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-11-16 11:07:02.000000000 +0100
*************** test: compat_informix/rfmtdate
*** 4,9 ****
--- 4,10 ----
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
  test: compat_informix/cursor
+ test: compat_informix/sqlda
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
diff -dcrpN pgsql.1/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
*** pgsql.1/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c	2009-11-16 11:07:02.000000000 +0100
***************
*** 0 ****
--- 1,585 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "sqlda.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 5 "sqlda.pgc"
+ 
+ 
+ 
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+ 
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+ 
+ /* Define Informix "standard" types */
+ #ifndef C_H
+ typedef int		int4;
+ typedef	short		int2;
+ #endif
+ typedef	char		int1;
+ 
+ typedef	int		mint;
+ typedef	long		mlong;
+ 
+ typedef	short		MSHORT;
+ typedef	char		MCHAR; 
+ 
+ typedef	unsigned int	uint4;
+ typedef	unsigned short	uint2;
+ typedef	unsigned char	uint1;
+ 
+ typedef	unsigned int	muint;
+ typedef	unsigned long	mulong;
+ 
+ typedef	unsigned short	MUSHORT;
+ typedef	unsigned char	MUCHAR; 
+ 
+ #define MI_INT_SIZE     (sizeof(int)    * 8)
+ #define MI_LONG_SIZE    (sizeof(long)   * 8)
+ #define MI_PTR_SIZE     (sizeof(char *) * 8)
+ 
+ typedef struct sqlvar_struct
+ {
+ 	int2	sqltype;		/* variable type                */
+ 	int4	sqllen;			/* length in bytes              */
+ 	char	   *sqldata;		/* pointer to data              */
+ 	int2	   *sqlind;		/* pointer to indicator         */
+ 	char	   *sqlname;		/* variable name                */
+ 	char	   *sqlformat;		/* reserved for future use      */
+ 	int2	sqlitype;		/* ind variable type            */
+ 	int2	sqlilen;		/* ind length in bytes          */
+ 	char	   *sqlidata;		/* ind data pointer             */
+ 	int4	sqlxid;			/* extended id type             */
+ 	char	   *sqltypename;	/* extended type name           */
+ 	int2	sqltypelen;		/* length of extended type name */
+ 	int2	sqlownerlen;		/* length of owner name         */
+ 	int2	sqlsourcetype;		/* source type for distinct of built-ins */
+ 	char	   *sqlownername;	/* owner name                   */
+ 	int4	sqlsourceid;		/* extended id of source type   */
+ 
+ 	/*
+ 	 * sqlilongdata is new.  It supports data that exceeds the 32k
+ 	 * limit.  sqlilen and sqlidata are for backward compatibility
+ 	 * and they have maximum value of <32K.
+ 	 */
+ 	char	   *sqlilongdata;	/* for data field beyond 32K    */
+ 	int4	sqlflags;		/* for internal use only        */
+ 	void	   *sqlreserved;	/* reserved for future use      */
+ } pg_sqlvar_t;
+ 
+ typedef struct sqlda
+ {
+ 	int2		sqld;
+ 	pg_sqlvar_t	   *sqlvar;
+ 	char		desc_name[19];	/* descriptor name              */
+ 	int2		desc_occ;	/* size of sqlda structure      */
+ 	struct sqlda	   *desc_next;	/* pointer to next sqlda struct */
+ 	void		   *reserved;	/* reserved for future use */
+ } pg_sqlda_t;
+ 
+ #endif /* POSTGRES_SQLDA_H */
+ 
+ #line 7 "sqlda.pgc"
+ 
+ 
+ #line 1 "sqltypes.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqltypes.h,v 1.9 2009/06/11 14:49:13 momjian Exp $
+  */
+ #ifndef ECPG_SQLTYPES_H
+ #define ECPG_SQLTYPES_H
+ 
+ #define CCHARTYPE	ECPGt_char
+ #define CSHORTTYPE	ECPGt_short
+ #define CINTTYPE	ECPGt_int
+ #define CLONGTYPE	ECPGt_long
+ #define CFLOATTYPE	ECPGt_float
+ #define CDOUBLETYPE ECPGt_double
+ #define CDECIMALTYPE	ECPGt_decimal
+ #define CFIXCHARTYPE	108
+ #define CSTRINGTYPE ECPGt_char
+ #define CDATETYPE	ECPGt_date
+ #define CMONEYTYPE	111
+ #define CDTIMETYPE	ECPGt_timestamp
+ #define CLOCATORTYPE	113
+ #define CVCHARTYPE	ECPGt_varchar
+ #define CINVTYPE	115
+ #define CFILETYPE	116
+ #define CINT8TYPE	ECPGt_long_long
+ #define CCOLLTYPE		118
+ #define CLVCHARTYPE		119
+ #define CFIXBINTYPE		120
+ #define CVARBINTYPE		121
+ #define CBOOLTYPE		ECPGt_bool
+ #define CROWTYPE		123
+ #define CLVCHARPTRTYPE	124
+ #define CTYPEMAX	25
+ 
+ /*
+  * Values used in sqlda->sqlvar[i]->sqltype
+  */
+ #define	SQLCHAR		0
+ #define	SQLSMINT	1
+ #define	SQLINT		2
+ #define	SQLFLOAT	3
+ #define	SQLSMFLOAT	4
+ #define	SQLDECIMAL	5
+ #define	SQLSERIAL	6
+ #define	SQLDATE		7
+ #define	SQLMONEY	8
+ #define	SQLDTIME	10
+ #define	SQLBYTES	11
+ #define	SQLTEXT		12
+ #define	SQLVCHAR	13
+ #define	SQLINTERVAL	14
+ #define	SQLNCHAR	15
+ #define	SQLNVCHAR	16
+ #define	SQLINT8		17
+ #define	SQLSERIAL8	18
+ 
+ #endif   /* ndef ECPG_SQLTYPES_H */
+ 
+ #line 8 "sqlda.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 10 "sqlda.pgc"
+ 
+ 
+ /* These shouldn't be under DECLARE SECTION */
+ pg_sqlda_t	*inp_sqlda, *outp_sqlda;
+ 
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (outp_sqlda->sqlvar[i].sqlind && *(outp_sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", outp_sqlda->sqlvar[i].sqlname);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case SQLCHAR:
+ 		case SQLVCHAR:
+ 		case SQLTEXT:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLSERIAL:
+ 		case SQLINT:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLSERIAL8:
+ 		case SQLINT8:
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLFLOAT:
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLDECIMAL:
+ 			{
+ 				char    val[64];
+ 				dectoasc((decimal *)sqlda->sqlvar[i].sqldata, val, 64, -1);
+ 				printf("name sqlda descriptor: '%s' value DECIMAL '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		
+ 		
+ 
+ #line 58 "sqlda.pgc"
+  char * stmt1 = "SELECT * FROM t1" ;
+  
+ #line 59 "sqlda.pgc"
+  char * stmt2 = "SELECT * FROM t1 WHERE id = ?" ;
+  
+ #line 60 "sqlda.pgc"
+  int rec ;
+  
+ #line 61 "sqlda.pgc"
+  int id ;
+ /* exec sql end declare section */
+ #line 62 "sqlda.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , "regress1", 0); 
+ #line 69 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 69 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 72 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 72 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
+ #line 80 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 80 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 3 , '\"c\"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 87 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 87 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 90 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 90 "sqlda.pgc"
+ 
+ 
+ 	/* SQLDA test for getting all records from a table */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 97 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 97 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	ECPG_informix_reset_sqlca(); /* declare mycur1 cursor for $1 */
+ #line 100 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1", 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 103 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 103 "sqlda.pgc"
+ 
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 105 "sqlda.pgc"
+ 
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, 
+ 	ECPGt_sqlda, & outp_sqlda , 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 111 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 111 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 111 "sqlda.pgc"
+  
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	/* exec sql whenever not found  continue ; */
+ #line 117 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT);
+ #line 120 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 120 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
+ #line 123 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 123 "sqlda.pgc"
+ 
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting all records from a table
+ 	   using the Informix-specific FETCH ... USING DESCRIPTOR
+ 	 */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
+ #line 134 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 134 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	ECPG_informix_reset_sqlca(); /* declare mycur2 cursor for $1 */
+ #line 137 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1", 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 140 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 140 "sqlda.pgc"
+ 
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 142 "sqlda.pgc"
+ 
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from mycur2", ECPGt_EOIT, 
+ 	ECPGt_sqlda, & outp_sqlda , 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 148 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 148 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 148 "sqlda.pgc"
+ 
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	/* exec sql whenever not found  continue ; */
+ #line 154 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT);
+ #line 157 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 157 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id2");
+ #line 160 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 160 "sqlda.pgc"
+ 
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor */
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id3", stmt2);
+ #line 183 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 183 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "execute");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, 1, "st_id3", 
+ 	ECPGt_sqlda, & inp_sqlda , 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_sqlda, & outp_sqlda , 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 186 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 186 "sqlda.pgc"
+ 
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id3");
+ #line 191 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 191 "sqlda.pgc"
+ 
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor
+ 	 * on a named connection
+ 	 */
+ 
+ 	{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , "con2", 0); 
+ #line 201 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 201 "sqlda.pgc"
+ 
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, "con2", 0, "st_id4", stmt2);
+ #line 220 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 220 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "execute");
+ 	{ ECPGdo(__LINE__, 1, 1, "con2", 0, 1, "st_id4", 
+ 	ECPGt_sqlda, & inp_sqlda , 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_sqlda, & outp_sqlda , 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 223 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 223 "sqlda.pgc"
+ 
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, "con2", "commit");
+ #line 228 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 228 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id4");
+ #line 231 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 231 "sqlda.pgc"
+ 
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	strcpy(msg, "disconnect");
+ 	{ ECPGdisconnect(__LINE__, "con2");
+ #line 238 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 238 "sqlda.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 243 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 243 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 246 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 246 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect");
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 249 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 249 "sqlda.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.1/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr
*** pgsql.1/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr	2009-11-16 11:07:02.000000000 +0100
***************
*** 0 ****
--- 1,252 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 72: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 72: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 72: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 75: query: create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 75: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 75: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 83: query: insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 3 , '"c"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 83: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 83: OK: INSERT 0 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 90: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 97: name st_id1; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: query: declare mycur1 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 103: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: -3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 111: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 111: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 111: no data found on line 111
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 120: query: close mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 120: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 120: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 123: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 134: name st_id2; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 140: query: declare mycur2 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 140: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 140: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: -3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 148: no data found on line 148
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 157: query: close mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 160: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 183: name st_id3; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 186: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 186: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 186: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 186: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 186: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 186: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 186: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 186: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 186: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 191: name st_id3
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 220: name st_id4; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 223: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection con2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 223: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 223: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 223: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 223: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 223: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 223: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 223: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 223: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 228: action "commit"; connection "con2"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 231: name st_id4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection con2 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 243: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 243: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 243: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 246: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.1/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout
*** pgsql.1/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout	2009-11-16 11:07:02.000000000 +0100
***************
*** 0 ****
--- 1,60 ----
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value DECIMAL '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a         '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value DECIMAL '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c         '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value DECIMAL '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a         '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value DECIMAL '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c         '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
#64Boszormenyi Zoltan
zb@cybertec.at
In reply to: Boszormenyi Zoltan (#63)
1 attachment(s)
Re: ECPG patch 3, DESCRIBE [OUTPUT] support

New version: rebased to current CVS.

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

Attachments:

3-pg85-describe-12-ctxdiff.patchtext/x-patch; name=3-pg85-describe-12-ctxdiff.patchDownload
diff -dcrpN pgsql.2/src/interfaces/ecpg/ecpglib/descriptor.c pgsql.3/src/interfaces/ecpg/ecpglib/descriptor.c
*** pgsql.2/src/interfaces/ecpg/ecpglib/descriptor.c	2009-08-07 13:06:28.000000000 +0200
--- pgsql.3/src/interfaces/ecpg/ecpglib/descriptor.c	2009-11-16 11:24:24.000000000 +0100
***************
*** 13,18 ****
--- 13,19 ----
  #include "ecpgerrno.h"
  #include "extern.h"
  #include "sqlca.h"
+ #include "sqlda.h"
  #include "sql3types.h"
  
  static void descriptor_free(struct descriptor * desc);
*************** get_char_item(int lineno, void *var, enu
*** 226,231 ****
--- 227,238 ----
  	return (true);
  }
  
+ #define RETURN_IF_NO_DATA	if (ntuples < 1) \
+ 				{ \
+ 					ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL); \
+ 					return (false); \
+ 				}
+ 
  bool
  ECPGget_desc(int lineno, const char *desc_name, int index,...)
  {
*************** ECPGget_desc(int lineno, const char *des
*** 244,254 ****
  		return (false);
  
  	ntuples = PQntuples(ECPGresult);
- 	if (ntuples < 1)
- 	{
- 		ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL);
- 		return (false);
- 	}
  
  	if (index < 1 || index > PQnfields(ECPGresult))
  	{
--- 251,256 ----
*************** ECPGget_desc(int lineno, const char *des
*** 283,288 ****
--- 285,291 ----
  		switch (type)
  		{
  			case (ECPGd_indicator):
+ 				RETURN_IF_NO_DATA;
  				data_var.ind_type = vartype;
  				data_var.ind_pointer = var;
  				data_var.ind_varcharsize = varcharsize;
*************** ECPGget_desc(int lineno, const char *des
*** 295,300 ****
--- 298,304 ----
  				break;
  
  			case ECPGd_data:
+ 				RETURN_IF_NO_DATA;
  				data_var.type = vartype;
  				data_var.pointer = var;
  				data_var.varcharsize = varcharsize;
*************** ECPGget_desc(int lineno, const char *des
*** 377,382 ****
--- 381,387 ----
  			case ECPGd_ret_length:
  			case ECPGd_ret_octet:
  
+ 				RETURN_IF_NO_DATA;
  				/*
  				 * this is like ECPGstore_result
  				 */
*************** ECPGget_desc(int lineno, const char *des
*** 480,485 ****
--- 485,491 ----
  	sqlca->sqlerrd[2] = ntuples;
  	return (true);
  }
+ #undef RETURN_IF_NO_DATA
  
  bool
  ECPGset_desc_header(int lineno, const char *desc_name, int count)
*************** ecpg_find_desc(int line, const char *nam
*** 722,730 ****
  	return NULL;				/* not found */
  }
  
  bool
! ECPGdescribe(int line, bool input, const char *statement,...)
  {
! 	ecpg_log("ECPGdescribe called on line %d for %s: %s\n", line, input ? "input" : "output", statement);
! 	return false;
  }
--- 728,841 ----
  	return NULL;				/* not found */
  }
  
+ static pg_sqlda_t*
+ build_sqlda(int lineno, bool input, const char *connection_name, const char *stmt_name)
+ {
+ 	struct connection *con;
+ 	PGresult	*res;
+ 	pg_sqlda_t	*sqlda = NULL;
+ 
+ 	con = ecpg_get_connection(connection_name);
+ 	res = PQdescribePrepared(con->connection, stmt_name);
+ 	if (!ecpg_check_PQresult(res, lineno, con->connection, ECPG_COMPAT_INFORMIX))
+ 		return NULL;
+ 
+ 	sqlda = ecpg_build_sqlda_for_PGresult(lineno, res, -1);
+ 
+ 	PQclear(res);
+ 	return sqlda;
+ }
+ 
  bool
! ECPGdescribe(int line, bool input, const char *connection_name, const char *stmt_name, ...)
  {
! 	bool		ret = false;
! 	va_list		args;
! 
! 	/* DESCRIBE INPUT is not yet supported */
! 	if (input)
! 		return false;
! 
! 	va_start(args, stmt_name);
! 
! 	for (;;)
! 	{
! 		enum ECPGttype	type, dummy_type;
! 		void		*ptr, *dummy_ptr;
! 		long		dummy;
! 
! 		/* variable type */
! 		type = va_arg(args, enum ECPGttype);
! 
! 		if (type == ECPGt_EORT)
! 			break;
! 
! 		/* rest of variable parameters*/
! 		ptr = va_arg(args, void *);
! 		dummy = va_arg(args, long);
! 		dummy = va_arg(args, long);
! 		dummy = va_arg(args, long);
! 
! 		/* variable indicator */
! 		dummy_type = va_arg(args, enum ECPGttype);
! 		dummy_ptr = va_arg(args, void *);
! 		dummy = va_arg(args, long);
! 		dummy = va_arg(args, long);
! 		dummy = va_arg(args, long);
! 
! 		switch (type)
! 		{
! 			case ECPGt_descriptor:
! 			{
! 				char	*name = ptr;
! 				struct connection *con = ecpg_get_connection(connection_name);
! 				struct descriptor *desc = ecpg_find_desc(line, name);
! 				PGresult	*res;
! 				ExecStatusType  ret;
! 
! 				if (con == NULL)
! 					break;
! 				if (desc == NULL)
! 					break;
! 
! 				res = PQdescribePrepared(con->connection, stmt_name);
! 				ret = PQresultStatus(res);
! 				if (ecpg_check_PQresult(res, line, con->connection, ECPG_COMPAT_PGSQL))
! 				{
! 					if (desc->result != NULL)
! 						PQclear(desc->result);
! 					desc->result = res;
! 					ret = true;
! 				}
! 				break;
! 			}
! 			case ECPGt_sqlda:
! 			{
! 				pg_sqlda_t **_sqlda = ptr;
! 				pg_sqlda_t *sqlda;
! 
! 				sqlda = build_sqlda(line, input, connection_name, stmt_name);
! 				if (sqlda)
! 				{
! 					pg_sqlda_t *sqlda_old = *_sqlda;
! 					if (sqlda_old)
! 					{
! 						if (sqlda->sqlvar != (pg_sqlvar_t *)(sqlda + 1))
! 							free(sqlda->sqlvar);
! 						free(sqlda_old);
! 					}
! 					*_sqlda = sqlda;
! 					ret = true;
! 				}
! 				break;
! 			}
! 			default:
! 				/* nothing else may come */
! 				;
! 		}
! 	}
! 
! 	va_end(args);
! 
! 	return ret;
  }
diff -dcrpN pgsql.2/src/interfaces/ecpg/include/ecpglib.h pgsql.3/src/interfaces/ecpg/include/ecpglib.h
*** pgsql.2/src/interfaces/ecpg/include/ecpglib.h	2009-09-21 15:19:11.000000000 +0200
--- pgsql.3/src/interfaces/ecpg/include/ecpglib.h	2009-11-16 11:24:24.000000000 +0100
*************** bool		ECPGset_desc(int, const char *, in
*** 83,89 ****
  
  void		ECPGset_noind_null(enum ECPGttype, void *);
  bool		ECPGis_noind_null(enum ECPGttype, void *);
! bool		ECPGdescribe(int, bool, const char *,...);
  
  /* dynamic result allocation */
  void		ECPGfree_auto_mem(void);
--- 83,89 ----
  
  void		ECPGset_noind_null(enum ECPGttype, void *);
  bool		ECPGis_noind_null(enum ECPGttype, void *);
! bool		ECPGdescribe(int, bool, const char *, const char *, ...);
  
  /* dynamic result allocation */
  void		ECPGfree_auto_mem(void);
diff -dcrpN pgsql.2/src/interfaces/ecpg/preproc/ecpg.trailer pgsql.3/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.2/src/interfaces/ecpg/preproc/ecpg.trailer	2009-11-16 11:07:02.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/preproc/ecpg.trailer	2009-11-16 11:33:34.000000000 +0100
*************** into_descriptor: INTO opt_sql SQL_DESCRI
*** 1047,1052 ****
--- 1047,1059 ----
  		}
  		;
  
+ into_sqlda: INTO name
+ 		{
+ 			add_variable_to_head(&argsresult, sqlda_variable($2), &no_indicator);
+ 			$$ = EMPTY;
+ 		}
+ 		;
+ 
  opt_sql: /*EMPTY*/		{ $$ = EMPTY; }
  		| SQL_SQL	{ $$ = make_str("sql"); }
  		;
*************** UsingConst: Iconst			{ $$ = $1; }
*** 1076,1103 ****
  		;
  
  /*
!  * We accept descibe but do nothing with it so far.
   */
! ECPGDescribe: SQL_DESCRIBE INPUT_P name using_descriptor
  	{
  		const char *con = connection ? connection : "NULL";
  		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
! 		$$ = (char *) mm_alloc(sizeof("1, ECPGprepared_statement(, \"\", __LINE__)") + strlen(con) + strlen($3));
! 		sprintf($$, "1, ECPGprepared_statement(%s, \"%s\", __LINE__)", con, $3);
  	}
! 	| SQL_DESCRIBE opt_output name using_descriptor
  	{
  		const char *con = connection ? connection : "NULL";
! 		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
! 		$$ = (char *) mm_alloc(sizeof("0, ECPGprepared_statement(, \"\", __LINE__)") + strlen(con) + strlen($3));
! 		sprintf($$, "0, ECPGprepared_statement(%s, \"%s\", __LINE__)", con, $3);
  	}
! 	| SQL_DESCRIBE opt_output name into_descriptor
  	{
  		const char *con = connection ? connection : "NULL";
  		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
! 		$$ = (char *) mm_alloc(sizeof("0, ECPGprepared_statement(, \"\", __LINE__)") + strlen(con) + strlen($3));
! 		sprintf($$, "0, ECPGprepared_statement(%s, \"%s\", __LINE__)", con, $3);
  	}
  	;
  
--- 1083,1131 ----
  		;
  
  /*
!  * We accept DESCRIBE [OUTPUT] but do nothing with DESCRIBE INPUT so far.
   */
! ECPGDescribe: SQL_DESCRIBE INPUT_P prepared_name using_descriptor
  	{
  		const char *con = connection ? connection : "NULL";
  		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
! 		$$ = (char *) mm_alloc(sizeof("1, , ") + strlen(con) + strlen($3));
! 		sprintf($$, "1, %s, %s", con, $3);
  	}
! 	| SQL_DESCRIBE opt_output prepared_name using_descriptor
  	{
  		const char *con = connection ? connection : "NULL";
! 		struct variable *var;
! 
! 		var = argsinsert->variable;
! 		remove_variable_from_list(&argsinsert, var);
! 		add_variable_to_head(&argsresult, var, &no_indicator);
! 
! 		$$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
! 		sprintf($$, "0, %s, %s", con, $3);
  	}
! 	| SQL_DESCRIBE opt_output prepared_name into_descriptor
! 	{
! 		const char *con = connection ? connection : "NULL";
! 		$$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
! 		sprintf($$, "0, %s, %s", con, $3);
! 	}
! 	| SQL_DESCRIBE INPUT_P prepared_name into_sqlda
  	{
  		const char *con = connection ? connection : "NULL";
  		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
! 		if (!INFORMIX_MODE)
! 			mmerror(PARSE_ERROR, ET_ERROR, "Not in Informix compatibility mode");
! 		$$ = (char *) mm_alloc(sizeof("1, , ") + strlen(con) + strlen($3));
! 		sprintf($$, "1, %s, %s", con, $3);
! 	}
! 	| SQL_DESCRIBE opt_output prepared_name into_sqlda
! 	{
! 		const char *con = connection ? connection : "NULL";
! 		if (!INFORMIX_MODE)
! 			mmerror(PARSE_ERROR, ET_ERROR, "Not in Informix compatibility mode");
! 		$$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
! 		sprintf($$, "0, %s, %s", con, $3);
  	}
  	;
  
diff -dcrpN pgsql.2/src/interfaces/ecpg/preproc/ecpg.type pgsql.3/src/interfaces/ecpg/preproc/ecpg.type
*** pgsql.2/src/interfaces/ecpg/preproc/ecpg.type	2009-11-16 11:07:02.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/preproc/ecpg.type	2009-11-16 11:24:24.000000000 +0100
***************
*** 73,78 ****
--- 73,79 ----
  %type <str> execute_rest
  %type <str> indicator
  %type <str> into_descriptor
+ %type <str> into_sqlda
  %type <str> Iresult
  %type <str> on_off
  %type <str> opt_bit_field
***************
*** 88,94 ****
  %type <str> opt_reference
  %type <str> opt_scale
  %type <str> opt_server
! %type <str> opt_sql   
  %type <str> opt_user
  %type <str> opt_opt_value
  %type <str> ora_user
--- 89,95 ----
  %type <str> opt_reference
  %type <str> opt_scale
  %type <str> opt_server
! %type <str> opt_sql
  %type <str> opt_user
  %type <str> opt_opt_value
  %type <str> ora_user
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/compat_informix/describe.pgc pgsql.3/src/interfaces/ecpg/test/compat_informix/describe.pgc
*** pgsql.2/src/interfaces/ecpg/test/compat_informix/describe.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/compat_informix/describe.pgc	2009-11-16 11:24:24.000000000 +0100
***************
*** 0 ****
--- 1,166 ----
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ exec sql include ../regression;
+ exec sql include sqlda.h;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ pg_sqlda_t	*sqlda1, *sqlda2, *sqlda3;
+ 
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ 	char	*stmt1 = "SELECT id, t FROM t1";
+ 	char	*stmt2 = "SELECT id, t FROM t1 WHERE id = -1";
+ 	int	i, count1, count2;
+ 	char	field_name1[30] = "not set";
+ 	char	field_name2[30] = "not set";
+ exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table t1(id serial primary key, t text);
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into t1(id, t) values (default, 'a');
+ 	exec sql insert into t1(id, t) values (default, 'b');
+ 	exec sql insert into t1(id, t) values (default, 'c');
+ 	exec sql insert into t1(id, t) values (default, 'd');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/*
+ 	 * Test DESCRIBE with a query producing tuples.
+ 	 * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
+ 	 * Informix-compat mode.
+ 	 */
+ 
+ 	strcpy(msg, "allocate");
+ 	exec sql allocate descriptor desc1;
+ 	exec sql allocate descriptor desc2;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id1 FROM :stmt1;
+ 
+ 	sqlda1 = sqlda2 = sqlda3 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	exec sql describe st_id1 into sql descriptor desc1;
+ 	exec sql describe st_id1 using sql descriptor desc2;
+ 
+ 	exec sql describe st_id1 into descriptor sqlda1;
+ 	exec sql describe st_id1 using descriptor sqlda2;
+ 	exec sql describe st_id1 into sqlda3;
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	exec sql get descriptor desc1 :count1 = count;
+ 	exec sql get descriptor desc1 :count2 = count;
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld &&
+ 		count1 == sqlda3->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		exec sql get descriptor desc1 value :i :field_name1 = name;
+ 		exec sql get descriptor desc2 value :i :field_name2 = name;
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname,
+ 			sqlda3->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate descriptor desc1;
+ 	exec sql deallocate descriptor desc2;
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 	free(sqlda3);
+ 
+ 	exec sql deallocate prepare st_id1;
+ 
+ 	/* Test DESCRIBE with a query not producing tuples */
+ 
+ 	strcpy(msg, "allocate");
+ 	exec sql allocate descriptor desc1;
+ 	exec sql allocate descriptor desc2;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id2 FROM :stmt2;
+ 
+ 	sqlda1 = sqlda2 = sqlda3 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	exec sql describe st_id2 into sql descriptor desc1;
+ 	exec sql describe st_id2 using sql descriptor desc2;
+ 
+ 	exec sql describe st_id2 into descriptor sqlda1;
+ 	exec sql describe st_id2 using descriptor sqlda2;
+ 	exec sql describe st_id2 into sqlda3;
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	exec sql get descriptor desc1 :count1 = count;
+ 	exec sql get descriptor desc1 :count2 = count;
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld &&
+ 		count1 == sqlda3->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		exec sql get descriptor desc1 value :i :field_name1 = name;
+ 		exec sql get descriptor desc2 value :i :field_name2 = name;
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname,
+ 			sqlda3->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate descriptor desc1;
+ 	exec sql deallocate descriptor desc2;
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 	free(sqlda3);
+ 
+ 	exec sql deallocate prepare st_id2;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table t1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/compat_informix/Makefile pgsql.3/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.2/src/interfaces/ecpg/test/compat_informix/Makefile	2009-11-16 11:07:02.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/compat_informix/Makefile	2009-11-16 11:24:24.000000000 +0100
*************** override LIBS := -lecpg_compat $(LIBS)
*** 13,18 ****
--- 13,19 ----
  TESTS = test_informix test_informix.c \
          test_informix2 test_informix2.c \
          cursor cursor.c \
+         describe describe.c \
          dec_test dec_test.c \
          rfmtdate rfmtdate.c \
          rfmtlong rfmtlong.c \
*************** test_informix2.c: test_informix2.pgc ../
*** 31,36 ****
--- 32,40 ----
  cursor.c: cursor.pgc ../regression.h
  	$(ECPG) -o $@ -I$(srcdir) $<
  
+ describe.c: describe.pgc ../regression.h
+ 	$(ECPG) -o $@ -I$(srcdir) $<
+ 
  sqlda.c: sqlda.pgc ../regression.h
  	$(ECPG) -o $@ -I$(srcdir) $<
  
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/ecpg_schedule pgsql.3/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.2/src/interfaces/ecpg/test/ecpg_schedule	2009-11-16 11:07:02.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/ecpg_schedule	2009-11-16 11:24:24.000000000 +0100
*************** test: compat_informix/rfmtlong
*** 5,10 ****
--- 5,11 ----
  test: compat_informix/rnull
  test: compat_informix/cursor
  test: compat_informix/sqlda
+ test: compat_informix/describe
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: preproc/array_of_struct
*** 19,24 ****
--- 20,26 ----
  test: preproc/autoprep
  test: preproc/comment
  test: preproc/cursor
+ test: preproc/describe
  test: preproc/define
  test: preproc/init
  test: preproc/strings
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/ecpg_schedule_tcp pgsql.3/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.2/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-11-16 11:07:02.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-11-16 11:24:24.000000000 +0100
*************** test: compat_informix/rfmtlong
*** 5,10 ****
--- 5,11 ----
  test: compat_informix/rnull
  test: compat_informix/cursor
  test: compat_informix/sqlda
+ test: compat_informix/describe
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: preproc/array_of_struct
*** 19,24 ****
--- 20,26 ----
  test: preproc/autoprep
  test: preproc/comment
  test: preproc/cursor
+ test: preproc/describe
  test: preproc/define
  test: preproc/init
  test: preproc/strings
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-describe.c pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.c
*** pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-describe.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.c	2009-11-16 11:24:24.000000000 +0100
***************
*** 0 ****
--- 1,490 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "describe.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 4 "describe.pgc"
+ 
+ 
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+ 
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+ 
+ /* Define Informix "standard" types */
+ #ifndef C_H
+ typedef int		int4;
+ typedef	short		int2;
+ #endif
+ typedef	char		int1;
+ 
+ typedef	int		mint;
+ typedef	long		mlong;
+ 
+ typedef	short		MSHORT;
+ typedef	char		MCHAR; 
+ 
+ typedef	unsigned int	uint4;
+ typedef	unsigned short	uint2;
+ typedef	unsigned char	uint1;
+ 
+ typedef	unsigned int	muint;
+ typedef	unsigned long	mulong;
+ 
+ typedef	unsigned short	MUSHORT;
+ typedef	unsigned char	MUCHAR; 
+ 
+ #define MI_INT_SIZE     (sizeof(int)    * 8)
+ #define MI_LONG_SIZE    (sizeof(long)   * 8)
+ #define MI_PTR_SIZE     (sizeof(char *) * 8)
+ 
+ typedef struct sqlvar_struct
+ {
+ 	int2	sqltype;		/* variable type                */
+ 	int4	sqllen;			/* length in bytes              */
+ 	char	   *sqldata;		/* pointer to data              */
+ 	int2	   *sqlind;		/* pointer to indicator         */
+ 	char	   *sqlname;		/* variable name                */
+ 	char	   *sqlformat;		/* reserved for future use      */
+ 	int2	sqlitype;		/* ind variable type            */
+ 	int2	sqlilen;		/* ind length in bytes          */
+ 	char	   *sqlidata;		/* ind data pointer             */
+ 	int4	sqlxid;			/* extended id type             */
+ 	char	   *sqltypename;	/* extended type name           */
+ 	int2	sqltypelen;		/* length of extended type name */
+ 	int2	sqlownerlen;		/* length of owner name         */
+ 	int2	sqlsourcetype;		/* source type for distinct of built-ins */
+ 	char	   *sqlownername;	/* owner name                   */
+ 	int4	sqlsourceid;		/* extended id of source type   */
+ 
+ 	/*
+ 	 * sqlilongdata is new.  It supports data that exceeds the 32k
+ 	 * limit.  sqlilen and sqlidata are for backward compatibility
+ 	 * and they have maximum value of <32K.
+ 	 */
+ 	char	   *sqlilongdata;	/* for data field beyond 32K    */
+ 	int4	sqlflags;		/* for internal use only        */
+ 	void	   *sqlreserved;	/* reserved for future use      */
+ } pg_sqlvar_t;
+ 
+ typedef struct sqlda
+ {
+ 	int2		sqld;
+ 	pg_sqlvar_t	   *sqlvar;
+ 	char		desc_name[19];	/* descriptor name              */
+ 	int2		desc_occ;	/* size of sqlda structure      */
+ 	struct sqlda	   *desc_next;	/* pointer to next sqlda struct */
+ 	void		   *reserved;	/* reserved for future use */
+ } pg_sqlda_t;
+ 
+ #endif /* POSTGRES_SQLDA_H */
+ 
+ #line 5 "describe.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 7 "describe.pgc"
+ 
+ 
+ pg_sqlda_t	*sqlda1, *sqlda2, *sqlda3;
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		  
+ 		  
+ 		  
+ 
+ #line 15 "describe.pgc"
+  char * stmt1 = "SELECT id, t FROM t1" ;
+  
+ #line 16 "describe.pgc"
+  char * stmt2 = "SELECT id, t FROM t1 WHERE id = -1" ;
+  
+ #line 17 "describe.pgc"
+  int i , count1 , count2 ;
+  
+ #line 18 "describe.pgc"
+  char field_name1 [ 30 ] = "not set" ;
+  
+ #line 19 "describe.pgc"
+  char field_name2 [ 30 ] = "not set" ;
+ /* exec sql end declare section */
+ #line 20 "describe.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0); 
+ #line 27 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 27 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 30 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 30 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
+ #line 33 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 33 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 36 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 37 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 38 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 39 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 39 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 42 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 42 "describe.pgc"
+ 
+ 
+ 	/*
+ 	 * Test DESCRIBE with a query producing tuples.
+ 	 * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
+ 	 * Informix-compat mode.
+ 	 */
+ 
+ 	strcpy(msg, "allocate");
+ 	ECPGallocate_desc(__LINE__, "desc1");
+ #line 51 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 51 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc2");
+ #line 52 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 52 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 55 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 55 "describe.pgc"
+ 
+ 
+ 	sqlda1 = sqlda2 = sqlda3 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 60 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 61 "describe.pgc"
+ 
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_sqlda, & sqlda1 , 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 63 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_sqlda, & sqlda2 , 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 64 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_sqlda, &sqlda3, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 65 "describe.pgc"
+ 
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));
+ 
+ #line 71 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 71 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count2));
+ 
+ #line 72 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 72 "describe.pgc"
+ 
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld &&
+ 		count1 == sqlda3->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+ 	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 82 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 82 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+ 	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 83 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 83 "describe.pgc"
+ 
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname,
+ 			sqlda3->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 93 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 93 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 94 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 94 "describe.pgc"
+ 
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 	free(sqlda3);
+ 
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
+ #line 99 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 99 "describe.pgc"
+ 
+ 
+ 	/* Test DESCRIBE with a query not producing tuples */
+ 
+ 	strcpy(msg, "allocate");
+ 	ECPGallocate_desc(__LINE__, "desc1");
+ #line 104 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 104 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc2");
+ #line 105 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 105 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2);
+ #line 108 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 108 "describe.pgc"
+ 
+ 
+ 	sqlda1 = sqlda2 = sqlda3 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 113 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 114 "describe.pgc"
+ 
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_sqlda, & sqlda1 , 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 116 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_sqlda, & sqlda2 , 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 117 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_sqlda, &sqlda3, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 118 "describe.pgc"
+ 
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));
+ 
+ #line 124 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 124 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count2));
+ 
+ #line 125 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 125 "describe.pgc"
+ 
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld &&
+ 		count1 == sqlda3->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+ 	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 135 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 135 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+ 	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 136 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 136 "describe.pgc"
+ 
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname,
+ 			sqlda3->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 146 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 146 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 147 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 147 "describe.pgc"
+ 
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 	free(sqlda3);
+ 
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id2");
+ #line 152 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 152 "describe.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 157 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 157 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 160 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 160 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 163 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 163 "describe.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr
*** pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr	2009-11-16 11:24:24.000000000 +0100
***************
*** 0 ****
--- 1,100 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: query: insert into t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 42: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 55: name st_id1; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 99: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 108: name st_id2; query: "SELECT id, t FROM t1 WHERE id = -1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 152: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 160: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout
*** pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout	2009-11-16 11:24:24.000000000 +0100
***************
*** 0 ****
--- 1,24 ----
+ 1
+ 	field_name1 'id'
+ 	field_name2 'id'
+ 	sqlda1 'id'
+ 	sqlda2 'id'
+ 	sqlda3 'id'
+ 2
+ 	field_name1 't'
+ 	field_name2 't'
+ 	sqlda1 't'
+ 	sqlda2 't'
+ 	sqlda3 't'
+ 1
+ 	field_name1 'id'
+ 	field_name2 'id'
+ 	sqlda1 'id'
+ 	sqlda2 'id'
+ 	sqlda3 'id'
+ 2
+ 	field_name1 't'
+ 	field_name2 't'
+ 	sqlda1 't'
+ 	sqlda2 't'
+ 	sqlda3 't'
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/preproc-describe.c pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.c
*** pgsql.2/src/interfaces/ecpg/test/expected/preproc-describe.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.c	2009-11-16 11:24:24.000000000 +0100
***************
*** 0 ****
--- 1,481 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "describe.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 4 "describe.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 6 "describe.pgc"
+ 
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		    
+ 		  
+ 		  
+ 		  
+ 		  
+ 
+ #line 12 "describe.pgc"
+  char * stmt1 = "SELECT id, t FROM t1" ;
+  
+ #line 13 "describe.pgc"
+  char * stmt2 = "SELECT id, t FROM t1 WHERE id = -1" ;
+  
+ #line 14 "describe.pgc"
+  int i , count1 , count2 , count3 , count4 ;
+  
+ #line 15 "describe.pgc"
+  char field_name1 [ 30 ] = "not set" ;
+  
+ #line 16 "describe.pgc"
+  char field_name2 [ 30 ] = "not set" ;
+  
+ #line 17 "describe.pgc"
+  char field_name3 [ 30 ] = "not set" ;
+  
+ #line 18 "describe.pgc"
+  char field_name4 [ 30 ] = "not set" ;
+ /* exec sql end declare section */
+ #line 19 "describe.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
+ #line 26 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 26 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 29 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 29 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
+ #line 32 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 32 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 35 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 35 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 36 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 37 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 38 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 41 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "describe.pgc"
+ 
+ 
+ 	/*
+ 	 * Test DESCRIBE with a query producing tuples.
+ 	 * DESCRIPTOR and SQL DESCRIPTOR are the same in native mode.
+ 	 */
+ 
+ 	strcpy(msg, "allocate");
+ 	ECPGallocate_desc(__LINE__, "desc1");
+ #line 49 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 49 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc2");
+ #line 50 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 50 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc3");
+ #line 51 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 51 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc4");
+ #line 52 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 52 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 55 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 55 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "describe");
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 58 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 59 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc3", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 60 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc4", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 61 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "get descriptor");
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));
+ 
+ #line 64 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 64 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc2", &(count2));
+ 
+ #line 65 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 65 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc3", &(count3));
+ 
+ #line 66 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 66 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc4", &(count4));
+ 
+ #line 67 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 67 "describe.pgc"
+ 
+ 
+ 	if (!(count1 == count2 && count1 == count3 && count1 == count4))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+ 	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 74 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 74 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+ 	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 75 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 75 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc3", i,ECPGd_name,
+ 	ECPGt_char,(field_name3),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 76 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 76 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc4", i,ECPGd_name,
+ 	ECPGt_char,(field_name4),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 77 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 77 "describe.pgc"
+ 
+ 		printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
+ 			field_name1, field_name2, field_name3, field_name4);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 83 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 83 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 84 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 84 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc3");
+ #line 85 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 85 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc4");
+ #line 86 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 86 "describe.pgc"
+ 
+ 
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
+ #line 88 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 88 "describe.pgc"
+ 
+ 
+ 	/* Test DESCRIBE with a query not producing tuples */
+ 
+ 	strcpy(msg, "allocate");
+ 	ECPGallocate_desc(__LINE__, "desc1");
+ #line 93 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 93 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc2");
+ #line 94 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 94 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc3");
+ #line 95 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 95 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc4");
+ #line 96 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 96 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2);
+ #line 99 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 99 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "describe");
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 102 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 103 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc3", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 104 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc4", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 105 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "get descriptor");
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));
+ 
+ #line 108 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 108 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc2", &(count2));
+ 
+ #line 109 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 109 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc3", &(count3));
+ 
+ #line 110 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 110 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc4", &(count4));
+ 
+ #line 111 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 111 "describe.pgc"
+ 
+ 
+ 	if (!(count1 == count2 && count1 == count3 && count1 == count4))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+ 	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 118 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 118 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+ 	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 119 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 119 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc3", i,ECPGd_name,
+ 	ECPGt_char,(field_name3),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 120 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 120 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc4", i,ECPGd_name,
+ 	ECPGt_char,(field_name4),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 121 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 121 "describe.pgc"
+ 
+ 		printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
+ 			field_name1, field_name2, field_name3, field_name4);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 127 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 127 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 128 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 128 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc3");
+ #line 129 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 129 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc4");
+ #line 130 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 130 "describe.pgc"
+ 
+ 
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
+ #line 132 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 132 "describe.pgc"
+ 
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 138 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 138 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 141 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 141 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 144 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 144 "describe.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/preproc-describe.stderr pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.stderr
*** pgsql.2/src/interfaces/ecpg/test/expected/preproc-describe.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.stderr	2009-11-16 11:24:24.000000000 +0100
***************
*** 0 ****
--- 1,140 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: query: insert into t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 41: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 55: name st_id1; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 88: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 99: name st_id2; query: "SELECT id, t FROM t1 WHERE id = -1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 132: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 138: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 138: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 138: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 141: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/preproc-describe.stdout pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.stdout
*** pgsql.2/src/interfaces/ecpg/test/expected/preproc-describe.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.stdout	2009-11-16 11:24:24.000000000 +0100
***************
*** 0 ****
--- 1,4 ----
+ field_name 1 'id' 2 'id' 3 'id' 4 'id'
+ field_name 1 't' 2 't' 3 't' 4 't'
+ field_name 1 'id' 2 'id' 3 'id' 4 'id'
+ field_name 1 't' 2 't' 3 't' 4 't'
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/preproc/describe.pgc pgsql.3/src/interfaces/ecpg/test/preproc/describe.pgc
*** pgsql.2/src/interfaces/ecpg/test/preproc/describe.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/preproc/describe.pgc	2009-11-16 11:24:24.000000000 +0100
***************
*** 0 ****
--- 1,147 ----
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ 	char	*stmt1 = "SELECT id, t FROM t1";
+ 	char	*stmt2 = "SELECT id, t FROM t1 WHERE id = -1";
+ 	int	i, count1, count2, count3, count4;
+ 	char	field_name1[30] = "not set";
+ 	char	field_name2[30] = "not set";
+ 	char	field_name3[30] = "not set";
+ 	char	field_name4[30] = "not set";
+ exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table t1(id serial primary key, t text);
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into t1(id, t) values (default, 'a');
+ 	exec sql insert into t1(id, t) values (default, 'b');
+ 	exec sql insert into t1(id, t) values (default, 'c');
+ 	exec sql insert into t1(id, t) values (default, 'd');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/*
+ 	 * Test DESCRIBE with a query producing tuples.
+ 	 * DESCRIPTOR and SQL DESCRIPTOR are the same in native mode.
+ 	 */
+ 
+ 	strcpy(msg, "allocate");
+ 	exec sql allocate descriptor desc1;
+ 	exec sql allocate descriptor desc2;
+ 	exec sql allocate descriptor desc3;
+ 	exec sql allocate descriptor desc4;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id1 FROM :stmt1;
+ 
+ 	strcpy(msg, "describe");
+ 	exec sql describe st_id1 into descriptor desc1;
+ 	exec sql describe st_id1 into sql descriptor desc2;
+ 	exec sql describe st_id1 using descriptor desc3;
+ 	exec sql describe st_id1 using sql descriptor desc4;
+ 
+ 	strcpy(msg, "get descriptor");
+ 	exec sql get descriptor desc1 :count1 = count;
+ 	exec sql get descriptor desc2 :count2 = count;
+ 	exec sql get descriptor desc3 :count3 = count;
+ 	exec sql get descriptor desc4 :count4 = count;
+ 
+ 	if (!(count1 == count2 && count1 == count3 && count1 == count4))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		exec sql get descriptor desc1 value :i :field_name1 = name;
+ 		exec sql get descriptor desc2 value :i :field_name2 = name;
+ 		exec sql get descriptor desc3 value :i :field_name3 = name;
+ 		exec sql get descriptor desc4 value :i :field_name4 = name;
+ 		printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
+ 			field_name1, field_name2, field_name3, field_name4);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate descriptor desc1;
+ 	exec sql deallocate descriptor desc2;
+ 	exec sql deallocate descriptor desc3;
+ 	exec sql deallocate descriptor desc4;
+ 
+ 	exec sql deallocate prepare st_id1;
+ 
+ 	/* Test DESCRIBE with a query not producing tuples */
+ 
+ 	strcpy(msg, "allocate");
+ 	exec sql allocate descriptor desc1;
+ 	exec sql allocate descriptor desc2;
+ 	exec sql allocate descriptor desc3;
+ 	exec sql allocate descriptor desc4;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id2 FROM :stmt2;
+ 
+ 	strcpy(msg, "describe");
+ 	exec sql describe st_id2 into descriptor desc1;
+ 	exec sql describe st_id2 into sql descriptor desc2;
+ 	exec sql describe st_id2 using descriptor desc3;
+ 	exec sql describe st_id2 using sql descriptor desc4;
+ 
+ 	strcpy(msg, "get descriptor");
+ 	exec sql get descriptor desc1 :count1 = count;
+ 	exec sql get descriptor desc2 :count2 = count;
+ 	exec sql get descriptor desc3 :count3 = count;
+ 	exec sql get descriptor desc4 :count4 = count;
+ 
+ 	if (!(count1 == count2 && count1 == count3 && count1 == count4))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		exec sql get descriptor desc1 value :i :field_name1 = name;
+ 		exec sql get descriptor desc2 value :i :field_name2 = name;
+ 		exec sql get descriptor desc3 value :i :field_name3 = name;
+ 		exec sql get descriptor desc4 value :i :field_name4 = name;
+ 		printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
+ 			field_name1, field_name2, field_name3, field_name4);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate descriptor desc1;
+ 	exec sql deallocate descriptor desc2;
+ 	exec sql deallocate descriptor desc3;
+ 	exec sql deallocate descriptor desc4;
+ 
+ 	exec sql deallocate prepare st_id2;
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table t1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/preproc/Makefile pgsql.3/src/interfaces/ecpg/test/preproc/Makefile
*** pgsql.2/src/interfaces/ecpg/test/preproc/Makefile	2009-11-16 10:52:22.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/preproc/Makefile	2009-11-16 11:24:24.000000000 +0100
*************** TESTS = array_of_struct array_of_struct.
*** 8,13 ****
--- 8,14 ----
  	autoprep autoprep.c \
  	comment comment.c \
  	cursor cursor.c \
+ 	describe describe.c \
  	define define.c \
  	init init.c \
  	strings strings.c \
#65Boszormenyi Zoltan
zb@cybertec.at
In reply to: Boszormenyi Zoltan (#64)
1 attachment(s)
ECPG patch 4, out-of-scope cursor support in Informix-mode

New version: rebased to current CVS.

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

Attachments:

4-pg85-outofscopedeclare-7-ctxdiff.patchtext/x-patch; name=4-pg85-outofscopedeclare-7-ctxdiff.patchDownload
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/descriptor.c pgsql.4/src/interfaces/ecpg/preproc/descriptor.c
*** pgsql.3/src/interfaces/ecpg/preproc/descriptor.c	2009-11-16 11:07:02.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/preproc/descriptor.c	2009-11-16 11:35:10.000000000 +0100
*************** struct variable *
*** 317,323 ****
  descriptor_variable(const char *name, int input)
  {
  	static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN];
! 	static const struct ECPGtype descriptor_type = {ECPGt_descriptor, NULL, NULL, {NULL}, 0};
  	static const struct variable varspace[2] = {
  		{descriptor_names[0], (struct ECPGtype *) & descriptor_type, 0, NULL},
  		{descriptor_names[1], (struct ECPGtype *) & descriptor_type, 0, NULL}
--- 317,323 ----
  descriptor_variable(const char *name, int input)
  {
  	static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN];
! 	static const struct ECPGtype descriptor_type = {ECPGt_descriptor, NULL, NULL, NULL, {NULL}, 0};
  	static const struct variable varspace[2] = {
  		{descriptor_names[0], (struct ECPGtype *) & descriptor_type, 0, NULL},
  		{descriptor_names[1], (struct ECPGtype *) & descriptor_type, 0, NULL}
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/ecpg.addons pgsql.4/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.3/src/interfaces/ecpg/preproc/ecpg.addons	2009-11-16 11:07:02.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/preproc/ecpg.addons	2009-11-16 11:35:10.000000000 +0100
*************** ECPG: DeclareCursorStmtDECLAREcursor_nam
*** 310,320 ****
--- 310,323 ----
  
  		this->next = cur;
  		this->name = $2;
+ 		this->function = (current_function ? mm_strdup(current_function) : NULL);
  		this->connection = connection;
  		this->opened = false;
  		this->command =  cat_str(7, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for"), $7);
  		this->argsinsert = argsinsert;
+ 		this->argsinsert_oos = NULL;
  		this->argsresult = argsresult;
+ 		this->argsresult_oos = NULL;
  		argsinsert = argsresult = NULL;
  		cur = this;
  
*************** ECPG: DeclareCursorStmtDECLAREcursor_nam
*** 324,333 ****
  		{
  			if (braces_open > 0) /* we're in a function */
  			{
! 				$$ = cat_str(4, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), make_str("ECPG_informix_reset_sqlca();"), comment);
  			}
  			else
! 				$$ = cat_str(3, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), comment);
  		}
  		else
  			$$ = comment;
--- 327,336 ----
  		{
  			if (braces_open > 0) /* we're in a function */
  			{
! 				$$ = cat_str(4, adjust_informix(this, true), adjust_informix(this, false), make_str("ECPG_informix_reset_sqlca();"), comment);
  			}
  			else
! 				$$ = cat_str(3, adjust_informix(this, true), adjust_informix(this, false), comment);
  		}
  		else
  			$$ = comment;
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/ecpg.header pgsql.4/src/interfaces/ecpg/preproc/ecpg.header
*** pgsql.3/src/interfaces/ecpg/preproc/ecpg.header	2009-11-06 11:06:24.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/preproc/ecpg.header	2009-11-16 11:35:10.000000000 +0100
***************
*** 33,38 ****
--- 33,39 ----
   */
  int struct_level = 0;
  int braces_open; /* brace level counter */
+ char *current_function;
  int ecpg_informix_var = 0;
  char	*connection = NULL;
  char	*input_filename = NULL;
*************** static char *ECPGstruct_sizeof = NULL;
*** 53,62 ****
  /* for forward declarations we have to store some data as well */
  static char *forward_name = NULL;
  
! struct ECPGtype ecpg_no_indicator = {ECPGt_NO_INDICATOR, NULL, NULL, {NULL}, 0};
  struct variable no_indicator = {"no_indicator", &ecpg_no_indicator, 0, NULL};
  
! struct ECPGtype ecpg_query = {ECPGt_char_variable, NULL, NULL, {NULL}, 0};
  
  /*
   * Handle parsing errors and warnings
--- 54,63 ----
  /* for forward declarations we have to store some data as well */
  static char *forward_name = NULL;
  
! struct ECPGtype ecpg_no_indicator = {ECPGt_NO_INDICATOR, NULL, NULL, NULL, {NULL}, 0};
  struct variable no_indicator = {"no_indicator", &ecpg_no_indicator, 0, NULL};
  
! struct ECPGtype ecpg_query = {ECPGt_char_variable, NULL, NULL, NULL, {NULL}, 0};
  
  /*
   * Handle parsing errors and warnings
*************** create_questionmarks(char *name, bool ar
*** 226,232 ****
  }
  
  static char *
! adjust_informix(struct arguments *list)
  {
  	/* Informix accepts DECLARE with variables that are out of scope when OPEN is called.
   	 * for instance you can declare variables in a function, and then subsequently use them
--- 227,233 ----
  }
  
  static char *
! adjust_informix(struct cursor *cur, bool insert)
  {
  	/* Informix accepts DECLARE with variables that are out of scope when OPEN is called.
   	 * for instance you can declare variables in a function, and then subsequently use them
*************** adjust_informix(struct arguments *list)
*** 240,301 ****
  	 * We have to change the variables to our own struct and just store the pointer instead of the variable
  	 */
  
  	 struct arguments *ptr;
  	 char *result = make_str("");
  
  	 for (ptr = list; ptr != NULL; ptr = ptr->next)
  	 {
  	 	char temp[20]; /* this should be sufficient unless you have 8 byte integers */
  		char *original_var;
  
  	 	/* change variable name to "ECPG_informix_get_var(<counter>)" */
  		original_var = ptr->variable->name;
  		sprintf(temp, "%d))", ecpg_informix_var);
  
! 		if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char && ptr->variable->type->type != ECPGt_unsigned_char && ptr->variable->type->type != ECPGt_string) && atoi(ptr->variable->type->size) > 1)
  		{
! 			ptr->variable = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, make_str("1"), ptr->variable->type->u.element->lineno), ptr->variable->type->size), 0);
  			sprintf(temp, "%d, (", ecpg_informix_var++);
  		}
  		else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char || ptr->variable->type->type == ECPGt_unsigned_char || ptr->variable->type->type == ECPGt_string) && atoi(ptr->variable->type->size) > 1)
  		{
! 			ptr->variable = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->lineno), 0);
! 			sprintf(temp, "%d, (", ecpg_informix_var++);
  		}
  		else
  		{
! 			ptr->variable = new_variable(cat_str(4, make_str("*("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->lineno), 0);
  			sprintf(temp, "%d, &(", ecpg_informix_var++);
  		}
  
  		/* create call to "ECPG_informix_set_var(<counter>, <pointer>. <linen number>)" */
! 		result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var), make_str("), __LINE__);\n"));
  
  		/* now the indicator if there is one */
! 		if (ptr->indicator->type->type != ECPGt_NO_INDICATOR)
  		{
  			/* change variable name to "ECPG_informix_get_var(<counter>)" */
  			original_var = ptr->indicator->name;
  			sprintf(temp, "%d))", ecpg_informix_var);
  
  			/* create call to "ECPG_informix_set_var(<counter>, <pointer>. <linen number>)" */
! 			if (atoi(ptr->indicator->type->size) > 1)
  			{
! 				ptr->indicator = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->lineno), 0);
  				sprintf(temp, "%d, (", ecpg_informix_var++);
  			}
  			else
  			{
! 				ptr->indicator = new_variable(cat_str(4, make_str("*("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->lineno), 0);
  				sprintf(temp, "%d, &(", ecpg_informix_var++);
  			}
  			result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var), make_str("), __LINE__);\n"));
  		}
  	 }
  
  	 return result;
  }
  
  static struct cursor *
  add_additional_variables(char *name, bool insert)
  {
--- 241,379 ----
  	 * We have to change the variables to our own struct and just store the pointer instead of the variable
  	 */
  
+ 	 struct arguments *list;
  	 struct arguments *ptr;
+ 	 struct arguments *newlist = NULL;
+ 	 struct variable *newvar, *newind;
  	 char *result = make_str("");
  
+ 	 list = (insert ? cur->argsinsert : cur->argsresult);
+ 
  	 for (ptr = list; ptr != NULL; ptr = ptr->next)
  	 {
  	 	char temp[20]; /* this should be sufficient unless you have 8 byte integers */
  		char *original_var;
+ 		bool skip_set_var = false;
  
  	 	/* change variable name to "ECPG_informix_get_var(<counter>)" */
  		original_var = ptr->variable->name;
  		sprintf(temp, "%d))", ecpg_informix_var);
  
! 		/* Don't emit ECPGinformix_set_var() calls for global variables */
! 		if (ptr->variable->brace_level == 0)
  		{
! 			newvar = ptr->variable;
! 			skip_set_var = true;
! 		}
! 		else if ((ptr->variable->type->type == ECPGt_char_variable) && (!strncmp(ptr->variable->name, "ECPGprepared_statement", strlen("ECPGprepared_statement"))))
! 		{
! 			newvar = ptr->variable;
! 			skip_set_var = true;
! 		}
! 		else if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char && ptr->variable->type->type != ECPGt_unsigned_char && ptr->variable->type->type != ECPGt_string) && atoi(ptr->variable->type->size) > 1)
! 		{
! 			newvar = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, make_str("1"), ptr->variable->type->u.element->lineno), ptr->variable->type->size), 0);
  			sprintf(temp, "%d, (", ecpg_informix_var++);
  		}
  		else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char || ptr->variable->type->type == ECPGt_unsigned_char || ptr->variable->type->type == ECPGt_string) && atoi(ptr->variable->type->size) > 1)
  		{
! 			newvar = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->lineno), 0);
! 			if (ptr->variable->type->type == ECPGt_varchar)
! 				sprintf(temp, "%d, &(", ecpg_informix_var++);
! 			else
! 				sprintf(temp, "%d, (", ecpg_informix_var++);
! 		}
! 		else if (ptr->variable->type->type == ECPGt_struct || ptr->variable->type->type == ECPGt_union)
! 		{
! 			sprintf(temp, "%d)))", ecpg_informix_var);
! 			newvar = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->variable->type->type_name), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->variable->type->u.members, ptr->variable->type->type, ptr->variable->type->type_name, ptr->variable->type->struct_sizeof), 0);
! 			sprintf(temp, "%d, &(", ecpg_informix_var++);
! 		}
! 		else if (ptr->variable->type->type == ECPGt_array)
! 		{
! 			if (ptr->variable->type->u.element->type == ECPGt_struct || ptr->variable->type->u.element->type == ECPGt_union)
! 			{
! 				sprintf(temp, "%d)))", ecpg_informix_var);
! 				newvar = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->variable->type->u.element->type_name), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->variable->type->u.element->u.members, ptr->variable->type->u.element->type, ptr->variable->type->u.element->type_name, ptr->variable->type->u.element->struct_sizeof), 0);
! 				sprintf(temp, "%d, (", ecpg_informix_var++);
! 			}
! 			else
! 			{
! 				newvar = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, ptr->variable->type->u.element->size, ptr->variable->type->u.element->lineno), ptr->variable->type->size), 0);
! 				sprintf(temp, "%d, &(", ecpg_informix_var++);
! 			}
  		}
  		else
  		{
! 			newvar = new_variable(cat_str(4, make_str("*("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->lineno), 0);
  			sprintf(temp, "%d, &(", ecpg_informix_var++);
  		}
  
  		/* create call to "ECPG_informix_set_var(<counter>, <pointer>. <linen number>)" */
! 		if (!skip_set_var)
! 			result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var), make_str("), __LINE__);\n"));
  
  		/* now the indicator if there is one */
! 		if ((ptr->indicator->type->type == ECPGt_NO_INDICATOR) || (ptr->indicator->brace_level == 0))
! 		{
! 			newind = ptr->indicator;
! 		}
! 		else
  		{
  			/* change variable name to "ECPG_informix_get_var(<counter>)" */
  			original_var = ptr->indicator->name;
  			sprintf(temp, "%d))", ecpg_informix_var);
  
  			/* create call to "ECPG_informix_set_var(<counter>, <pointer>. <linen number>)" */
! 			if (ptr->indicator->type->type == ECPGt_struct || ptr->indicator->type->type == ECPGt_union)
  			{
! 				sprintf(temp, "%d)))", ecpg_informix_var);
! 				newind = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->indicator->type->type_name), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->indicator->type->u.members, ptr->indicator->type->type, ptr->indicator->type->type_name, ptr->indicator->type->struct_sizeof), 0);
! 				sprintf(temp, "%d, &(", ecpg_informix_var++);
! 			}
! 			else if (ptr->indicator->type->type == ECPGt_array)
! 			{
! 				if (ptr->indicator->type->u.element->type == ECPGt_struct || ptr->indicator->type->u.element->type == ECPGt_union)
! 				{
! 					sprintf(temp, "%d)))", ecpg_informix_var);
! 					newind = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->indicator->type->u.element->type_name), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->indicator->type->u.element->u.members, ptr->indicator->type->u.element->type, ptr->indicator->type->u.element->type_name, ptr->indicator->type->u.element->struct_sizeof), 0);
! 					sprintf(temp, "%d, (", ecpg_informix_var++);
! 				}
! 				else
! 				{
! 					newind = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->indicator->type->u.element->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->indicator->type->u.element->type, ptr->indicator->type->u.element->size, ptr->indicator->type->u.element->lineno), ptr->indicator->type->size), 0);
! 					sprintf(temp, "%d, &(", ecpg_informix_var++);
! 				}
! 			}
! 			else if (atoi(ptr->indicator->type->size) > 1)
! 			{
! 				newind = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->lineno), 0);
  				sprintf(temp, "%d, (", ecpg_informix_var++);
  			}
  			else
  			{
! 				newind = new_variable(cat_str(4, make_str("*("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->lineno), 0);
  				sprintf(temp, "%d, &(", ecpg_informix_var++);
  			}
  			result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var), make_str("), __LINE__);\n"));
  		}
+ 
+ 		add_variable_to_tail(&newlist, newvar, newind);
  	 }
  
+ 	 if (insert)
+ 		cur->argsinsert_oos = newlist;
+ 	 else
+ 		cur->argsresult_oos = newlist;
+ 
  	 return result;
  }
  
+ /* This tests whether the cursor was declared and opened in the same function. */
+ #define SAMEFUNC(cur)	\
+ 	((cur->function == NULL) ||		\
+ 	 (cur->function != NULL && !strcmp(cur->function, current_function)))
+ 
  static struct cursor *
  add_additional_variables(char *name, bool insert)
  {
*************** add_additional_variables(char *name, boo
*** 318,329 ****
  	{
  		/* add all those input variables that were given earlier
  		 * note that we have to append here but have to keep the existing order */
! 		for (p = ptr->argsinsert; p; p = p->next)
  			add_variable_to_tail(&argsinsert, p->variable, p->indicator);
  	}
  
  	/* add all those output variables that were given earlier */
! 	for (p = ptr->argsresult; p; p = p->next)
  		add_variable_to_tail(&argsresult, p->variable, p->indicator);
  
  	return ptr;
--- 396,407 ----
  	{
  		/* add all those input variables that were given earlier
  		 * note that we have to append here but have to keep the existing order */
! 		for (p = ((!INFORMIX_MODE || SAMEFUNC(ptr)) ? ptr->argsinsert : ptr->argsinsert_oos); p; p = p->next)
  			add_variable_to_tail(&argsinsert, p->variable, p->indicator);
  	}
  
  	/* add all those output variables that were given earlier */
! 	for (p = ((!INFORMIX_MODE || SAMEFUNC(ptr)) ? ptr->argsresult : ptr->argsresult_oos); p; p = p->next)
  		add_variable_to_tail(&argsresult, p->variable, p->indicator);
  
  	return ptr;
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/ecpg.trailer pgsql.4/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.3/src/interfaces/ecpg/preproc/ecpg.trailer	2009-11-16 11:33:34.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/preproc/ecpg.trailer	2009-11-16 11:35:10.000000000 +0100
*************** statement: ecpgstart at stmt ';'        
*** 16,22 ****
                  | c_thing               { fprintf(yyout, "%s", $1); free($1); }
                  | CPP_LINE              { fprintf(yyout, "%s", $1); free($1); }
                  | '{'                   { braces_open++; fputs("{", yyout); }
!                 | '}'                   { remove_typedefs(braces_open); remove_variables(braces_open--); fputs("}", yyout); }
                  ;
  
  CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
--- 16,32 ----
                  | c_thing               { fprintf(yyout, "%s", $1); free($1); }
                  | CPP_LINE              { fprintf(yyout, "%s", $1); free($1); }
                  | '{'                   { braces_open++; fputs("{", yyout); }
!                 | '}'
! 		{
! 			remove_typedefs(braces_open);
! 			remove_variables(braces_open--);
! 			if (braces_open == 0)
! 			{
! 				free(current_function);
! 				current_function = NULL;
! 			}
! 			fputs("}", yyout);
! 		}
                  ;
  
  CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 313,318 ****
--- 323,329 ----
  			char *cursor_marker = $2[0] == ':' ? make_str("$0") : mm_strdup($2);
  			struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable));
  			const char *con = connection ? connection : "NULL";
+ 			char *comment;
  
  			for (ptr = cur; ptr != NULL; ptr = ptr->next)
  			{
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 326,334 ****
--- 337,347 ----
  			/* initial definition */
  			this->next = cur;
  			this->name = $2;
+ 			this->function = (current_function ? mm_strdup(current_function) : NULL);
  			this->connection = connection;
  			this->command =  cat_str(6, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for $1"));
  			this->argsresult = NULL;
+ 			this->argsresult_oos = NULL;
  
  			thisquery->type = &ecpg_query;
  			thisquery->brace_level = 0;
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 337,342 ****
--- 350,356 ----
  			sprintf(thisquery->name, "ECPGprepared_statement(%s, %s, __LINE__)", con, $7);
  
  			this->argsinsert = NULL;
+ 			this->argsinsert_oos = NULL;
  			if ($2[0] == ':')
  			{
  				struct variable *var = find_variable($2 + 1);
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 347,356 ****
  
  			cur = this;
  
! 			if (INFORMIX_MODE && braces_open > 0) /* we're in a function */
! 				$$ = cat_str(4, make_str("ECPG_informix_reset_sqlca();"), make_str("/*"), mm_strdup(this->command), make_str("*/"));
  			else
! 				$$ = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/"));
  		}
  		;
  
--- 361,377 ----
  
  			cur = this;
  
! 			comment = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/"));
! 
! 			if (INFORMIX_MODE)
! 			{
! 				if (braces_open > 0) /* we're in a function */
! 					$$ = cat_str(4, adjust_informix(this, true), adjust_informix(this, false), make_str("ECPG_informix_reset_sqlca();"), comment);
! 				else
! 					$$ = cat_str(3, adjust_informix(this, true), adjust_informix(this, false), comment);
! 			}
  			else
! 				$$ = comment;
  		}
  		;
  
*************** var_declaration: storage_declaration
*** 434,439 ****
--- 455,461 ----
  		var_type
  		{
  			actual_type[struct_level].type_enum = $2.type_enum;
+ 			actual_type[struct_level].type_str = $2.type_str;
  			actual_type[struct_level].type_dimension = $2.type_dimension;
  			actual_type[struct_level].type_index = $2.type_index;
  			actual_type[struct_level].type_sizeof = $2.type_sizeof;
*************** var_declaration: storage_declaration
*** 447,452 ****
--- 469,475 ----
  		| var_type
  		{
  			actual_type[struct_level].type_enum = $1.type_enum;
+ 			actual_type[struct_level].type_str = $1.type_str;
  			actual_type[struct_level].type_dimension = $1.type_dimension;
  			actual_type[struct_level].type_index = $1.type_index;
  			actual_type[struct_level].type_sizeof = $1.type_sizeof;
*************** variable: opt_pointer ECPGColLabel opt_a
*** 858,866 ****
  				case ECPGt_struct:
  				case ECPGt_union:
  					if (atoi(dimension) < 0)
! 						type = ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_sizeof);
  					else
! 						type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_sizeof), dimension);
  
  					$$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
  					break;
--- 881,889 ----
  				case ECPGt_struct:
  				case ECPGt_union:
  					if (atoi(dimension) < 0)
! 						type = ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_str, actual_type[struct_level].type_sizeof);
  					else
! 						type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_str, actual_type[struct_level].type_sizeof), dimension);
  
  					$$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
  					break;
*************** ECPGVar: SQL_VAR
*** 1364,1372 ****
  					case ECPGt_struct:
  					case ECPGt_union:
  						if (atoi(dimension) < 0)
! 							type = ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_sizeof);
  						else
! 							type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum,$5.type_sizeof), dimension);
  						break;
  
  					case ECPGt_varchar:
--- 1387,1395 ----
  					case ECPGt_struct:
  					case ECPGt_union:
  						if (atoi(dimension) < 0)
! 							type = ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_str, $5.type_sizeof);
  						else
! 							type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_str, $5.type_sizeof), dimension);
  						break;
  
  					case ECPGt_varchar:
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/extern.h pgsql.4/src/interfaces/ecpg/preproc/extern.h
*** pgsql.3/src/interfaces/ecpg/preproc/extern.h	2009-11-16 11:07:02.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/preproc/extern.h	2009-11-16 11:35:10.000000000 +0100
*************** extern int	braces_open,
*** 29,34 ****
--- 29,35 ----
  			ecpg_informix_var,
  			regression_mode,
  			auto_prepare;
+ extern char *current_function;
  extern char *descriptor_index;
  extern char *descriptor_name;
  extern char *connection;
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/pgc.l pgsql.4/src/interfaces/ecpg/preproc/pgc.l
*** pgsql.3/src/interfaces/ecpg/preproc/pgc.l	2009-09-18 08:26:55.000000000 +0200
--- pgsql.4/src/interfaces/ecpg/preproc/pgc.l	2009-11-16 11:35:10.000000000 +0100
*************** static char    *literalbuf = NULL;		/* e
*** 41,46 ****
--- 41,49 ----
  static int		literallen;				/* actual current length */
  static int		literalalloc;			/* current allocated buffer size */
  
+ /* Used for detecting global state together with braces_open */
+ static int		parenths_open;
+ 
  #define startlit()	(literalbuf[0] = '\0', literallen = 0)
  static void addlit(char *ytext, int yleng);
  static void addlitchar (unsigned char);
*************** cppline			{space}*#(.*\\{space})*.*{newl
*** 788,794 ****
  					}
  <C>{identifier} 	{
  						const ScanKeyword		*keyword;
! 							
  						/* Informix uses SQL defines only in SQL space */
  						/* however, some defines have to be taken care of for compatibility */
  						if ((!INFORMIX_MODE || !isinformixdefine()) && !isdefine())
--- 791,807 ----
  					}
  <C>{identifier} 	{
  						const ScanKeyword		*keyword;
! 
! 						/*
! 						 * Try to detect a function name:
! 						 * look for identifiers at the global scope
! 						 * keep the last identifier before the first '(' and '{' */
! 						if (braces_open == 0 && parenths_open == 0)
! 						{
! 							if (current_function)
! 								free(current_function);
! 							current_function = mm_strdup(yytext);
! 						}
  						/* Informix uses SQL defines only in SQL space */
  						/* however, some defines have to be taken care of for compatibility */
  						if ((!INFORMIX_MODE || !isinformixdefine()) && !isdefine())
*************** cppline			{space}*#(.*\\{space})*.*{newl
*** 811,818 ****
  <C>"/"				{ return('/'); }
  <C>"+"				{ return('+'); }
  <C>"-"				{ return('-'); }
! <C>"("				{ return('('); }
! <C>")"				{ return(')'); }
  <C,xskip>{space}		{ ECHO; }
  <C>\{				{ return('{'); }
  <C>\}				{ return('}'); }
--- 824,831 ----
  <C>"/"				{ return('/'); }
  <C>"+"				{ return('+'); }
  <C>"-"				{ return('-'); }
! <C>"("				{ parenths_open++; return('('); }
! <C>")"				{ parenths_open--; return(')'); }
  <C,xskip>{space}		{ ECHO; }
  <C>\{				{ return('{'); }
  <C>\}				{ return('}'); }
*************** void
*** 1178,1183 ****
--- 1191,1198 ----
  lex_init(void)
  {
  	braces_open = 0;
+ 	parenths_open = 0;
+ 	current_function = NULL;
  
  	preproc_tos = 0;
  	yylineno = 1;
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/type.c pgsql.4/src/interfaces/ecpg/preproc/type.c
*** pgsql.3/src/interfaces/ecpg/preproc/type.c	2009-11-16 11:07:02.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/preproc/type.c	2009-11-16 11:35:10.000000000 +0100
*************** ECPGstruct_member_dup(struct ECPGstruct_
*** 46,52 ****
  		{
  			case ECPGt_struct:
  			case ECPGt_union:
! 				type = ECPGmake_struct_type(rm->type->u.members, rm->type->type, rm->type->struct_sizeof);
  				break;
  			case ECPGt_array:
  
--- 46,52 ----
  		{
  			case ECPGt_struct:
  			case ECPGt_union:
! 				type = ECPGmake_struct_type(rm->type->u.members, rm->type->type, rm->type->type_name, rm->type->struct_sizeof);
  				break;
  			case ECPGt_array:
  
*************** ECPGstruct_member_dup(struct ECPGstruct_
*** 55,61 ****
  				 * create the struct too
  				 */
  				if (rm->type->u.element->type == ECPGt_struct)
! 					type = ECPGmake_struct_type(rm->type->u.element->u.members, rm->type->u.element->type, rm->type->u.element->struct_sizeof);
  				else
  					type = ECPGmake_array_type(ECPGmake_simple_type(rm->type->u.element->type, rm->type->u.element->size, rm->type->u.element->lineno), rm->type->size);
  				break;
--- 55,61 ----
  				 * create the struct too
  				 */
  				if (rm->type->u.element->type == ECPGt_struct)
! 					type = ECPGmake_struct_type(rm->type->u.element->u.members, rm->type->u.element->type, rm->type->u.element->type_name, rm->type->u.element->struct_sizeof);
  				else
  					type = ECPGmake_array_type(ECPGmake_simple_type(rm->type->u.element->type, rm->type->u.element->size, rm->type->u.element->lineno), rm->type->size);
  				break;
*************** ECPGmake_simple_type(enum ECPGttype type
*** 98,103 ****
--- 98,104 ----
  	struct ECPGtype *ne = (struct ECPGtype *) mm_alloc(sizeof(struct ECPGtype));
  
  	ne->type = type;
+ 	ne->type_name = NULL;
  	ne->size = size;
  	ne->u.element = NULL;
  	ne->struct_sizeof = NULL;
*************** ECPGmake_array_type(struct ECPGtype * ty
*** 117,126 ****
  }
  
  struct ECPGtype *
! ECPGmake_struct_type(struct ECPGstruct_member * rm, enum ECPGttype type, char *struct_sizeof)
  {
  	struct ECPGtype *ne = ECPGmake_simple_type(type, make_str("1"), 0);
  
  	ne->u.members = ECPGstruct_member_dup(rm);
  	ne->struct_sizeof = struct_sizeof;
  
--- 118,128 ----
  }
  
  struct ECPGtype *
! ECPGmake_struct_type(struct ECPGstruct_member * rm, enum ECPGttype type, char *type_name, char *struct_sizeof)
  {
  	struct ECPGtype *ne = ECPGmake_simple_type(type, make_str("1"), 0);
  
+ 	ne->type_name = mm_strdup(type_name);
  	ne->u.members = ECPGstruct_member_dup(rm);
  	ne->struct_sizeof = struct_sizeof;
  
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/type.h pgsql.4/src/interfaces/ecpg/preproc/type.h
*** pgsql.3/src/interfaces/ecpg/preproc/type.h	2009-06-13 18:25:05.000000000 +0200
--- pgsql.4/src/interfaces/ecpg/preproc/type.h	2009-11-16 11:35:10.000000000 +0100
*************** struct ECPGstruct_member
*** 17,22 ****
--- 17,23 ----
  struct ECPGtype
  {
  	enum ECPGttype type;
+ 	char	   *type_name;			/* For struct and union types it is the struct name */
  	char	   *size;			/* For array it is the number of elements. For
  								 * varchar it is the maxsize of the area. */
  	char	   *struct_sizeof;	/* For a struct this is the sizeof() type as
*************** void		ECPGmake_struct_member(char *, str
*** 36,42 ****
  struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, char *, int);
  struct ECPGtype *ECPGmake_varchar_type(enum ECPGttype, long);
  struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, char *);
! struct ECPGtype *ECPGmake_struct_type(struct ECPGstruct_member *, enum ECPGttype, char *);
  struct ECPGstruct_member *ECPGstruct_member_dup(struct ECPGstruct_member *);
  
  /* Frees a type. */
--- 37,43 ----
  struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, char *, int);
  struct ECPGtype *ECPGmake_varchar_type(enum ECPGttype, long);
  struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, char *);
! struct ECPGtype *ECPGmake_struct_type(struct ECPGstruct_member *, enum ECPGttype, char *, char *);
  struct ECPGstruct_member *ECPGstruct_member_dup(struct ECPGstruct_member *);
  
  /* Frees a type. */
*************** struct _include_path
*** 123,133 ****
--- 124,137 ----
  struct cursor
  {
  	char	   *name;
+ 	char	   *function;
  	char	   *command;
  	char	   *connection;
  	bool		opened;
  	struct arguments *argsinsert;
+ 	struct arguments *argsinsert_oos;
  	struct arguments *argsresult;
+ 	struct arguments *argsresult_oos;
  	struct cursor *next;
  };
  
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/variable.c pgsql.4/src/interfaces/ecpg/preproc/variable.c
*** pgsql.3/src/interfaces/ecpg/preproc/variable.c	2009-11-16 10:44:18.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/preproc/variable.c	2009-11-16 11:35:10.000000000 +0100
*************** find_struct_member(char *name, char *str
*** 47,53 ****
  						return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->type, members->type->u.element->size, members->type->u.element->lineno), members->type->size), brace_level));
  					case ECPGt_struct:
  					case ECPGt_union:
! 						return (new_variable(name, ECPGmake_struct_type(members->type->u.members, members->type->type, members->type->struct_sizeof), brace_level));
  					default:
  						return (new_variable(name, ECPGmake_simple_type(members->type->type, members->type->size, members->type->lineno), brace_level));
  				}
--- 47,53 ----
  						return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->type, members->type->u.element->size, members->type->u.element->lineno), members->type->size), brace_level));
  					case ECPGt_struct:
  					case ECPGt_union:
! 						return (new_variable(name, ECPGmake_struct_type(members->type->u.members, members->type->type, members->type->type_name, members->type->struct_sizeof), brace_level));
  					default:
  						return (new_variable(name, ECPGmake_simple_type(members->type->type, members->type->size, members->type->lineno), brace_level));
  				}
*************** find_struct_member(char *name, char *str
*** 94,100 ****
  								return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->u.element->type, members->type->u.element->u.element->size, members->type->u.element->u.element->lineno), members->type->u.element->size), brace_level));
  							case ECPGt_struct:
  							case ECPGt_union:
! 								return (new_variable(name, ECPGmake_struct_type(members->type->u.element->u.members, members->type->u.element->type, members->type->u.element->struct_sizeof), brace_level));
  							default:
  								return (new_variable(name, ECPGmake_simple_type(members->type->u.element->type, members->type->u.element->size, members->type->u.element->lineno), brace_level));
  						}
--- 94,100 ----
  								return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->u.element->type, members->type->u.element->u.element->size, members->type->u.element->u.element->lineno), members->type->u.element->size), brace_level));
  							case ECPGt_struct:
  							case ECPGt_union:
! 								return (new_variable(name, ECPGmake_struct_type(members->type->u.element->u.members, members->type->u.element->type, members->type->u.element->type_name, members->type->u.element->struct_sizeof), brace_level));
  							default:
  								return (new_variable(name, ECPGmake_simple_type(members->type->u.element->type, members->type->u.element->size, members->type->u.element->lineno), brace_level));
  						}
*************** find_variable(char *name)
*** 235,241 ****
  						return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(p->type->u.element->u.element->type, p->type->u.element->u.element->size, p->type->u.element->u.element->lineno), p->type->u.element->size), p->brace_level));
  					case ECPGt_struct:
  					case ECPGt_union:
! 						return (new_variable(name, ECPGmake_struct_type(p->type->u.element->u.members, p->type->u.element->type, p->type->u.element->struct_sizeof), p->brace_level));
  					default:
  						return (new_variable(name, ECPGmake_simple_type(p->type->u.element->type, p->type->u.element->size, p->type->u.element->lineno), p->brace_level));
  				}
--- 235,241 ----
  						return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(p->type->u.element->u.element->type, p->type->u.element->u.element->size, p->type->u.element->u.element->lineno), p->type->u.element->size), p->brace_level));
  					case ECPGt_struct:
  					case ECPGt_union:
! 						return (new_variable(name, ECPGmake_struct_type(p->type->u.element->u.members, p->type->u.element->type, p->type->u.element->type_name, p->type->u.element->struct_sizeof), p->brace_level));
  					default:
  						return (new_variable(name, ECPGmake_simple_type(p->type->u.element->type, p->type->u.element->size, p->type->u.element->lineno), p->brace_level));
  				}
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/compat_informix/Makefile pgsql.4/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.3/src/interfaces/ecpg/test/compat_informix/Makefile	2009-11-16 11:24:24.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/compat_informix/Makefile	2009-11-16 11:35:10.000000000 +0100
*************** TESTS = test_informix test_informix.c \
*** 14,19 ****
--- 14,21 ----
          test_informix2 test_informix2.c \
          cursor cursor.c \
          describe describe.c \
+         struct struct.c \
+         outofscope outofscope.c \
          dec_test dec_test.c \
          rfmtdate rfmtdate.c \
          rfmtlong rfmtlong.c \
*************** describe.c: describe.pgc ../regression.h
*** 38,43 ****
--- 40,51 ----
  sqlda.c: sqlda.pgc ../regression.h
  	$(ECPG) -o $@ -I$(srcdir) $<
  
+ struct.c: struct.pgc ../regression.h
+ 	$(ECPG) -o $@ -I$(srcdir) $<
+ 
+ outofscope.c: outofscope.pgc ../regression.h
+ 	$(ECPG) -o $@ -I$(srcdir) $<
+ 
  dec_test.c: dec_test.pgc ../regression.h
  	$(ECPG) -o $@ -I$(srcdir) $<
  
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/compat_informix/outofscope.pgc pgsql.4/src/interfaces/ecpg/test/compat_informix/outofscope.pgc
*** pgsql.3/src/interfaces/ecpg/test/compat_informix/outofscope.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/compat_informix/outofscope.pgc	2009-11-16 11:35:10.000000000 +0100
***************
*** 0 ****
--- 1,256 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql include sqlda.h;
+ exec sql include sqltypes.h;
+ 
+ exec sql begin declare section;
+ exec sql include struct.h;
+ exec sql end declare section;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ /* Functions for test 1 */
+ 
+ static void
+ get_var1(MYTYPE **myvar0, MYNULLTYPE **mynullvar0)
+ {
+ 	exec sql begin declare section;
+ 	MYTYPE		*myvar = malloc(sizeof(MYTYPE));
+ 	MYNULLTYPE	*mynullvar = malloc(sizeof(MYNULLTYPE));
+ 	exec sql end declare section;
+ 
+ 	/* Test DECLARE ... SELECT ... INTO with pointers */
+ 
+ 	exec sql declare mycur cursor for select * INTO :myvar :mynullvar from a1;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ 
+ 	*myvar0 = myvar;
+ 	*mynullvar0 = mynullvar;
+ }
+ 
+ static void
+ open_cur1(void)
+ {
+ 	exec sql open mycur;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ get_record1(void)
+ {
+ 	exec sql fetch mycur;
+ 
+ 	if (sqlca.sqlcode != 0 && sqlca.sqlcode != SQLNOTFOUND)
+ 		exit(1);
+ }
+ 
+ static void
+ close_cur1(void)
+ {
+ 	exec sql close mycur;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ /* Functions for test 2 */
+ 
+ pg_sqlda_t	*inp_sqlda, *outp_sqlda;
+ 
+ exec sql begin declare section;
+ char	*stmt2 = "SELECT * FROM a1 WHERE id = ?";
+ char	*curname2 = "mycur";
+ int	id;
+ exec sql end declare section;
+ 
+ static void
+ prepare2(void)
+ {
+ 	exec sql prepare prepared_stmt from :stmt2;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ 
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 	id = 4;
+ }
+ 
+ static void
+ declare2(void)
+ {
+ 	exec sql declare :curname2 cursor for prepared_stmt;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ dealloc_prep2(void)
+ {
+ 	exec sql deallocate prepare prepared_stmt;
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ }
+ 
+ static void
+ open_cur2(void)
+ {
+ 	exec sql open :curname2 using descriptor inp_sqlda;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ close_cur2(void)
+ {
+ 	exec sql close :curname2;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ get_record2(void)
+ {
+ 	exec sql fetch :curname2 into descriptor outp_sqlda;
+ 
+ 	if (sqlca.sqlcode != 0 && sqlca.sqlcode != SQLNOTFOUND)
+ 		exit(1);
+ }
+ 
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (outp_sqlda->sqlvar[i].sqlind && *(outp_sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", outp_sqlda->sqlvar[i].sqlname);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case SQLCHAR:
+ 		case SQLVCHAR:
+ 		case SQLTEXT:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLSERIAL:
+ 		case SQLINT:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLSERIAL8:
+ 		case SQLINT8:
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLFLOAT: 
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLDECIMAL:
+ 			{
+ 				char	val[64];
+ 				dectoasc((dec_t *)sqlda->sqlvar[i].sqldata, val, 64, -1);
+ 				printf("name sqlda descriptor: '%s' value DECIMAL '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ 	MYTYPE		*myvar;
+ 	MYNULLTYPE	*mynullvar;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table a1(id serial primary key, t text, d1 numeric, d2 float8, c character(10));
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, 'a', 1.0, 2, 'a');
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, null, null, null, null);
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, '"a"', -1.0, 'nan'::float8, 'a');
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, 'b', 2.0, 3, 'b');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE */
+ 
+ 	get_var1(&myvar, &mynullvar);
+ 	open_cur1();
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	while (1)
+ 	{
+ 		memset(myvar, 0, sizeof(MYTYPE));
+ 		get_record1();
+ 		if (sqlca.sqlcode == SQLNOTFOUND)
+ 			break;
+ 		printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+ 			myvar->id, mynullvar->id ? " (NULL)" : "",
+ 			myvar->t, mynullvar->t ? " (NULL)" : "",
+ 			myvar->d1, mynullvar->d1 ? " (NULL)" : "",
+ 			myvar->d2, mynullvar->d2 ? " (NULL)" : "",
+ 			myvar->c, mynullvar->c ? " (NULL)" : "");
+ 	}
+ 
+ 	close_cur1();
+ 
+ 	/* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE interaction
+ 	 * with a dynamic cursor and prepared statment using an sqlda
+ 	 */
+ 
+ 	prepare2();
+ 	declare2();
+ 	open_cur2();
+ 
+ 	get_record2();
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	close_cur2();
+ 	dealloc_prep2();
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table a1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/compat_informix/struct.h pgsql.4/src/interfaces/ecpg/test/compat_informix/struct.h
*** pgsql.3/src/interfaces/ecpg/test/compat_informix/struct.h	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/compat_informix/struct.h	2009-11-16 11:35:10.000000000 +0100
***************
*** 0 ****
--- 1,18 ----
+ 
+ struct mytype {
+ 	int	id;
+ 	char	t[64];
+ 	double	d1; /* dec_t */
+ 	double	d2;
+ 	char	c[30];
+ };
+ typedef struct mytype MYTYPE;
+ 
+ struct mynulltype {
+ 	int	id;
+ 	int	t;
+ 	int	d1;
+ 	int	d2;
+ 	int	c;
+ };
+ typedef struct mynulltype MYNULLTYPE;
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/compat_informix/struct.pgc pgsql.4/src/interfaces/ecpg/test/compat_informix/struct.pgc
*** pgsql.3/src/interfaces/ecpg/test/compat_informix/struct.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/compat_informix/struct.pgc	2009-11-16 11:35:10.000000000 +0100
***************
*** 0 ****
--- 1,76 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql begin declare section;
+ exec sql include struct.h;
+ exec sql end declare section;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ int
+ main (void)
+ {
+ 	exec sql begin declare section;
+ 	MYTYPE		myvar;
+ 	MYNULLTYPE	mynullvar;
+ 	exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table a1(id serial primary key, t text, d1 numeric, d2 float8, c character(10));
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, 'a', 1.0, 2, 'a');
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, null, null, null, null);
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, '"a"', -1.0, 'nan'::float8, 'a');
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, 'b', 2.0, 3, 'b');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* Test DECLARE ... SELECT ... INTO with struct type */
+ 
+ 	exec sql declare mycur cursor for select * into :myvar :mynullvar from a1;
+ 	exec sql open mycur;
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	while (1)
+ 	{
+ 		memset(&myvar, 0, sizeof(myvar));
+ 		exec sql fetch mycur;
+ 		printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+ 			myvar.id, mynullvar.id ? " (NULL)" : "",
+ 			myvar.t, mynullvar.t ? " (NULL)" : "",
+ 			myvar.d1, mynullvar.d1 ? " (NULL)" : "",
+ 			myvar.d2, mynullvar.d2 ? " (NULL)" : "",
+ 			myvar.c, mynullvar.c ? " (NULL)" : "");
+ 	}
+ 
+ 	exec sql close mycur;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table a1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/ecpg_schedule pgsql.4/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.3/src/interfaces/ecpg/test/ecpg_schedule	2009-11-16 11:24:24.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/ecpg_schedule	2009-11-16 11:35:10.000000000 +0100
*************** test: compat_informix/rnull
*** 6,11 ****
--- 6,13 ----
  test: compat_informix/cursor
  test: compat_informix/sqlda
  test: compat_informix/describe
+ test: compat_informix/struct
+ test: compat_informix/outofscope
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/ecpg_schedule_tcp pgsql.4/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.3/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-11-16 11:24:24.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-11-16 11:35:10.000000000 +0100
*************** test: compat_informix/rnull
*** 6,11 ****
--- 6,13 ----
  test: compat_informix/cursor
  test: compat_informix/sqlda
  test: compat_informix/describe
+ test: compat_informix/struct
+ test: compat_informix/outofscope
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-cursor.c pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-cursor.c
*** pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-cursor.c	2009-11-16 10:52:22.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-cursor.c	2009-11-16 11:35:10.000000000 +0100
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 162,168 ****
  
  	strcpy(msg, "open");
  	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
! 	ECPGt_char,&(*( char  *)(ECPG_informix_get_var( 0))),(long)0,(long)1,(1)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 62 "cursor.pgc"
  
--- 162,168 ----
  
  	strcpy(msg, "open");
  	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
! 	ECPGt_char,&(curname1),(long)0,(long)1,(1)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 62 "cursor.pgc"
  
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 298,308 ****
  
  	strcpy(msg, "open");
  	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
! 	ECPGt_char,&(*( char  *)(ECPG_informix_get_var( 3))),(long)0,(long)1,(1)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
! 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
! 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 103 "cursor.pgc"
  
--- 298,308 ----
  
  	strcpy(msg, "open");
  	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for select id , t from t1", 
! 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
! 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
! 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 103 "cursor.pgc"
  
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 314,322 ****
  	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from $0", 
  	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
! 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
! 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 106 "cursor.pgc"
  
--- 314,322 ----
  	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from $0", 
  	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
! 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
! 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 106 "cursor.pgc"
  
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 329,337 ****
  	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0", 
  	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
! 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
! 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 110 "cursor.pgc"
  
--- 329,337 ----
  	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0", 
  	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
! 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
! 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 110 "cursor.pgc"
  
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 344,352 ****
  	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0", 
  	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
! 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
! 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 114 "cursor.pgc"
  
--- 344,352 ----
  	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from $0", 
  	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
! 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
! 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 114 "cursor.pgc"
  
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 362,370 ****
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
  	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
! 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
! 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 119 "cursor.pgc"
  
--- 362,370 ----
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
  	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
! 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
! 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 119 "cursor.pgc"
  
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 377,385 ****
  	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0", 
  	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
! 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
! 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 123 "cursor.pgc"
  
--- 377,385 ----
  	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "move absolute 0 $0", 
  	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
! 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
! 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 123 "cursor.pgc"
  
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 391,399 ****
  	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 $0", 
  	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
! 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
! 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 126 "cursor.pgc"
  
--- 391,399 ----
  	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 $0", 
  	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
! 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
! 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 126 "cursor.pgc"
  
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 409,417 ****
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
  	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
! 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 2))),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
! 	ECPGt_char,(( char  *)(ECPG_informix_get_var( 1))),(long)64,(long)1,(64)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 131 "cursor.pgc"
  
--- 409,417 ----
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
  	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
! 	ECPGt_int,&(id),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
! 	ECPGt_char,(t),(long)64,(long)1,(64)*sizeof(char), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 131 "cursor.pgc"
  
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 441,447 ****
  
  
  	strcpy(msg, "declare");
! 	ECPG_informix_reset_sqlca(); /* declare $0 cursor for $1 */
  #line 143 "cursor.pgc"
  
  
--- 441,448 ----
  
  
  	strcpy(msg, "declare");
! 	ECPG_informix_set_var( 4, &( curname3 ), __LINE__);\
!  ECPG_informix_reset_sqlca(); /* declare $0 cursor for $1 */
  #line 143 "cursor.pgc"
  
  
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 596,602 ****
  
  
  	strcpy(msg, "declare");
! 	ECPG_informix_reset_sqlca(); /* declare $0 cursor for $1 */
  #line 193 "cursor.pgc"
  
  
--- 597,604 ----
  
  
  	strcpy(msg, "declare");
! 	ECPG_informix_set_var( 5, &( curname4 ), __LINE__);\
!  ECPG_informix_reset_sqlca(); /* declare $0 cursor for $1 */
  #line 193 "cursor.pgc"
  
  
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-outofscope.c pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-outofscope.c
*** pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-outofscope.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-outofscope.c	2009-11-16 11:35:10.000000000 +0100
***************
*** 0 ****
--- 1,629 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "outofscope.pgc"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 6 "outofscope.pgc"
+ 
+ 
+ 
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+ 
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+ 
+ /* Define Informix "standard" types */
+ #ifndef C_H
+ typedef int		int4;
+ typedef	short		int2;
+ #endif
+ typedef	char		int1;
+ 
+ typedef	int		mint;
+ typedef	long		mlong;
+ 
+ typedef	short		MSHORT;
+ typedef	char		MCHAR; 
+ 
+ typedef	unsigned int	uint4;
+ typedef	unsigned short	uint2;
+ typedef	unsigned char	uint1;
+ 
+ typedef	unsigned int	muint;
+ typedef	unsigned long	mulong;
+ 
+ typedef	unsigned short	MUSHORT;
+ typedef	unsigned char	MUCHAR; 
+ 
+ #define MI_INT_SIZE     (sizeof(int)    * 8)
+ #define MI_LONG_SIZE    (sizeof(long)   * 8)
+ #define MI_PTR_SIZE     (sizeof(char *) * 8)
+ 
+ typedef struct sqlvar_struct
+ {
+ 	int2	sqltype;		/* variable type                */
+ 	int4	sqllen;			/* length in bytes              */
+ 	char	   *sqldata;		/* pointer to data              */
+ 	int2	   *sqlind;		/* pointer to indicator         */
+ 	char	   *sqlname;		/* variable name                */
+ 	char	   *sqlformat;		/* reserved for future use      */
+ 	int2	sqlitype;		/* ind variable type            */
+ 	int2	sqlilen;		/* ind length in bytes          */
+ 	char	   *sqlidata;		/* ind data pointer             */
+ 	int4	sqlxid;			/* extended id type             */
+ 	char	   *sqltypename;	/* extended type name           */
+ 	int2	sqltypelen;		/* length of extended type name */
+ 	int2	sqlownerlen;		/* length of owner name         */
+ 	int2	sqlsourcetype;		/* source type for distinct of built-ins */
+ 	char	   *sqlownername;	/* owner name                   */
+ 	int4	sqlsourceid;		/* extended id of source type   */
+ 
+ 	/*
+ 	 * sqlilongdata is new.  It supports data that exceeds the 32k
+ 	 * limit.  sqlilen and sqlidata are for backward compatibility
+ 	 * and they have maximum value of <32K.
+ 	 */
+ 	char	   *sqlilongdata;	/* for data field beyond 32K    */
+ 	int4	sqlflags;		/* for internal use only        */
+ 	void	   *sqlreserved;	/* reserved for future use      */
+ } pg_sqlvar_t;
+ 
+ typedef struct sqlda
+ {
+ 	int2		sqld;
+ 	pg_sqlvar_t	   *sqlvar;
+ 	char		desc_name[19];	/* descriptor name              */
+ 	int2		desc_occ;	/* size of sqlda structure      */
+ 	struct sqlda	   *desc_next;	/* pointer to next sqlda struct */
+ 	void		   *reserved;	/* reserved for future use */
+ } pg_sqlda_t;
+ 
+ #endif /* POSTGRES_SQLDA_H */
+ 
+ #line 8 "outofscope.pgc"
+ 
+ 
+ #line 1 "sqltypes.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqltypes.h,v 1.9 2009/06/11 14:49:13 momjian Exp $
+  */
+ #ifndef ECPG_SQLTYPES_H
+ #define ECPG_SQLTYPES_H
+ 
+ #define CCHARTYPE	ECPGt_char
+ #define CSHORTTYPE	ECPGt_short
+ #define CINTTYPE	ECPGt_int
+ #define CLONGTYPE	ECPGt_long
+ #define CFLOATTYPE	ECPGt_float
+ #define CDOUBLETYPE ECPGt_double
+ #define CDECIMALTYPE	ECPGt_decimal
+ #define CFIXCHARTYPE	108
+ #define CSTRINGTYPE ECPGt_char
+ #define CDATETYPE	ECPGt_date
+ #define CMONEYTYPE	111
+ #define CDTIMETYPE	ECPGt_timestamp
+ #define CLOCATORTYPE	113
+ #define CVCHARTYPE	ECPGt_varchar
+ #define CINVTYPE	115
+ #define CFILETYPE	116
+ #define CINT8TYPE	ECPGt_long_long
+ #define CCOLLTYPE		118
+ #define CLVCHARTYPE		119
+ #define CFIXBINTYPE		120
+ #define CVARBINTYPE		121
+ #define CBOOLTYPE		ECPGt_bool
+ #define CROWTYPE		123
+ #define CLVCHARPTRTYPE	124
+ #define CTYPEMAX	25
+ 
+ /*
+  * Values used in sqlda->sqlvar[i]->sqltype
+  */
+ #define	SQLCHAR		0
+ #define	SQLSMINT	1
+ #define	SQLINT		2
+ #define	SQLFLOAT	3
+ #define	SQLSMFLOAT	4
+ #define	SQLDECIMAL	5
+ #define	SQLSERIAL	6
+ #define	SQLDATE		7
+ #define	SQLMONEY	8
+ #define	SQLDTIME	10
+ #define	SQLBYTES	11
+ #define	SQLTEXT		12
+ #define	SQLVCHAR	13
+ #define	SQLINTERVAL	14
+ #define	SQLNCHAR	15
+ #define	SQLNVCHAR	16
+ #define	SQLINT8		17
+ #define	SQLSERIAL8	18
+ 
+ #endif   /* ndef ECPG_SQLTYPES_H */
+ 
+ #line 9 "outofscope.pgc"
+ 
+ 
+ /* exec sql begin declare section */
+ 
+ #line 1 "struct.h"
+ 
+   
+ 		
+ 		
+ 		 /* dec_t */
+ 		
+ 		
+ 
+    typedef struct mytype  MYTYPE ;
+ 
+ #line 9 "struct.h"
+ 
+ 
+   
+ 		
+ 		
+ 		
+ 		
+ 		
+ 
+    typedef struct mynulltype  MYNULLTYPE ;
+ 
+ #line 18 "struct.h"
+ 
+ 
+ #line 12 "outofscope.pgc"
+ 
+ struct mytype { 
+ #line 3 "struct.h"
+  int id ;
+  
+ #line 4 "struct.h"
+  char t [ 64 ] ;
+  
+ #line 5 "struct.h"
+  double d1 ;
+  
+ #line 6 "struct.h"
+  double d2 ;
+  
+ #line 7 "struct.h"
+  char c [ 30 ] ;
+  } ; struct mynulltype { 
+ #line 12 "struct.h"
+  int id ;
+  
+ #line 13 "struct.h"
+  int t ;
+  
+ #line 14 "struct.h"
+  int d1 ;
+  
+ #line 15 "struct.h"
+  int d2 ;
+  
+ #line 16 "struct.h"
+  int c ;
+  } ;/* exec sql end declare section */
+ #line 13 "outofscope.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 15 "outofscope.pgc"
+ 
+ 
+ /* Functions for test 1 */
+ 
+ static void
+ get_var1(MYTYPE **myvar0, MYNULLTYPE **mynullvar0)
+ {
+ 	/* exec sql begin declare section */
+ 			  
+ 		  
+ 	
+ #line 23 "outofscope.pgc"
+  MYTYPE * myvar = malloc ( sizeof ( MYTYPE ) ) ;
+  
+ #line 24 "outofscope.pgc"
+  MYNULLTYPE * mynullvar = malloc ( sizeof ( MYNULLTYPE ) ) ;
+ /* exec sql end declare section */
+ #line 25 "outofscope.pgc"
+ 
+ 
+ 	/* Test DECLARE ... SELECT ... INTO with pointers */
+ 
+ 	ECPG_informix_set_var( 0, ( myvar ), __LINE__);\
+  ECPG_informix_set_var( 1, ( mynullvar ), __LINE__);\
+  ECPG_informix_reset_sqlca(); /* declare mycur cursor for select * from a1 */
+ #line 29 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ 
+ 	*myvar0 = myvar;
+ 	*mynullvar0 = mynullvar;
+ }
+ 
+ static void
+ open_cur1(void)
+ {
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT, 
+ 	ECPGt_int,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).t),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).d1),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).d1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).d2),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).d2),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).c),(long)30,(long)1,(30)*sizeof(char), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 41 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ get_record1(void)
+ {
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch mycur", ECPGt_EOIT, 
+ 	ECPGt_int,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).t),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).d1),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).d1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).d2),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).d2),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).c),(long)30,(long)1,(30)*sizeof(char), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 50 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 50 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0 && sqlca.sqlcode != SQLNOTFOUND)
+ 		exit(1);
+ }
+ 
+ static void
+ close_cur1(void)
+ {
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur", ECPGt_EOIT, ECPGt_EORT);
+ #line 59 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 59 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ /* Functions for test 2 */
+ 
+ pg_sqlda_t	*inp_sqlda, *outp_sqlda;
+ 
+ /* exec sql begin declare section */
+ 	  
+ 	  
+ 	
+ 
+ #line 70 "outofscope.pgc"
+  char * stmt2 = "SELECT * FROM a1 WHERE id = ?" ;
+  
+ #line 71 "outofscope.pgc"
+  char * curname2 = "mycur" ;
+  
+ #line 72 "outofscope.pgc"
+  int id ;
+ /* exec sql end declare section */
+ #line 73 "outofscope.pgc"
+ 
+ 
+ static void
+ prepare2(void)
+ {
+ 	{ ECPGprepare(__LINE__, NULL, 0, "prepared_stmt", stmt2);
+ #line 78 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 78 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ 
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 	id = 4;
+ }
+ 
+ static void
+ declare2(void)
+ {
+ 	ECPG_informix_reset_sqlca(); /* declare $0 cursor for $1 */
+ #line 97 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ dealloc_prep2(void)
+ {
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "prepared_stmt");
+ #line 106 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 106 "outofscope.pgc"
+ 
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ }
+ 
+ static void
+ open_cur2(void)
+ {
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for $1", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "prepared_stmt", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_sqlda, & inp_sqlda , 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 116 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 116 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ close_cur2(void)
+ {
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 125 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 125 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ get_record2(void)
+ {
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_sqlda, & outp_sqlda , 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 134 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 134 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0 && sqlca.sqlcode != SQLNOTFOUND)
+ 		exit(1);
+ }
+ 
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (outp_sqlda->sqlvar[i].sqlind && *(outp_sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", outp_sqlda->sqlvar[i].sqlname);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case SQLCHAR:
+ 		case SQLVCHAR:
+ 		case SQLTEXT:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLSERIAL:
+ 		case SQLINT:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLSERIAL8:
+ 		case SQLINT8:
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLFLOAT: 
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLDECIMAL:
+ 			{
+ 				char	val[64];
+ 				dectoasc((decimal *)sqlda->sqlvar[i].sqldata, val, 64, -1);
+ 				printf("name sqlda descriptor: '%s' value DECIMAL '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ 	MYTYPE		*myvar;
+ 	MYNULLTYPE	*mynullvar;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0); 
+ #line 190 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 190 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 193 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 193 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
+ #line 196 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 196 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 199 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 199 "outofscope.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null )", ECPGt_EOIT, ECPGt_EORT);
+ #line 200 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 200 "outofscope.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , '\"a\"' , - 1.0 , 'nan' :: float8 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 201 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 201 "outofscope.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 202 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 202 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 205 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 205 "outofscope.pgc"
+ 
+ 
+ 	/* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE */
+ 
+ 	get_var1(&myvar, &mynullvar);
+ 	open_cur1();
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 212 "outofscope.pgc"
+ 
+ 
+ 	while (1)
+ 	{
+ 		memset(myvar, 0, sizeof(MYTYPE));
+ 		get_record1();
+ 		if (sqlca.sqlcode == SQLNOTFOUND)
+ 			break;
+ 		printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+ 			myvar->id, mynullvar->id ? " (NULL)" : "",
+ 			myvar->t, mynullvar->t ? " (NULL)" : "",
+ 			myvar->d1, mynullvar->d1 ? " (NULL)" : "",
+ 			myvar->d2, mynullvar->d2 ? " (NULL)" : "",
+ 			myvar->c, mynullvar->c ? " (NULL)" : "");
+ 	}
+ 
+ 	close_cur1();
+ 
+ 	/* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE interaction
+ 	 * with a dynamic cursor and prepared statment using an sqlda
+ 	 */
+ 
+ 	prepare2();
+ 	declare2();
+ 	open_cur2();
+ 
+ 	get_record2();
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	close_cur2();
+ 	dealloc_prep2();
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table a1", ECPGt_EOIT, ECPGt_EORT);
+ #line 247 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 247 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 250 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 250 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 253 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 253 "outofscope.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stderr pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stderr
*** pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stderr	2009-11-16 11:35:10.000000000 +0100
***************
*** 0 ****
--- 1,170 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 193: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 193: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 193: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: query: create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 200: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 200: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 200: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 201: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , '"a"' , - 1.0 , 'nan' :: float8 , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 201: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 201: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 202: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 202: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 202: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 205: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: query: declare mycur cursor for select * from a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: "a" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: -1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 2.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: b          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 50: no data found on line 50
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 59: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 59: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 59: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 78: name prepared_stmt; query: "SELECT * FROM a1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: query: declare mycur cursor for SELECT * FROM a1 WHERE id = $1; with 1 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: using PQexecParams
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 116: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 134: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 134: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 134: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 134: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 134: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 134: RESULT: 2.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 134: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 134: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 125: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 125: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 125: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 106: name prepared_stmt
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 247: query: drop table a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 247: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 247: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 250: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stdout pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stdout
*** pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stdout	2009-11-16 11:35:10.000000000 +0100
***************
*** 0 ****
--- 1,9 ----
+ id=1 t='a' d1=1.000000 d2=2.000000 c = 'a         '
+ id=2 t='' (NULL) d1=0.000000 (NULL) d2=0.000000 (NULL) c = '' (NULL)
+ id=3 t='"a"' d1=-1.000000 d2=nan c = 'a         '
+ id=4 t='b' d1=2.000000 d2=3.000000 c = 'b         '
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'b'
+ name sqlda descriptor: 'd1' value DECIMAL '2.0'
+ name sqlda descriptor: 'd2' value 3.000000
+ name sqlda descriptor: 'c' value 'b         '
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-struct.c pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-struct.c
*** pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-struct.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-struct.c	2009-11-16 11:35:10.000000000 +0100
***************
*** 0 ****
--- 1,265 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "struct.pgc"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 5 "struct.pgc"
+ 
+ 
+ /* exec sql begin declare section */
+ 
+ #line 1 "struct.h"
+ 
+   
+ 		
+ 		
+ 		 /* dec_t */
+ 		
+ 		
+ 
+    typedef struct mytype  MYTYPE ;
+ 
+ #line 9 "struct.h"
+ 
+ 
+   
+ 		
+ 		
+ 		
+ 		
+ 		
+ 
+    typedef struct mynulltype  MYNULLTYPE ;
+ 
+ #line 18 "struct.h"
+ 
+ 
+ #line 8 "struct.pgc"
+ 
+ struct mytype { 
+ #line 3 "struct.h"
+  int id ;
+  
+ #line 4 "struct.h"
+  char t [ 64 ] ;
+  
+ #line 5 "struct.h"
+  double d1 ;
+  
+ #line 6 "struct.h"
+  double d2 ;
+  
+ #line 7 "struct.h"
+  char c [ 30 ] ;
+  } ; struct mynulltype { 
+ #line 12 "struct.h"
+  int id ;
+  
+ #line 13 "struct.h"
+  int t ;
+  
+ #line 14 "struct.h"
+  int d1 ;
+  
+ #line 15 "struct.h"
+  int d2 ;
+  
+ #line 16 "struct.h"
+  int c ;
+  } ;/* exec sql end declare section */
+ #line 9 "struct.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 11 "struct.pgc"
+ 
+ 
+ int
+ main (void)
+ {
+ 	/* exec sql begin declare section */
+ 			
+ 		
+ 	
+ #line 17 "struct.pgc"
+  MYTYPE myvar ;
+  
+ #line 18 "struct.pgc"
+  MYNULLTYPE mynullvar ;
+ /* exec sql end declare section */
+ #line 19 "struct.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0); 
+ #line 26 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 26 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 29 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 29 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
+ #line 32 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 32 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 35 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 35 "struct.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null )", ECPGt_EOIT, ECPGt_EORT);
+ #line 36 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "struct.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , '\"a\"' , - 1.0 , 'nan' :: float8 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 37 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "struct.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 38 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 41 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "struct.pgc"
+ 
+ 
+ 	/* Test DECLARE ... SELECT ... INTO with struct type */
+ 
+ 	ECPG_informix_set_var( 0, &( myvar ), __LINE__);\
+  ECPG_informix_set_var( 1, &( mynullvar ), __LINE__);\
+  ECPG_informix_reset_sqlca(); /* declare mycur cursor for select * from a1 */
+ #line 45 "struct.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT, 
+ 	ECPGt_int,&(myvar.id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&(mynullvar.id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&(myvar.t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_int,&(mynullvar.t),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&(myvar.d1),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&(mynullvar.d1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&(myvar.d2),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&(mynullvar.d2),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&(myvar.c),(long)30,(long)1,(30)*sizeof(char), 
+ 	ECPGt_int,&(mynullvar.c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 46 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 46 "struct.pgc"
+ 
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 48 "struct.pgc"
+ 
+ 
+ 	while (1)
+ 	{
+ 		memset(&myvar, 0, sizeof(myvar));
+ 		{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch mycur", ECPGt_EOIT, 
+ 	ECPGt_int,&(myvar.id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&(mynullvar.id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&(myvar.t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_int,&(mynullvar.t),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&(myvar.d1),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&(mynullvar.d1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&(myvar.d2),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&(mynullvar.d2),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&(myvar.c),(long)30,(long)1,(30)*sizeof(char), 
+ 	ECPGt_int,&(mynullvar.c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 53 "struct.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 53 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 53 "struct.pgc"
+ 
+ 		printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+ 			myvar.id, mynullvar.id ? " (NULL)" : "",
+ 			myvar.t, mynullvar.t ? " (NULL)" : "",
+ 			myvar.d1, mynullvar.d1 ? " (NULL)" : "",
+ 			myvar.d2, mynullvar.d2 ? " (NULL)" : "",
+ 			myvar.c, mynullvar.c ? " (NULL)" : "");
+ 	}
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur", ECPGt_EOIT, ECPGt_EORT);
+ #line 62 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 62 "struct.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table a1", ECPGt_EOIT, ECPGt_EORT);
+ #line 67 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 67 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 70 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 70 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 73 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 73 "struct.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-struct.stderr pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-struct.stderr
*** pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-struct.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-struct.stderr	2009-11-16 11:35:10.000000000 +0100
***************
*** 0 ****
--- 1,136 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: query: create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , '"a"' , - 1.0 , 'nan' :: float8 , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 41: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 46: query: declare mycur cursor for select * from a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 46: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 46: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: "a" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: -1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 2.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: b          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 53: no data found on line 53
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 62: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 67: query: drop table a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 67: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 67: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 70: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-struct.stdout pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-struct.stdout
*** pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-struct.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-struct.stdout	2009-11-16 11:35:10.000000000 +0100
***************
*** 0 ****
--- 1,4 ----
+ id=1 t='a' d1=1.000000 d2=2.000000 c = 'a         '
+ id=2 t='' (NULL) d1=0.000000 (NULL) d2=0.000000 (NULL) c = '' (NULL)
+ id=3 t='"a"' d1=-1.000000 d2=nan c = 'a         '
+ id=4 t='b' d1=2.000000 d2=3.000000 c = 'b         '
#66Michael Meskes
meskes@postgresql.org
In reply to: Boszormenyi Zoltan (#62)
Re: ECPG patch 1, dynamic cursorname

On Mon, Nov 16, 2009 at 11:58:04AM +0100, Boszormenyi Zoltan wrote:

I have rebased the ECPG patches to current CVS.
This mail contains the dynamic cursorname,
the fine-grained split-up was re-united as per
Alvaro's comment.

Rest of it committed to HEAD.

Thanks for your work.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ: 179140304, AIM/Yahoo/Skype: michaelmeskes, Jabber: meskes@jabber.org
VfL Borussia! Forca Barca! Go SF 49ers! Use: Debian GNU/Linux, PostgreSQL

#67Boszormenyi Zoltan
zb@cybertec.at
In reply to: Michael Meskes (#66)
Re: ECPG patch 1, dynamic cursorname

Michael Meskes �rta:

On Mon, Nov 16, 2009 at 11:58:04AM +0100, Boszormenyi Zoltan wrote:

I have rebased the ECPG patches to current CVS.
This mail contains the dynamic cursorname,
the fine-grained split-up was re-united as per
Alvaro's comment.

Rest of it committed to HEAD.

Thanks for your work.

Michael

Thanks very much for committing this.

Best regards,
Zolt�n B�sz�rm�nyi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

#68Jaime Casanova
jcasanov@systemguards.com.ec
In reply to: Boszormenyi Zoltan (#63)
Re: ECPG patch 2, SQLDA support

On Mon, Nov 16, 2009 at 5:59 AM, Boszormenyi Zoltan <zb@cybertec.at> wrote:

New version: rebased to current CVS.

This one no longer applies to HEAD, could you update it please?

--
Atentamente,
Jaime Casanova
Soporte y capacitación de PostgreSQL
Asesoría y desarrollo de sistemas
Guayaquil - Ecuador
Cel. +59387171157

#69Boszormenyi Zoltan
zb@cybertec.at
In reply to: Jaime Casanova (#68)
Re: ECPG patch 2, SQLDA support

Hi,

Jaime Casanova írta:

On Mon, Nov 16, 2009 at 5:59 AM, Boszormenyi Zoltan <zb@cybertec.at> wrote:

New version: rebased to current CVS.

This one no longer applies to HEAD, could you update it please?

Will post a new version soon, Michael asked to turn it
into an ECPG native feature instead of compat-mode-only.

Best regards,
Zoltán Böszörményi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

#70Boszormenyi Zoltan
zb@cybertec.at
In reply to: Boszormenyi Zoltan (#69)
1 attachment(s)
Re: ECPG patch 2, SQLDA support

Boszormenyi Zoltan írta:

Will post a new version soon, Michael asked to turn it
into an ECPG native feature instead of compat-mode-only.

Attached is the new version that applies cleanly to HEAD.

Changes:
- SQLDA is now an ECPG native feature, not compat-only.
- As a consequence, and to be coherent with the Informix syntax,
keyword "SQL" in SQL DESCRIPTOR is now mandatory
to denote the named SQL descriptor. "DESCRIPTOR"
without "SQL" means SQLDA descriptor
- SQLDA can now return more than one tuples using
the ->desc_next pointer
- Bcause SQLDA is now a native feature, there are two
sqlda.pgc regression tests, to test compat-only syntax in
compat mode and multi-tuple return values in native mode.
- sqlda->sqlvar[i].sqltype uses ECPGt_* type symbols,
no more funny-looking typedefs in sqltypes.h, it's a clean
compat-only header, as it was before

Best regards,
Zoltán Böszörményi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

Attachments:

2-pg85-sqlda-15-ctxdiff.patchtext/x-patch; name=2-pg85-sqlda-15-ctxdiff.patchDownload
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/execute.c pgsql.2/src/interfaces/ecpg/ecpglib/execute.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/execute.c	2009-09-03 14:37:34.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/ecpglib/execute.c	2009-12-14 12:41:24.000000000 +0100
***************
*** 25,30 ****
--- 25,31 ----
  #include "ecpgerrno.h"
  #include "extern.h"
  #include "sqlca.h"
+ #include "sqlda.h"
  #include "sql3types.h"
  #include "pgtypes_numeric.h"
  #include "pgtypes_date.h"
*************** ecpg_store_input(const int lineno, const
*** 1033,1038 ****
--- 1034,1040 ----
  				break;
  
  			case ECPGt_descriptor:
+ 			case ECPGt_sqlda:
  				break;
  
  			default:
*************** ecpg_execute(struct statement * stmt)
*** 1172,1177 ****
--- 1174,1234 ----
  			if (desc->count == desc_counter)
  				desc_counter = 0;
  		}
+ 		else if (var->type == ECPGt_sqlda)
+ 		{
+ 			pg_sqlda_t	   *sqlda = *(pg_sqlda_t **)var->pointer;
+ 			struct variable	desc_inlist;
+ 			int		i;
+ 
+ 			if (sqlda == NULL)
+ 				return false;
+ 
+ 			desc_counter++;
+ 			for (i = 0; i < sqlda->sqld; i++)
+ 			{
+ 				if (i + 1 == desc_counter)
+ 				{
+ 					desc_inlist.type = sqlda->sqlvar[i].sqltype;
+ 					desc_inlist.value = sqlda->sqlvar[i].sqldata;
+ 					desc_inlist.pointer = &(sqlda->sqlvar[i].sqldata);
+ 					switch (desc_inlist.type)
+ 					{
+ 						case ECPGt_char:
+ 						case ECPGt_varchar:
+ 							desc_inlist.varcharsize = strlen(sqlda->sqlvar[i].sqldata);
+ 							break;
+ 						default:
+ 							desc_inlist.varcharsize = 0;
+ 							break;
+ 					}
+ 					desc_inlist.arrsize = 1;
+ 					desc_inlist.offset = 0;
+ 					if (sqlda->sqlvar[i].sqlind)
+ 					{
+ 						desc_inlist.ind_type = ECPGt_short;
+ 						/* ECPG expects indicator value < 0 */
+ 						if (*(sqlda->sqlvar[i].sqlind))
+ 							*(sqlda->sqlvar[i].sqlind) = -1;
+ 						desc_inlist.ind_value = sqlda->sqlvar[i].sqlind;
+ 						desc_inlist.ind_pointer = &(sqlda->sqlvar[i].sqlind);
+ 						desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = 1;
+ 						desc_inlist.ind_offset = 0;
+ 					}
+ 					else
+ 					{
+ 						desc_inlist.ind_type = ECPGt_NO_INDICATOR;
+ 						desc_inlist.ind_value = desc_inlist.ind_pointer = NULL;
+ 						desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = desc_inlist.ind_offset = 0;
+ 					}
+ 					if (!ecpg_store_input(stmt->lineno, stmt->force_indicator, &desc_inlist, &tobeinserted, false))
+ 						return false;
+ 
+ 					break;
+ 				}
+ 			}
+ 			if (sqlda->sqld == desc_counter)
+ 				desc_counter = 0;
+ 		}
  		else
  		{
  			if (!ecpg_store_input(stmt->lineno, stmt->force_indicator, var, &tobeinserted, false))
*************** ecpg_execute(struct statement * stmt)
*** 1353,1358 ****
--- 1410,1460 ----
  				}
  				var = var->next;
  			}
+ 			else if (var != NULL && var->type == ECPGt_sqlda)
+ 			{
+ 				pg_sqlda_t	  **_sqlda = (pg_sqlda_t **)var->pointer;
+ 				pg_sqlda_t	   *sqlda = *_sqlda;
+ 				pg_sqlda_t	   *sqlda_new, *sqlda_new1;
+ 				int		i;
+ 
+ 				sqlda_new1 = NULL;
+ 				for (i = ntuples - 1; i >= 0; i--)
+ 				{
+ 					/* Build a new sqlda structure. Note that only fetching 1 record is supported */
+ 					sqlda_new = ecpg_build_sqlda_for_PGresult(stmt->lineno, results, i, stmt->compat);
+ 
+ 					if (!sqlda_new)
+ 					{
+ 						ecpg_log("ecpg_execute on line %d: out of memory allocating a new sqlda\n", stmt->lineno);
+ 						status = false;
+ 						break;
+ 					}
+ 					else
+ 					{
+ 						ecpg_log("ecpg_execute on line %d: new sqlda was built\n", stmt->lineno);
+ 
+ 						/* If we are passed in a previously existing sqlda then free it. */
+ 						if (sqlda)
+ 						{
+ 							if (sqlda->sqlvar != (pg_sqlvar_t *)(sqlda + 1))
+ 								free(sqlda->sqlvar);
+ 							free(sqlda);
+ 							sqlda = NULL;
+ 						}
+ 
+ 						*_sqlda = sqlda_new;
+ 
+ 						ecpg_set_sqlda_from_PGresult(stmt->lineno, _sqlda, results, i, stmt->compat);
+ 						ecpg_log("ecpg_execute on line %d: putting result (1 tuple %d fields) into sqlda descriptor\n",
+ 								stmt->lineno, PQnfields(results));
+ 
+ 						sqlda_new->desc_next = sqlda_new1;
+ 						sqlda_new1 = sqlda_new;
+ 					}
+ 				}
+ 
+ 				var = var->next;
+ 			}
  			else
  				for (act_field = 0; act_field < nfields && status; act_field++)
  				{
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/extern.h pgsql.2/src/interfaces/ecpg/ecpglib/extern.h
*** pgsql.orig/src/interfaces/ecpg/ecpglib/extern.h	2009-05-25 12:08:48.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/ecpglib/extern.h	2009-12-14 12:41:24.000000000 +0100
***************
*** 6,11 ****
--- 6,12 ----
  #include "postgres_fe.h"
  #include "libpq-fe.h"
  #include "sqlca.h"
+ #include "sqlda.h"
  #include "ecpg_config.h"
  #ifndef CHAR_BIT
  #include <limits.h>
*************** bool		ecpg_init(const struct connection 
*** 129,134 ****
--- 130,136 ----
  char	   *ecpg_strdup(const char *, int);
  const char *ecpg_type_name(enum ECPGttype);
  int			ecpg_dynamic_type(Oid);
+ int			sqlda_dynamic_type(Oid, enum COMPAT_MODE);
  void		ecpg_free_auto_mem(void);
  void		ecpg_clear_auto_mem(void);
  
*************** void		ecpg_log(const char *format,...);
*** 149,154 ****
--- 151,159 ----
  bool		ecpg_auto_prepare(int, const char *, const int, char **, const char *);
  void		ecpg_init_sqlca(struct sqlca_t * sqlca);
  
+ pg_sqlda_t *ecpg_build_sqlda_for_PGresult(int, PGresult *, int, enum COMPAT_MODE);
+ void		ecpg_set_sqlda_from_PGresult(int, pg_sqlda_t **, const PGresult *, int, enum COMPAT_MODE);
+ 
  /* SQLSTATE values generated or processed by ecpglib (intentionally
   * not exported -- users should refer to the codes directly) */
  
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/Makefile pgsql.2/src/interfaces/ecpg/ecpglib/Makefile
*** pgsql.orig/src/interfaces/ecpg/ecpglib/Makefile	2009-07-13 11:16:41.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/ecpglib/Makefile	2009-12-14 12:41:24.000000000 +0100
*************** override CFLAGS += $(PTHREAD_CFLAGS)
*** 24,30 ****
  # Need to recompile any libpgport object files
  LIBS := $(filter-out -lpgport, $(LIBS))
  
! OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
  	connect.o misc.o path.o pgstrcasecmp.o \
  	$(filter snprintf.o strlcpy.o, $(LIBOBJS))
  
--- 24,30 ----
  # Need to recompile any libpgport object files
  LIBS := $(filter-out -lpgport, $(LIBS))
  
! OBJS= execute.o typename.o descriptor.o sqlda.o data.o error.o prepare.o memory.o \
  	connect.o misc.o path.o pgstrcasecmp.o \
  	$(filter snprintf.o strlcpy.o, $(LIBOBJS))
  
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/sqlda.c pgsql.2/src/interfaces/ecpg/ecpglib/sqlda.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/sqlda.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/ecpglib/sqlda.c	2009-12-14 12:41:24.000000000 +0100
***************
*** 0 ****
--- 1,387 ----
+ /*
+  * SQLDA support routines
+  *
+  * The allocated memory area pointed by an sqlda pointer
+  * contains both the metadata and the data, so freeing up
+  * is a simple free(sqlda) as expected by the ESQL/C examples.
+  */
+ 
+ #define POSTGRES_ECPG_INTERNAL
+ #include "postgres_fe.h"
+ #include "pg_type.h"
+ 
+ #include <inttypes.h>
+ #include <dlfcn.h>
+ 
+ #include "ecpg-pthread-win32.h"
+ #include "decimal.h"
+ #include "ecpgtype.h"
+ #include "ecpglib.h"
+ #include "ecpgerrno.h"
+ #include "extern.h"
+ #include "sqlca.h"
+ #include "sqlda.h"
+ 
+ /*
+  * Compute the next variable's offset with
+  * the current variable's size and alignment.
+  * 
+  *
+  * Returns:
+  * - the current variable's offset in *current
+  * - the next variable's offset in *next
+  */
+ static void
+ ecpg_sqlda_align_add_size(long offset, int alignment, int size, long *current, long *next)
+ {
+ 	if (offset % alignment)
+ 		offset += alignment - (offset % alignment);
+ 	if (current)
+ 		*current = offset;
+ 	offset += size;
+ 	if (next)
+ 		*next = offset;
+ }
+ 
+ static long
+ ecpg_sqlda_empty_size(const PGresult *res)
+ {
+ 	long	offset;
+ 	int	i;
+ 	int	sqld = PQnfields(res);
+ 
+ 	/* Initial size to store main structure and field structures */
+ 	offset = sizeof(pg_sqlda_t) + sqld * sizeof(pg_sqlvar_t);
+ 
+ 	/* Add space for field names */
+ 	for (i = 0; i < sqld; i++)
+ 		offset += strlen(PQfname(res, i)) + 1;
+ 
+ 	/* Add padding to the first field value */
+ 	ecpg_sqlda_align_add_size(offset, sizeof(int), 0, &offset, NULL);
+ 
+ 	return offset;
+ }
+ 
+ static long
+ ecpg_sqlda_total_size(const PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ 	int	i;
+ 	int	sqld = PQnfields(res);
+ 	long	offset, next_offset;
+ 
+ 	offset = ecpg_sqlda_empty_size(res);
+ 
+ 	if (row < 0)
+ 		return offset;
+ 
+ 	/* Add space for the field values */
+ 	for (i = 0; i < sqld; i++)
+ 	{
+ 		enum ECPGttype type = sqlda_dynamic_type(PQftype(res, i), compat);
+ 		switch (type)
+ 		{
+ 			case ECPGt_short:
+ 			case ECPGt_unsigned_short:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_int:
+ 			case ECPGt_unsigned_int:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_long:
+ 			case ECPGt_unsigned_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_long_long:
+ 			case ECPGt_unsigned_long_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_bool:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_float:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_double:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_decimal:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_numeric:
+ 				/*
+ 				 * Let's align both the numeric struct and the digits array to int
+ 				 * Unfortunately we need to do double work here to compute the size
+ 				 * of the space needed for the numeric structure.
+ 				 */
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset1 %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				if (!PQgetisnull(res, row, i))
+ 				{
+ 					char	   *val = PQgetvalue(res, row, i);
+ 					numeric	   *num;
+ 
+ 					num = PGTYPESnumeric_from_asc(val, NULL);
+ 					if (!num)
+ 						break;
+ 					ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
+ 					ecpg_log("%s type %s offset2 %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 					PGTYPESnumeric_free(num);
+ 				}
+ 				break;
+ 			case ECPGt_date:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(date), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_timestamp:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(timestamp), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_interval:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(interval), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_char:
+ 			case ECPGt_unsigned_char:
+ 			case ECPGt_string:
+ 			default:
+ 			{
+ 				long	datalen = strlen(PQgetvalue(res, row, i)) + 1;
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			}
+ 		}
+ 		offset = next_offset;
+ 	}
+ 	return offset;
+ }
+ 
+ /*
+  * Build pg_sqlda_t (metadata only) from PGresult
+  * leaving enough space for the field values in
+  * the given row number
+  */
+ pg_sqlda_t *
+ ecpg_build_sqlda_for_PGresult(int line, PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ 	pg_sqlda_t *sqlda;
+ 	pg_sqlvar_t*sqlvar;
+ 	char	   *fname;
+ 	long		size;
+ 	int		sqld;
+ 	int		i;
+ 
+ 	size = ecpg_sqlda_total_size(res, row, compat);
+ 	sqlda = (pg_sqlda_t *)ecpg_alloc(size, line);
+ 	if (!sqlda)
+ 		return NULL;
+ 
+ 	memset(sqlda, 0, size);
+ 	sqlvar = (pg_sqlvar_t *)(sqlda + 1);
+ 	sqld = PQnfields(res);
+ 	fname = (char *)(sqlvar + sqld);
+ 
+ 	sqlda->sqld = sqld;
+ 	sqlda->desc_occ = size; /* cheat here, keep the full allocated size */
+ 	sqlda->sqlvar = sqlvar;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		sqlda->sqlvar[i].sqltype = sqlda_dynamic_type(PQftype(res, i), compat);
+ 		strcpy(fname, PQfname(res, i));
+ 		sqlda->sqlvar[i].sqlname = fname;
+ 		fname += strlen(sqlda->sqlvar[i].sqlname) + 1;
+ 		sqlda->sqlvar[i].sqlformat = (char *)(long)PQfformat(res, i);
+ 		sqlda->sqlvar[i].sqlxid = PQftype(res, i);
+ 		sqlda->sqlvar[i].sqltypelen = PQfsize(res, i);
+ 	}
+ 
+ 	return sqlda;
+ }
+ 
+ /*
+  * Sets values from PGresult.
+  */
+ static int2	value_is_null = -1;
+ static int2	value_is_not_null = 0;
+ 
+ void
+ ecpg_set_sqlda_from_PGresult(int lineno, pg_sqlda_t **_sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ 	pg_sqlda_t *sqlda = (*_sqlda);
+ 	int		i;
+ 	long		offset, next_offset;
+ 
+ 	/* Offset for the first field value */
+ 	offset = ecpg_sqlda_empty_size(res);
+ 
+ 	if (row < 0)
+ 		return;
+ 
+ 	/*
+ 	 * Set sqlvar[i]->sqldata pointers and convert values to correct format
+ 	 */
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		int	isnull;
+ 		int	datalen;
+ 		bool	set_data = true;
+ 
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 			case ECPGt_short:
+ 			case ECPGt_unsigned_short:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(short);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_int:
+ 			case ECPGt_unsigned_int:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(int);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_long:
+ 			case ECPGt_unsigned_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(long);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_long_long:
+ 			case ECPGt_unsigned_long_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(long long);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_bool:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(bool);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_float:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(float);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_double:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(double);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_decimal:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(decimal);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_numeric:
+ 			{
+ 				numeric	   *num;
+ 				char	   *val;
+ 
+ 				set_data = false;
+ 
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(numeric);
+ 				ecpg_log("%s type %s offset1 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 
+ 				if (PQgetisnull(res, row, i))
+ 				{
+ 					ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
+ 					break;
+ 				}
+ 
+ 				val = PQgetvalue(res, row, i);
+ 				num = PGTYPESnumeric_from_asc(val, NULL);
+ 				if (!num)
+ 				{
+ 					ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
+ 					break;
+ 				}
+ 
+ 				memcpy(sqlda->sqlvar[i].sqldata, num, sizeof(numeric));
+ 
+ 				ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
+ 				memcpy((char *)sqlda + offset, num->buf, num->ndigits + 1);
+ 				ecpg_log("%s type %s offset2 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 
+ 				((numeric *)sqlda->sqlvar[i].sqldata)->buf = (NumericDigit *)sqlda + offset;
+ 				((numeric *)sqlda->sqlvar[i].sqldata)->digits = (NumericDigit *)sqlda + offset + (num->digits - num->buf);
+ 
+ 				PGTYPESnumeric_free(num);
+ 
+ 				break;
+ 			}
+ 			case ECPGt_date:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(date), sizeof(date), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(date);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_timestamp:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(timestamp), sizeof(timestamp), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(timestamp);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_interval:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int64_t), sizeof(interval), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(interval);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_char:
+ 			case ECPGt_unsigned_char:
+ 			case ECPGt_string:
+ 			default:
+ 				datalen = strlen(PQgetvalue(res, row, i)) + 1;
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = datalen;
+ 				if (datalen > 32768)
+ 					sqlda->sqlvar[i].sqlilongdata = sqlda->sqlvar[i].sqldata;
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 		}
+ 
+ 		isnull = PQgetisnull(res, row, i);
+ 		ecpg_log("%s row %d col %d %s\n", __FUNCTION__, row, i, isnull ? "IS NULL" : "IS NOT NULL");
+ 		sqlda->sqlvar[i].sqlind = isnull ? &value_is_null : &value_is_not_null;
+ 		sqlda->sqlvar[i].sqlitype = ECPGt_short;
+ 		sqlda->sqlvar[i].sqlilen = sizeof(short);
+ 		if (!isnull)
+ 		{
+ 			if (set_data)
+ 				ecpg_get_data(res, row, i, lineno,
+ 						sqlda->sqlvar[i].sqltype, ECPGt_NO_INDICATOR,
+ 						sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
+ 						ECPG_ARRAY_NONE, ECPG_COMPAT_INFORMIX, false);
+ 		}
+ 		else
+ 		{
+ 			if (INFORMIX_MODE(compat))
+ 				ECPGset_noind_null(sqlda->sqlvar[i].sqltype, sqlda->sqlvar[i].sqldata);
+ 		}
+ 
+ 		offset = next_offset;
+ 	}
+ }
+ 
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/typename.c pgsql.2/src/interfaces/ecpg/ecpglib/typename.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/typename.c	2009-08-07 13:06:28.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/ecpglib/typename.c	2009-12-14 12:41:24.000000000 +0100
***************
*** 7,12 ****
--- 7,13 ----
  #include "ecpgtype.h"
  #include "ecpglib.h"
  #include "extern.h"
+ #include "sqltypes.h"
  #include "sql3types.h"
  #include "pg_type.h"
  
*************** ecpg_dynamic_type(Oid type)
*** 100,102 ****
--- 101,142 ----
  			return -(int) type;
  	}
  }
+ 
+ int
+ sqlda_dynamic_type(Oid type, enum COMPAT_MODE compat)
+ {
+ 	switch (type)
+ 	{
+ 		case CHAROID:
+ 		case VARCHAROID:
+ 		case BPCHAROID:
+ 		case TEXTOID:
+ 			return ECPGt_char;
+ 		case INT2OID:
+ 			return ECPGt_short;
+ 		case INT4OID:
+ 			return ECPGt_int;
+ 		case FLOAT8OID:
+ 			return ECPGt_double;
+ 		case FLOAT4OID:
+ 			return ECPGt_float;
+ 		case NUMERICOID:
+ 			return INFORMIX_MODE(compat) ? ECPGt_decimal : ECPGt_numeric;
+ 		case DATEOID:
+ 			return ECPGt_date;
+ 		case TIMESTAMPOID:
+ 		case TIMESTAMPTZOID:
+ 			return ECPGt_timestamp;
+ 		case INTERVALOID:
+ 			return ECPGt_interval;
+ 		case INT8OID:
+ #ifdef HAVE_LONG_LONG_INT_64
+ 			return ECPGt_long_long;
+ #endif
+ #ifdef HAVE_LONG_INT_64
+ 			return ECPGt_long;
+ #endif
+ 		default:
+ 			return (-type);
+ 	}
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/ecpgtype.h pgsql.2/src/interfaces/ecpg/include/ecpgtype.h
*** pgsql.orig/src/interfaces/ecpg/include/ecpgtype.h	2009-08-07 13:06:28.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/include/ecpgtype.h	2009-12-14 12:41:24.000000000 +0100
*************** enum ECPGttype
*** 62,68 ****
  	ECPGt_EOIT,					/* End of insert types. */
  	ECPGt_EORT,					/* End of result types. */
  	ECPGt_NO_INDICATOR,			/* no indicator */
! 	ECPGt_string                            /* trimmed (char *) type */
  };
  
   /* descriptor items */
--- 62,69 ----
  	ECPGt_EOIT,					/* End of insert types. */
  	ECPGt_EORT,					/* End of result types. */
  	ECPGt_NO_INDICATOR,			/* no indicator */
! 	ECPGt_string,				/* trimmed (char *) type */
! 	ECPGt_sqlda				/* C struct descriptor */
  };
  
   /* descriptor items */
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/Makefile pgsql.2/src/interfaces/ecpg/include/Makefile
*** pgsql.orig/src/interfaces/ecpg/include/Makefile	2009-10-27 20:36:17.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/include/Makefile	2009-12-14 12:41:24.000000000 +0100
*************** install: all installdirs install-headers
*** 14,21 ****
  
  .PHONY: install-headers
  ecpg_headers = ecpgerrno.h ecpglib.h ecpgtype.h sqlca.h sql3types.h ecpg_informix.h \
! 	pgtypes_error.h pgtypes_numeric.h pgtypes_timestamp.h pgtypes_date.h pgtypes_interval.h
! informix_headers = datetime.h decimal.h sqltypes.h sqlda.h
  
  install-headers: $(ecpg_headers) $(informix_headers)
  	$(INSTALL_DATA) $(addprefix $(srcdir)/,$(ecpg_headers)) '$(DESTDIR)$(includedir)/'
--- 14,22 ----
  
  .PHONY: install-headers
  ecpg_headers = ecpgerrno.h ecpglib.h ecpgtype.h sqlca.h sql3types.h ecpg_informix.h \
! 	pgtypes_error.h pgtypes_numeric.h pgtypes_timestamp.h pgtypes_date.h pgtypes_interval.h \
! 	sqlda.h
! informix_headers = datetime.h decimal.h sqltypes.h
  
  install-headers: $(ecpg_headers) $(informix_headers)
  	$(INSTALL_DATA) $(addprefix $(srcdir)/,$(ecpg_headers)) '$(DESTDIR)$(includedir)/'
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/sqlda.h pgsql.2/src/interfaces/ecpg/include/sqlda.h
*** pgsql.orig/src/interfaces/ecpg/include/sqlda.h	2009-06-13 18:25:05.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/include/sqlda.h	2009-12-14 12:41:24.000000000 +0100
***************
*** 1,3 ****
--- 1,49 ----
  /*
   * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
   */
+ 
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+ 
+ #include "ecpglib.h"
+ 
+ typedef struct sqlvar_struct
+ {
+ 	short	sqltype;		/* variable type                */
+ 	int	sqllen;			/* length in bytes              */
+ 	char	   *sqldata;		/* pointer to data              */
+ 	short	   *sqlind;		/* pointer to indicator         */
+ 	char	   *sqlname;		/* variable name                */
+ 	char	   *sqlformat;		/* reserved for future use      */
+ 	short	sqlitype;		/* ind variable type            */
+ 	short	sqlilen;		/* ind length in bytes          */
+ 	char	   *sqlidata;		/* ind data pointer             */
+ 	int	sqlxid;			/* extended id type             */
+ 	char	   *sqltypename;	/* extended type name           */
+ 	short	sqltypelen;		/* length of extended type name */
+ 	short	sqlownerlen;		/* length of owner name         */
+ 	short	sqlsourcetype;		/* source type for distinct of built-ins */
+ 	char	   *sqlownername;	/* owner name                   */
+ 	int	sqlsourceid;		/* extended id of source type   */
+ 
+ 	/*
+ 	 * sqlilongdata is new.  It supports data that exceeds the 32k
+ 	 * limit.  sqlilen and sqlidata are for backward compatibility
+ 	 * and they have maximum value of <32K.
+ 	 */
+ 	char	   *sqlilongdata;	/* for data field beyond 32K    */
+ 	int	sqlflags;		/* for internal use only        */
+ 	void	   *sqlreserved;	/* reserved for future use      */
+ } pg_sqlvar_t;
+ 
+ typedef struct sqlda
+ {
+ 	short		sqld;
+ 	pg_sqlvar_t	   *sqlvar;
+ 	char		desc_name[19];	/* descriptor name              */
+ 	short		desc_occ;	/* size of sqlda structure      */
+ 	struct sqlda	   *desc_next;	/* pointer to next sqlda struct */
+ 	void		   *reserved;	/* reserved for future use */
+ } pg_sqlda_t;
+ 
+ #endif /* POSTGRES_SQLDA_H */
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/sqltypes.h pgsql.2/src/interfaces/ecpg/include/sqltypes.h
*** pgsql.orig/src/interfaces/ecpg/include/sqltypes.h	2009-06-13 18:25:05.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/include/sqltypes.h	2009-12-14 12:41:24.000000000 +0100
***************
*** 4,9 ****
--- 4,11 ----
  #ifndef ECPG_SQLTYPES_H
  #define ECPG_SQLTYPES_H
  
+ #include <limits.h>
+ 
  #define CCHARTYPE	ECPGt_char
  #define CSHORTTYPE	ECPGt_short
  #define CINTTYPE	ECPGt_int
***************
*** 30,33 ****
--- 32,60 ----
  #define CLVCHARPTRTYPE	124
  #define CTYPEMAX	25
  
+ /*
+  * Values used in sqlda->sqlvar[i]->sqltype
+  */
+ #define	SQLCHAR		ECPGt_char
+ #define	SQLSMINT	ECPGt_short
+ #define	SQLINT		ECPGt_int
+ #define	SQLFLOAT	ECPGt_double
+ #define	SQLSMFLOAT	ECPGt_float
+ #define	SQLDECIMAL	ECPGt_decimal
+ #define	SQLSERIAL	ECPGt_int
+ #define	SQLDATE		ECPGt_date
+ #define	SQLDTIME	ECPGt_timestamp
+ #define	SQLTEXT		ECPGt_char
+ #define	SQLVCHAR	ECPGt_char
+ #define SQLINTERVAL     ECPGt_interval
+ #define	SQLNCHAR	ECPGt_char
+ #define	SQLNVCHAR	ECPGt_char
+ #if (LONG_BIT == 64)
+ #define	SQLINT8		ECPGt_long
+ #define	SQLSERIAL8	ECPGt_long
+ #else
+ #define	SQLINT8		ECPGt_long_long
+ #define	SQLSERIAL8	ECPGt_long_long
+ #endif
+ 
  #endif   /* ndef ECPG_SQLTYPES_H */
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/descriptor.c pgsql.2/src/interfaces/ecpg/preproc/descriptor.c
*** pgsql.orig/src/interfaces/ecpg/preproc/descriptor.c	2009-01-30 17:28:46.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/preproc/descriptor.c	2009-12-14 12:41:24.000000000 +0100
*************** descriptor_variable(const char *name, in
*** 326,328 ****
--- 326,347 ----
  	strlcpy(descriptor_names[input], name, sizeof(descriptor_names[input]));
  	return (struct variable *) & varspace[input];
  }
+ 
+ struct variable *
+ sqlda_variable(const char *name)
+ {
+ 	struct variable *p = (struct variable *) mm_alloc(sizeof(struct variable));
+ 
+ 	p->name = mm_strdup(name);
+ 	p->type = (struct ECPGtype *) mm_alloc(sizeof(struct ECPGtype));
+ 	p->type->type = ECPGt_sqlda;
+ 	p->type->size = NULL;
+ 	p->type->struct_sizeof = NULL;
+ 	p->type->u.element = NULL;
+ 	p->type->lineno = 0;
+ 	p->brace_level = 0;
+ 	p->next = NULL;
+ 
+ 	return p;
+ }
+ 
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.addons pgsql.2/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.addons	2009-11-29 10:14:36.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/preproc/ecpg.addons	2009-12-14 12:41:24.000000000 +0100
*************** ECPG: VariableShowStmtSHOWALL block
*** 408,436 ****
  		$$ = EMPTY;
  	}
  ECPG: FetchStmtMOVEfetch_args rule
! 	| FETCH fetch_args ecpg_into
  	{
  		$$ = cat2_str(make_str("fetch"), $2);
  	}
! 	| FETCH FORWARD cursor_name opt_ecpg_into
  	{
  		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
  		add_additional_variables($3, false);
  		$$ = cat_str(2, make_str("fetch forward"), cursor_marker);
  	}
! 	| FETCH FORWARD from_in cursor_name opt_ecpg_into
  	{
  		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
  		add_additional_variables($4, false);
  		$$ = cat_str(2, make_str("fetch forward from"), cursor_marker);
  	}
! 	| FETCH BACKWARD cursor_name opt_ecpg_into
  	{
  		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
  		add_additional_variables($3, false);
  		$$ = cat_str(2, make_str("fetch backward"), cursor_marker);
  	}
! 	| FETCH BACKWARD from_in cursor_name opt_ecpg_into
  	{
  		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
  		add_additional_variables($4, false);
--- 408,436 ----
  		$$ = EMPTY;
  	}
  ECPG: FetchStmtMOVEfetch_args rule
! 	| FETCH fetch_args ecpg_fetch_into
  	{
  		$$ = cat2_str(make_str("fetch"), $2);
  	}
! 	| FETCH FORWARD cursor_name opt_ecpg_fetch_into
  	{
  		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
  		add_additional_variables($3, false);
  		$$ = cat_str(2, make_str("fetch forward"), cursor_marker);
  	}
! 	| FETCH FORWARD from_in cursor_name opt_ecpg_fetch_into
  	{
  		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
  		add_additional_variables($4, false);
  		$$ = cat_str(2, make_str("fetch forward from"), cursor_marker);
  	}
! 	| FETCH BACKWARD cursor_name opt_ecpg_fetch_into
  	{
  		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
  		add_additional_variables($3, false);
  		$$ = cat_str(2, make_str("fetch backward"), cursor_marker);
  	}
! 	| FETCH BACKWARD from_in cursor_name opt_ecpg_fetch_into
  	{
  		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
  		add_additional_variables($4, false);
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.trailer pgsql.2/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.trailer	2009-11-26 18:57:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/preproc/ecpg.trailer	2009-12-14 12:41:24.000000000 +0100
*************** ecpg_using:	USING using_list 	{ $$ = EMP
*** 970,991 ****
  		| using_descriptor      { $$ = $1; }
  		;
  
! using_descriptor: USING opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
  		{
  			add_variable_to_head(&argsinsert, descriptor_variable($4,0), &no_indicator);
  			$$ = EMPTY;
  		}
  		;
  
! into_descriptor: INTO opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
  		{
  			add_variable_to_head(&argsresult, descriptor_variable($4,1), &no_indicator);
  			$$ = EMPTY;
  		}
  		;
  
- opt_sql: /*EMPTY*/ | SQL_SQL;
- 
  using_list: UsingValue | UsingValue ',' using_list;
  
  UsingValue: UsingConst
--- 970,999 ----
  		| using_descriptor      { $$ = $1; }
  		;
  
! using_descriptor: USING SQL_SQL SQL_DESCRIPTOR quoted_ident_stringvar
  		{
  			add_variable_to_head(&argsinsert, descriptor_variable($4,0), &no_indicator);
  			$$ = EMPTY;
  		}
+ 		| USING SQL_DESCRIPTOR name
+ 		{
+ 			add_variable_to_head(&argsinsert, sqlda_variable($3), &no_indicator);
+ 			$$ = EMPTY;
+ 		}
  		;
  
! into_descriptor: INTO SQL_SQL SQL_DESCRIPTOR quoted_ident_stringvar
  		{
  			add_variable_to_head(&argsresult, descriptor_variable($4,1), &no_indicator);
  			$$ = EMPTY;
  		}
+ 		| INTO SQL_DESCRIPTOR name
+ 		{
+ 			add_variable_to_head(&argsresult, sqlda_variable($3), &no_indicator);
+ 			$$ = EMPTY;
+ 		}
  		;
  
  using_list: UsingValue | UsingValue ',' using_list;
  
  UsingValue: UsingConst
*************** ecpg_into: INTO into_list	{ $$ = EMPTY; 
*** 1806,1813 ****
          | into_descriptor	{ $$ = $1; }
  	;
  
! opt_ecpg_into:	/* EMPTY */	{ $$ = EMPTY; }
! 	| ecpg_into		{ $$ = $1; }
  	;
  
  %%
--- 1814,1836 ----
          | into_descriptor	{ $$ = $1; }
  	;
  
! ecpg_fetch_into: ecpg_into	{ $$ = $1; }
! 	| using_descriptor
! 	{
! 		struct variable *var;
! 
! 		if (!INFORMIX_MODE)
! 			mmerror(PARSE_ERROR, ET_ERROR, "Not in Informix compatibility mode");
! 
! 		var = argsinsert->variable;
! 		remove_variable_from_list(&argsinsert, var);
! 		add_variable_to_head(&argsresult, var, &no_indicator);
! 		$$ = $1;
! 	}
! 	;
! 
! opt_ecpg_fetch_into:	/* EMPTY */	{ $$ = EMPTY; }
! 	| ecpg_fetch_into		{ $$ = $1; }
  	;
  
  %%
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.type pgsql.2/src/interfaces/ecpg/preproc/ecpg.type
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.type	2009-11-26 18:57:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/preproc/ecpg.type	2009-12-14 12:41:24.000000000 +0100
***************
*** 61,66 ****
--- 61,67 ----
  %type <str> ecpg_ident
  %type <str> ecpg_interval
  %type <str> ecpg_into
+ %type <str> ecpg_fetch_into
  %type <str> ecpg_param
  %type <str> ecpg_sconst
  %type <str> ecpg_using
***************
*** 76,82 ****
  %type <str> opt_bit_field
  %type <str> opt_connection_name
  %type <str> opt_database_name
! %type <str> opt_ecpg_into
  %type <str> opt_ecpg_using
  %type <str> opt_initializer
  %type <str> opt_options
--- 77,83 ----
  %type <str> opt_bit_field
  %type <str> opt_connection_name
  %type <str> opt_database_name
! %type <str> opt_ecpg_fetch_into
  %type <str> opt_ecpg_using
  %type <str> opt_initializer
  %type <str> opt_options
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/extern.h pgsql.2/src/interfaces/ecpg/preproc/extern.h
*** pgsql.orig/src/interfaces/ecpg/preproc/extern.h	2009-11-26 18:57:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/preproc/extern.h	2009-12-14 12:41:24.000000000 +0100
*************** extern void add_descriptor(char *, char 
*** 88,93 ****
--- 88,94 ----
  extern void drop_descriptor(char *, char *);
  extern struct descriptor *lookup_descriptor(char *, char *);
  extern struct variable *descriptor_variable(const char *name, int input);
+ extern struct variable *sqlda_variable(const char *name);
  extern void add_variable_to_head(struct arguments **, struct variable *, struct variable *);
  extern void add_variable_to_tail(struct arguments **, struct variable *, struct variable *);
  extern void remove_variable_from_list(struct arguments ** list, struct variable * var);
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/type.c pgsql.2/src/interfaces/ecpg/preproc/type.c
*** pgsql.orig/src/interfaces/ecpg/preproc/type.c	2009-09-03 12:25:47.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/preproc/type.c	2009-12-14 12:41:24.000000000 +0100
*************** get_type(enum ECPGttype type)
*** 194,199 ****
--- 194,202 ----
  		case ECPGt_descriptor:
  			return ("ECPGt_descriptor");
  			break;
+ 		case ECPGt_sqlda:
+ 			return ("ECPGt_sqlda");
+ 			break;
  		case ECPGt_date:
  			return ("ECPGt_date");
  			break;
*************** ECPGdump_a_simple(FILE *o, const char *n
*** 328,333 ****
--- 331,338 ----
  	else if (type == ECPGt_descriptor)
  		/* remember that name here already contains quotes (if needed) */
  		fprintf(o, "\n\tECPGt_descriptor, %s, 0L, 0L, 0L, ", name);
+ 	else if (type == ECPGt_sqlda)
+ 		fprintf(o, "\n\tECPGt_sqlda, &%s, 0L, 0L, 0L, ", name);
  	else
  	{
  		char	   *variable = (char *) mm_alloc(strlen(name) + ((prefix == NULL) ? 0 : strlen(prefix)) + 4);
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/compat_informix/Makefile pgsql.2/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.orig/src/interfaces/ecpg/test/compat_informix/Makefile	2006-09-19 17:36:08.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/test/compat_informix/Makefile	2009-12-14 12:41:24.000000000 +0100
*************** TESTS = test_informix test_informix.c \
*** 16,21 ****
--- 16,22 ----
          rfmtdate rfmtdate.c \
          rfmtlong rfmtlong.c \
          rnull rnull.c \
+         sqlda sqlda.c \
          charfuncs charfuncs.c
  
  all: $(TESTS)
*************** test_informix.c: test_informix.pgc ../re
*** 26,31 ****
--- 27,35 ----
  test_informix2.c: test_informix2.pgc ../regression.h
  	$(ECPG) -o $@ -I$(srcdir) $<
  
+ sqlda.c: sqlda.pgc ../regression.h
+ 	$(ECPG) -o $@ -I$(srcdir) $<
+ 
  dec_test.c: dec_test.pgc ../regression.h
  	$(ECPG) -o $@ -I$(srcdir) $<
  
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/compat_informix/sqlda.pgc pgsql.2/src/interfaces/ecpg/test/compat_informix/sqlda.pgc
*** pgsql.orig/src/interfaces/ecpg/test/compat_informix/sqlda.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/compat_informix/sqlda.pgc	2009-12-14 12:41:24.000000000 +0100
***************
*** 0 ****
--- 1,248 ----
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql include sqlda.h;
+ exec sql include sqltypes.h;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ /* These shouldn't be under DECLARE SECTION */
+ pg_sqlda_t	*inp_sqlda, *outp_sqlda;
+ 
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (sqlda->sqlvar[i].sqlind && *(sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", sqlda->sqlvar[i].sqlname);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case SQLCHAR:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLINT:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLINT8:
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLFLOAT:
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLDECIMAL:
+ 			{
+ 				char    val[64];
+ 				dectoasc((dec_t *)sqlda->sqlvar[i].sqldata, val, 64, -1);
+ 				printf("name sqlda descriptor: '%s' value DECIMAL '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ 	char	*stmt1 = "SELECT * FROM t1";
+ 	char	*stmt2 = "SELECT * FROM t1 WHERE id = ?";
+ 	int	rec;
+ 	int	id;
+ exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1 as regress1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table t1(
+ 		id integer,
+ 		t text,
+ 		d1 numeric,
+ 		d2 float8,
+ 		c char(10));
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into t1 values
+ 		(1, 'a', 1.0, 1, 'a'),
+ 		(2, null, null, null, null),
+ 		(3, '"c"', -3, 'nan'::float8, 'c'),
+ 		(4, 'd', 4.0, 4, 'd');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* SQLDA test for getting all records from a table */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id1 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare mycur1 cursor for st_id1;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open mycur1;
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		exec sql fetch 1 from mycur1 into descriptor outp_sqlda; 
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	exec sql whenever not found continue;
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close mycur1;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id1;
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting all records from a table
+ 	   using the Informix-specific FETCH ... USING DESCRIPTOR
+ 	 */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id2 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare mycur2 cursor for st_id2;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open mycur2;
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		exec sql fetch from mycur2 using descriptor outp_sqlda;
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	exec sql whenever not found continue;
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close mycur2;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id2;
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor */
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id3 FROM :stmt2;
+ 
+ 	strcpy(msg, "execute");
+ 	exec sql execute st_id3 using descriptor inp_sqlda into descriptor outp_sqlda;
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id3;
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor
+ 	 * on a named connection
+ 	 */
+ 
+ 	exec sql connect to REGRESSDB1 as con2;
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql at con2 prepare st_id4 FROM :stmt2;
+ 
+ 	strcpy(msg, "execute");
+ 	exec sql at con2 execute st_id4 using descriptor inp_sqlda into descriptor outp_sqlda;
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql at con2 commit;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id4;
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	strcpy(msg, "disconnect");
+ 	exec sql disconnect con2;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table t1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect");
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule pgsql.2/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule	2009-11-26 18:57:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/ecpg_schedule	2009-12-14 12:41:24.000000000 +0100
*************** test: compat_informix/charfuncs
*** 3,8 ****
--- 3,9 ----
  test: compat_informix/rfmtdate
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
+ test: compat_informix/sqlda
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: sql/code100
*** 29,34 ****
--- 30,36 ----
  test: sql/copystdout
  test: sql/define
  test: sql/desc
+ test: sql/sqlda
  test: sql/dynalloc
  test: sql/dynalloc2
  test: sql/dyntest
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule_tcp pgsql.2/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-11-26 18:57:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-12-14 12:41:24.000000000 +0100
*************** test: compat_informix/charfuncs
*** 3,8 ****
--- 3,9 ----
  test: compat_informix/rfmtdate
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
+ test: compat_informix/sqlda
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: sql/code100
*** 29,34 ****
--- 30,36 ----
  test: sql/copystdout
  test: sql/define
  test: sql/desc
+ test: sql/sqlda
  test: sql/dynalloc
  test: sql/dynalloc2
  test: sql/dyntest
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c	2009-12-14 12:41:24.000000000 +0100
***************
*** 0 ****
--- 1,561 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "sqlda.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 5 "sqlda.pgc"
+ 
+ 
+ 
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+ 
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+ 
+ #include "ecpglib.h"
+ 
+ typedef struct sqlvar_struct
+ {
+ 	short	sqltype;		/* variable type                */
+ 	int	sqllen;			/* length in bytes              */
+ 	char	   *sqldata;		/* pointer to data              */
+ 	short	   *sqlind;		/* pointer to indicator         */
+ 	char	   *sqlname;		/* variable name                */
+ 	char	   *sqlformat;		/* reserved for future use      */
+ 	short	sqlitype;		/* ind variable type            */
+ 	short	sqlilen;		/* ind length in bytes          */
+ 	char	   *sqlidata;		/* ind data pointer             */
+ 	int	sqlxid;			/* extended id type             */
+ 	char	   *sqltypename;	/* extended type name           */
+ 	short	sqltypelen;		/* length of extended type name */
+ 	short	sqlownerlen;		/* length of owner name         */
+ 	short	sqlsourcetype;		/* source type for distinct of built-ins */
+ 	char	   *sqlownername;	/* owner name                   */
+ 	int	sqlsourceid;		/* extended id of source type   */
+ 
+ 	/*
+ 	 * sqlilongdata is new.  It supports data that exceeds the 32k
+ 	 * limit.  sqlilen and sqlidata are for backward compatibility
+ 	 * and they have maximum value of <32K.
+ 	 */
+ 	char	   *sqlilongdata;	/* for data field beyond 32K    */
+ 	int	sqlflags;		/* for internal use only        */
+ 	void	   *sqlreserved;	/* reserved for future use      */
+ } pg_sqlvar_t;
+ 
+ typedef struct sqlda
+ {
+ 	short		sqld;
+ 	pg_sqlvar_t	   *sqlvar;
+ 	char		desc_name[19];	/* descriptor name              */
+ 	short		desc_occ;	/* size of sqlda structure      */
+ 	struct sqlda	   *desc_next;	/* pointer to next sqlda struct */
+ 	void		   *reserved;	/* reserved for future use */
+ } pg_sqlda_t;
+ 
+ #endif /* POSTGRES_SQLDA_H */
+ 
+ #line 7 "sqlda.pgc"
+ 
+ 
+ #line 1 "sqltypes.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqltypes.h,v 1.9 2009/06/11 14:49:13 momjian Exp $
+  */
+ #ifndef ECPG_SQLTYPES_H
+ #define ECPG_SQLTYPES_H
+ 
+ #include <limits.h>
+ 
+ #define CCHARTYPE	ECPGt_char
+ #define CSHORTTYPE	ECPGt_short
+ #define CINTTYPE	ECPGt_int
+ #define CLONGTYPE	ECPGt_long
+ #define CFLOATTYPE	ECPGt_float
+ #define CDOUBLETYPE ECPGt_double
+ #define CDECIMALTYPE	ECPGt_decimal
+ #define CFIXCHARTYPE	108
+ #define CSTRINGTYPE ECPGt_char
+ #define CDATETYPE	ECPGt_date
+ #define CMONEYTYPE	111
+ #define CDTIMETYPE	ECPGt_timestamp
+ #define CLOCATORTYPE	113
+ #define CVCHARTYPE	ECPGt_varchar
+ #define CINVTYPE	115
+ #define CFILETYPE	116
+ #define CINT8TYPE	ECPGt_long_long
+ #define CCOLLTYPE		118
+ #define CLVCHARTYPE		119
+ #define CFIXBINTYPE		120
+ #define CVARBINTYPE		121
+ #define CBOOLTYPE		ECPGt_bool
+ #define CROWTYPE		123
+ #define CLVCHARPTRTYPE	124
+ #define CTYPEMAX	25
+ 
+ /*
+  * Values used in sqlda->sqlvar[i]->sqltype
+  */
+ #define	SQLCHAR		ECPGt_char
+ #define	SQLSMINT	ECPGt_short
+ #define	SQLINT		ECPGt_int
+ #define	SQLFLOAT	ECPGt_double
+ #define	SQLSMFLOAT	ECPGt_float
+ #define	SQLDECIMAL	ECPGt_decimal
+ #define	SQLSERIAL	ECPGt_int
+ #define	SQLDATE		ECPGt_date
+ #define	SQLDTIME	ECPGt_timestamp
+ #define	SQLTEXT		ECPGt_char
+ #define	SQLVCHAR	ECPGt_char
+ #define SQLINTERVAL     ECPGt_interval
+ #define	SQLNCHAR	ECPGt_char
+ #define	SQLNVCHAR	ECPGt_char
+ #if (LONG_BIT == 64)
+ #define	SQLINT8		ECPGt_long
+ #define	SQLSERIAL8	ECPGt_long
+ #else
+ #define	SQLINT8		ECPGt_long_long
+ #define	SQLSERIAL8	ECPGt_long_long
+ #endif
+ 
+ #endif   /* ndef ECPG_SQLTYPES_H */
+ 
+ #line 8 "sqlda.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 10 "sqlda.pgc"
+ 
+ 
+ /* These shouldn't be under DECLARE SECTION */
+ pg_sqlda_t	*inp_sqlda, *outp_sqlda;
+ 
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (sqlda->sqlvar[i].sqlind && *(sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", sqlda->sqlvar[i].sqlname);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case SQLCHAR:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLINT:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLINT8:
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLFLOAT:
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLDECIMAL:
+ 			{
+ 				char    val[64];
+ 				dectoasc((decimal *)sqlda->sqlvar[i].sqldata, val, 64, -1);
+ 				printf("name sqlda descriptor: '%s' value DECIMAL '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		
+ 		
+ 
+ #line 54 "sqlda.pgc"
+  char * stmt1 = "SELECT * FROM t1" ;
+  
+ #line 55 "sqlda.pgc"
+  char * stmt2 = "SELECT * FROM t1 WHERE id = ?" ;
+  
+ #line 56 "sqlda.pgc"
+  int rec ;
+  
+ #line 57 "sqlda.pgc"
+  int id ;
+ /* exec sql end declare section */
+ #line 58 "sqlda.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , "regress1", 0); 
+ #line 65 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 65 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 68 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 68 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
+ #line 76 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 76 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 3 , '\"c\"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 83 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 83 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 86 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 86 "sqlda.pgc"
+ 
+ 
+ 	/* SQLDA test for getting all records from a table */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 93 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 93 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	ECPG_informix_reset_sqlca(); /* declare mycur1 cursor for $1 */
+ #line 96 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1", 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 99 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 99 "sqlda.pgc"
+ 
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 101 "sqlda.pgc"
+ 
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 107 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 107 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 107 "sqlda.pgc"
+  
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	/* exec sql whenever not found  continue ; */
+ #line 113 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT);
+ #line 116 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 116 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
+ #line 119 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 119 "sqlda.pgc"
+ 
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting all records from a table
+ 	   using the Informix-specific FETCH ... USING DESCRIPTOR
+ 	 */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
+ #line 130 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 130 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	ECPG_informix_reset_sqlca(); /* declare mycur2 cursor for $1 */
+ #line 133 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1", 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 136 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 136 "sqlda.pgc"
+ 
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 138 "sqlda.pgc"
+ 
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from mycur2", ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 144 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 144 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 144 "sqlda.pgc"
+ 
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	/* exec sql whenever not found  continue ; */
+ #line 150 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT);
+ #line 153 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 153 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id2");
+ #line 156 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 156 "sqlda.pgc"
+ 
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor */
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id3", stmt2);
+ #line 179 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 179 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "execute");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, 1, "st_id3", 
+ 	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 182 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 182 "sqlda.pgc"
+ 
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id3");
+ #line 187 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 187 "sqlda.pgc"
+ 
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor
+ 	 * on a named connection
+ 	 */
+ 
+ 	{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , "con2", 0); 
+ #line 197 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 197 "sqlda.pgc"
+ 
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, "con2", 0, "st_id4", stmt2);
+ #line 216 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 216 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "execute");
+ 	{ ECPGdo(__LINE__, 1, 1, "con2", 0, 1, "st_id4", 
+ 	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 219 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 219 "sqlda.pgc"
+ 
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, "con2", "commit");
+ #line 224 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 224 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id4");
+ #line 227 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 227 "sqlda.pgc"
+ 
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	strcpy(msg, "disconnect");
+ 	{ ECPGdisconnect(__LINE__, "con2");
+ #line 234 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 234 "sqlda.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 239 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 239 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 242 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 242 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect");
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 245 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 245 "sqlda.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr	2009-12-14 12:41:24.000000000 +0100
***************
*** 0 ****
--- 1,584 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 68: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 68: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 68: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 71: query: create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 71: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 71: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 79: query: insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 3 , '"c"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 79: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 79: OK: INSERT 0 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 86: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 93: name st_id1; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 99: query: declare mycur1 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 99: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 99: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: "c" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: -3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: c          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 107: no data found on line 107
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 116: query: close mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 119: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 130: name st_id2; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 136: query: declare mycur2 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 136: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 136: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: "c" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: -3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: c          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 144: no data found on line 144
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 153: query: close mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 156: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 179: name st_id3; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 182: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 182: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 182: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 182: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 182: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 182: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 182: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 182: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 182: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 182: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 182: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 187: name st_id3
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 216: name st_id4; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection con2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 219: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 224: action "commit"; connection "con2"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 227: name st_id4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection con2 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 239: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 239: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 239: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 242: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout	2009-12-14 12:41:24.000000000 +0100
***************
*** 0 ****
--- 1,60 ----
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value DECIMAL '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a         '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value DECIMAL '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c         '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value DECIMAL '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a         '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value DECIMAL '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c         '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.c pgsql.2/src/interfaces/ecpg/test/expected/sql-sqlda.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/expected/sql-sqlda.c	2009-12-14 12:41:24.000000000 +0100
***************
*** 0 ****
--- 1,569 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "sqlda.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ #include <limits.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 6 "sqlda.pgc"
+ 
+ 
+ 
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+ 
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+ 
+ #include "ecpglib.h"
+ 
+ typedef struct sqlvar_struct
+ {
+ 	short	sqltype;		/* variable type                */
+ 	int	sqllen;			/* length in bytes              */
+ 	char	   *sqldata;		/* pointer to data              */
+ 	short	   *sqlind;		/* pointer to indicator         */
+ 	char	   *sqlname;		/* variable name                */
+ 	char	   *sqlformat;		/* reserved for future use      */
+ 	short	sqlitype;		/* ind variable type            */
+ 	short	sqlilen;		/* ind length in bytes          */
+ 	char	   *sqlidata;		/* ind data pointer             */
+ 	int	sqlxid;			/* extended id type             */
+ 	char	   *sqltypename;	/* extended type name           */
+ 	short	sqltypelen;		/* length of extended type name */
+ 	short	sqlownerlen;		/* length of owner name         */
+ 	short	sqlsourcetype;		/* source type for distinct of built-ins */
+ 	char	   *sqlownername;	/* owner name                   */
+ 	int	sqlsourceid;		/* extended id of source type   */
+ 
+ 	/*
+ 	 * sqlilongdata is new.  It supports data that exceeds the 32k
+ 	 * limit.  sqlilen and sqlidata are for backward compatibility
+ 	 * and they have maximum value of <32K.
+ 	 */
+ 	char	   *sqlilongdata;	/* for data field beyond 32K    */
+ 	int	sqlflags;		/* for internal use only        */
+ 	void	   *sqlreserved;	/* reserved for future use      */
+ } pg_sqlvar_t;
+ 
+ typedef struct sqlda
+ {
+ 	short		sqld;
+ 	pg_sqlvar_t	   *sqlvar;
+ 	char		desc_name[19];	/* descriptor name              */
+ 	short		desc_occ;	/* size of sqlda structure      */
+ 	struct sqlda	   *desc_next;	/* pointer to next sqlda struct */
+ 	void		   *reserved;	/* reserved for future use */
+ } pg_sqlda_t;
+ 
+ #endif /* POSTGRES_SQLDA_H */
+ 
+ #line 8 "sqlda.pgc"
+ 
+ 
+ #line 1 "pgtypes_numeric.h"
+ /* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_numeric.h,v 1.16 2006/08/09 07:30:56 meskes Exp $ */
+ 
+ #ifndef PGTYPES_NUMERIC
+ #define PGTYPES_NUMERIC
+ 
+ #define NUMERIC_POS						0x0000
+ #define NUMERIC_NEG						0x4000
+ #define NUMERIC_NAN						0xC000
+ #define NUMERIC_MAX_PRECISION			1000
+ #define NUMERIC_MAX_DISPLAY_SCALE		NUMERIC_MAX_PRECISION
+ #define NUMERIC_MIN_DISPLAY_SCALE		0
+ #define NUMERIC_MIN_SIG_DIGITS			16
+ 
+ #define DECSIZE 30
+ 
+ typedef unsigned char NumericDigit;
+ typedef struct
+ {
+ 	int			ndigits;		/* number of digits in digits[] - can be 0! */
+ 	int			weight;			/* weight of first digit */
+ 	int			rscale;			/* result scale */
+ 	int			dscale;			/* display scale */
+ 	int			sign;			/* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
+ 	NumericDigit *buf;			/* start of alloc'd space for digits[] */
+ 	NumericDigit *digits;		/* decimal digits */
+ } numeric;
+ 
+ typedef struct
+ {
+ 	int			ndigits;		/* number of digits in digits[] - can be 0! */
+ 	int			weight;			/* weight of first digit */
+ 	int			rscale;			/* result scale */
+ 	int			dscale;			/* display scale */
+ 	int			sign;			/* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
+ 	NumericDigit digits[DECSIZE];		/* decimal digits */
+ } decimal;
+ 
+ #ifdef __cplusplus
+ extern		"C"
+ {
+ #endif
+ 
+ numeric    *PGTYPESnumeric_new(void);
+ decimal    *PGTYPESdecimal_new(void);
+ void		PGTYPESnumeric_free(numeric *);
+ void		PGTYPESdecimal_free(decimal *);
+ numeric    *PGTYPESnumeric_from_asc(char *, char **);
+ char	   *PGTYPESnumeric_to_asc(numeric *, int);
+ int			PGTYPESnumeric_add(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_sub(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_mul(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_div(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_cmp(numeric *, numeric *);
+ int			PGTYPESnumeric_from_int(signed int, numeric *);
+ int			PGTYPESnumeric_from_long(signed long int, numeric *);
+ int			PGTYPESnumeric_copy(numeric *, numeric *);
+ int			PGTYPESnumeric_from_double(double, numeric *);
+ int			PGTYPESnumeric_to_double(numeric *, double *);
+ int			PGTYPESnumeric_to_int(numeric *, int *);
+ int			PGTYPESnumeric_to_long(numeric *, long *);
+ int			PGTYPESnumeric_to_decimal(numeric *, decimal *);
+ int			PGTYPESnumeric_from_decimal(decimal *, numeric *);
+ 
+ #ifdef __cplusplus
+ }
+ #endif
+ 
+ #endif   /* PGTYPES_NUMERIC */
+ 
+ #line 9 "sqlda.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 11 "sqlda.pgc"
+ 
+ 
+ /* These shouldn't be under DECLARE SECTION */
+ pg_sqlda_t	*inp_sqlda, *outp_sqlda, *outp_sqlda1;
+ 
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (sqlda->sqlvar[i].sqlind && *(sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", sqlda->sqlvar[i].sqlname);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case ECPGt_char:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_int:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ #if (LONG_BIT == 64) /* Defined via <limits.h> */
+ 		case ECPGt_long:
+ #else
+ # if (LONG_BIT = 32)
+ 		case ECPGt_long_long:
+ # else
+ #  error Neither "long" nor "long long" are 64-bit
+ # endif
+ #endif
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_double:
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_numeric:
+ 			{
+ 				char    *val;
+ 
+ 				val = PGTYPESnumeric_to_asc((numeric*)sqlda->sqlvar[i].sqldata, -1);
+ 				printf("name sqlda descriptor: '%s' value NUMERIC '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ 				free(val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		
+ 		
+ 
+ #line 65 "sqlda.pgc"
+  char * stmt1 = "SELECT * FROM t1" ;
+  
+ #line 66 "sqlda.pgc"
+  char * stmt2 = "SELECT * FROM t1 WHERE id = ?" ;
+  
+ #line 67 "sqlda.pgc"
+  int rec ;
+  
+ #line 68 "sqlda.pgc"
+  int id ;
+ /* exec sql end declare section */
+ #line 69 "sqlda.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , "regress1", 0); 
+ #line 76 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 76 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 79 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 79 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
+ #line 87 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 87 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 3 , '\"c\"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 94 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 94 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 97 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 97 "sqlda.pgc"
+ 
+ 
+ 	/* SQLDA test for getting all records from a table */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 104 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 104 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	/* declare mycur1 cursor for $1 */
+ #line 107 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1", 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 110 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 110 "sqlda.pgc"
+ 
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 112 "sqlda.pgc"
+ 
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 118 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 118 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 118 "sqlda.pgc"
+  
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	/* exec sql whenever not found  continue ; */
+ #line 124 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT);
+ #line 127 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 127 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
+ #line 130 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 130 "sqlda.pgc"
+ 
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting ALL records into the sqlda list */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
+ #line 139 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 139 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	/* declare mycur2 cursor for $1 */
+ #line 142 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1", 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 145 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 145 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch all from mycur2", ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 148 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 148 "sqlda.pgc"
+ 
+ 
+ 	outp_sqlda1 = outp_sqlda;
+ 	rec = 0;
+ 	while (outp_sqlda1)
+ 	{
+ 		pg_sqlda_t	*ptr;
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda1);
+ 
+ 		ptr = outp_sqlda1;
+ 		outp_sqlda1 = outp_sqlda1->desc_next;
+ 		free(ptr);
+ 	}
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT);
+ #line 164 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 164 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
+ #line 167 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 167 "sqlda.pgc"
+ 
+ 
+ 	/* SQLDA test for getting one record using an input descriptor */
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id3", stmt2);
+ #line 188 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 188 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "execute");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, 1, "st_id3", 
+ 	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 191 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 191 "sqlda.pgc"
+ 
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id3");
+ #line 196 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 196 "sqlda.pgc"
+ 
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor
+ 	 * on a named connection
+ 	 */
+ 
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , "con2", 0); 
+ #line 206 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 206 "sqlda.pgc"
+ 
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, "con2", 0, "st_id4", stmt2);
+ #line 225 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 225 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "execute");
+ 	{ ECPGdo(__LINE__, 0, 1, "con2", 0, 1, "st_id4", 
+ 	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 228 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 228 "sqlda.pgc"
+ 
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, "con2", "commit");
+ #line 233 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 233 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id4");
+ #line 236 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 236 "sqlda.pgc"
+ 
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	strcpy(msg, "disconnect");
+ 	{ ECPGdisconnect(__LINE__, "con2");
+ #line 243 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 243 "sqlda.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 248 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 248 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 251 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 251 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect");
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 254 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 254 "sqlda.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.stderr pgsql.2/src/interfaces/ecpg/test/expected/sql-sqlda.stderr
*** pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/expected/sql-sqlda.stderr	2009-12-14 12:41:24.000000000 +0100
***************
*** 0 ****
--- 1,574 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 79: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 79: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 79: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: query: create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: query: insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 3 , '"c"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: OK: INSERT 0 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 97: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 104: name st_id1; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: query: declare mycur1 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: "c" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: c          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 118: no data found on line 118
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 127: query: close mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 127: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 127: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 130: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 139: name st_id2; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 145: query: declare mycur2 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 145: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 145: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: query: fetch all from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: correctly got 4 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 3 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 3 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 3 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 3 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 3 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 2 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 2 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: "c" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 2 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 2 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 2 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: c          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 1 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 1 col 1 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 1 col 2 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 1 col 3 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 1 col 4 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 164: query: close mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 164: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 164: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 167: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 188: name st_id3; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 191: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 191: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 191: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 191: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 191: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 191: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 191: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 191: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 191: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 191: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 196: name st_id3
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 225: name st_id4; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection con2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 228: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 228: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 228: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 228: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 228: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 233: action "commit"; connection "con2"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 236: name st_id4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection con2 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 248: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 248: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 248: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 251: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.stdout pgsql.2/src/interfaces/ecpg/test/expected/sql-sqlda.stdout
*** pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/expected/sql-sqlda.stdout	2009-12-14 12:41:24.000000000 +0100
***************
*** 0 ****
--- 1,60 ----
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value NUMERIC '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a         '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value NUMERIC '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c         '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value NUMERIC '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value NUMERIC '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a         '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value NUMERIC '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c         '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value NUMERIC '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value NUMERIC '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value NUMERIC '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/desc.pgc pgsql.2/src/interfaces/ecpg/test/sql/desc.pgc
*** pgsql.orig/src/interfaces/ecpg/test/sql/desc.pgc	2007-08-14 12:01:54.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/test/sql/desc.pgc	2009-12-14 12:41:24.000000000 +0100
*************** main(void)
*** 32,61 ****
  	EXEC SQL PREPARE foo2 FROM :stmt2;
  	EXEC SQL PREPARE foo3 FROM :stmt3;
  
! 	EXEC SQL EXECUTE foo1 USING DESCRIPTOR indesc;
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2null, DATA = :val2;
  
! 	EXEC SQL EXECUTE foo1 USING DESCRIPTOR indesc;
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 3;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val1, DATA = 'this is a long test';
  
! 	EXEC SQL EXECUTE "Foo-1" USING DESCRIPTOR indesc;
  
  	EXEC SQL DEALLOCATE "Foo-1";
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = :val1;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2i, DATA = :val2;
  
! 	EXEC SQL EXECUTE foo2 USING DESCRIPTOR indesc INTO DESCRIPTOR outdesc;
  
  	EXEC SQL GET DESCRIPTOR outdesc VALUE 1 :val2output = DATA;
  	printf("output = %s\n", val2output);
  
  	EXEC SQL DECLARE c1 CURSOR FOR foo2;
! 	EXEC SQL OPEN c1 USING DESCRIPTOR indesc;
  
  	EXEC SQL FETCH next FROM c1 INTO :val1output:ind1, :val2output:ind2;
  	printf("val1=%d (ind1: %d) val2=%s (ind2: %d)\n",
--- 32,61 ----
  	EXEC SQL PREPARE foo2 FROM :stmt2;
  	EXEC SQL PREPARE foo3 FROM :stmt3;
  
! 	EXEC SQL EXECUTE foo1 USING SQL DESCRIPTOR indesc;
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2null, DATA = :val2;
  
! 	EXEC SQL EXECUTE foo1 USING SQL DESCRIPTOR indesc;
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 3;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val1, DATA = 'this is a long test';
  
! 	EXEC SQL EXECUTE "Foo-1" USING SQL DESCRIPTOR indesc;
  
  	EXEC SQL DEALLOCATE "Foo-1";
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = :val1;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2i, DATA = :val2;
  
! 	EXEC SQL EXECUTE foo2 USING SQL DESCRIPTOR indesc INTO SQL DESCRIPTOR outdesc;
  
  	EXEC SQL GET DESCRIPTOR outdesc VALUE 1 :val2output = DATA;
  	printf("output = %s\n", val2output);
  
  	EXEC SQL DECLARE c1 CURSOR FOR foo2;
! 	EXEC SQL OPEN c1 USING SQL DESCRIPTOR indesc;
  
  	EXEC SQL FETCH next FROM c1 INTO :val1output:ind1, :val2output:ind2;
  	printf("val1=%d (ind1: %d) val2=%s (ind2: %d)\n",
*************** main(void)
*** 67,73 ****
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
  
  	EXEC SQL DECLARE c2 CURSOR FOR foo3;
! 	EXEC SQL OPEN c2 USING DESCRIPTOR indesc;
  
  	EXEC SQL FETCH next FROM c2 INTO :val1output, :val2output :val2i;
  	printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output);
--- 67,73 ----
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
  
  	EXEC SQL DECLARE c2 CURSOR FOR foo3;
! 	EXEC SQL OPEN c2 USING SQL DESCRIPTOR indesc;
  
  	EXEC SQL FETCH next FROM c2 INTO :val1output, :val2output :val2i;
  	printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output);
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/dynalloc2.pgc pgsql.2/src/interfaces/ecpg/test/sql/dynalloc2.pgc
*** pgsql.orig/src/interfaces/ecpg/test/sql/dynalloc2.pgc	2006-08-19 15:42:40.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/test/sql/dynalloc2.pgc	2009-12-14 12:41:24.000000000 +0100
*************** int main(void)
*** 30,36 ****
     exec sql insert into test values (NULL, NULL);
  
     exec sql allocate descriptor mydesc;
!    exec sql select * into descriptor mydesc from test;
     exec sql get descriptor mydesc :colnum=COUNT;
     exec sql get descriptor mydesc value 1 :ip1=DATA, :ipointer1=INDICATOR;
     exec sql get descriptor mydesc value 2 :cp2=DATA, :ipointer2=INDICATOR;
--- 30,36 ----
     exec sql insert into test values (NULL, NULL);
  
     exec sql allocate descriptor mydesc;
!    exec sql select * into sql descriptor mydesc from test;
     exec sql get descriptor mydesc :colnum=COUNT;
     exec sql get descriptor mydesc value 1 :ip1=DATA, :ipointer1=INDICATOR;
     exec sql get descriptor mydesc value 2 :cp2=DATA, :ipointer2=INDICATOR;
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/dynalloc.pgc pgsql.2/src/interfaces/ecpg/test/sql/dynalloc.pgc
*** pgsql.orig/src/interfaces/ecpg/test/sql/dynalloc.pgc	2006-08-19 15:42:40.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/test/sql/dynalloc.pgc	2009-12-14 12:41:24.000000000 +0100
*************** int main(void)
*** 39,45 ****
     exec sql insert into test (b, c, d, e, f, g, h, i) values (2.446456, NULL, 'v', 'c', '2003-03-03 12:33:07 PDT', false, NULL, NULL);
  
     exec sql allocate descriptor mydesc;
!    exec sql select a,b,c,d,e,f,g,h,i into descriptor mydesc from test order by a;
     exec sql get descriptor mydesc value 1 :d1=DATA, :i1=INDICATOR;
     exec sql get descriptor mydesc value 2 :d2=DATA, :i2=INDICATOR;
     exec sql get descriptor mydesc value 3 :d3=DATA, :i3=INDICATOR;
--- 39,45 ----
     exec sql insert into test (b, c, d, e, f, g, h, i) values (2.446456, NULL, 'v', 'c', '2003-03-03 12:33:07 PDT', false, NULL, NULL);
  
     exec sql allocate descriptor mydesc;
!    exec sql select a,b,c,d,e,f,g,h,i into sql descriptor mydesc from test order by a;
     exec sql get descriptor mydesc value 1 :d1=DATA, :i1=INDICATOR;
     exec sql get descriptor mydesc value 2 :d2=DATA, :i2=INDICATOR;
     exec sql get descriptor mydesc value 3 :d3=DATA, :i3=INDICATOR;
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/Makefile pgsql.2/src/interfaces/ecpg/test/sql/Makefile
*** pgsql.orig/src/interfaces/ecpg/test/sql/Makefile	2007-08-14 12:01:54.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/test/sql/Makefile	2009-12-14 12:41:24.000000000 +0100
*************** TESTS = array array.c \
*** 20,25 ****
--- 20,26 ----
          parser parser.c \
          quote quote.c \
          show show.c \
+         sqlda sqlda.c \
          insupd insupd.c 
  
  all: $(TESTS)
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/sqlda.pgc pgsql.2/src/interfaces/ecpg/test/sql/sqlda.pgc
*** pgsql.orig/src/interfaces/ecpg/test/sql/sqlda.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/sql/sqlda.pgc	2009-12-14 12:41:24.000000000 +0100
***************
*** 0 ****
--- 1,257 ----
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ #include <limits.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql include sqlda.h;
+ exec sql include pgtypes_numeric.h;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ /* These shouldn't be under DECLARE SECTION */
+ pg_sqlda_t	*inp_sqlda, *outp_sqlda, *outp_sqlda1;
+ 
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (sqlda->sqlvar[i].sqlind && *(sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", sqlda->sqlvar[i].sqlname);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case ECPGt_char:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_int:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ #if (LONG_BIT == 64) /* Defined via <limits.h> */
+ 		case ECPGt_long:
+ #else
+ # if (LONG_BIT = 32)
+ 		case ECPGt_long_long:
+ # else
+ #  error Neither "long" nor "long long" are 64-bit
+ # endif
+ #endif
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_double:
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_numeric:
+ 			{
+ 				char    *val;
+ 
+ 				val = PGTYPESnumeric_to_asc((numeric*)sqlda->sqlvar[i].sqldata, -1);
+ 				printf("name sqlda descriptor: '%s' value NUMERIC '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ 				free(val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ 	char	*stmt1 = "SELECT * FROM t1";
+ 	char	*stmt2 = "SELECT * FROM t1 WHERE id = ?";
+ 	int	rec;
+ 	int	id;
+ exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1 as regress1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table t1(
+ 		id integer,
+ 		t text,
+ 		d1 numeric,
+ 		d2 float8,
+ 		c char(10));
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into t1 values
+ 		(1, 'a', 1.0, 1, 'a'),
+ 		(2, null, null, null, null),
+ 		(3, '"c"', -3, 'nan'::float8, 'c'),
+ 		(4, 'd', 4.0, 4, 'd');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* SQLDA test for getting all records from a table */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id1 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare mycur1 cursor for st_id1;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open mycur1;
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		exec sql fetch 1 from mycur1 into descriptor outp_sqlda; 
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	exec sql whenever not found continue;
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close mycur1;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id1;
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting ALL records into the sqlda list */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id2 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare mycur2 cursor for st_id2;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open mycur2;
+ 
+ 	strcpy(msg, "fetch");
+ 	exec sql fetch all from mycur2 into descriptor outp_sqlda;
+ 
+ 	outp_sqlda1 = outp_sqlda;
+ 	rec = 0;
+ 	while (outp_sqlda1)
+ 	{
+ 		pg_sqlda_t	*ptr;
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda1);
+ 
+ 		ptr = outp_sqlda1;
+ 		outp_sqlda1 = outp_sqlda1->desc_next;
+ 		free(ptr);
+ 	}
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close mycur2;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id2;
+ 
+ 	/* SQLDA test for getting one record using an input descriptor */
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id3 FROM :stmt2;
+ 
+ 	strcpy(msg, "execute");
+ 	exec sql execute st_id3 using descriptor inp_sqlda into descriptor outp_sqlda;
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id3;
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor
+ 	 * on a named connection
+ 	 */
+ 
+ 	exec sql connect to REGRESSDB1 as con2;
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql at con2 prepare st_id4 FROM :stmt2;
+ 
+ 	strcpy(msg, "execute");
+ 	exec sql at con2 execute st_id4 using descriptor inp_sqlda into descriptor outp_sqlda;
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql at con2 commit;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id4;
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	strcpy(msg, "disconnect");
+ 	exec sql disconnect con2;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table t1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect");
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
#71Boszormenyi Zoltan
zb@cybertec.at
In reply to: Boszormenyi Zoltan (#64)
1 attachment(s)
Re: ECPG patch 3, DESCRIBE [OUTPUT] support

New version, rebased to the previously sent
new SQLDA patch.

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

Attachments:

3-pg85-describe-13-ctxdiff.patchtext/x-patch; name=3-pg85-describe-13-ctxdiff.patchDownload
diff -dcrpN pgsql.2/src/interfaces/ecpg/ecpglib/descriptor.c pgsql.3/src/interfaces/ecpg/ecpglib/descriptor.c
*** pgsql.2/src/interfaces/ecpg/ecpglib/descriptor.c	2009-08-07 13:06:28.000000000 +0200
--- pgsql.3/src/interfaces/ecpg/ecpglib/descriptor.c	2009-12-14 13:43:36.000000000 +0100
***************
*** 13,18 ****
--- 13,19 ----
  #include "ecpgerrno.h"
  #include "extern.h"
  #include "sqlca.h"
+ #include "sqlda.h"
  #include "sql3types.h"
  
  static void descriptor_free(struct descriptor * desc);
*************** get_char_item(int lineno, void *var, enu
*** 226,231 ****
--- 227,238 ----
  	return (true);
  }
  
+ #define RETURN_IF_NO_DATA	if (ntuples < 1) \
+ 				{ \
+ 					ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL); \
+ 					return (false); \
+ 				}
+ 
  bool
  ECPGget_desc(int lineno, const char *desc_name, int index,...)
  {
*************** ECPGget_desc(int lineno, const char *des
*** 244,254 ****
  		return (false);
  
  	ntuples = PQntuples(ECPGresult);
- 	if (ntuples < 1)
- 	{
- 		ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL);
- 		return (false);
- 	}
  
  	if (index < 1 || index > PQnfields(ECPGresult))
  	{
--- 251,256 ----
*************** ECPGget_desc(int lineno, const char *des
*** 283,288 ****
--- 285,291 ----
  		switch (type)
  		{
  			case (ECPGd_indicator):
+ 				RETURN_IF_NO_DATA;
  				data_var.ind_type = vartype;
  				data_var.ind_pointer = var;
  				data_var.ind_varcharsize = varcharsize;
*************** ECPGget_desc(int lineno, const char *des
*** 295,300 ****
--- 298,304 ----
  				break;
  
  			case ECPGd_data:
+ 				RETURN_IF_NO_DATA;
  				data_var.type = vartype;
  				data_var.pointer = var;
  				data_var.varcharsize = varcharsize;
*************** ECPGget_desc(int lineno, const char *des
*** 377,382 ****
--- 381,387 ----
  			case ECPGd_ret_length:
  			case ECPGd_ret_octet:
  
+ 				RETURN_IF_NO_DATA;
  				/*
  				 * this is like ECPGstore_result
  				 */
*************** ECPGget_desc(int lineno, const char *des
*** 480,485 ****
--- 485,491 ----
  	sqlca->sqlerrd[2] = ntuples;
  	return (true);
  }
+ #undef RETURN_IF_NO_DATA
  
  bool
  ECPGset_desc_header(int lineno, const char *desc_name, int count)
*************** ecpg_find_desc(int line, const char *nam
*** 722,730 ****
  	return NULL;				/* not found */
  }
  
  bool
! ECPGdescribe(int line, bool input, const char *statement,...)
  {
! 	ecpg_log("ECPGdescribe called on line %d for %s: %s\n", line, input ? "input" : "output", statement);
! 	return false;
  }
--- 728,845 ----
  	return NULL;				/* not found */
  }
  
+ static pg_sqlda_t*
+ build_sqlda(int lineno, bool input, const char *connection_name, const char *stmt_name)
+ {
+ 	struct connection *con;
+ 	struct prepared_statement *prep;
+ 	PGresult	*res;
+ 	pg_sqlda_t	*sqlda = NULL;
+ 
+ 	con = ecpg_get_connection(connection_name);
+ 	prep = ecpg_find_prepared_statement(stmt_name, con, NULL);
+ 	if (!prep)
+ 		return NULL;
+ 	res = PQdescribePrepared(con->connection, stmt_name);
+ 	if (!ecpg_check_PQresult(res, lineno, con->connection, ECPG_COMPAT_INFORMIX))
+ 		return NULL;
+ 
+ 	sqlda = ecpg_build_sqlda_for_PGresult(lineno, res, -1, prep->stmt->compat);
+ 
+ 	PQclear(res);
+ 	return sqlda;
+ }
+ 
  bool
! ECPGdescribe(int line, bool input, const char *connection_name, const char *stmt_name, ...)
  {
! 	bool		ret = false;
! 	va_list		args;
! 
! 	/* DESCRIBE INPUT is not yet supported */
! 	if (input)
! 		return false;
! 
! 	va_start(args, stmt_name);
! 
! 	for (;;)
! 	{
! 		enum ECPGttype	type, dummy_type;
! 		void		*ptr, *dummy_ptr;
! 		long		dummy;
! 
! 		/* variable type */
! 		type = va_arg(args, enum ECPGttype);
! 
! 		if (type == ECPGt_EORT)
! 			break;
! 
! 		/* rest of variable parameters*/
! 		ptr = va_arg(args, void *);
! 		dummy = va_arg(args, long);
! 		dummy = va_arg(args, long);
! 		dummy = va_arg(args, long);
! 
! 		/* variable indicator */
! 		dummy_type = va_arg(args, enum ECPGttype);
! 		dummy_ptr = va_arg(args, void *);
! 		dummy = va_arg(args, long);
! 		dummy = va_arg(args, long);
! 		dummy = va_arg(args, long);
! 
! 		switch (type)
! 		{
! 			case ECPGt_descriptor:
! 			{
! 				char	*name = ptr;
! 				struct connection *con = ecpg_get_connection(connection_name);
! 				struct descriptor *desc = ecpg_find_desc(line, name);
! 				PGresult	*res;
! 				ExecStatusType  ret;
! 
! 				if (con == NULL)
! 					break;
! 				if (desc == NULL)
! 					break;
! 
! 				res = PQdescribePrepared(con->connection, stmt_name);
! 				ret = PQresultStatus(res);
! 				if (ecpg_check_PQresult(res, line, con->connection, ECPG_COMPAT_PGSQL))
! 				{
! 					if (desc->result != NULL)
! 						PQclear(desc->result);
! 					desc->result = res;
! 					ret = true;
! 				}
! 				break;
! 			}
! 			case ECPGt_sqlda:
! 			{
! 				pg_sqlda_t **_sqlda = ptr;
! 				pg_sqlda_t *sqlda;
! 
! 				sqlda = build_sqlda(line, input, connection_name, stmt_name);
! 				if (sqlda)
! 				{
! 					pg_sqlda_t *sqlda_old = *_sqlda;
! 					if (sqlda_old)
! 					{
! 						if (sqlda->sqlvar != (pg_sqlvar_t *)(sqlda + 1))
! 							free(sqlda->sqlvar);
! 						free(sqlda_old);
! 					}
! 					*_sqlda = sqlda;
! 					ret = true;
! 				}
! 				break;
! 			}
! 			default:
! 				/* nothing else may come */
! 				;
! 		}
! 	}
! 
! 	va_end(args);
! 
! 	return ret;
  }
diff -dcrpN pgsql.2/src/interfaces/ecpg/ecpglib/extern.h pgsql.3/src/interfaces/ecpg/ecpglib/extern.h
*** pgsql.2/src/interfaces/ecpg/ecpglib/extern.h	2009-12-14 12:41:24.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/ecpglib/extern.h	2009-12-14 13:41:48.000000000 +0100
*************** struct statement
*** 59,64 ****
--- 59,73 ----
  	struct variable *outlist;
  };
  
+ /* structure to store prepared statements for a connection */
+ struct prepared_statement
+ {
+ 	char	   *name;
+ 	bool		prepared;
+ 	struct statement *stmt;
+ 	struct prepared_statement *next;
+ };
+ 
  /* structure to store connections */
  struct connection
  {
*************** struct descriptor *ecpggetdescp(int, cha
*** 138,143 ****
--- 147,155 ----
  
  struct descriptor *ecpg_find_desc(int line, const char *name);
  
+ struct prepared_statement *ecpg_find_prepared_statement(const char *,
+ 				  struct connection *, struct prepared_statement **);
+ 
  bool ecpg_store_result(const PGresult *results, int act_field,
  				  const struct statement * stmt, struct variable * var);
  bool		ecpg_store_input(const int, const bool, const struct variable *, char **, bool);
diff -dcrpN pgsql.2/src/interfaces/ecpg/ecpglib/prepare.c pgsql.3/src/interfaces/ecpg/ecpglib/prepare.c
*** pgsql.2/src/interfaces/ecpg/ecpglib/prepare.c	2009-10-15 13:26:30.000000000 +0200
--- pgsql.3/src/interfaces/ecpg/ecpglib/prepare.c	2009-12-14 13:44:47.000000000 +0100
***************
*** 11,24 ****
  #include "extern.h"
  #include "sqlca.h"
  
- struct prepared_statement
- {
- 	char	   *name;
- 	bool		prepared;
- 	struct statement *stmt;
- 	struct prepared_statement *next;
- };
- 
  #define STMTID_SIZE 32
  
  typedef struct
--- 11,16 ----
*************** static const int stmtCacheNBuckets = 203
*** 35,42 ****
  static const int stmtCacheEntPerBucket = 8;		/* # entries/bucket		*/
  static stmtCacheEntry stmtCacheEntries[16384] = {{0, {0}, 0, 0, 0}};
  
- static struct prepared_statement *find_prepared_statement(const char *name,
- 				 struct connection * con, struct prepared_statement ** prev);
  static bool deallocate_one(int lineno, enum COMPAT_MODE c, struct connection * con,
  		 struct prepared_statement * prev, struct prepared_statement * this);
  
--- 27,32 ----
*************** ECPGprepare(int lineno, const char *conn
*** 126,132 ****
  		return false;
  
  	/* check if we already have prepared this statement */
! 	this = find_prepared_statement(name, con, &prev);
  	if (this && !deallocate_one(lineno, ECPG_COMPAT_PGSQL, con, prev, this))
  		return false;
  
--- 116,122 ----
  		return false;
  
  	/* check if we already have prepared this statement */
! 	this = ecpg_find_prepared_statement(name, con, &prev);
  	if (this && !deallocate_one(lineno, ECPG_COMPAT_PGSQL, con, prev, this))
  		return false;
  
*************** ECPGprepare(int lineno, const char *conn
*** 179,186 ****
  	return true;
  }
  
! static struct prepared_statement *
! find_prepared_statement(const char *name,
  				 struct connection * con, struct prepared_statement ** prev_)
  {
  	struct prepared_statement *this,
--- 169,176 ----
  	return true;
  }
  
! struct prepared_statement *
! ecpg_find_prepared_statement(const char *name,
  				 struct connection * con, struct prepared_statement ** prev_)
  {
  	struct prepared_statement *this,
*************** ECPGdeallocate(int lineno, int c, const 
*** 262,268 ****
  	if (!ecpg_init(con, connection_name, lineno))
  		return false;
  
! 	this = find_prepared_statement(name, con, &prev);
  	if (this)
  		return deallocate_one(lineno, c, con, prev, this);
  
--- 252,258 ----
  	if (!ecpg_init(con, connection_name, lineno))
  		return false;
  
! 	this = ecpg_find_prepared_statement(name, con, &prev);
  	if (this)
  		return deallocate_one(lineno, c, con, prev, this);
  
*************** ecpg_prepared(const char *name, struct c
*** 297,303 ****
  {
  	struct prepared_statement *this;
  
! 	this = find_prepared_statement(name, con, NULL);
  	return this ? this->stmt->command : NULL;
  }
  
--- 287,293 ----
  {
  	struct prepared_statement *this;
  
! 	this = ecpg_find_prepared_statement(name, con, NULL);
  	return this ? this->stmt->command : NULL;
  }
  
*************** ecpg_freeStmtCacheEntry(int lineno, int 
*** 394,400 ****
  	con = ecpg_get_connection(entry->connection);
  
  	/* free the 'prepared_statement' list entry		  */
! 	this = find_prepared_statement(entry->stmtID, con, &prev);
  	if (this && !deallocate_one(lineno, compat, con, prev, this))
  		return (-1);
  
--- 384,390 ----
  	con = ecpg_get_connection(entry->connection);
  
  	/* free the 'prepared_statement' list entry		  */
! 	this = ecpg_find_prepared_statement(entry->stmtID, con, &prev);
  	if (this && !deallocate_one(lineno, compat, con, prev, this))
  		return (-1);
  
diff -dcrpN pgsql.2/src/interfaces/ecpg/include/ecpglib.h pgsql.3/src/interfaces/ecpg/include/ecpglib.h
*** pgsql.2/src/interfaces/ecpg/include/ecpglib.h	2009-09-21 15:19:11.000000000 +0200
--- pgsql.3/src/interfaces/ecpg/include/ecpglib.h	2009-12-14 12:42:44.000000000 +0100
*************** bool		ECPGset_desc(int, const char *, in
*** 83,89 ****
  
  void		ECPGset_noind_null(enum ECPGttype, void *);
  bool		ECPGis_noind_null(enum ECPGttype, void *);
! bool		ECPGdescribe(int, bool, const char *,...);
  
  /* dynamic result allocation */
  void		ECPGfree_auto_mem(void);
--- 83,89 ----
  
  void		ECPGset_noind_null(enum ECPGttype, void *);
  bool		ECPGis_noind_null(enum ECPGttype, void *);
! bool		ECPGdescribe(int, bool, const char *, const char *, ...);
  
  /* dynamic result allocation */
  void		ECPGfree_auto_mem(void);
diff -dcrpN pgsql.2/src/interfaces/ecpg/preproc/ecpg.trailer pgsql.3/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.2/src/interfaces/ecpg/preproc/ecpg.trailer	2009-12-14 12:41:24.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/preproc/ecpg.trailer	2009-12-14 12:45:12.000000000 +0100
*************** into_descriptor: INTO SQL_SQL SQL_DESCRI
*** 994,999 ****
--- 994,1006 ----
  		}
  		;
  
+ into_sqlda: INTO name
+ 		{
+ 			add_variable_to_head(&argsresult, sqlda_variable($2), &no_indicator);
+ 			$$ = EMPTY;
+ 		}
+ 		;
+ 
  using_list: UsingValue | UsingValue ',' using_list;
  
  UsingValue: UsingConst
*************** UsingConst: Iconst			{ $$ = $1; }
*** 1019,1046 ****
  		;
  
  /*
!  * We accept descibe but do nothing with it so far.
   */
! ECPGDescribe: SQL_DESCRIBE INPUT_P name using_descriptor
  	{
  		const char *con = connection ? connection : "NULL";
  		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
! 		$$ = (char *) mm_alloc(sizeof("1, ECPGprepared_statement(, \"\", __LINE__)") + strlen(con) + strlen($3));
! 		sprintf($$, "1, ECPGprepared_statement(%s, \"%s\", __LINE__)", con, $3);
  	}
! 	| SQL_DESCRIBE opt_output name using_descriptor
  	{
  		const char *con = connection ? connection : "NULL";
! 		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
! 		$$ = (char *) mm_alloc(sizeof("0, ECPGprepared_statement(, \"\", __LINE__)") + strlen(con) + strlen($3));
! 		sprintf($$, "0, ECPGprepared_statement(%s, \"%s\", __LINE__)", con, $3);
  	}
! 	| SQL_DESCRIBE opt_output name into_descriptor
  	{
  		const char *con = connection ? connection : "NULL";
  		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
! 		$$ = (char *) mm_alloc(sizeof("0, ECPGprepared_statement(, \"\", __LINE__)") + strlen(con) + strlen($3));
! 		sprintf($$, "0, ECPGprepared_statement(%s, \"%s\", __LINE__)", con, $3);
  	}
  	;
  
--- 1026,1074 ----
  		;
  
  /*
!  * We accept DESCRIBE [OUTPUT] but do nothing with DESCRIBE INPUT so far.
   */
! ECPGDescribe: SQL_DESCRIBE INPUT_P prepared_name using_descriptor
  	{
  		const char *con = connection ? connection : "NULL";
  		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
! 		$$ = (char *) mm_alloc(sizeof("1, , ") + strlen(con) + strlen($3));
! 		sprintf($$, "1, %s, %s", con, $3);
  	}
! 	| SQL_DESCRIBE opt_output prepared_name using_descriptor
  	{
  		const char *con = connection ? connection : "NULL";
! 		struct variable *var;
! 
! 		var = argsinsert->variable;
! 		remove_variable_from_list(&argsinsert, var);
! 		add_variable_to_head(&argsresult, var, &no_indicator);
! 
! 		$$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
! 		sprintf($$, "0, %s, %s", con, $3);
  	}
! 	| SQL_DESCRIBE opt_output prepared_name into_descriptor
! 	{
! 		const char *con = connection ? connection : "NULL";
! 		$$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
! 		sprintf($$, "0, %s, %s", con, $3);
! 	}
! 	| SQL_DESCRIBE INPUT_P prepared_name into_sqlda
  	{
  		const char *con = connection ? connection : "NULL";
  		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
! 		if (!INFORMIX_MODE)
! 			mmerror(PARSE_ERROR, ET_ERROR, "Not in Informix compatibility mode");
! 		$$ = (char *) mm_alloc(sizeof("1, , ") + strlen(con) + strlen($3));
! 		sprintf($$, "1, %s, %s", con, $3);
! 	}
! 	| SQL_DESCRIBE opt_output prepared_name into_sqlda
! 	{
! 		const char *con = connection ? connection : "NULL";
! 		if (!INFORMIX_MODE)
! 			mmerror(PARSE_ERROR, ET_ERROR, "Not in Informix compatibility mode");
! 		$$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
! 		sprintf($$, "0, %s, %s", con, $3);
  	}
  	;
  
diff -dcrpN pgsql.2/src/interfaces/ecpg/preproc/ecpg.type pgsql.3/src/interfaces/ecpg/preproc/ecpg.type
*** pgsql.2/src/interfaces/ecpg/preproc/ecpg.type	2009-12-14 12:41:24.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/preproc/ecpg.type	2009-12-14 12:42:44.000000000 +0100
***************
*** 72,77 ****
--- 72,78 ----
  %type <str> execute_rest
  %type <str> indicator
  %type <str> into_descriptor
+ %type <str> into_sqlda
  %type <str> Iresult
  %type <str> on_off
  %type <str> opt_bit_field
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/compat_informix/describe.pgc pgsql.3/src/interfaces/ecpg/test/compat_informix/describe.pgc
*** pgsql.2/src/interfaces/ecpg/test/compat_informix/describe.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/compat_informix/describe.pgc	2009-12-14 14:01:17.000000000 +0100
***************
*** 0 ****
--- 1,166 ----
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ exec sql include ../regression;
+ exec sql include sqlda.h;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ pg_sqlda_t	*sqlda1, *sqlda2, *sqlda3;
+ 
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ 	char	*stmt1 = "SELECT id, t FROM t1";
+ 	char	*stmt2 = "SELECT id, t FROM t1 WHERE id = -1";
+ 	int	i, count1, count2;
+ 	char	field_name1[30] = "not set";
+ 	char	field_name2[30] = "not set";
+ exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table t1(id serial primary key, t text);
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into t1(id, t) values (default, 'a');
+ 	exec sql insert into t1(id, t) values (default, 'b');
+ 	exec sql insert into t1(id, t) values (default, 'c');
+ 	exec sql insert into t1(id, t) values (default, 'd');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/*
+ 	 * Test DESCRIBE with a query producing tuples.
+ 	 * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
+ 	 * Informix-compat mode.
+ 	 */
+ 
+ 	strcpy(msg, "allocate");
+ 	exec sql allocate descriptor desc1;
+ 	exec sql allocate descriptor desc2;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id1 FROM :stmt1;
+ 
+ 	sqlda1 = sqlda2 = sqlda3 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	exec sql describe st_id1 into sql descriptor desc1;
+ 	exec sql describe st_id1 using sql descriptor desc2;
+ 
+ 	exec sql describe st_id1 into descriptor sqlda1;
+ 	exec sql describe st_id1 using descriptor sqlda2;
+ 	exec sql describe st_id1 into sqlda3;
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	exec sql get descriptor desc1 :count1 = count;
+ 	exec sql get descriptor desc1 :count2 = count;
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld &&
+ 		count1 == sqlda3->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		exec sql get descriptor desc1 value :i :field_name1 = name;
+ 		exec sql get descriptor desc2 value :i :field_name2 = name;
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname,
+ 			sqlda3->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate descriptor desc1;
+ 	exec sql deallocate descriptor desc2;
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 	free(sqlda3);
+ 
+ 	exec sql deallocate prepare st_id1;
+ 
+ 	/* Test DESCRIBE with a query not producing tuples */
+ 
+ 	strcpy(msg, "allocate");
+ 	exec sql allocate descriptor desc1;
+ 	exec sql allocate descriptor desc2;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id2 FROM :stmt2;
+ 
+ 	sqlda1 = sqlda2 = sqlda3 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	exec sql describe st_id2 into sql descriptor desc1;
+ 	exec sql describe st_id2 using sql descriptor desc2;
+ 
+ 	exec sql describe st_id2 into descriptor sqlda1;
+ 	exec sql describe st_id2 using descriptor sqlda2;
+ 	exec sql describe st_id2 into sqlda3;
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	exec sql get descriptor desc1 :count1 = count;
+ 	exec sql get descriptor desc1 :count2 = count;
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld &&
+ 		count1 == sqlda3->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		exec sql get descriptor desc1 value :i :field_name1 = name;
+ 		exec sql get descriptor desc2 value :i :field_name2 = name;
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname,
+ 			sqlda3->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate descriptor desc1;
+ 	exec sql deallocate descriptor desc2;
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 	free(sqlda3);
+ 
+ 	exec sql deallocate prepare st_id2;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table t1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/compat_informix/Makefile pgsql.3/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.2/src/interfaces/ecpg/test/compat_informix/Makefile	2009-12-14 12:41:24.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/compat_informix/Makefile	2009-12-14 14:01:34.000000000 +0100
*************** TESTS = test_informix test_informix.c \
*** 17,22 ****
--- 17,23 ----
          rfmtlong rfmtlong.c \
          rnull rnull.c \
          sqlda sqlda.c \
+         describe describe.c \
          charfuncs charfuncs.c
  
  all: $(TESTS)
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/compat_informix/Makefile.orig pgsql.3/src/interfaces/ecpg/test/compat_informix/Makefile.orig
*** pgsql.2/src/interfaces/ecpg/test/compat_informix/Makefile.orig	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/compat_informix/Makefile.orig	2009-12-14 12:41:24.000000000 +0100
***************
*** 0 ****
--- 1,46 ----
+ subdir = src/interfaces/ecpg/test/compat_informix
+ top_builddir = ../../../../..
+ include $(top_builddir)/src/Makefile.global
+ include $(top_srcdir)/$(subdir)/../Makefile.regress
+ 
+ # special informix compatibility switches
+ ECPG += -C INFORMIX
+ ECPG_NOIND  = $(ECPG) -r no_indicator
+ 
+ override LDFLAGS := -L../../compatlib $(LDFLAGS)
+ override LIBS := -lecpg_compat $(LIBS)
+ 
+ TESTS = test_informix test_informix.c \
+         test_informix2 test_informix2.c \
+         dec_test dec_test.c \
+         rfmtdate rfmtdate.c \
+         rfmtlong rfmtlong.c \
+         rnull rnull.c \
+         sqlda sqlda.c \
+         charfuncs charfuncs.c
+ 
+ all: $(TESTS)
+ 
+ test_informix.c: test_informix.pgc ../regression.h
+ 	$(ECPG) -o $@ -I$(srcdir) $<
+ 
+ test_informix2.c: test_informix2.pgc ../regression.h
+ 	$(ECPG) -o $@ -I$(srcdir) $<
+ 
+ sqlda.c: sqlda.pgc ../regression.h
+ 	$(ECPG) -o $@ -I$(srcdir) $<
+ 
+ dec_test.c: dec_test.pgc ../regression.h
+ 	$(ECPG) -o $@ -I$(srcdir) $<
+ 
+ rfmtdate.c: rfmtdate.pgc ../regression.h
+ 	$(ECPG) -o $@ -I$(srcdir) $<
+ 
+ rfmtlong.c: rfmtlong.pgc ../regression.h
+ 	$(ECPG) -o $@ -I$(srcdir) $<
+ 
+ rnull.c: rnull.pgc ../regression.h
+ 	$(ECPG_NOIND) -o $@ -I$(srcdir) $<
+ 
+ charfuncs.c: charfuncs.pgc ../regression.h
+ 	$(ECPG) -o $@ -I$(srcdir) $<
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/ecpg_schedule pgsql.3/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.2/src/interfaces/ecpg/test/ecpg_schedule	2009-12-14 12:41:24.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/ecpg_schedule	2009-12-14 14:04:58.000000000 +0100
*************** test: compat_informix/rfmtdate
*** 4,9 ****
--- 4,10 ----
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
  test: compat_informix/sqlda
+ test: compat_informix/describe
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: sql/copystdout
*** 31,36 ****
--- 32,38 ----
  test: sql/define
  test: sql/desc
  test: sql/sqlda
+ test: sql/describe
  test: sql/dynalloc
  test: sql/dynalloc2
  test: sql/dyntest
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/ecpg_schedule.orig pgsql.3/src/interfaces/ecpg/test/ecpg_schedule.orig
*** pgsql.2/src/interfaces/ecpg/test/ecpg_schedule.orig	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/ecpg_schedule.orig	2009-12-14 12:41:24.000000000 +0100
***************
*** 0 ****
--- 1,50 ----
+ test: compat_informix/dec_test
+ test: compat_informix/charfuncs
+ test: compat_informix/rfmtdate
+ test: compat_informix/rfmtlong
+ test: compat_informix/rnull
+ test: compat_informix/sqlda
+ test: compat_informix/test_informix
+ test: compat_informix/test_informix2
+ test: connect/test2
+ test: connect/test3
+ test: connect/test4
+ test: connect/test5
+ test: pgtypeslib/dt_test
+ test: pgtypeslib/dt_test2
+ test: pgtypeslib/num_test
+ test: pgtypeslib/num_test2
+ test: preproc/array_of_struct
+ test: preproc/autoprep
+ test: preproc/comment
+ test: preproc/cursor
+ test: preproc/define
+ test: preproc/init
+ test: preproc/strings
+ test: preproc/type
+ test: preproc/variable
+ test: preproc/whenever
+ test: sql/array
+ test: sql/binary
+ test: sql/code100
+ test: sql/copystdout
+ test: sql/define
+ test: sql/desc
+ test: sql/sqlda
+ test: sql/dynalloc
+ test: sql/dynalloc2
+ test: sql/dyntest
+ test: sql/execute
+ test: sql/fetch
+ test: sql/func
+ test: sql/indicators
+ test: sql/oldexec
+ test: sql/quote
+ test: sql/show
+ test: sql/insupd
+ test: sql/parser
+ test: thread/thread
+ test: thread/thread_implicit
+ test: thread/prep
+ test: thread/alloc
+ test: thread/descriptor
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/ecpg_schedule_tcp pgsql.3/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.2/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-12-14 12:41:24.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-12-14 14:05:07.000000000 +0100
*************** test: compat_informix/rfmtdate
*** 4,9 ****
--- 4,10 ----
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
  test: compat_informix/sqlda
+ test: compat_informix/describe
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: sql/copystdout
*** 31,36 ****
--- 32,38 ----
  test: sql/define
  test: sql/desc
  test: sql/sqlda
+ test: sql/describe
  test: sql/dynalloc
  test: sql/dynalloc2
  test: sql/dyntest
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/ecpg_schedule_tcp.orig pgsql.3/src/interfaces/ecpg/test/ecpg_schedule_tcp.orig
*** pgsql.2/src/interfaces/ecpg/test/ecpg_schedule_tcp.orig	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/ecpg_schedule_tcp.orig	2009-12-14 12:41:24.000000000 +0100
***************
*** 0 ****
--- 1,52 ----
+ test: compat_informix/dec_test
+ test: compat_informix/charfuncs
+ test: compat_informix/rfmtdate
+ test: compat_informix/rfmtlong
+ test: compat_informix/rnull
+ test: compat_informix/sqlda
+ test: compat_informix/test_informix
+ test: compat_informix/test_informix2
+ test: connect/test2
+ test: connect/test3
+ test: connect/test4
+ test: connect/test5
+ test: pgtypeslib/dt_test
+ test: pgtypeslib/dt_test2
+ test: pgtypeslib/num_test
+ test: pgtypeslib/num_test2
+ test: preproc/array_of_struct
+ test: preproc/autoprep
+ test: preproc/comment
+ test: preproc/cursor
+ test: preproc/define
+ test: preproc/init
+ test: preproc/strings
+ test: preproc/type
+ test: preproc/variable
+ test: preproc/whenever
+ test: sql/array
+ test: sql/binary
+ test: sql/code100
+ test: sql/copystdout
+ test: sql/define
+ test: sql/desc
+ test: sql/sqlda
+ test: sql/dynalloc
+ test: sql/dynalloc2
+ test: sql/dyntest
+ test: sql/execute
+ test: sql/fetch
+ test: sql/func
+ test: sql/indicators
+ test: sql/oldexec
+ test: sql/quote
+ test: sql/show
+ test: sql/insupd
+ test: sql/parser
+ test: thread/thread
+ test: thread/thread_implicit
+ test: thread/prep
+ test: thread/alloc
+ test: thread/descriptor
+ test: connect/test1
+ 
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-describe.c pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.c
*** pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-describe.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.c	2009-12-14 14:07:05.000000000 +0100
***************
*** 0 ****
--- 1,465 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "describe.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 4 "describe.pgc"
+ 
+ 
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+ 
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+ 
+ #include "ecpglib.h"
+ 
+ typedef struct sqlvar_struct
+ {
+ 	short	sqltype;		/* variable type                */
+ 	int	sqllen;			/* length in bytes              */
+ 	char	   *sqldata;		/* pointer to data              */
+ 	short	   *sqlind;		/* pointer to indicator         */
+ 	char	   *sqlname;		/* variable name                */
+ 	char	   *sqlformat;		/* reserved for future use      */
+ 	short	sqlitype;		/* ind variable type            */
+ 	short	sqlilen;		/* ind length in bytes          */
+ 	char	   *sqlidata;		/* ind data pointer             */
+ 	int	sqlxid;			/* extended id type             */
+ 	char	   *sqltypename;	/* extended type name           */
+ 	short	sqltypelen;		/* length of extended type name */
+ 	short	sqlownerlen;		/* length of owner name         */
+ 	short	sqlsourcetype;		/* source type for distinct of built-ins */
+ 	char	   *sqlownername;	/* owner name                   */
+ 	int	sqlsourceid;		/* extended id of source type   */
+ 
+ 	/*
+ 	 * sqlilongdata is new.  It supports data that exceeds the 32k
+ 	 * limit.  sqlilen and sqlidata are for backward compatibility
+ 	 * and they have maximum value of <32K.
+ 	 */
+ 	char	   *sqlilongdata;	/* for data field beyond 32K    */
+ 	int	sqlflags;		/* for internal use only        */
+ 	void	   *sqlreserved;	/* reserved for future use      */
+ } pg_sqlvar_t;
+ 
+ typedef struct sqlda
+ {
+ 	short		sqld;
+ 	pg_sqlvar_t	   *sqlvar;
+ 	char		desc_name[19];	/* descriptor name              */
+ 	short		desc_occ;	/* size of sqlda structure      */
+ 	struct sqlda	   *desc_next;	/* pointer to next sqlda struct */
+ 	void		   *reserved;	/* reserved for future use */
+ } pg_sqlda_t;
+ 
+ #endif /* POSTGRES_SQLDA_H */
+ 
+ #line 5 "describe.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 7 "describe.pgc"
+ 
+ 
+ pg_sqlda_t	*sqlda1, *sqlda2, *sqlda3;
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		  
+ 		  
+ 		  
+ 
+ #line 15 "describe.pgc"
+  char * stmt1 = "SELECT id, t FROM t1" ;
+  
+ #line 16 "describe.pgc"
+  char * stmt2 = "SELECT id, t FROM t1 WHERE id = -1" ;
+  
+ #line 17 "describe.pgc"
+  int i , count1 , count2 ;
+  
+ #line 18 "describe.pgc"
+  char field_name1 [ 30 ] = "not set" ;
+  
+ #line 19 "describe.pgc"
+  char field_name2 [ 30 ] = "not set" ;
+ /* exec sql end declare section */
+ #line 20 "describe.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0); 
+ #line 27 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 27 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 30 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 30 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
+ #line 33 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 33 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 36 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 37 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 38 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 39 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 39 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 42 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 42 "describe.pgc"
+ 
+ 
+ 	/*
+ 	 * Test DESCRIBE with a query producing tuples.
+ 	 * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
+ 	 * Informix-compat mode.
+ 	 */
+ 
+ 	strcpy(msg, "allocate");
+ 	ECPGallocate_desc(__LINE__, "desc1");
+ #line 51 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 51 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc2");
+ #line 52 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 52 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 55 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 55 "describe.pgc"
+ 
+ 
+ 	sqlda1 = sqlda2 = sqlda3 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 60 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 61 "describe.pgc"
+ 
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_sqlda, &sqlda1, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 63 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_sqlda, &sqlda2, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 64 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_sqlda, &sqlda3, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 65 "describe.pgc"
+ 
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));
+ 
+ #line 71 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 71 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count2));
+ 
+ #line 72 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 72 "describe.pgc"
+ 
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld &&
+ 		count1 == sqlda3->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+ 	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 82 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 82 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+ 	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 83 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 83 "describe.pgc"
+ 
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname,
+ 			sqlda3->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 93 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 93 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 94 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 94 "describe.pgc"
+ 
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 	free(sqlda3);
+ 
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
+ #line 99 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 99 "describe.pgc"
+ 
+ 
+ 	/* Test DESCRIBE with a query not producing tuples */
+ 
+ 	strcpy(msg, "allocate");
+ 	ECPGallocate_desc(__LINE__, "desc1");
+ #line 104 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 104 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc2");
+ #line 105 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 105 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2);
+ #line 108 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 108 "describe.pgc"
+ 
+ 
+ 	sqlda1 = sqlda2 = sqlda3 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 113 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 114 "describe.pgc"
+ 
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_sqlda, &sqlda1, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 116 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_sqlda, &sqlda2, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 117 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_sqlda, &sqlda3, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 118 "describe.pgc"
+ 
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));
+ 
+ #line 124 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 124 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count2));
+ 
+ #line 125 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 125 "describe.pgc"
+ 
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld &&
+ 		count1 == sqlda3->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+ 	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 135 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 135 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+ 	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 136 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 136 "describe.pgc"
+ 
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname,
+ 			sqlda3->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 146 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 146 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 147 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 147 "describe.pgc"
+ 
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 	free(sqlda3);
+ 
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id2");
+ #line 152 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 152 "describe.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 157 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 157 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 160 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 160 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 163 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 163 "describe.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr
*** pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr	2009-12-14 12:42:44.000000000 +0100
***************
*** 0 ****
--- 1,100 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: query: insert into t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 42: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 55: name st_id1; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 99: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 108: name st_id2; query: "SELECT id, t FROM t1 WHERE id = -1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 152: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 160: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout
*** pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout	2009-12-14 12:42:44.000000000 +0100
***************
*** 0 ****
--- 1,24 ----
+ 1
+ 	field_name1 'id'
+ 	field_name2 'id'
+ 	sqlda1 'id'
+ 	sqlda2 'id'
+ 	sqlda3 'id'
+ 2
+ 	field_name1 't'
+ 	field_name2 't'
+ 	sqlda1 't'
+ 	sqlda2 't'
+ 	sqlda3 't'
+ 1
+ 	field_name1 'id'
+ 	field_name2 'id'
+ 	sqlda1 'id'
+ 	sqlda2 'id'
+ 	sqlda3 'id'
+ 2
+ 	field_name1 't'
+ 	field_name2 't'
+ 	sqlda1 't'
+ 	sqlda2 't'
+ 	sqlda3 't'
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/preproc-describe.c pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.c
*** pgsql.2/src/interfaces/ecpg/test/expected/preproc-describe.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.c	2009-12-14 12:42:44.000000000 +0100
***************
*** 0 ****
--- 1,481 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "describe.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 4 "describe.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 6 "describe.pgc"
+ 
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		    
+ 		  
+ 		  
+ 		  
+ 		  
+ 
+ #line 12 "describe.pgc"
+  char * stmt1 = "SELECT id, t FROM t1" ;
+  
+ #line 13 "describe.pgc"
+  char * stmt2 = "SELECT id, t FROM t1 WHERE id = -1" ;
+  
+ #line 14 "describe.pgc"
+  int i , count1 , count2 , count3 , count4 ;
+  
+ #line 15 "describe.pgc"
+  char field_name1 [ 30 ] = "not set" ;
+  
+ #line 16 "describe.pgc"
+  char field_name2 [ 30 ] = "not set" ;
+  
+ #line 17 "describe.pgc"
+  char field_name3 [ 30 ] = "not set" ;
+  
+ #line 18 "describe.pgc"
+  char field_name4 [ 30 ] = "not set" ;
+ /* exec sql end declare section */
+ #line 19 "describe.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
+ #line 26 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 26 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 29 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 29 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
+ #line 32 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 32 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 35 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 35 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 36 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 37 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 38 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 41 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "describe.pgc"
+ 
+ 
+ 	/*
+ 	 * Test DESCRIBE with a query producing tuples.
+ 	 * DESCRIPTOR and SQL DESCRIPTOR are the same in native mode.
+ 	 */
+ 
+ 	strcpy(msg, "allocate");
+ 	ECPGallocate_desc(__LINE__, "desc1");
+ #line 49 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 49 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc2");
+ #line 50 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 50 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc3");
+ #line 51 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 51 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc4");
+ #line 52 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 52 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 55 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 55 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "describe");
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 58 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 59 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc3", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 60 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc4", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 61 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "get descriptor");
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));
+ 
+ #line 64 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 64 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc2", &(count2));
+ 
+ #line 65 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 65 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc3", &(count3));
+ 
+ #line 66 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 66 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc4", &(count4));
+ 
+ #line 67 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 67 "describe.pgc"
+ 
+ 
+ 	if (!(count1 == count2 && count1 == count3 && count1 == count4))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+ 	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 74 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 74 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+ 	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 75 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 75 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc3", i,ECPGd_name,
+ 	ECPGt_char,(field_name3),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 76 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 76 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc4", i,ECPGd_name,
+ 	ECPGt_char,(field_name4),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 77 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 77 "describe.pgc"
+ 
+ 		printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
+ 			field_name1, field_name2, field_name3, field_name4);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 83 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 83 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 84 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 84 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc3");
+ #line 85 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 85 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc4");
+ #line 86 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 86 "describe.pgc"
+ 
+ 
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
+ #line 88 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 88 "describe.pgc"
+ 
+ 
+ 	/* Test DESCRIBE with a query not producing tuples */
+ 
+ 	strcpy(msg, "allocate");
+ 	ECPGallocate_desc(__LINE__, "desc1");
+ #line 93 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 93 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc2");
+ #line 94 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 94 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc3");
+ #line 95 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 95 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc4");
+ #line 96 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 96 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2);
+ #line 99 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 99 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "describe");
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 102 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 103 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc3", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 104 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc4", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 105 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "get descriptor");
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));
+ 
+ #line 108 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 108 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc2", &(count2));
+ 
+ #line 109 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 109 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc3", &(count3));
+ 
+ #line 110 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 110 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc4", &(count4));
+ 
+ #line 111 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 111 "describe.pgc"
+ 
+ 
+ 	if (!(count1 == count2 && count1 == count3 && count1 == count4))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+ 	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 118 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 118 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+ 	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 119 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 119 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc3", i,ECPGd_name,
+ 	ECPGt_char,(field_name3),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 120 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 120 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc4", i,ECPGd_name,
+ 	ECPGt_char,(field_name4),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 121 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 121 "describe.pgc"
+ 
+ 		printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
+ 			field_name1, field_name2, field_name3, field_name4);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 127 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 127 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 128 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 128 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc3");
+ #line 129 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 129 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc4");
+ #line 130 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 130 "describe.pgc"
+ 
+ 
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
+ #line 132 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 132 "describe.pgc"
+ 
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 138 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 138 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 141 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 141 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 144 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 144 "describe.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/preproc-describe.stderr pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.stderr
*** pgsql.2/src/interfaces/ecpg/test/expected/preproc-describe.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.stderr	2009-12-14 12:42:44.000000000 +0100
***************
*** 0 ****
--- 1,140 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: query: insert into t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 41: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 55: name st_id1; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 88: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 99: name st_id2; query: "SELECT id, t FROM t1 WHERE id = -1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 132: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 138: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 138: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 138: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 141: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/preproc-describe.stdout pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.stdout
*** pgsql.2/src/interfaces/ecpg/test/expected/preproc-describe.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.stdout	2009-12-14 12:42:44.000000000 +0100
***************
*** 0 ****
--- 1,4 ----
+ field_name 1 'id' 2 'id' 3 'id' 4 'id'
+ field_name 1 't' 2 't' 3 't' 4 't'
+ field_name 1 'id' 2 'id' 3 'id' 4 'id'
+ field_name 1 't' 2 't' 3 't' 4 't'
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/sql-describe.c pgsql.3/src/interfaces/ecpg/test/expected/sql-describe.c
*** pgsql.2/src/interfaces/ecpg/test/expected/sql-describe.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/sql-describe.c	2009-12-14 14:06:16.000000000 +0100
***************
*** 0 ****
--- 1,447 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "describe.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 4 "describe.pgc"
+ 
+ 
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+ 
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+ 
+ #include "ecpglib.h"
+ 
+ typedef struct sqlvar_struct
+ {
+ 	short	sqltype;		/* variable type                */
+ 	int	sqllen;			/* length in bytes              */
+ 	char	   *sqldata;		/* pointer to data              */
+ 	short	   *sqlind;		/* pointer to indicator         */
+ 	char	   *sqlname;		/* variable name                */
+ 	char	   *sqlformat;		/* reserved for future use      */
+ 	short	sqlitype;		/* ind variable type            */
+ 	short	sqlilen;		/* ind length in bytes          */
+ 	char	   *sqlidata;		/* ind data pointer             */
+ 	int	sqlxid;			/* extended id type             */
+ 	char	   *sqltypename;	/* extended type name           */
+ 	short	sqltypelen;		/* length of extended type name */
+ 	short	sqlownerlen;		/* length of owner name         */
+ 	short	sqlsourcetype;		/* source type for distinct of built-ins */
+ 	char	   *sqlownername;	/* owner name                   */
+ 	int	sqlsourceid;		/* extended id of source type   */
+ 
+ 	/*
+ 	 * sqlilongdata is new.  It supports data that exceeds the 32k
+ 	 * limit.  sqlilen and sqlidata are for backward compatibility
+ 	 * and they have maximum value of <32K.
+ 	 */
+ 	char	   *sqlilongdata;	/* for data field beyond 32K    */
+ 	int	sqlflags;		/* for internal use only        */
+ 	void	   *sqlreserved;	/* reserved for future use      */
+ } pg_sqlvar_t;
+ 
+ typedef struct sqlda
+ {
+ 	short		sqld;
+ 	pg_sqlvar_t	   *sqlvar;
+ 	char		desc_name[19];	/* descriptor name              */
+ 	short		desc_occ;	/* size of sqlda structure      */
+ 	struct sqlda	   *desc_next;	/* pointer to next sqlda struct */
+ 	void		   *reserved;	/* reserved for future use */
+ } pg_sqlda_t;
+ 
+ #endif /* POSTGRES_SQLDA_H */
+ 
+ #line 5 "describe.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 7 "describe.pgc"
+ 
+ 
+ pg_sqlda_t	*sqlda1, *sqlda2;
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		  
+ 		  
+ 		  
+ 
+ #line 15 "describe.pgc"
+  char * stmt1 = "SELECT id, t FROM t1" ;
+  
+ #line 16 "describe.pgc"
+  char * stmt2 = "SELECT id, t FROM t1 WHERE id = -1" ;
+  
+ #line 17 "describe.pgc"
+  int i , count1 , count2 ;
+  
+ #line 18 "describe.pgc"
+  char field_name1 [ 30 ] = "not set" ;
+  
+ #line 19 "describe.pgc"
+  char field_name2 [ 30 ] = "not set" ;
+ /* exec sql end declare section */
+ #line 20 "describe.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
+ #line 27 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 27 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 30 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 30 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
+ #line 33 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 33 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 36 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 37 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 38 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 39 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 39 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 42 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 42 "describe.pgc"
+ 
+ 
+ 	/*
+ 	 * Test DESCRIBE with a query producing tuples.
+ 	 * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
+ 	 * Informix-compat mode.
+ 	 */
+ 
+ 	strcpy(msg, "allocate");
+ 	ECPGallocate_desc(__LINE__, "desc1");
+ #line 51 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 51 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc2");
+ #line 52 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 52 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 55 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 55 "describe.pgc"
+ 
+ 
+ 	sqlda1 = sqlda2 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 60 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 61 "describe.pgc"
+ 
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_sqlda, &sqlda1, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 63 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_sqlda, &sqlda2, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 64 "describe.pgc"
+ 
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));
+ 
+ #line 70 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 70 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count2));
+ 
+ #line 71 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 71 "describe.pgc"
+ 
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+ 	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 80 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 80 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+ 	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 81 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 81 "describe.pgc"
+ 
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 90 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 90 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 91 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 91 "describe.pgc"
+ 
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
+ #line 95 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 95 "describe.pgc"
+ 
+ 
+ 	/* Test DESCRIBE with a query not producing tuples */
+ 
+ 	strcpy(msg, "allocate");
+ 	ECPGallocate_desc(__LINE__, "desc1");
+ #line 100 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 100 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc2");
+ #line 101 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 101 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2);
+ #line 104 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 104 "describe.pgc"
+ 
+ 
+ 	sqlda1 = sqlda2 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 109 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 110 "describe.pgc"
+ 
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_sqlda, &sqlda1, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 112 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_sqlda, &sqlda2, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 113 "describe.pgc"
+ 
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));
+ 
+ #line 119 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 119 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count2));
+ 
+ #line 120 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 120 "describe.pgc"
+ 
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+ 	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 129 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 129 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+ 	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 130 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 130 "describe.pgc"
+ 
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 139 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 139 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 140 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 140 "describe.pgc"
+ 
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
+ #line 144 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 144 "describe.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 149 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 149 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 152 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 152 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 155 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 155 "describe.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/sql-describe.stderr pgsql.3/src/interfaces/ecpg/test/expected/sql-describe.stderr
*** pgsql.2/src/interfaces/ecpg/test/expected/sql-describe.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/sql-describe.stderr	2009-12-14 14:06:16.000000000 +0100
***************
*** 0 ****
--- 1,100 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: query: insert into t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 42: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 55: name st_id1; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 95: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 104: name st_id2; query: "SELECT id, t FROM t1 WHERE id = -1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 144: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 152: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/sql-describe.stdout pgsql.3/src/interfaces/ecpg/test/expected/sql-describe.stdout
*** pgsql.2/src/interfaces/ecpg/test/expected/sql-describe.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/sql-describe.stdout	2009-12-14 14:06:16.000000000 +0100
***************
*** 0 ****
--- 1,20 ----
+ 1
+ 	field_name1 'id'
+ 	field_name2 'id'
+ 	sqlda1 'id'
+ 	sqlda2 'id'
+ 2
+ 	field_name1 't'
+ 	field_name2 't'
+ 	sqlda1 't'
+ 	sqlda2 't'
+ 1
+ 	field_name1 'id'
+ 	field_name2 'id'
+ 	sqlda1 'id'
+ 	sqlda2 'id'
+ 2
+ 	field_name1 't'
+ 	field_name2 't'
+ 	sqlda1 't'
+ 	sqlda2 't'
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/sql/describe.pgc pgsql.3/src/interfaces/ecpg/test/sql/describe.pgc
*** pgsql.2/src/interfaces/ecpg/test/sql/describe.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/sql/describe.pgc	2009-12-14 14:03:53.000000000 +0100
***************
*** 0 ****
--- 1,158 ----
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ exec sql include ../regression;
+ exec sql include sqlda.h;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ pg_sqlda_t	*sqlda1, *sqlda2;
+ 
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ 	char	*stmt1 = "SELECT id, t FROM t1";
+ 	char	*stmt2 = "SELECT id, t FROM t1 WHERE id = -1";
+ 	int	i, count1, count2;
+ 	char	field_name1[30] = "not set";
+ 	char	field_name2[30] = "not set";
+ exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table t1(id serial primary key, t text);
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into t1(id, t) values (default, 'a');
+ 	exec sql insert into t1(id, t) values (default, 'b');
+ 	exec sql insert into t1(id, t) values (default, 'c');
+ 	exec sql insert into t1(id, t) values (default, 'd');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/*
+ 	 * Test DESCRIBE with a query producing tuples.
+ 	 * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
+ 	 * Informix-compat mode.
+ 	 */
+ 
+ 	strcpy(msg, "allocate");
+ 	exec sql allocate descriptor desc1;
+ 	exec sql allocate descriptor desc2;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id1 FROM :stmt1;
+ 
+ 	sqlda1 = sqlda2 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	exec sql describe st_id1 into sql descriptor desc1;
+ 	exec sql describe st_id1 using sql descriptor desc2;
+ 
+ 	exec sql describe st_id1 into descriptor sqlda1;
+ 	exec sql describe st_id1 using descriptor sqlda2;
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	exec sql get descriptor desc1 :count1 = count;
+ 	exec sql get descriptor desc1 :count2 = count;
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		exec sql get descriptor desc1 value :i :field_name1 = name;
+ 		exec sql get descriptor desc2 value :i :field_name2 = name;
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate descriptor desc1;
+ 	exec sql deallocate descriptor desc2;
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 
+ 	exec sql deallocate prepare st_id1;
+ 
+ 	/* Test DESCRIBE with a query not producing tuples */
+ 
+ 	strcpy(msg, "allocate");
+ 	exec sql allocate descriptor desc1;
+ 	exec sql allocate descriptor desc2;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id2 FROM :stmt2;
+ 
+ 	sqlda1 = sqlda2 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	exec sql describe st_id2 into sql descriptor desc1;
+ 	exec sql describe st_id2 using sql descriptor desc2;
+ 
+ 	exec sql describe st_id2 into descriptor sqlda1;
+ 	exec sql describe st_id2 using descriptor sqlda2;
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	exec sql get descriptor desc1 :count1 = count;
+ 	exec sql get descriptor desc1 :count2 = count;
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		exec sql get descriptor desc1 value :i :field_name1 = name;
+ 		exec sql get descriptor desc2 value :i :field_name2 = name;
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate descriptor desc1;
+ 	exec sql deallocate descriptor desc2;
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 
+ 	exec sql deallocate prepare st_id2;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table t1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/sql/Makefile pgsql.3/src/interfaces/ecpg/test/sql/Makefile
*** pgsql.2/src/interfaces/ecpg/test/sql/Makefile	2009-12-14 12:41:24.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/sql/Makefile	2009-12-14 13:59:40.000000000 +0100
*************** TESTS = array array.c \
*** 9,14 ****
--- 9,16 ----
          copystdout copystdout.c \
  	define define.c \
          desc desc.c \
+         sqlda sqlda.c \
+         describe describe.c \
          dyntest dyntest.c \
          dynalloc dynalloc.c \
          dynalloc2 dynalloc2.c \
*************** TESTS = array array.c \
*** 20,26 ****
          parser parser.c \
          quote quote.c \
          show show.c \
-         sqlda sqlda.c \
          insupd insupd.c 
  
  all: $(TESTS)
--- 22,27 ----
#72Boszormenyi Zoltan
zb@cybertec.at
In reply to: Boszormenyi Zoltan (#70)
1 attachment(s)
Re: ECPG patch 2, SQLDA support

Boszormenyi Zoltan írta:

Boszormenyi Zoltan írta:

Will post a new version soon, Michael asked to turn it
into an ECPG native feature instead of compat-mode-only.

Attached is the new version that applies cleanly to HEAD.

Changes:
- SQLDA is now an ECPG native feature, not compat-only.
- As a consequence, and to be coherent with the Informix syntax,
keyword "SQL" in SQL DESCRIPTOR is now mandatory
to denote the named SQL descriptor. "DESCRIPTOR"
without "SQL" means SQLDA descriptor
- SQLDA can now return more than one tuples using
the ->desc_next pointer
- Bcause SQLDA is now a native feature, there are two
sqlda.pgc regression tests, to test compat-only syntax in
compat mode and multi-tuple return values in native mode.
- sqlda->sqlvar[i].sqltype uses ECPGt_* type symbols,
no more funny-looking typedefs in sqltypes.h, it's a clean
compat-only header, as it was before

New version, fixed some loose ends introduced by
the native mode and multi-tuple SQLDA.

Best regards,
Zoltán Böszörményi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

Attachments:

2-pg85-sqlda-17-ctxdiff.patchtext/x-patch; name=2-pg85-sqlda-17-ctxdiff.patchDownload
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/execute.c pgsql.2/src/interfaces/ecpg/ecpglib/execute.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/execute.c	2009-09-03 14:37:34.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/ecpglib/execute.c	2009-12-15 10:08:46.000000000 +0100
***************
*** 25,30 ****
--- 25,31 ----
  #include "ecpgerrno.h"
  #include "extern.h"
  #include "sqlca.h"
+ #include "sqlda.h"
  #include "sql3types.h"
  #include "pgtypes_numeric.h"
  #include "pgtypes_date.h"
*************** ecpg_store_input(const int lineno, const
*** 1033,1038 ****
--- 1034,1040 ----
  				break;
  
  			case ECPGt_descriptor:
+ 			case ECPGt_sqlda:
  				break;
  
  			default:
*************** ecpg_execute(struct statement * stmt)
*** 1172,1177 ****
--- 1174,1234 ----
  			if (desc->count == desc_counter)
  				desc_counter = 0;
  		}
+ 		else if (var->type == ECPGt_sqlda)
+ 		{
+ 			pg_sqlda_t	   *sqlda = *(pg_sqlda_t **)var->pointer;
+ 			struct variable	desc_inlist;
+ 			int		i;
+ 
+ 			if (sqlda == NULL)
+ 				return false;
+ 
+ 			desc_counter++;
+ 			for (i = 0; i < sqlda->sqld; i++)
+ 			{
+ 				if (i + 1 == desc_counter)
+ 				{
+ 					desc_inlist.type = sqlda->sqlvar[i].sqltype;
+ 					desc_inlist.value = sqlda->sqlvar[i].sqldata;
+ 					desc_inlist.pointer = &(sqlda->sqlvar[i].sqldata);
+ 					switch (desc_inlist.type)
+ 					{
+ 						case ECPGt_char:
+ 						case ECPGt_varchar:
+ 							desc_inlist.varcharsize = strlen(sqlda->sqlvar[i].sqldata);
+ 							break;
+ 						default:
+ 							desc_inlist.varcharsize = 0;
+ 							break;
+ 					}
+ 					desc_inlist.arrsize = 1;
+ 					desc_inlist.offset = 0;
+ 					if (sqlda->sqlvar[i].sqlind)
+ 					{
+ 						desc_inlist.ind_type = ECPGt_short;
+ 						/* ECPG expects indicator value < 0 */
+ 						if (*(sqlda->sqlvar[i].sqlind))
+ 							*(sqlda->sqlvar[i].sqlind) = -1;
+ 						desc_inlist.ind_value = sqlda->sqlvar[i].sqlind;
+ 						desc_inlist.ind_pointer = &(sqlda->sqlvar[i].sqlind);
+ 						desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = 1;
+ 						desc_inlist.ind_offset = 0;
+ 					}
+ 					else
+ 					{
+ 						desc_inlist.ind_type = ECPGt_NO_INDICATOR;
+ 						desc_inlist.ind_value = desc_inlist.ind_pointer = NULL;
+ 						desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = desc_inlist.ind_offset = 0;
+ 					}
+ 					if (!ecpg_store_input(stmt->lineno, stmt->force_indicator, &desc_inlist, &tobeinserted, false))
+ 						return false;
+ 
+ 					break;
+ 				}
+ 			}
+ 			if (sqlda->sqld == desc_counter)
+ 				desc_counter = 0;
+ 		}
  		else
  		{
  			if (!ecpg_store_input(stmt->lineno, stmt->force_indicator, var, &tobeinserted, false))
*************** ecpg_execute(struct statement * stmt)
*** 1353,1358 ****
--- 1410,1467 ----
  				}
  				var = var->next;
  			}
+ 			else if (var != NULL && var->type == ECPGt_sqlda)
+ 			{
+ 				pg_sqlda_t	  **_sqlda = (pg_sqlda_t **)var->pointer;
+ 				pg_sqlda_t	   *sqlda = *_sqlda;
+ 				pg_sqlda_t	   *sqlda_new;
+ 				int		i;
+ 
+ 				/* If we are passed in a previously existing sqlda (chain) then free it. */
+ 				while (sqlda)
+ 				{
+ 					sqlda_new = sqlda->desc_next;
+ 					free(sqlda);
+ 					sqlda = sqlda_new;
+ 				}
+ 				*_sqlda = sqlda = sqlda_new = NULL;
+ 				for (i = ntuples - 1; i >= 0; i--)
+ 				{
+ 					/* Build a new sqlda structure. Note that only fetching 1 record is supported */
+ 					sqlda_new = ecpg_build_sqlda_for_PGresult(stmt->lineno, results, i, stmt->compat);
+ 
+ 					if (!sqlda_new)
+ 					{
+ 						/* cleanup all SQLDAs we created up */
+ 						while (sqlda)
+ 						{
+ 							sqlda_new = sqlda->desc_next;
+ 							free(sqlda);
+ 							sqlda = sqlda_new;
+ 						}
+ 						*_sqlda = NULL;
+ 
+ 						ecpg_log("ecpg_execute on line %d: out of memory allocating a new sqlda\n", stmt->lineno);
+ 						status = false;
+ 						break;
+ 					}
+ 					else
+ 					{
+ 						ecpg_log("ecpg_execute on line %d: new sqlda was built\n", stmt->lineno);
+ 
+ 						*_sqlda = sqlda_new;
+ 
+ 						ecpg_set_sqlda_from_PGresult(stmt->lineno, _sqlda, results, i, stmt->compat);
+ 						ecpg_log("ecpg_execute on line %d: putting result (1 tuple %d fields) into sqlda descriptor\n",
+ 								stmt->lineno, PQnfields(results));
+ 
+ 						sqlda_new->desc_next = sqlda;
+ 						sqlda = sqlda_new;
+ 					}
+ 				}
+ 
+ 				var = var->next;
+ 			}
  			else
  				for (act_field = 0; act_field < nfields && status; act_field++)
  				{
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/extern.h pgsql.2/src/interfaces/ecpg/ecpglib/extern.h
*** pgsql.orig/src/interfaces/ecpg/ecpglib/extern.h	2009-05-25 12:08:48.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/ecpglib/extern.h	2009-12-14 12:41:24.000000000 +0100
***************
*** 6,11 ****
--- 6,12 ----
  #include "postgres_fe.h"
  #include "libpq-fe.h"
  #include "sqlca.h"
+ #include "sqlda.h"
  #include "ecpg_config.h"
  #ifndef CHAR_BIT
  #include <limits.h>
*************** bool		ecpg_init(const struct connection 
*** 129,134 ****
--- 130,136 ----
  char	   *ecpg_strdup(const char *, int);
  const char *ecpg_type_name(enum ECPGttype);
  int			ecpg_dynamic_type(Oid);
+ int			sqlda_dynamic_type(Oid, enum COMPAT_MODE);
  void		ecpg_free_auto_mem(void);
  void		ecpg_clear_auto_mem(void);
  
*************** void		ecpg_log(const char *format,...);
*** 149,154 ****
--- 151,159 ----
  bool		ecpg_auto_prepare(int, const char *, const int, char **, const char *);
  void		ecpg_init_sqlca(struct sqlca_t * sqlca);
  
+ pg_sqlda_t *ecpg_build_sqlda_for_PGresult(int, PGresult *, int, enum COMPAT_MODE);
+ void		ecpg_set_sqlda_from_PGresult(int, pg_sqlda_t **, const PGresult *, int, enum COMPAT_MODE);
+ 
  /* SQLSTATE values generated or processed by ecpglib (intentionally
   * not exported -- users should refer to the codes directly) */
  
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/Makefile pgsql.2/src/interfaces/ecpg/ecpglib/Makefile
*** pgsql.orig/src/interfaces/ecpg/ecpglib/Makefile	2009-07-13 11:16:41.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/ecpglib/Makefile	2009-12-14 12:41:24.000000000 +0100
*************** override CFLAGS += $(PTHREAD_CFLAGS)
*** 24,30 ****
  # Need to recompile any libpgport object files
  LIBS := $(filter-out -lpgport, $(LIBS))
  
! OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
  	connect.o misc.o path.o pgstrcasecmp.o \
  	$(filter snprintf.o strlcpy.o, $(LIBOBJS))
  
--- 24,30 ----
  # Need to recompile any libpgport object files
  LIBS := $(filter-out -lpgport, $(LIBS))
  
! OBJS= execute.o typename.o descriptor.o sqlda.o data.o error.o prepare.o memory.o \
  	connect.o misc.o path.o pgstrcasecmp.o \
  	$(filter snprintf.o strlcpy.o, $(LIBOBJS))
  
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/sqlda.c pgsql.2/src/interfaces/ecpg/ecpglib/sqlda.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/sqlda.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/ecpglib/sqlda.c	2009-12-14 12:41:24.000000000 +0100
***************
*** 0 ****
--- 1,387 ----
+ /*
+  * SQLDA support routines
+  *
+  * The allocated memory area pointed by an sqlda pointer
+  * contains both the metadata and the data, so freeing up
+  * is a simple free(sqlda) as expected by the ESQL/C examples.
+  */
+ 
+ #define POSTGRES_ECPG_INTERNAL
+ #include "postgres_fe.h"
+ #include "pg_type.h"
+ 
+ #include <inttypes.h>
+ #include <dlfcn.h>
+ 
+ #include "ecpg-pthread-win32.h"
+ #include "decimal.h"
+ #include "ecpgtype.h"
+ #include "ecpglib.h"
+ #include "ecpgerrno.h"
+ #include "extern.h"
+ #include "sqlca.h"
+ #include "sqlda.h"
+ 
+ /*
+  * Compute the next variable's offset with
+  * the current variable's size and alignment.
+  * 
+  *
+  * Returns:
+  * - the current variable's offset in *current
+  * - the next variable's offset in *next
+  */
+ static void
+ ecpg_sqlda_align_add_size(long offset, int alignment, int size, long *current, long *next)
+ {
+ 	if (offset % alignment)
+ 		offset += alignment - (offset % alignment);
+ 	if (current)
+ 		*current = offset;
+ 	offset += size;
+ 	if (next)
+ 		*next = offset;
+ }
+ 
+ static long
+ ecpg_sqlda_empty_size(const PGresult *res)
+ {
+ 	long	offset;
+ 	int	i;
+ 	int	sqld = PQnfields(res);
+ 
+ 	/* Initial size to store main structure and field structures */
+ 	offset = sizeof(pg_sqlda_t) + sqld * sizeof(pg_sqlvar_t);
+ 
+ 	/* Add space for field names */
+ 	for (i = 0; i < sqld; i++)
+ 		offset += strlen(PQfname(res, i)) + 1;
+ 
+ 	/* Add padding to the first field value */
+ 	ecpg_sqlda_align_add_size(offset, sizeof(int), 0, &offset, NULL);
+ 
+ 	return offset;
+ }
+ 
+ static long
+ ecpg_sqlda_total_size(const PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ 	int	i;
+ 	int	sqld = PQnfields(res);
+ 	long	offset, next_offset;
+ 
+ 	offset = ecpg_sqlda_empty_size(res);
+ 
+ 	if (row < 0)
+ 		return offset;
+ 
+ 	/* Add space for the field values */
+ 	for (i = 0; i < sqld; i++)
+ 	{
+ 		enum ECPGttype type = sqlda_dynamic_type(PQftype(res, i), compat);
+ 		switch (type)
+ 		{
+ 			case ECPGt_short:
+ 			case ECPGt_unsigned_short:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_int:
+ 			case ECPGt_unsigned_int:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_long:
+ 			case ECPGt_unsigned_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_long_long:
+ 			case ECPGt_unsigned_long_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_bool:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_float:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_double:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_decimal:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_numeric:
+ 				/*
+ 				 * Let's align both the numeric struct and the digits array to int
+ 				 * Unfortunately we need to do double work here to compute the size
+ 				 * of the space needed for the numeric structure.
+ 				 */
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset1 %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				if (!PQgetisnull(res, row, i))
+ 				{
+ 					char	   *val = PQgetvalue(res, row, i);
+ 					numeric	   *num;
+ 
+ 					num = PGTYPESnumeric_from_asc(val, NULL);
+ 					if (!num)
+ 						break;
+ 					ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
+ 					ecpg_log("%s type %s offset2 %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 					PGTYPESnumeric_free(num);
+ 				}
+ 				break;
+ 			case ECPGt_date:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(date), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_timestamp:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(timestamp), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_interval:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(interval), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_char:
+ 			case ECPGt_unsigned_char:
+ 			case ECPGt_string:
+ 			default:
+ 			{
+ 				long	datalen = strlen(PQgetvalue(res, row, i)) + 1;
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			}
+ 		}
+ 		offset = next_offset;
+ 	}
+ 	return offset;
+ }
+ 
+ /*
+  * Build pg_sqlda_t (metadata only) from PGresult
+  * leaving enough space for the field values in
+  * the given row number
+  */
+ pg_sqlda_t *
+ ecpg_build_sqlda_for_PGresult(int line, PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ 	pg_sqlda_t *sqlda;
+ 	pg_sqlvar_t*sqlvar;
+ 	char	   *fname;
+ 	long		size;
+ 	int		sqld;
+ 	int		i;
+ 
+ 	size = ecpg_sqlda_total_size(res, row, compat);
+ 	sqlda = (pg_sqlda_t *)ecpg_alloc(size, line);
+ 	if (!sqlda)
+ 		return NULL;
+ 
+ 	memset(sqlda, 0, size);
+ 	sqlvar = (pg_sqlvar_t *)(sqlda + 1);
+ 	sqld = PQnfields(res);
+ 	fname = (char *)(sqlvar + sqld);
+ 
+ 	sqlda->sqld = sqld;
+ 	sqlda->desc_occ = size; /* cheat here, keep the full allocated size */
+ 	sqlda->sqlvar = sqlvar;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		sqlda->sqlvar[i].sqltype = sqlda_dynamic_type(PQftype(res, i), compat);
+ 		strcpy(fname, PQfname(res, i));
+ 		sqlda->sqlvar[i].sqlname = fname;
+ 		fname += strlen(sqlda->sqlvar[i].sqlname) + 1;
+ 		sqlda->sqlvar[i].sqlformat = (char *)(long)PQfformat(res, i);
+ 		sqlda->sqlvar[i].sqlxid = PQftype(res, i);
+ 		sqlda->sqlvar[i].sqltypelen = PQfsize(res, i);
+ 	}
+ 
+ 	return sqlda;
+ }
+ 
+ /*
+  * Sets values from PGresult.
+  */
+ static int2	value_is_null = -1;
+ static int2	value_is_not_null = 0;
+ 
+ void
+ ecpg_set_sqlda_from_PGresult(int lineno, pg_sqlda_t **_sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ 	pg_sqlda_t *sqlda = (*_sqlda);
+ 	int		i;
+ 	long		offset, next_offset;
+ 
+ 	/* Offset for the first field value */
+ 	offset = ecpg_sqlda_empty_size(res);
+ 
+ 	if (row < 0)
+ 		return;
+ 
+ 	/*
+ 	 * Set sqlvar[i]->sqldata pointers and convert values to correct format
+ 	 */
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		int	isnull;
+ 		int	datalen;
+ 		bool	set_data = true;
+ 
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 			case ECPGt_short:
+ 			case ECPGt_unsigned_short:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(short);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_int:
+ 			case ECPGt_unsigned_int:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(int);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_long:
+ 			case ECPGt_unsigned_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(long);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_long_long:
+ 			case ECPGt_unsigned_long_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(long long);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_bool:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(bool);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_float:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(float);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_double:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(double);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_decimal:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(decimal);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_numeric:
+ 			{
+ 				numeric	   *num;
+ 				char	   *val;
+ 
+ 				set_data = false;
+ 
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(numeric);
+ 				ecpg_log("%s type %s offset1 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 
+ 				if (PQgetisnull(res, row, i))
+ 				{
+ 					ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
+ 					break;
+ 				}
+ 
+ 				val = PQgetvalue(res, row, i);
+ 				num = PGTYPESnumeric_from_asc(val, NULL);
+ 				if (!num)
+ 				{
+ 					ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
+ 					break;
+ 				}
+ 
+ 				memcpy(sqlda->sqlvar[i].sqldata, num, sizeof(numeric));
+ 
+ 				ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
+ 				memcpy((char *)sqlda + offset, num->buf, num->ndigits + 1);
+ 				ecpg_log("%s type %s offset2 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 
+ 				((numeric *)sqlda->sqlvar[i].sqldata)->buf = (NumericDigit *)sqlda + offset;
+ 				((numeric *)sqlda->sqlvar[i].sqldata)->digits = (NumericDigit *)sqlda + offset + (num->digits - num->buf);
+ 
+ 				PGTYPESnumeric_free(num);
+ 
+ 				break;
+ 			}
+ 			case ECPGt_date:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(date), sizeof(date), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(date);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_timestamp:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(timestamp), sizeof(timestamp), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(timestamp);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_interval:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int64_t), sizeof(interval), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(interval);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_char:
+ 			case ECPGt_unsigned_char:
+ 			case ECPGt_string:
+ 			default:
+ 				datalen = strlen(PQgetvalue(res, row, i)) + 1;
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = datalen;
+ 				if (datalen > 32768)
+ 					sqlda->sqlvar[i].sqlilongdata = sqlda->sqlvar[i].sqldata;
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 		}
+ 
+ 		isnull = PQgetisnull(res, row, i);
+ 		ecpg_log("%s row %d col %d %s\n", __FUNCTION__, row, i, isnull ? "IS NULL" : "IS NOT NULL");
+ 		sqlda->sqlvar[i].sqlind = isnull ? &value_is_null : &value_is_not_null;
+ 		sqlda->sqlvar[i].sqlitype = ECPGt_short;
+ 		sqlda->sqlvar[i].sqlilen = sizeof(short);
+ 		if (!isnull)
+ 		{
+ 			if (set_data)
+ 				ecpg_get_data(res, row, i, lineno,
+ 						sqlda->sqlvar[i].sqltype, ECPGt_NO_INDICATOR,
+ 						sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
+ 						ECPG_ARRAY_NONE, ECPG_COMPAT_INFORMIX, false);
+ 		}
+ 		else
+ 		{
+ 			if (INFORMIX_MODE(compat))
+ 				ECPGset_noind_null(sqlda->sqlvar[i].sqltype, sqlda->sqlvar[i].sqldata);
+ 		}
+ 
+ 		offset = next_offset;
+ 	}
+ }
+ 
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/typename.c pgsql.2/src/interfaces/ecpg/ecpglib/typename.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/typename.c	2009-08-07 13:06:28.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/ecpglib/typename.c	2009-12-14 12:41:24.000000000 +0100
***************
*** 7,12 ****
--- 7,13 ----
  #include "ecpgtype.h"
  #include "ecpglib.h"
  #include "extern.h"
+ #include "sqltypes.h"
  #include "sql3types.h"
  #include "pg_type.h"
  
*************** ecpg_dynamic_type(Oid type)
*** 100,102 ****
--- 101,142 ----
  			return -(int) type;
  	}
  }
+ 
+ int
+ sqlda_dynamic_type(Oid type, enum COMPAT_MODE compat)
+ {
+ 	switch (type)
+ 	{
+ 		case CHAROID:
+ 		case VARCHAROID:
+ 		case BPCHAROID:
+ 		case TEXTOID:
+ 			return ECPGt_char;
+ 		case INT2OID:
+ 			return ECPGt_short;
+ 		case INT4OID:
+ 			return ECPGt_int;
+ 		case FLOAT8OID:
+ 			return ECPGt_double;
+ 		case FLOAT4OID:
+ 			return ECPGt_float;
+ 		case NUMERICOID:
+ 			return INFORMIX_MODE(compat) ? ECPGt_decimal : ECPGt_numeric;
+ 		case DATEOID:
+ 			return ECPGt_date;
+ 		case TIMESTAMPOID:
+ 		case TIMESTAMPTZOID:
+ 			return ECPGt_timestamp;
+ 		case INTERVALOID:
+ 			return ECPGt_interval;
+ 		case INT8OID:
+ #ifdef HAVE_LONG_LONG_INT_64
+ 			return ECPGt_long_long;
+ #endif
+ #ifdef HAVE_LONG_INT_64
+ 			return ECPGt_long;
+ #endif
+ 		default:
+ 			return (-type);
+ 	}
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/ecpgtype.h pgsql.2/src/interfaces/ecpg/include/ecpgtype.h
*** pgsql.orig/src/interfaces/ecpg/include/ecpgtype.h	2009-08-07 13:06:28.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/include/ecpgtype.h	2009-12-14 12:41:24.000000000 +0100
*************** enum ECPGttype
*** 62,68 ****
  	ECPGt_EOIT,					/* End of insert types. */
  	ECPGt_EORT,					/* End of result types. */
  	ECPGt_NO_INDICATOR,			/* no indicator */
! 	ECPGt_string                            /* trimmed (char *) type */
  };
  
   /* descriptor items */
--- 62,69 ----
  	ECPGt_EOIT,					/* End of insert types. */
  	ECPGt_EORT,					/* End of result types. */
  	ECPGt_NO_INDICATOR,			/* no indicator */
! 	ECPGt_string,				/* trimmed (char *) type */
! 	ECPGt_sqlda				/* C struct descriptor */
  };
  
   /* descriptor items */
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/Makefile pgsql.2/src/interfaces/ecpg/include/Makefile
*** pgsql.orig/src/interfaces/ecpg/include/Makefile	2009-10-27 20:36:17.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/include/Makefile	2009-12-14 12:41:24.000000000 +0100
*************** install: all installdirs install-headers
*** 14,21 ****
  
  .PHONY: install-headers
  ecpg_headers = ecpgerrno.h ecpglib.h ecpgtype.h sqlca.h sql3types.h ecpg_informix.h \
! 	pgtypes_error.h pgtypes_numeric.h pgtypes_timestamp.h pgtypes_date.h pgtypes_interval.h
! informix_headers = datetime.h decimal.h sqltypes.h sqlda.h
  
  install-headers: $(ecpg_headers) $(informix_headers)
  	$(INSTALL_DATA) $(addprefix $(srcdir)/,$(ecpg_headers)) '$(DESTDIR)$(includedir)/'
--- 14,22 ----
  
  .PHONY: install-headers
  ecpg_headers = ecpgerrno.h ecpglib.h ecpgtype.h sqlca.h sql3types.h ecpg_informix.h \
! 	pgtypes_error.h pgtypes_numeric.h pgtypes_timestamp.h pgtypes_date.h pgtypes_interval.h \
! 	sqlda.h
! informix_headers = datetime.h decimal.h sqltypes.h
  
  install-headers: $(ecpg_headers) $(informix_headers)
  	$(INSTALL_DATA) $(addprefix $(srcdir)/,$(ecpg_headers)) '$(DESTDIR)$(includedir)/'
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/sqlda.h pgsql.2/src/interfaces/ecpg/include/sqlda.h
*** pgsql.orig/src/interfaces/ecpg/include/sqlda.h	2009-06-13 18:25:05.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/include/sqlda.h	2009-12-14 12:41:24.000000000 +0100
***************
*** 1,3 ****
--- 1,49 ----
  /*
   * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
   */
+ 
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+ 
+ #include "ecpglib.h"
+ 
+ typedef struct sqlvar_struct
+ {
+ 	short	sqltype;		/* variable type                */
+ 	int	sqllen;			/* length in bytes              */
+ 	char	   *sqldata;		/* pointer to data              */
+ 	short	   *sqlind;		/* pointer to indicator         */
+ 	char	   *sqlname;		/* variable name                */
+ 	char	   *sqlformat;		/* reserved for future use      */
+ 	short	sqlitype;		/* ind variable type            */
+ 	short	sqlilen;		/* ind length in bytes          */
+ 	char	   *sqlidata;		/* ind data pointer             */
+ 	int	sqlxid;			/* extended id type             */
+ 	char	   *sqltypename;	/* extended type name           */
+ 	short	sqltypelen;		/* length of extended type name */
+ 	short	sqlownerlen;		/* length of owner name         */
+ 	short	sqlsourcetype;		/* source type for distinct of built-ins */
+ 	char	   *sqlownername;	/* owner name                   */
+ 	int	sqlsourceid;		/* extended id of source type   */
+ 
+ 	/*
+ 	 * sqlilongdata is new.  It supports data that exceeds the 32k
+ 	 * limit.  sqlilen and sqlidata are for backward compatibility
+ 	 * and they have maximum value of <32K.
+ 	 */
+ 	char	   *sqlilongdata;	/* for data field beyond 32K    */
+ 	int	sqlflags;		/* for internal use only        */
+ 	void	   *sqlreserved;	/* reserved for future use      */
+ } pg_sqlvar_t;
+ 
+ typedef struct sqlda
+ {
+ 	short		sqld;
+ 	pg_sqlvar_t	   *sqlvar;
+ 	char		desc_name[19];	/* descriptor name              */
+ 	short		desc_occ;	/* size of sqlda structure      */
+ 	struct sqlda	   *desc_next;	/* pointer to next sqlda struct */
+ 	void		   *reserved;	/* reserved for future use */
+ } pg_sqlda_t;
+ 
+ #endif /* POSTGRES_SQLDA_H */
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/sqltypes.h pgsql.2/src/interfaces/ecpg/include/sqltypes.h
*** pgsql.orig/src/interfaces/ecpg/include/sqltypes.h	2009-06-13 18:25:05.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/include/sqltypes.h	2009-12-14 12:41:24.000000000 +0100
***************
*** 4,9 ****
--- 4,11 ----
  #ifndef ECPG_SQLTYPES_H
  #define ECPG_SQLTYPES_H
  
+ #include <limits.h>
+ 
  #define CCHARTYPE	ECPGt_char
  #define CSHORTTYPE	ECPGt_short
  #define CINTTYPE	ECPGt_int
***************
*** 30,33 ****
--- 32,60 ----
  #define CLVCHARPTRTYPE	124
  #define CTYPEMAX	25
  
+ /*
+  * Values used in sqlda->sqlvar[i]->sqltype
+  */
+ #define	SQLCHAR		ECPGt_char
+ #define	SQLSMINT	ECPGt_short
+ #define	SQLINT		ECPGt_int
+ #define	SQLFLOAT	ECPGt_double
+ #define	SQLSMFLOAT	ECPGt_float
+ #define	SQLDECIMAL	ECPGt_decimal
+ #define	SQLSERIAL	ECPGt_int
+ #define	SQLDATE		ECPGt_date
+ #define	SQLDTIME	ECPGt_timestamp
+ #define	SQLTEXT		ECPGt_char
+ #define	SQLVCHAR	ECPGt_char
+ #define SQLINTERVAL     ECPGt_interval
+ #define	SQLNCHAR	ECPGt_char
+ #define	SQLNVCHAR	ECPGt_char
+ #if (LONG_BIT == 64)
+ #define	SQLINT8		ECPGt_long
+ #define	SQLSERIAL8	ECPGt_long
+ #else
+ #define	SQLINT8		ECPGt_long_long
+ #define	SQLSERIAL8	ECPGt_long_long
+ #endif
+ 
  #endif   /* ndef ECPG_SQLTYPES_H */
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/descriptor.c pgsql.2/src/interfaces/ecpg/preproc/descriptor.c
*** pgsql.orig/src/interfaces/ecpg/preproc/descriptor.c	2009-01-30 17:28:46.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/preproc/descriptor.c	2009-12-14 12:41:24.000000000 +0100
*************** descriptor_variable(const char *name, in
*** 326,328 ****
--- 326,347 ----
  	strlcpy(descriptor_names[input], name, sizeof(descriptor_names[input]));
  	return (struct variable *) & varspace[input];
  }
+ 
+ struct variable *
+ sqlda_variable(const char *name)
+ {
+ 	struct variable *p = (struct variable *) mm_alloc(sizeof(struct variable));
+ 
+ 	p->name = mm_strdup(name);
+ 	p->type = (struct ECPGtype *) mm_alloc(sizeof(struct ECPGtype));
+ 	p->type->type = ECPGt_sqlda;
+ 	p->type->size = NULL;
+ 	p->type->struct_sizeof = NULL;
+ 	p->type->u.element = NULL;
+ 	p->type->lineno = 0;
+ 	p->brace_level = 0;
+ 	p->next = NULL;
+ 
+ 	return p;
+ }
+ 
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.addons pgsql.2/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.addons	2009-11-29 10:14:36.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/preproc/ecpg.addons	2009-12-14 12:41:24.000000000 +0100
*************** ECPG: VariableShowStmtSHOWALL block
*** 408,436 ****
  		$$ = EMPTY;
  	}
  ECPG: FetchStmtMOVEfetch_args rule
! 	| FETCH fetch_args ecpg_into
  	{
  		$$ = cat2_str(make_str("fetch"), $2);
  	}
! 	| FETCH FORWARD cursor_name opt_ecpg_into
  	{
  		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
  		add_additional_variables($3, false);
  		$$ = cat_str(2, make_str("fetch forward"), cursor_marker);
  	}
! 	| FETCH FORWARD from_in cursor_name opt_ecpg_into
  	{
  		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
  		add_additional_variables($4, false);
  		$$ = cat_str(2, make_str("fetch forward from"), cursor_marker);
  	}
! 	| FETCH BACKWARD cursor_name opt_ecpg_into
  	{
  		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
  		add_additional_variables($3, false);
  		$$ = cat_str(2, make_str("fetch backward"), cursor_marker);
  	}
! 	| FETCH BACKWARD from_in cursor_name opt_ecpg_into
  	{
  		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
  		add_additional_variables($4, false);
--- 408,436 ----
  		$$ = EMPTY;
  	}
  ECPG: FetchStmtMOVEfetch_args rule
! 	| FETCH fetch_args ecpg_fetch_into
  	{
  		$$ = cat2_str(make_str("fetch"), $2);
  	}
! 	| FETCH FORWARD cursor_name opt_ecpg_fetch_into
  	{
  		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
  		add_additional_variables($3, false);
  		$$ = cat_str(2, make_str("fetch forward"), cursor_marker);
  	}
! 	| FETCH FORWARD from_in cursor_name opt_ecpg_fetch_into
  	{
  		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
  		add_additional_variables($4, false);
  		$$ = cat_str(2, make_str("fetch forward from"), cursor_marker);
  	}
! 	| FETCH BACKWARD cursor_name opt_ecpg_fetch_into
  	{
  		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
  		add_additional_variables($3, false);
  		$$ = cat_str(2, make_str("fetch backward"), cursor_marker);
  	}
! 	| FETCH BACKWARD from_in cursor_name opt_ecpg_fetch_into
  	{
  		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
  		add_additional_variables($4, false);
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.trailer pgsql.2/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.trailer	2009-11-26 18:57:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/preproc/ecpg.trailer	2009-12-14 12:41:24.000000000 +0100
*************** ecpg_using:	USING using_list 	{ $$ = EMP
*** 970,991 ****
  		| using_descriptor      { $$ = $1; }
  		;
  
! using_descriptor: USING opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
  		{
  			add_variable_to_head(&argsinsert, descriptor_variable($4,0), &no_indicator);
  			$$ = EMPTY;
  		}
  		;
  
! into_descriptor: INTO opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
  		{
  			add_variable_to_head(&argsresult, descriptor_variable($4,1), &no_indicator);
  			$$ = EMPTY;
  		}
  		;
  
- opt_sql: /*EMPTY*/ | SQL_SQL;
- 
  using_list: UsingValue | UsingValue ',' using_list;
  
  UsingValue: UsingConst
--- 970,999 ----
  		| using_descriptor      { $$ = $1; }
  		;
  
! using_descriptor: USING SQL_SQL SQL_DESCRIPTOR quoted_ident_stringvar
  		{
  			add_variable_to_head(&argsinsert, descriptor_variable($4,0), &no_indicator);
  			$$ = EMPTY;
  		}
+ 		| USING SQL_DESCRIPTOR name
+ 		{
+ 			add_variable_to_head(&argsinsert, sqlda_variable($3), &no_indicator);
+ 			$$ = EMPTY;
+ 		}
  		;
  
! into_descriptor: INTO SQL_SQL SQL_DESCRIPTOR quoted_ident_stringvar
  		{
  			add_variable_to_head(&argsresult, descriptor_variable($4,1), &no_indicator);
  			$$ = EMPTY;
  		}
+ 		| INTO SQL_DESCRIPTOR name
+ 		{
+ 			add_variable_to_head(&argsresult, sqlda_variable($3), &no_indicator);
+ 			$$ = EMPTY;
+ 		}
  		;
  
  using_list: UsingValue | UsingValue ',' using_list;
  
  UsingValue: UsingConst
*************** ecpg_into: INTO into_list	{ $$ = EMPTY; 
*** 1806,1813 ****
          | into_descriptor	{ $$ = $1; }
  	;
  
! opt_ecpg_into:	/* EMPTY */	{ $$ = EMPTY; }
! 	| ecpg_into		{ $$ = $1; }
  	;
  
  %%
--- 1814,1836 ----
          | into_descriptor	{ $$ = $1; }
  	;
  
! ecpg_fetch_into: ecpg_into	{ $$ = $1; }
! 	| using_descriptor
! 	{
! 		struct variable *var;
! 
! 		if (!INFORMIX_MODE)
! 			mmerror(PARSE_ERROR, ET_ERROR, "Not in Informix compatibility mode");
! 
! 		var = argsinsert->variable;
! 		remove_variable_from_list(&argsinsert, var);
! 		add_variable_to_head(&argsresult, var, &no_indicator);
! 		$$ = $1;
! 	}
! 	;
! 
! opt_ecpg_fetch_into:	/* EMPTY */	{ $$ = EMPTY; }
! 	| ecpg_fetch_into		{ $$ = $1; }
  	;
  
  %%
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.type pgsql.2/src/interfaces/ecpg/preproc/ecpg.type
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.type	2009-11-26 18:57:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/preproc/ecpg.type	2009-12-14 12:41:24.000000000 +0100
***************
*** 61,66 ****
--- 61,67 ----
  %type <str> ecpg_ident
  %type <str> ecpg_interval
  %type <str> ecpg_into
+ %type <str> ecpg_fetch_into
  %type <str> ecpg_param
  %type <str> ecpg_sconst
  %type <str> ecpg_using
***************
*** 76,82 ****
  %type <str> opt_bit_field
  %type <str> opt_connection_name
  %type <str> opt_database_name
! %type <str> opt_ecpg_into
  %type <str> opt_ecpg_using
  %type <str> opt_initializer
  %type <str> opt_options
--- 77,83 ----
  %type <str> opt_bit_field
  %type <str> opt_connection_name
  %type <str> opt_database_name
! %type <str> opt_ecpg_fetch_into
  %type <str> opt_ecpg_using
  %type <str> opt_initializer
  %type <str> opt_options
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/extern.h pgsql.2/src/interfaces/ecpg/preproc/extern.h
*** pgsql.orig/src/interfaces/ecpg/preproc/extern.h	2009-11-26 18:57:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/preproc/extern.h	2009-12-14 12:41:24.000000000 +0100
*************** extern void add_descriptor(char *, char 
*** 88,93 ****
--- 88,94 ----
  extern void drop_descriptor(char *, char *);
  extern struct descriptor *lookup_descriptor(char *, char *);
  extern struct variable *descriptor_variable(const char *name, int input);
+ extern struct variable *sqlda_variable(const char *name);
  extern void add_variable_to_head(struct arguments **, struct variable *, struct variable *);
  extern void add_variable_to_tail(struct arguments **, struct variable *, struct variable *);
  extern void remove_variable_from_list(struct arguments ** list, struct variable * var);
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/type.c pgsql.2/src/interfaces/ecpg/preproc/type.c
*** pgsql.orig/src/interfaces/ecpg/preproc/type.c	2009-09-03 12:25:47.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/preproc/type.c	2009-12-14 12:41:24.000000000 +0100
*************** get_type(enum ECPGttype type)
*** 194,199 ****
--- 194,202 ----
  		case ECPGt_descriptor:
  			return ("ECPGt_descriptor");
  			break;
+ 		case ECPGt_sqlda:
+ 			return ("ECPGt_sqlda");
+ 			break;
  		case ECPGt_date:
  			return ("ECPGt_date");
  			break;
*************** ECPGdump_a_simple(FILE *o, const char *n
*** 328,333 ****
--- 331,338 ----
  	else if (type == ECPGt_descriptor)
  		/* remember that name here already contains quotes (if needed) */
  		fprintf(o, "\n\tECPGt_descriptor, %s, 0L, 0L, 0L, ", name);
+ 	else if (type == ECPGt_sqlda)
+ 		fprintf(o, "\n\tECPGt_sqlda, &%s, 0L, 0L, 0L, ", name);
  	else
  	{
  		char	   *variable = (char *) mm_alloc(strlen(name) + ((prefix == NULL) ? 0 : strlen(prefix)) + 4);
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/compat_informix/Makefile pgsql.2/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.orig/src/interfaces/ecpg/test/compat_informix/Makefile	2006-09-19 17:36:08.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/test/compat_informix/Makefile	2009-12-14 12:41:24.000000000 +0100
*************** TESTS = test_informix test_informix.c \
*** 16,21 ****
--- 16,22 ----
          rfmtdate rfmtdate.c \
          rfmtlong rfmtlong.c \
          rnull rnull.c \
+         sqlda sqlda.c \
          charfuncs charfuncs.c
  
  all: $(TESTS)
*************** test_informix.c: test_informix.pgc ../re
*** 26,31 ****
--- 27,35 ----
  test_informix2.c: test_informix2.pgc ../regression.h
  	$(ECPG) -o $@ -I$(srcdir) $<
  
+ sqlda.c: sqlda.pgc ../regression.h
+ 	$(ECPG) -o $@ -I$(srcdir) $<
+ 
  dec_test.c: dec_test.pgc ../regression.h
  	$(ECPG) -o $@ -I$(srcdir) $<
  
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/compat_informix/sqlda.pgc pgsql.2/src/interfaces/ecpg/test/compat_informix/sqlda.pgc
*** pgsql.orig/src/interfaces/ecpg/test/compat_informix/sqlda.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/compat_informix/sqlda.pgc	2009-12-14 12:41:24.000000000 +0100
***************
*** 0 ****
--- 1,248 ----
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql include sqlda.h;
+ exec sql include sqltypes.h;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ /* These shouldn't be under DECLARE SECTION */
+ pg_sqlda_t	*inp_sqlda, *outp_sqlda;
+ 
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (sqlda->sqlvar[i].sqlind && *(sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", sqlda->sqlvar[i].sqlname);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case SQLCHAR:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLINT:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLINT8:
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLFLOAT:
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLDECIMAL:
+ 			{
+ 				char    val[64];
+ 				dectoasc((dec_t *)sqlda->sqlvar[i].sqldata, val, 64, -1);
+ 				printf("name sqlda descriptor: '%s' value DECIMAL '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ 	char	*stmt1 = "SELECT * FROM t1";
+ 	char	*stmt2 = "SELECT * FROM t1 WHERE id = ?";
+ 	int	rec;
+ 	int	id;
+ exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1 as regress1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table t1(
+ 		id integer,
+ 		t text,
+ 		d1 numeric,
+ 		d2 float8,
+ 		c char(10));
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into t1 values
+ 		(1, 'a', 1.0, 1, 'a'),
+ 		(2, null, null, null, null),
+ 		(3, '"c"', -3, 'nan'::float8, 'c'),
+ 		(4, 'd', 4.0, 4, 'd');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* SQLDA test for getting all records from a table */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id1 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare mycur1 cursor for st_id1;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open mycur1;
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		exec sql fetch 1 from mycur1 into descriptor outp_sqlda; 
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	exec sql whenever not found continue;
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close mycur1;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id1;
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting all records from a table
+ 	   using the Informix-specific FETCH ... USING DESCRIPTOR
+ 	 */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id2 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare mycur2 cursor for st_id2;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open mycur2;
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		exec sql fetch from mycur2 using descriptor outp_sqlda;
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	exec sql whenever not found continue;
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close mycur2;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id2;
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor */
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id3 FROM :stmt2;
+ 
+ 	strcpy(msg, "execute");
+ 	exec sql execute st_id3 using descriptor inp_sqlda into descriptor outp_sqlda;
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id3;
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor
+ 	 * on a named connection
+ 	 */
+ 
+ 	exec sql connect to REGRESSDB1 as con2;
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql at con2 prepare st_id4 FROM :stmt2;
+ 
+ 	strcpy(msg, "execute");
+ 	exec sql at con2 execute st_id4 using descriptor inp_sqlda into descriptor outp_sqlda;
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql at con2 commit;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id4;
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	strcpy(msg, "disconnect");
+ 	exec sql disconnect con2;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table t1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect");
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule pgsql.2/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule	2009-11-26 18:57:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/ecpg_schedule	2009-12-14 12:41:24.000000000 +0100
*************** test: compat_informix/charfuncs
*** 3,8 ****
--- 3,9 ----
  test: compat_informix/rfmtdate
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
+ test: compat_informix/sqlda
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: sql/code100
*** 29,34 ****
--- 30,36 ----
  test: sql/copystdout
  test: sql/define
  test: sql/desc
+ test: sql/sqlda
  test: sql/dynalloc
  test: sql/dynalloc2
  test: sql/dyntest
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule_tcp pgsql.2/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-11-26 18:57:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-12-14 12:41:24.000000000 +0100
*************** test: compat_informix/charfuncs
*** 3,8 ****
--- 3,9 ----
  test: compat_informix/rfmtdate
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
+ test: compat_informix/sqlda
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: sql/code100
*** 29,34 ****
--- 30,36 ----
  test: sql/copystdout
  test: sql/define
  test: sql/desc
+ test: sql/sqlda
  test: sql/dynalloc
  test: sql/dynalloc2
  test: sql/dyntest
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c	2009-12-14 12:41:24.000000000 +0100
***************
*** 0 ****
--- 1,561 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "sqlda.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 5 "sqlda.pgc"
+ 
+ 
+ 
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+ 
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+ 
+ #include "ecpglib.h"
+ 
+ typedef struct sqlvar_struct
+ {
+ 	short	sqltype;		/* variable type                */
+ 	int	sqllen;			/* length in bytes              */
+ 	char	   *sqldata;		/* pointer to data              */
+ 	short	   *sqlind;		/* pointer to indicator         */
+ 	char	   *sqlname;		/* variable name                */
+ 	char	   *sqlformat;		/* reserved for future use      */
+ 	short	sqlitype;		/* ind variable type            */
+ 	short	sqlilen;		/* ind length in bytes          */
+ 	char	   *sqlidata;		/* ind data pointer             */
+ 	int	sqlxid;			/* extended id type             */
+ 	char	   *sqltypename;	/* extended type name           */
+ 	short	sqltypelen;		/* length of extended type name */
+ 	short	sqlownerlen;		/* length of owner name         */
+ 	short	sqlsourcetype;		/* source type for distinct of built-ins */
+ 	char	   *sqlownername;	/* owner name                   */
+ 	int	sqlsourceid;		/* extended id of source type   */
+ 
+ 	/*
+ 	 * sqlilongdata is new.  It supports data that exceeds the 32k
+ 	 * limit.  sqlilen and sqlidata are for backward compatibility
+ 	 * and they have maximum value of <32K.
+ 	 */
+ 	char	   *sqlilongdata;	/* for data field beyond 32K    */
+ 	int	sqlflags;		/* for internal use only        */
+ 	void	   *sqlreserved;	/* reserved for future use      */
+ } pg_sqlvar_t;
+ 
+ typedef struct sqlda
+ {
+ 	short		sqld;
+ 	pg_sqlvar_t	   *sqlvar;
+ 	char		desc_name[19];	/* descriptor name              */
+ 	short		desc_occ;	/* size of sqlda structure      */
+ 	struct sqlda	   *desc_next;	/* pointer to next sqlda struct */
+ 	void		   *reserved;	/* reserved for future use */
+ } pg_sqlda_t;
+ 
+ #endif /* POSTGRES_SQLDA_H */
+ 
+ #line 7 "sqlda.pgc"
+ 
+ 
+ #line 1 "sqltypes.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqltypes.h,v 1.9 2009/06/11 14:49:13 momjian Exp $
+  */
+ #ifndef ECPG_SQLTYPES_H
+ #define ECPG_SQLTYPES_H
+ 
+ #include <limits.h>
+ 
+ #define CCHARTYPE	ECPGt_char
+ #define CSHORTTYPE	ECPGt_short
+ #define CINTTYPE	ECPGt_int
+ #define CLONGTYPE	ECPGt_long
+ #define CFLOATTYPE	ECPGt_float
+ #define CDOUBLETYPE ECPGt_double
+ #define CDECIMALTYPE	ECPGt_decimal
+ #define CFIXCHARTYPE	108
+ #define CSTRINGTYPE ECPGt_char
+ #define CDATETYPE	ECPGt_date
+ #define CMONEYTYPE	111
+ #define CDTIMETYPE	ECPGt_timestamp
+ #define CLOCATORTYPE	113
+ #define CVCHARTYPE	ECPGt_varchar
+ #define CINVTYPE	115
+ #define CFILETYPE	116
+ #define CINT8TYPE	ECPGt_long_long
+ #define CCOLLTYPE		118
+ #define CLVCHARTYPE		119
+ #define CFIXBINTYPE		120
+ #define CVARBINTYPE		121
+ #define CBOOLTYPE		ECPGt_bool
+ #define CROWTYPE		123
+ #define CLVCHARPTRTYPE	124
+ #define CTYPEMAX	25
+ 
+ /*
+  * Values used in sqlda->sqlvar[i]->sqltype
+  */
+ #define	SQLCHAR		ECPGt_char
+ #define	SQLSMINT	ECPGt_short
+ #define	SQLINT		ECPGt_int
+ #define	SQLFLOAT	ECPGt_double
+ #define	SQLSMFLOAT	ECPGt_float
+ #define	SQLDECIMAL	ECPGt_decimal
+ #define	SQLSERIAL	ECPGt_int
+ #define	SQLDATE		ECPGt_date
+ #define	SQLDTIME	ECPGt_timestamp
+ #define	SQLTEXT		ECPGt_char
+ #define	SQLVCHAR	ECPGt_char
+ #define SQLINTERVAL     ECPGt_interval
+ #define	SQLNCHAR	ECPGt_char
+ #define	SQLNVCHAR	ECPGt_char
+ #if (LONG_BIT == 64)
+ #define	SQLINT8		ECPGt_long
+ #define	SQLSERIAL8	ECPGt_long
+ #else
+ #define	SQLINT8		ECPGt_long_long
+ #define	SQLSERIAL8	ECPGt_long_long
+ #endif
+ 
+ #endif   /* ndef ECPG_SQLTYPES_H */
+ 
+ #line 8 "sqlda.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 10 "sqlda.pgc"
+ 
+ 
+ /* These shouldn't be under DECLARE SECTION */
+ pg_sqlda_t	*inp_sqlda, *outp_sqlda;
+ 
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (sqlda->sqlvar[i].sqlind && *(sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", sqlda->sqlvar[i].sqlname);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case SQLCHAR:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLINT:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLINT8:
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLFLOAT:
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLDECIMAL:
+ 			{
+ 				char    val[64];
+ 				dectoasc((decimal *)sqlda->sqlvar[i].sqldata, val, 64, -1);
+ 				printf("name sqlda descriptor: '%s' value DECIMAL '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		
+ 		
+ 
+ #line 54 "sqlda.pgc"
+  char * stmt1 = "SELECT * FROM t1" ;
+  
+ #line 55 "sqlda.pgc"
+  char * stmt2 = "SELECT * FROM t1 WHERE id = ?" ;
+  
+ #line 56 "sqlda.pgc"
+  int rec ;
+  
+ #line 57 "sqlda.pgc"
+  int id ;
+ /* exec sql end declare section */
+ #line 58 "sqlda.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , "regress1", 0); 
+ #line 65 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 65 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 68 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 68 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
+ #line 76 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 76 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 3 , '\"c\"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 83 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 83 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 86 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 86 "sqlda.pgc"
+ 
+ 
+ 	/* SQLDA test for getting all records from a table */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 93 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 93 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	ECPG_informix_reset_sqlca(); /* declare mycur1 cursor for $1 */
+ #line 96 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1", 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 99 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 99 "sqlda.pgc"
+ 
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 101 "sqlda.pgc"
+ 
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 107 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 107 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 107 "sqlda.pgc"
+  
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	/* exec sql whenever not found  continue ; */
+ #line 113 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT);
+ #line 116 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 116 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
+ #line 119 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 119 "sqlda.pgc"
+ 
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting all records from a table
+ 	   using the Informix-specific FETCH ... USING DESCRIPTOR
+ 	 */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
+ #line 130 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 130 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	ECPG_informix_reset_sqlca(); /* declare mycur2 cursor for $1 */
+ #line 133 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1", 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 136 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 136 "sqlda.pgc"
+ 
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 138 "sqlda.pgc"
+ 
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from mycur2", ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 144 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 144 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 144 "sqlda.pgc"
+ 
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	/* exec sql whenever not found  continue ; */
+ #line 150 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT);
+ #line 153 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 153 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id2");
+ #line 156 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 156 "sqlda.pgc"
+ 
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor */
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id3", stmt2);
+ #line 179 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 179 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "execute");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, 1, "st_id3", 
+ 	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 182 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 182 "sqlda.pgc"
+ 
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id3");
+ #line 187 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 187 "sqlda.pgc"
+ 
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor
+ 	 * on a named connection
+ 	 */
+ 
+ 	{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , "con2", 0); 
+ #line 197 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 197 "sqlda.pgc"
+ 
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, "con2", 0, "st_id4", stmt2);
+ #line 216 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 216 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "execute");
+ 	{ ECPGdo(__LINE__, 1, 1, "con2", 0, 1, "st_id4", 
+ 	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 219 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 219 "sqlda.pgc"
+ 
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, "con2", "commit");
+ #line 224 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 224 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id4");
+ #line 227 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 227 "sqlda.pgc"
+ 
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	strcpy(msg, "disconnect");
+ 	{ ECPGdisconnect(__LINE__, "con2");
+ #line 234 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 234 "sqlda.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 239 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 239 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 242 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 242 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect");
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 245 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 245 "sqlda.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr	2009-12-14 12:41:24.000000000 +0100
***************
*** 0 ****
--- 1,584 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 68: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 68: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 68: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 71: query: create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 71: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 71: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 79: query: insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 3 , '"c"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 79: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 79: OK: INSERT 0 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 86: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 93: name st_id1; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 99: query: declare mycur1 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 99: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 99: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: "c" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: -3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: c          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 107: no data found on line 107
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 116: query: close mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 119: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 130: name st_id2; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 136: query: declare mycur2 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 136: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 136: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: "c" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: -3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: c          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 144: no data found on line 144
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 153: query: close mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 156: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 179: name st_id3; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 182: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 182: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 182: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 182: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 182: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 182: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 182: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 182: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 182: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 182: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 182: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 187: name st_id3
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 216: name st_id4; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection con2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 219: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 224: action "commit"; connection "con2"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 227: name st_id4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection con2 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 239: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 239: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 239: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 242: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout	2009-12-14 12:41:24.000000000 +0100
***************
*** 0 ****
--- 1,60 ----
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value DECIMAL '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a         '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value DECIMAL '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c         '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value DECIMAL '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a         '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value DECIMAL '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c         '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.c pgsql.2/src/interfaces/ecpg/test/expected/sql-sqlda.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/expected/sql-sqlda.c	2009-12-14 12:41:24.000000000 +0100
***************
*** 0 ****
--- 1,569 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "sqlda.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ #include <limits.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 6 "sqlda.pgc"
+ 
+ 
+ 
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+ 
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+ 
+ #include "ecpglib.h"
+ 
+ typedef struct sqlvar_struct
+ {
+ 	short	sqltype;		/* variable type                */
+ 	int	sqllen;			/* length in bytes              */
+ 	char	   *sqldata;		/* pointer to data              */
+ 	short	   *sqlind;		/* pointer to indicator         */
+ 	char	   *sqlname;		/* variable name                */
+ 	char	   *sqlformat;		/* reserved for future use      */
+ 	short	sqlitype;		/* ind variable type            */
+ 	short	sqlilen;		/* ind length in bytes          */
+ 	char	   *sqlidata;		/* ind data pointer             */
+ 	int	sqlxid;			/* extended id type             */
+ 	char	   *sqltypename;	/* extended type name           */
+ 	short	sqltypelen;		/* length of extended type name */
+ 	short	sqlownerlen;		/* length of owner name         */
+ 	short	sqlsourcetype;		/* source type for distinct of built-ins */
+ 	char	   *sqlownername;	/* owner name                   */
+ 	int	sqlsourceid;		/* extended id of source type   */
+ 
+ 	/*
+ 	 * sqlilongdata is new.  It supports data that exceeds the 32k
+ 	 * limit.  sqlilen and sqlidata are for backward compatibility
+ 	 * and they have maximum value of <32K.
+ 	 */
+ 	char	   *sqlilongdata;	/* for data field beyond 32K    */
+ 	int	sqlflags;		/* for internal use only        */
+ 	void	   *sqlreserved;	/* reserved for future use      */
+ } pg_sqlvar_t;
+ 
+ typedef struct sqlda
+ {
+ 	short		sqld;
+ 	pg_sqlvar_t	   *sqlvar;
+ 	char		desc_name[19];	/* descriptor name              */
+ 	short		desc_occ;	/* size of sqlda structure      */
+ 	struct sqlda	   *desc_next;	/* pointer to next sqlda struct */
+ 	void		   *reserved;	/* reserved for future use */
+ } pg_sqlda_t;
+ 
+ #endif /* POSTGRES_SQLDA_H */
+ 
+ #line 8 "sqlda.pgc"
+ 
+ 
+ #line 1 "pgtypes_numeric.h"
+ /* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_numeric.h,v 1.16 2006/08/09 07:30:56 meskes Exp $ */
+ 
+ #ifndef PGTYPES_NUMERIC
+ #define PGTYPES_NUMERIC
+ 
+ #define NUMERIC_POS						0x0000
+ #define NUMERIC_NEG						0x4000
+ #define NUMERIC_NAN						0xC000
+ #define NUMERIC_MAX_PRECISION			1000
+ #define NUMERIC_MAX_DISPLAY_SCALE		NUMERIC_MAX_PRECISION
+ #define NUMERIC_MIN_DISPLAY_SCALE		0
+ #define NUMERIC_MIN_SIG_DIGITS			16
+ 
+ #define DECSIZE 30
+ 
+ typedef unsigned char NumericDigit;
+ typedef struct
+ {
+ 	int			ndigits;		/* number of digits in digits[] - can be 0! */
+ 	int			weight;			/* weight of first digit */
+ 	int			rscale;			/* result scale */
+ 	int			dscale;			/* display scale */
+ 	int			sign;			/* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
+ 	NumericDigit *buf;			/* start of alloc'd space for digits[] */
+ 	NumericDigit *digits;		/* decimal digits */
+ } numeric;
+ 
+ typedef struct
+ {
+ 	int			ndigits;		/* number of digits in digits[] - can be 0! */
+ 	int			weight;			/* weight of first digit */
+ 	int			rscale;			/* result scale */
+ 	int			dscale;			/* display scale */
+ 	int			sign;			/* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
+ 	NumericDigit digits[DECSIZE];		/* decimal digits */
+ } decimal;
+ 
+ #ifdef __cplusplus
+ extern		"C"
+ {
+ #endif
+ 
+ numeric    *PGTYPESnumeric_new(void);
+ decimal    *PGTYPESdecimal_new(void);
+ void		PGTYPESnumeric_free(numeric *);
+ void		PGTYPESdecimal_free(decimal *);
+ numeric    *PGTYPESnumeric_from_asc(char *, char **);
+ char	   *PGTYPESnumeric_to_asc(numeric *, int);
+ int			PGTYPESnumeric_add(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_sub(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_mul(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_div(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_cmp(numeric *, numeric *);
+ int			PGTYPESnumeric_from_int(signed int, numeric *);
+ int			PGTYPESnumeric_from_long(signed long int, numeric *);
+ int			PGTYPESnumeric_copy(numeric *, numeric *);
+ int			PGTYPESnumeric_from_double(double, numeric *);
+ int			PGTYPESnumeric_to_double(numeric *, double *);
+ int			PGTYPESnumeric_to_int(numeric *, int *);
+ int			PGTYPESnumeric_to_long(numeric *, long *);
+ int			PGTYPESnumeric_to_decimal(numeric *, decimal *);
+ int			PGTYPESnumeric_from_decimal(decimal *, numeric *);
+ 
+ #ifdef __cplusplus
+ }
+ #endif
+ 
+ #endif   /* PGTYPES_NUMERIC */
+ 
+ #line 9 "sqlda.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 11 "sqlda.pgc"
+ 
+ 
+ /* These shouldn't be under DECLARE SECTION */
+ pg_sqlda_t	*inp_sqlda, *outp_sqlda, *outp_sqlda1;
+ 
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (sqlda->sqlvar[i].sqlind && *(sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", sqlda->sqlvar[i].sqlname);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case ECPGt_char:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_int:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ #if (LONG_BIT == 64) /* Defined via <limits.h> */
+ 		case ECPGt_long:
+ #else
+ # if (LONG_BIT = 32)
+ 		case ECPGt_long_long:
+ # else
+ #  error Neither "long" nor "long long" are 64-bit
+ # endif
+ #endif
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_double:
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_numeric:
+ 			{
+ 				char    *val;
+ 
+ 				val = PGTYPESnumeric_to_asc((numeric*)sqlda->sqlvar[i].sqldata, -1);
+ 				printf("name sqlda descriptor: '%s' value NUMERIC '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ 				free(val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		
+ 		
+ 
+ #line 65 "sqlda.pgc"
+  char * stmt1 = "SELECT * FROM t1" ;
+  
+ #line 66 "sqlda.pgc"
+  char * stmt2 = "SELECT * FROM t1 WHERE id = ?" ;
+  
+ #line 67 "sqlda.pgc"
+  int rec ;
+  
+ #line 68 "sqlda.pgc"
+  int id ;
+ /* exec sql end declare section */
+ #line 69 "sqlda.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , "regress1", 0); 
+ #line 76 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 76 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 79 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 79 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
+ #line 87 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 87 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 3 , '\"c\"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 94 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 94 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 97 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 97 "sqlda.pgc"
+ 
+ 
+ 	/* SQLDA test for getting all records from a table */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 104 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 104 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	/* declare mycur1 cursor for $1 */
+ #line 107 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1", 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 110 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 110 "sqlda.pgc"
+ 
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 112 "sqlda.pgc"
+ 
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 118 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 118 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 118 "sqlda.pgc"
+  
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	/* exec sql whenever not found  continue ; */
+ #line 124 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT);
+ #line 127 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 127 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
+ #line 130 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 130 "sqlda.pgc"
+ 
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting ALL records into the sqlda list */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
+ #line 139 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 139 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	/* declare mycur2 cursor for $1 */
+ #line 142 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1", 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 145 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 145 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch all from mycur2", ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 148 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 148 "sqlda.pgc"
+ 
+ 
+ 	outp_sqlda1 = outp_sqlda;
+ 	rec = 0;
+ 	while (outp_sqlda1)
+ 	{
+ 		pg_sqlda_t	*ptr;
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda1);
+ 
+ 		ptr = outp_sqlda1;
+ 		outp_sqlda1 = outp_sqlda1->desc_next;
+ 		free(ptr);
+ 	}
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT);
+ #line 164 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 164 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
+ #line 167 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 167 "sqlda.pgc"
+ 
+ 
+ 	/* SQLDA test for getting one record using an input descriptor */
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id3", stmt2);
+ #line 188 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 188 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "execute");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, 1, "st_id3", 
+ 	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 191 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 191 "sqlda.pgc"
+ 
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id3");
+ #line 196 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 196 "sqlda.pgc"
+ 
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor
+ 	 * on a named connection
+ 	 */
+ 
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , "con2", 0); 
+ #line 206 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 206 "sqlda.pgc"
+ 
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, "con2", 0, "st_id4", stmt2);
+ #line 225 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 225 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "execute");
+ 	{ ECPGdo(__LINE__, 0, 1, "con2", 0, 1, "st_id4", 
+ 	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 228 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 228 "sqlda.pgc"
+ 
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, "con2", "commit");
+ #line 233 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 233 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id4");
+ #line 236 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 236 "sqlda.pgc"
+ 
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	strcpy(msg, "disconnect");
+ 	{ ECPGdisconnect(__LINE__, "con2");
+ #line 243 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 243 "sqlda.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 248 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 248 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 251 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 251 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect");
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 254 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 254 "sqlda.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.stderr pgsql.2/src/interfaces/ecpg/test/expected/sql-sqlda.stderr
*** pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/expected/sql-sqlda.stderr	2009-12-14 12:41:24.000000000 +0100
***************
*** 0 ****
--- 1,574 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 79: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 79: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 79: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: query: create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: query: insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 3 , '"c"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: OK: INSERT 0 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 97: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 104: name st_id1; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: query: declare mycur1 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: "c" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: c          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 118: no data found on line 118
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 127: query: close mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 127: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 127: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 130: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 139: name st_id2; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 145: query: declare mycur2 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 145: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 145: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: query: fetch all from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: correctly got 4 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 3 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 3 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 3 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 3 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 3 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 2 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 2 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: "c" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 2 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 2 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 2 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: c          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 1 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 1 col 1 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 1 col 2 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 1 col 3 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 1 col 4 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 164: query: close mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 164: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 164: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 167: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 188: name st_id3; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 191: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 191: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 191: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 191: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 191: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 191: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 191: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 191: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 191: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 191: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 196: name st_id3
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 225: name st_id4; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection con2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 228: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 228: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 228: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 228: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 228: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 233: action "commit"; connection "con2"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 236: name st_id4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection con2 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 248: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 248: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 248: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 251: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.stdout pgsql.2/src/interfaces/ecpg/test/expected/sql-sqlda.stdout
*** pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/expected/sql-sqlda.stdout	2009-12-14 12:41:24.000000000 +0100
***************
*** 0 ****
--- 1,60 ----
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value NUMERIC '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a         '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value NUMERIC '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c         '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value NUMERIC '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value NUMERIC '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a         '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value NUMERIC '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c         '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value NUMERIC '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value NUMERIC '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value NUMERIC '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/desc.pgc pgsql.2/src/interfaces/ecpg/test/sql/desc.pgc
*** pgsql.orig/src/interfaces/ecpg/test/sql/desc.pgc	2007-08-14 12:01:54.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/test/sql/desc.pgc	2009-12-14 12:41:24.000000000 +0100
*************** main(void)
*** 32,61 ****
  	EXEC SQL PREPARE foo2 FROM :stmt2;
  	EXEC SQL PREPARE foo3 FROM :stmt3;
  
! 	EXEC SQL EXECUTE foo1 USING DESCRIPTOR indesc;
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2null, DATA = :val2;
  
! 	EXEC SQL EXECUTE foo1 USING DESCRIPTOR indesc;
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 3;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val1, DATA = 'this is a long test';
  
! 	EXEC SQL EXECUTE "Foo-1" USING DESCRIPTOR indesc;
  
  	EXEC SQL DEALLOCATE "Foo-1";
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = :val1;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2i, DATA = :val2;
  
! 	EXEC SQL EXECUTE foo2 USING DESCRIPTOR indesc INTO DESCRIPTOR outdesc;
  
  	EXEC SQL GET DESCRIPTOR outdesc VALUE 1 :val2output = DATA;
  	printf("output = %s\n", val2output);
  
  	EXEC SQL DECLARE c1 CURSOR FOR foo2;
! 	EXEC SQL OPEN c1 USING DESCRIPTOR indesc;
  
  	EXEC SQL FETCH next FROM c1 INTO :val1output:ind1, :val2output:ind2;
  	printf("val1=%d (ind1: %d) val2=%s (ind2: %d)\n",
--- 32,61 ----
  	EXEC SQL PREPARE foo2 FROM :stmt2;
  	EXEC SQL PREPARE foo3 FROM :stmt3;
  
! 	EXEC SQL EXECUTE foo1 USING SQL DESCRIPTOR indesc;
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2null, DATA = :val2;
  
! 	EXEC SQL EXECUTE foo1 USING SQL DESCRIPTOR indesc;
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 3;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val1, DATA = 'this is a long test';
  
! 	EXEC SQL EXECUTE "Foo-1" USING SQL DESCRIPTOR indesc;
  
  	EXEC SQL DEALLOCATE "Foo-1";
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = :val1;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2i, DATA = :val2;
  
! 	EXEC SQL EXECUTE foo2 USING SQL DESCRIPTOR indesc INTO SQL DESCRIPTOR outdesc;
  
  	EXEC SQL GET DESCRIPTOR outdesc VALUE 1 :val2output = DATA;
  	printf("output = %s\n", val2output);
  
  	EXEC SQL DECLARE c1 CURSOR FOR foo2;
! 	EXEC SQL OPEN c1 USING SQL DESCRIPTOR indesc;
  
  	EXEC SQL FETCH next FROM c1 INTO :val1output:ind1, :val2output:ind2;
  	printf("val1=%d (ind1: %d) val2=%s (ind2: %d)\n",
*************** main(void)
*** 67,73 ****
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
  
  	EXEC SQL DECLARE c2 CURSOR FOR foo3;
! 	EXEC SQL OPEN c2 USING DESCRIPTOR indesc;
  
  	EXEC SQL FETCH next FROM c2 INTO :val1output, :val2output :val2i;
  	printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output);
--- 67,73 ----
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
  
  	EXEC SQL DECLARE c2 CURSOR FOR foo3;
! 	EXEC SQL OPEN c2 USING SQL DESCRIPTOR indesc;
  
  	EXEC SQL FETCH next FROM c2 INTO :val1output, :val2output :val2i;
  	printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output);
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/dynalloc2.pgc pgsql.2/src/interfaces/ecpg/test/sql/dynalloc2.pgc
*** pgsql.orig/src/interfaces/ecpg/test/sql/dynalloc2.pgc	2006-08-19 15:42:40.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/test/sql/dynalloc2.pgc	2009-12-14 12:41:24.000000000 +0100
*************** int main(void)
*** 30,36 ****
     exec sql insert into test values (NULL, NULL);
  
     exec sql allocate descriptor mydesc;
!    exec sql select * into descriptor mydesc from test;
     exec sql get descriptor mydesc :colnum=COUNT;
     exec sql get descriptor mydesc value 1 :ip1=DATA, :ipointer1=INDICATOR;
     exec sql get descriptor mydesc value 2 :cp2=DATA, :ipointer2=INDICATOR;
--- 30,36 ----
     exec sql insert into test values (NULL, NULL);
  
     exec sql allocate descriptor mydesc;
!    exec sql select * into sql descriptor mydesc from test;
     exec sql get descriptor mydesc :colnum=COUNT;
     exec sql get descriptor mydesc value 1 :ip1=DATA, :ipointer1=INDICATOR;
     exec sql get descriptor mydesc value 2 :cp2=DATA, :ipointer2=INDICATOR;
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/dynalloc.pgc pgsql.2/src/interfaces/ecpg/test/sql/dynalloc.pgc
*** pgsql.orig/src/interfaces/ecpg/test/sql/dynalloc.pgc	2006-08-19 15:42:40.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/test/sql/dynalloc.pgc	2009-12-14 12:41:24.000000000 +0100
*************** int main(void)
*** 39,45 ****
     exec sql insert into test (b, c, d, e, f, g, h, i) values (2.446456, NULL, 'v', 'c', '2003-03-03 12:33:07 PDT', false, NULL, NULL);
  
     exec sql allocate descriptor mydesc;
!    exec sql select a,b,c,d,e,f,g,h,i into descriptor mydesc from test order by a;
     exec sql get descriptor mydesc value 1 :d1=DATA, :i1=INDICATOR;
     exec sql get descriptor mydesc value 2 :d2=DATA, :i2=INDICATOR;
     exec sql get descriptor mydesc value 3 :d3=DATA, :i3=INDICATOR;
--- 39,45 ----
     exec sql insert into test (b, c, d, e, f, g, h, i) values (2.446456, NULL, 'v', 'c', '2003-03-03 12:33:07 PDT', false, NULL, NULL);
  
     exec sql allocate descriptor mydesc;
!    exec sql select a,b,c,d,e,f,g,h,i into sql descriptor mydesc from test order by a;
     exec sql get descriptor mydesc value 1 :d1=DATA, :i1=INDICATOR;
     exec sql get descriptor mydesc value 2 :d2=DATA, :i2=INDICATOR;
     exec sql get descriptor mydesc value 3 :d3=DATA, :i3=INDICATOR;
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/Makefile pgsql.2/src/interfaces/ecpg/test/sql/Makefile
*** pgsql.orig/src/interfaces/ecpg/test/sql/Makefile	2007-08-14 12:01:54.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/test/sql/Makefile	2009-12-14 12:41:24.000000000 +0100
*************** TESTS = array array.c \
*** 20,25 ****
--- 20,26 ----
          parser parser.c \
          quote quote.c \
          show show.c \
+         sqlda sqlda.c \
          insupd insupd.c 
  
  all: $(TESTS)
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/sqlda.pgc pgsql.2/src/interfaces/ecpg/test/sql/sqlda.pgc
*** pgsql.orig/src/interfaces/ecpg/test/sql/sqlda.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/sql/sqlda.pgc	2009-12-14 12:41:24.000000000 +0100
***************
*** 0 ****
--- 1,257 ----
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ #include <limits.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql include sqlda.h;
+ exec sql include pgtypes_numeric.h;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ /* These shouldn't be under DECLARE SECTION */
+ pg_sqlda_t	*inp_sqlda, *outp_sqlda, *outp_sqlda1;
+ 
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (sqlda->sqlvar[i].sqlind && *(sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", sqlda->sqlvar[i].sqlname);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case ECPGt_char:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_int:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ #if (LONG_BIT == 64) /* Defined via <limits.h> */
+ 		case ECPGt_long:
+ #else
+ # if (LONG_BIT = 32)
+ 		case ECPGt_long_long:
+ # else
+ #  error Neither "long" nor "long long" are 64-bit
+ # endif
+ #endif
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_double:
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_numeric:
+ 			{
+ 				char    *val;
+ 
+ 				val = PGTYPESnumeric_to_asc((numeric*)sqlda->sqlvar[i].sqldata, -1);
+ 				printf("name sqlda descriptor: '%s' value NUMERIC '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ 				free(val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ 	char	*stmt1 = "SELECT * FROM t1";
+ 	char	*stmt2 = "SELECT * FROM t1 WHERE id = ?";
+ 	int	rec;
+ 	int	id;
+ exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1 as regress1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table t1(
+ 		id integer,
+ 		t text,
+ 		d1 numeric,
+ 		d2 float8,
+ 		c char(10));
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into t1 values
+ 		(1, 'a', 1.0, 1, 'a'),
+ 		(2, null, null, null, null),
+ 		(3, '"c"', -3, 'nan'::float8, 'c'),
+ 		(4, 'd', 4.0, 4, 'd');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* SQLDA test for getting all records from a table */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id1 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare mycur1 cursor for st_id1;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open mycur1;
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		exec sql fetch 1 from mycur1 into descriptor outp_sqlda; 
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	exec sql whenever not found continue;
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close mycur1;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id1;
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting ALL records into the sqlda list */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id2 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare mycur2 cursor for st_id2;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open mycur2;
+ 
+ 	strcpy(msg, "fetch");
+ 	exec sql fetch all from mycur2 into descriptor outp_sqlda;
+ 
+ 	outp_sqlda1 = outp_sqlda;
+ 	rec = 0;
+ 	while (outp_sqlda1)
+ 	{
+ 		pg_sqlda_t	*ptr;
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda1);
+ 
+ 		ptr = outp_sqlda1;
+ 		outp_sqlda1 = outp_sqlda1->desc_next;
+ 		free(ptr);
+ 	}
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close mycur2;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id2;
+ 
+ 	/* SQLDA test for getting one record using an input descriptor */
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id3 FROM :stmt2;
+ 
+ 	strcpy(msg, "execute");
+ 	exec sql execute st_id3 using descriptor inp_sqlda into descriptor outp_sqlda;
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id3;
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor
+ 	 * on a named connection
+ 	 */
+ 
+ 	exec sql connect to REGRESSDB1 as con2;
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql at con2 prepare st_id4 FROM :stmt2;
+ 
+ 	strcpy(msg, "execute");
+ 	exec sql at con2 execute st_id4 using descriptor inp_sqlda into descriptor outp_sqlda;
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql at con2 commit;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id4;
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	strcpy(msg, "disconnect");
+ 	exec sql disconnect con2;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table t1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect");
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
#73Boszormenyi Zoltan
zb@cybertec.at
In reply to: Boszormenyi Zoltan (#71)
1 attachment(s)
Re: ECPG patch 3, DESCRIBE [OUTPUT] support

Boszormenyi Zoltan �rta:

New version, rebased to the previously sent
new SQLDA patch.

New version, fixed some loose ends introduced by
the native mode and multi-tuple SQLDA. No more
build_sqlda() in ecpglib/descriptor.c, common code
is factored out for ECPGt_descriptor and ECPGt_sqlda
in ECPGdescribe().

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

Attachments:

3-pg85-describe-16-ctxdiff.patchtext/x-patch; name=3-pg85-describe-16-ctxdiff.patchDownload
diff -dcrpN pgsql.2/src/interfaces/ecpg/ecpglib/descriptor.c pgsql.3/src/interfaces/ecpg/ecpglib/descriptor.c
*** pgsql.2/src/interfaces/ecpg/ecpglib/descriptor.c	2009-08-07 13:06:28.000000000 +0200
--- pgsql.3/src/interfaces/ecpg/ecpglib/descriptor.c	2009-12-15 10:22:33.000000000 +0100
***************
*** 13,18 ****
--- 13,19 ----
  #include "ecpgerrno.h"
  #include "extern.h"
  #include "sqlca.h"
+ #include "sqlda.h"
  #include "sql3types.h"
  
  static void descriptor_free(struct descriptor * desc);
*************** get_char_item(int lineno, void *var, enu
*** 226,231 ****
--- 227,238 ----
  	return (true);
  }
  
+ #define RETURN_IF_NO_DATA	if (ntuples < 1) \
+ 				{ \
+ 					ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL); \
+ 					return (false); \
+ 				}
+ 
  bool
  ECPGget_desc(int lineno, const char *desc_name, int index,...)
  {
*************** ECPGget_desc(int lineno, const char *des
*** 244,254 ****
  		return (false);
  
  	ntuples = PQntuples(ECPGresult);
- 	if (ntuples < 1)
- 	{
- 		ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL);
- 		return (false);
- 	}
  
  	if (index < 1 || index > PQnfields(ECPGresult))
  	{
--- 251,256 ----
*************** ECPGget_desc(int lineno, const char *des
*** 283,288 ****
--- 285,291 ----
  		switch (type)
  		{
  			case (ECPGd_indicator):
+ 				RETURN_IF_NO_DATA;
  				data_var.ind_type = vartype;
  				data_var.ind_pointer = var;
  				data_var.ind_varcharsize = varcharsize;
*************** ECPGget_desc(int lineno, const char *des
*** 295,300 ****
--- 298,304 ----
  				break;
  
  			case ECPGd_data:
+ 				RETURN_IF_NO_DATA;
  				data_var.type = vartype;
  				data_var.pointer = var;
  				data_var.varcharsize = varcharsize;
*************** ECPGget_desc(int lineno, const char *des
*** 377,382 ****
--- 381,387 ----
  			case ECPGd_ret_length:
  			case ECPGd_ret_octet:
  
+ 				RETURN_IF_NO_DATA;
  				/*
  				 * this is like ECPGstore_result
  				 */
*************** ECPGget_desc(int lineno, const char *des
*** 480,485 ****
--- 485,491 ----
  	sqlca->sqlerrd[2] = ntuples;
  	return (true);
  }
+ #undef RETURN_IF_NO_DATA
  
  bool
  ECPGset_desc_header(int lineno, const char *desc_name, int count)
*************** ecpg_find_desc(int line, const char *nam
*** 723,730 ****
  }
  
  bool
! ECPGdescribe(int line, bool input, const char *statement,...)
  {
! 	ecpg_log("ECPGdescribe called on line %d for %s: %s\n", line, input ? "input" : "output", statement);
! 	return false;
  }
--- 729,837 ----
  }
  
  bool
! ECPGdescribe(int line, bool input, const char *connection_name, const char *stmt_name, ...)
  {
! 	bool		ret = false;
! 	struct connection *con;
! 	struct prepared_statement *prep;
! 	PGresult   *res;
! 	va_list		args;
! 
! 	/* DESCRIBE INPUT is not yet supported */
! 	if (input)
! 		return ret;
! 
! 	con = ecpg_get_connection(connection_name);
! 	if (!con)
! 		return false;
! 	prep = ecpg_find_prepared_statement(stmt_name, con, NULL);
! 	if (!prep)
! 		return ret;
! 
! 	va_start(args, stmt_name);
! 
! 	for (;;)
! 	{
! 		enum ECPGttype	type, dummy_type;
! 		void		*ptr, *dummy_ptr;
! 		long		dummy;
! 
! 		/* variable type */
! 		type = va_arg(args, enum ECPGttype);
! 
! 		if (type == ECPGt_EORT)
! 			break;
! 
! 		/* rest of variable parameters*/
! 		ptr = va_arg(args, void *);
! 		dummy = va_arg(args, long);
! 		dummy = va_arg(args, long);
! 		dummy = va_arg(args, long);
! 
! 		/* variable indicator */
! 		dummy_type = va_arg(args, enum ECPGttype);
! 		dummy_ptr = va_arg(args, void *);
! 		dummy = va_arg(args, long);
! 		dummy = va_arg(args, long);
! 		dummy = va_arg(args, long);
! 
! 		switch (type)
! 		{
! 			case ECPGt_descriptor:
! 			{
! 				char	*name = ptr;
! 				struct descriptor *desc = ecpg_find_desc(line, name);
! 
! 				if (desc == NULL)
! 					break;
! 
! 				res = PQdescribePrepared(con->connection, stmt_name);
! 				if (!ecpg_check_PQresult(res, line, con->connection, prep->stmt->compat))
! 					break;
! 
! 				if (desc->result != NULL)
! 					PQclear(desc->result);
! 
! 				desc->result = res;
! 				ret = true;
! 				break;
! 			}
! 			case ECPGt_sqlda:
! 			{
! 				pg_sqlda_t **_sqlda = ptr;
! 				pg_sqlda_t *sqlda;
! 
! 				res = PQdescribePrepared(con->connection, stmt_name);
! 				if (!ecpg_check_PQresult(res, line, con->connection, prep->stmt->compat))
! 					break;
! 
! 				sqlda = ecpg_build_sqlda_for_PGresult(line, res, -1, prep->stmt->compat);
! 				if (sqlda)
! 				{
! 					pg_sqlda_t *sqlda_old = *_sqlda;
! 					pg_sqlda_t *sqlda_old1;
! 
! 					while (sqlda_old)
! 					{
! 						sqlda_old1 = sqlda_old->desc_next;
! 						free(sqlda_old);
! 						sqlda_old = sqlda_old1;
! 					}
! 
! 					*_sqlda = sqlda;
! 					ret = true;
! 				}
! 
! 				PQclear(res);
! 				break;
! 			}
! 			default:
! 				/* nothing else may come */
! 				;
! 		}
! 	}
! 
! 	va_end(args);
! 
! 	return ret;
  }
diff -dcrpN pgsql.2/src/interfaces/ecpg/ecpglib/extern.h pgsql.3/src/interfaces/ecpg/ecpglib/extern.h
*** pgsql.2/src/interfaces/ecpg/ecpglib/extern.h	2009-12-14 12:41:24.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/ecpglib/extern.h	2009-12-14 13:41:48.000000000 +0100
*************** struct statement
*** 59,64 ****
--- 59,73 ----
  	struct variable *outlist;
  };
  
+ /* structure to store prepared statements for a connection */
+ struct prepared_statement
+ {
+ 	char	   *name;
+ 	bool		prepared;
+ 	struct statement *stmt;
+ 	struct prepared_statement *next;
+ };
+ 
  /* structure to store connections */
  struct connection
  {
*************** struct descriptor *ecpggetdescp(int, cha
*** 138,143 ****
--- 147,155 ----
  
  struct descriptor *ecpg_find_desc(int line, const char *name);
  
+ struct prepared_statement *ecpg_find_prepared_statement(const char *,
+ 				  struct connection *, struct prepared_statement **);
+ 
  bool ecpg_store_result(const PGresult *results, int act_field,
  				  const struct statement * stmt, struct variable * var);
  bool		ecpg_store_input(const int, const bool, const struct variable *, char **, bool);
diff -dcrpN pgsql.2/src/interfaces/ecpg/ecpglib/prepare.c pgsql.3/src/interfaces/ecpg/ecpglib/prepare.c
*** pgsql.2/src/interfaces/ecpg/ecpglib/prepare.c	2009-10-15 13:26:30.000000000 +0200
--- pgsql.3/src/interfaces/ecpg/ecpglib/prepare.c	2009-12-14 13:44:47.000000000 +0100
***************
*** 11,24 ****
  #include "extern.h"
  #include "sqlca.h"
  
- struct prepared_statement
- {
- 	char	   *name;
- 	bool		prepared;
- 	struct statement *stmt;
- 	struct prepared_statement *next;
- };
- 
  #define STMTID_SIZE 32
  
  typedef struct
--- 11,16 ----
*************** static const int stmtCacheNBuckets = 203
*** 35,42 ****
  static const int stmtCacheEntPerBucket = 8;		/* # entries/bucket		*/
  static stmtCacheEntry stmtCacheEntries[16384] = {{0, {0}, 0, 0, 0}};
  
- static struct prepared_statement *find_prepared_statement(const char *name,
- 				 struct connection * con, struct prepared_statement ** prev);
  static bool deallocate_one(int lineno, enum COMPAT_MODE c, struct connection * con,
  		 struct prepared_statement * prev, struct prepared_statement * this);
  
--- 27,32 ----
*************** ECPGprepare(int lineno, const char *conn
*** 126,132 ****
  		return false;
  
  	/* check if we already have prepared this statement */
! 	this = find_prepared_statement(name, con, &prev);
  	if (this && !deallocate_one(lineno, ECPG_COMPAT_PGSQL, con, prev, this))
  		return false;
  
--- 116,122 ----
  		return false;
  
  	/* check if we already have prepared this statement */
! 	this = ecpg_find_prepared_statement(name, con, &prev);
  	if (this && !deallocate_one(lineno, ECPG_COMPAT_PGSQL, con, prev, this))
  		return false;
  
*************** ECPGprepare(int lineno, const char *conn
*** 179,186 ****
  	return true;
  }
  
! static struct prepared_statement *
! find_prepared_statement(const char *name,
  				 struct connection * con, struct prepared_statement ** prev_)
  {
  	struct prepared_statement *this,
--- 169,176 ----
  	return true;
  }
  
! struct prepared_statement *
! ecpg_find_prepared_statement(const char *name,
  				 struct connection * con, struct prepared_statement ** prev_)
  {
  	struct prepared_statement *this,
*************** ECPGdeallocate(int lineno, int c, const 
*** 262,268 ****
  	if (!ecpg_init(con, connection_name, lineno))
  		return false;
  
! 	this = find_prepared_statement(name, con, &prev);
  	if (this)
  		return deallocate_one(lineno, c, con, prev, this);
  
--- 252,258 ----
  	if (!ecpg_init(con, connection_name, lineno))
  		return false;
  
! 	this = ecpg_find_prepared_statement(name, con, &prev);
  	if (this)
  		return deallocate_one(lineno, c, con, prev, this);
  
*************** ecpg_prepared(const char *name, struct c
*** 297,303 ****
  {
  	struct prepared_statement *this;
  
! 	this = find_prepared_statement(name, con, NULL);
  	return this ? this->stmt->command : NULL;
  }
  
--- 287,293 ----
  {
  	struct prepared_statement *this;
  
! 	this = ecpg_find_prepared_statement(name, con, NULL);
  	return this ? this->stmt->command : NULL;
  }
  
*************** ecpg_freeStmtCacheEntry(int lineno, int 
*** 394,400 ****
  	con = ecpg_get_connection(entry->connection);
  
  	/* free the 'prepared_statement' list entry		  */
! 	this = find_prepared_statement(entry->stmtID, con, &prev);
  	if (this && !deallocate_one(lineno, compat, con, prev, this))
  		return (-1);
  
--- 384,390 ----
  	con = ecpg_get_connection(entry->connection);
  
  	/* free the 'prepared_statement' list entry		  */
! 	this = ecpg_find_prepared_statement(entry->stmtID, con, &prev);
  	if (this && !deallocate_one(lineno, compat, con, prev, this))
  		return (-1);
  
diff -dcrpN pgsql.2/src/interfaces/ecpg/include/ecpglib.h pgsql.3/src/interfaces/ecpg/include/ecpglib.h
*** pgsql.2/src/interfaces/ecpg/include/ecpglib.h	2009-09-21 15:19:11.000000000 +0200
--- pgsql.3/src/interfaces/ecpg/include/ecpglib.h	2009-12-14 12:42:44.000000000 +0100
*************** bool		ECPGset_desc(int, const char *, in
*** 83,89 ****
  
  void		ECPGset_noind_null(enum ECPGttype, void *);
  bool		ECPGis_noind_null(enum ECPGttype, void *);
! bool		ECPGdescribe(int, bool, const char *,...);
  
  /* dynamic result allocation */
  void		ECPGfree_auto_mem(void);
--- 83,89 ----
  
  void		ECPGset_noind_null(enum ECPGttype, void *);
  bool		ECPGis_noind_null(enum ECPGttype, void *);
! bool		ECPGdescribe(int, bool, const char *, const char *, ...);
  
  /* dynamic result allocation */
  void		ECPGfree_auto_mem(void);
diff -dcrpN pgsql.2/src/interfaces/ecpg/preproc/ecpg.trailer pgsql.3/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.2/src/interfaces/ecpg/preproc/ecpg.trailer	2009-12-14 12:41:24.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/preproc/ecpg.trailer	2009-12-14 12:45:12.000000000 +0100
*************** into_descriptor: INTO SQL_SQL SQL_DESCRI
*** 994,999 ****
--- 994,1006 ----
  		}
  		;
  
+ into_sqlda: INTO name
+ 		{
+ 			add_variable_to_head(&argsresult, sqlda_variable($2), &no_indicator);
+ 			$$ = EMPTY;
+ 		}
+ 		;
+ 
  using_list: UsingValue | UsingValue ',' using_list;
  
  UsingValue: UsingConst
*************** UsingConst: Iconst			{ $$ = $1; }
*** 1019,1046 ****
  		;
  
  /*
!  * We accept descibe but do nothing with it so far.
   */
! ECPGDescribe: SQL_DESCRIBE INPUT_P name using_descriptor
  	{
  		const char *con = connection ? connection : "NULL";
  		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
! 		$$ = (char *) mm_alloc(sizeof("1, ECPGprepared_statement(, \"\", __LINE__)") + strlen(con) + strlen($3));
! 		sprintf($$, "1, ECPGprepared_statement(%s, \"%s\", __LINE__)", con, $3);
  	}
! 	| SQL_DESCRIBE opt_output name using_descriptor
  	{
  		const char *con = connection ? connection : "NULL";
! 		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
! 		$$ = (char *) mm_alloc(sizeof("0, ECPGprepared_statement(, \"\", __LINE__)") + strlen(con) + strlen($3));
! 		sprintf($$, "0, ECPGprepared_statement(%s, \"%s\", __LINE__)", con, $3);
  	}
! 	| SQL_DESCRIBE opt_output name into_descriptor
  	{
  		const char *con = connection ? connection : "NULL";
  		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
! 		$$ = (char *) mm_alloc(sizeof("0, ECPGprepared_statement(, \"\", __LINE__)") + strlen(con) + strlen($3));
! 		sprintf($$, "0, ECPGprepared_statement(%s, \"%s\", __LINE__)", con, $3);
  	}
  	;
  
--- 1026,1074 ----
  		;
  
  /*
!  * We accept DESCRIBE [OUTPUT] but do nothing with DESCRIBE INPUT so far.
   */
! ECPGDescribe: SQL_DESCRIBE INPUT_P prepared_name using_descriptor
  	{
  		const char *con = connection ? connection : "NULL";
  		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
! 		$$ = (char *) mm_alloc(sizeof("1, , ") + strlen(con) + strlen($3));
! 		sprintf($$, "1, %s, %s", con, $3);
  	}
! 	| SQL_DESCRIBE opt_output prepared_name using_descriptor
  	{
  		const char *con = connection ? connection : "NULL";
! 		struct variable *var;
! 
! 		var = argsinsert->variable;
! 		remove_variable_from_list(&argsinsert, var);
! 		add_variable_to_head(&argsresult, var, &no_indicator);
! 
! 		$$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
! 		sprintf($$, "0, %s, %s", con, $3);
  	}
! 	| SQL_DESCRIBE opt_output prepared_name into_descriptor
! 	{
! 		const char *con = connection ? connection : "NULL";
! 		$$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
! 		sprintf($$, "0, %s, %s", con, $3);
! 	}
! 	| SQL_DESCRIBE INPUT_P prepared_name into_sqlda
  	{
  		const char *con = connection ? connection : "NULL";
  		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
! 		if (!INFORMIX_MODE)
! 			mmerror(PARSE_ERROR, ET_ERROR, "Not in Informix compatibility mode");
! 		$$ = (char *) mm_alloc(sizeof("1, , ") + strlen(con) + strlen($3));
! 		sprintf($$, "1, %s, %s", con, $3);
! 	}
! 	| SQL_DESCRIBE opt_output prepared_name into_sqlda
! 	{
! 		const char *con = connection ? connection : "NULL";
! 		if (!INFORMIX_MODE)
! 			mmerror(PARSE_ERROR, ET_ERROR, "Not in Informix compatibility mode");
! 		$$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
! 		sprintf($$, "0, %s, %s", con, $3);
  	}
  	;
  
diff -dcrpN pgsql.2/src/interfaces/ecpg/preproc/ecpg.type pgsql.3/src/interfaces/ecpg/preproc/ecpg.type
*** pgsql.2/src/interfaces/ecpg/preproc/ecpg.type	2009-12-14 12:41:24.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/preproc/ecpg.type	2009-12-14 12:42:44.000000000 +0100
***************
*** 72,77 ****
--- 72,78 ----
  %type <str> execute_rest
  %type <str> indicator
  %type <str> into_descriptor
+ %type <str> into_sqlda
  %type <str> Iresult
  %type <str> on_off
  %type <str> opt_bit_field
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/compat_informix/describe.pgc pgsql.3/src/interfaces/ecpg/test/compat_informix/describe.pgc
*** pgsql.2/src/interfaces/ecpg/test/compat_informix/describe.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/compat_informix/describe.pgc	2009-12-14 14:01:17.000000000 +0100
***************
*** 0 ****
--- 1,166 ----
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ exec sql include ../regression;
+ exec sql include sqlda.h;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ pg_sqlda_t	*sqlda1, *sqlda2, *sqlda3;
+ 
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ 	char	*stmt1 = "SELECT id, t FROM t1";
+ 	char	*stmt2 = "SELECT id, t FROM t1 WHERE id = -1";
+ 	int	i, count1, count2;
+ 	char	field_name1[30] = "not set";
+ 	char	field_name2[30] = "not set";
+ exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table t1(id serial primary key, t text);
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into t1(id, t) values (default, 'a');
+ 	exec sql insert into t1(id, t) values (default, 'b');
+ 	exec sql insert into t1(id, t) values (default, 'c');
+ 	exec sql insert into t1(id, t) values (default, 'd');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/*
+ 	 * Test DESCRIBE with a query producing tuples.
+ 	 * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
+ 	 * Informix-compat mode.
+ 	 */
+ 
+ 	strcpy(msg, "allocate");
+ 	exec sql allocate descriptor desc1;
+ 	exec sql allocate descriptor desc2;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id1 FROM :stmt1;
+ 
+ 	sqlda1 = sqlda2 = sqlda3 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	exec sql describe st_id1 into sql descriptor desc1;
+ 	exec sql describe st_id1 using sql descriptor desc2;
+ 
+ 	exec sql describe st_id1 into descriptor sqlda1;
+ 	exec sql describe st_id1 using descriptor sqlda2;
+ 	exec sql describe st_id1 into sqlda3;
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	exec sql get descriptor desc1 :count1 = count;
+ 	exec sql get descriptor desc1 :count2 = count;
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld &&
+ 		count1 == sqlda3->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		exec sql get descriptor desc1 value :i :field_name1 = name;
+ 		exec sql get descriptor desc2 value :i :field_name2 = name;
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname,
+ 			sqlda3->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate descriptor desc1;
+ 	exec sql deallocate descriptor desc2;
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 	free(sqlda3);
+ 
+ 	exec sql deallocate prepare st_id1;
+ 
+ 	/* Test DESCRIBE with a query not producing tuples */
+ 
+ 	strcpy(msg, "allocate");
+ 	exec sql allocate descriptor desc1;
+ 	exec sql allocate descriptor desc2;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id2 FROM :stmt2;
+ 
+ 	sqlda1 = sqlda2 = sqlda3 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	exec sql describe st_id2 into sql descriptor desc1;
+ 	exec sql describe st_id2 using sql descriptor desc2;
+ 
+ 	exec sql describe st_id2 into descriptor sqlda1;
+ 	exec sql describe st_id2 using descriptor sqlda2;
+ 	exec sql describe st_id2 into sqlda3;
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	exec sql get descriptor desc1 :count1 = count;
+ 	exec sql get descriptor desc1 :count2 = count;
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld &&
+ 		count1 == sqlda3->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		exec sql get descriptor desc1 value :i :field_name1 = name;
+ 		exec sql get descriptor desc2 value :i :field_name2 = name;
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname,
+ 			sqlda3->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate descriptor desc1;
+ 	exec sql deallocate descriptor desc2;
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 	free(sqlda3);
+ 
+ 	exec sql deallocate prepare st_id2;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table t1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/compat_informix/Makefile pgsql.3/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.2/src/interfaces/ecpg/test/compat_informix/Makefile	2009-12-14 12:41:24.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/compat_informix/Makefile	2009-12-14 14:01:34.000000000 +0100
*************** TESTS = test_informix test_informix.c \
*** 17,22 ****
--- 17,23 ----
          rfmtlong rfmtlong.c \
          rnull rnull.c \
          sqlda sqlda.c \
+         describe describe.c \
          charfuncs charfuncs.c
  
  all: $(TESTS)
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/ecpg_schedule pgsql.3/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.2/src/interfaces/ecpg/test/ecpg_schedule	2009-12-14 12:41:24.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/ecpg_schedule	2009-12-14 14:04:58.000000000 +0100
*************** test: compat_informix/rfmtdate
*** 4,9 ****
--- 4,10 ----
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
  test: compat_informix/sqlda
+ test: compat_informix/describe
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: sql/copystdout
*** 31,36 ****
--- 32,38 ----
  test: sql/define
  test: sql/desc
  test: sql/sqlda
+ test: sql/describe
  test: sql/dynalloc
  test: sql/dynalloc2
  test: sql/dyntest
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/ecpg_schedule_tcp pgsql.3/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.2/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-12-14 12:41:24.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-12-14 14:05:07.000000000 +0100
*************** test: compat_informix/rfmtdate
*** 4,9 ****
--- 4,10 ----
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
  test: compat_informix/sqlda
+ test: compat_informix/describe
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: sql/copystdout
*** 31,36 ****
--- 32,38 ----
  test: sql/define
  test: sql/desc
  test: sql/sqlda
+ test: sql/describe
  test: sql/dynalloc
  test: sql/dynalloc2
  test: sql/dyntest
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-describe.c pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.c
*** pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-describe.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.c	2009-12-14 14:07:05.000000000 +0100
***************
*** 0 ****
--- 1,465 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "describe.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 4 "describe.pgc"
+ 
+ 
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+ 
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+ 
+ #include "ecpglib.h"
+ 
+ typedef struct sqlvar_struct
+ {
+ 	short	sqltype;		/* variable type                */
+ 	int	sqllen;			/* length in bytes              */
+ 	char	   *sqldata;		/* pointer to data              */
+ 	short	   *sqlind;		/* pointer to indicator         */
+ 	char	   *sqlname;		/* variable name                */
+ 	char	   *sqlformat;		/* reserved for future use      */
+ 	short	sqlitype;		/* ind variable type            */
+ 	short	sqlilen;		/* ind length in bytes          */
+ 	char	   *sqlidata;		/* ind data pointer             */
+ 	int	sqlxid;			/* extended id type             */
+ 	char	   *sqltypename;	/* extended type name           */
+ 	short	sqltypelen;		/* length of extended type name */
+ 	short	sqlownerlen;		/* length of owner name         */
+ 	short	sqlsourcetype;		/* source type for distinct of built-ins */
+ 	char	   *sqlownername;	/* owner name                   */
+ 	int	sqlsourceid;		/* extended id of source type   */
+ 
+ 	/*
+ 	 * sqlilongdata is new.  It supports data that exceeds the 32k
+ 	 * limit.  sqlilen and sqlidata are for backward compatibility
+ 	 * and they have maximum value of <32K.
+ 	 */
+ 	char	   *sqlilongdata;	/* for data field beyond 32K    */
+ 	int	sqlflags;		/* for internal use only        */
+ 	void	   *sqlreserved;	/* reserved for future use      */
+ } pg_sqlvar_t;
+ 
+ typedef struct sqlda
+ {
+ 	short		sqld;
+ 	pg_sqlvar_t	   *sqlvar;
+ 	char		desc_name[19];	/* descriptor name              */
+ 	short		desc_occ;	/* size of sqlda structure      */
+ 	struct sqlda	   *desc_next;	/* pointer to next sqlda struct */
+ 	void		   *reserved;	/* reserved for future use */
+ } pg_sqlda_t;
+ 
+ #endif /* POSTGRES_SQLDA_H */
+ 
+ #line 5 "describe.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 7 "describe.pgc"
+ 
+ 
+ pg_sqlda_t	*sqlda1, *sqlda2, *sqlda3;
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		  
+ 		  
+ 		  
+ 
+ #line 15 "describe.pgc"
+  char * stmt1 = "SELECT id, t FROM t1" ;
+  
+ #line 16 "describe.pgc"
+  char * stmt2 = "SELECT id, t FROM t1 WHERE id = -1" ;
+  
+ #line 17 "describe.pgc"
+  int i , count1 , count2 ;
+  
+ #line 18 "describe.pgc"
+  char field_name1 [ 30 ] = "not set" ;
+  
+ #line 19 "describe.pgc"
+  char field_name2 [ 30 ] = "not set" ;
+ /* exec sql end declare section */
+ #line 20 "describe.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0); 
+ #line 27 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 27 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 30 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 30 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
+ #line 33 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 33 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 36 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 37 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 38 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 39 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 39 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 42 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 42 "describe.pgc"
+ 
+ 
+ 	/*
+ 	 * Test DESCRIBE with a query producing tuples.
+ 	 * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
+ 	 * Informix-compat mode.
+ 	 */
+ 
+ 	strcpy(msg, "allocate");
+ 	ECPGallocate_desc(__LINE__, "desc1");
+ #line 51 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 51 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc2");
+ #line 52 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 52 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 55 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 55 "describe.pgc"
+ 
+ 
+ 	sqlda1 = sqlda2 = sqlda3 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 60 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 61 "describe.pgc"
+ 
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_sqlda, &sqlda1, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 63 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_sqlda, &sqlda2, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 64 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_sqlda, &sqlda3, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 65 "describe.pgc"
+ 
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));
+ 
+ #line 71 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 71 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count2));
+ 
+ #line 72 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 72 "describe.pgc"
+ 
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld &&
+ 		count1 == sqlda3->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+ 	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 82 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 82 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+ 	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 83 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 83 "describe.pgc"
+ 
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname,
+ 			sqlda3->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 93 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 93 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 94 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 94 "describe.pgc"
+ 
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 	free(sqlda3);
+ 
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
+ #line 99 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 99 "describe.pgc"
+ 
+ 
+ 	/* Test DESCRIBE with a query not producing tuples */
+ 
+ 	strcpy(msg, "allocate");
+ 	ECPGallocate_desc(__LINE__, "desc1");
+ #line 104 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 104 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc2");
+ #line 105 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 105 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2);
+ #line 108 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 108 "describe.pgc"
+ 
+ 
+ 	sqlda1 = sqlda2 = sqlda3 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 113 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 114 "describe.pgc"
+ 
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_sqlda, &sqlda1, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 116 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_sqlda, &sqlda2, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 117 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_sqlda, &sqlda3, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 118 "describe.pgc"
+ 
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));
+ 
+ #line 124 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 124 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count2));
+ 
+ #line 125 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 125 "describe.pgc"
+ 
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld &&
+ 		count1 == sqlda3->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+ 	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 135 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 135 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+ 	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 136 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 136 "describe.pgc"
+ 
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname,
+ 			sqlda3->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 146 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 146 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 147 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 147 "describe.pgc"
+ 
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 	free(sqlda3);
+ 
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id2");
+ #line 152 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 152 "describe.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 157 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 157 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 160 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 160 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 163 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 163 "describe.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr
*** pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr	2009-12-14 12:42:44.000000000 +0100
***************
*** 0 ****
--- 1,100 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: query: insert into t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 42: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 55: name st_id1; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 99: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 108: name st_id2; query: "SELECT id, t FROM t1 WHERE id = -1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 152: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 157: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 160: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout
*** pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout	2009-12-14 12:42:44.000000000 +0100
***************
*** 0 ****
--- 1,24 ----
+ 1
+ 	field_name1 'id'
+ 	field_name2 'id'
+ 	sqlda1 'id'
+ 	sqlda2 'id'
+ 	sqlda3 'id'
+ 2
+ 	field_name1 't'
+ 	field_name2 't'
+ 	sqlda1 't'
+ 	sqlda2 't'
+ 	sqlda3 't'
+ 1
+ 	field_name1 'id'
+ 	field_name2 'id'
+ 	sqlda1 'id'
+ 	sqlda2 'id'
+ 	sqlda3 'id'
+ 2
+ 	field_name1 't'
+ 	field_name2 't'
+ 	sqlda1 't'
+ 	sqlda2 't'
+ 	sqlda3 't'
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/preproc-describe.c pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.c
*** pgsql.2/src/interfaces/ecpg/test/expected/preproc-describe.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.c	2009-12-14 12:42:44.000000000 +0100
***************
*** 0 ****
--- 1,481 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "describe.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 4 "describe.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 6 "describe.pgc"
+ 
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		    
+ 		  
+ 		  
+ 		  
+ 		  
+ 
+ #line 12 "describe.pgc"
+  char * stmt1 = "SELECT id, t FROM t1" ;
+  
+ #line 13 "describe.pgc"
+  char * stmt2 = "SELECT id, t FROM t1 WHERE id = -1" ;
+  
+ #line 14 "describe.pgc"
+  int i , count1 , count2 , count3 , count4 ;
+  
+ #line 15 "describe.pgc"
+  char field_name1 [ 30 ] = "not set" ;
+  
+ #line 16 "describe.pgc"
+  char field_name2 [ 30 ] = "not set" ;
+  
+ #line 17 "describe.pgc"
+  char field_name3 [ 30 ] = "not set" ;
+  
+ #line 18 "describe.pgc"
+  char field_name4 [ 30 ] = "not set" ;
+ /* exec sql end declare section */
+ #line 19 "describe.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
+ #line 26 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 26 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 29 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 29 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
+ #line 32 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 32 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 35 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 35 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 36 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 37 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 38 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 41 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "describe.pgc"
+ 
+ 
+ 	/*
+ 	 * Test DESCRIBE with a query producing tuples.
+ 	 * DESCRIPTOR and SQL DESCRIPTOR are the same in native mode.
+ 	 */
+ 
+ 	strcpy(msg, "allocate");
+ 	ECPGallocate_desc(__LINE__, "desc1");
+ #line 49 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 49 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc2");
+ #line 50 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 50 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc3");
+ #line 51 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 51 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc4");
+ #line 52 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 52 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 55 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 55 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "describe");
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 58 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 59 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc3", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 60 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc4", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 61 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "get descriptor");
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));
+ 
+ #line 64 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 64 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc2", &(count2));
+ 
+ #line 65 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 65 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc3", &(count3));
+ 
+ #line 66 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 66 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc4", &(count4));
+ 
+ #line 67 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 67 "describe.pgc"
+ 
+ 
+ 	if (!(count1 == count2 && count1 == count3 && count1 == count4))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+ 	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 74 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 74 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+ 	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 75 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 75 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc3", i,ECPGd_name,
+ 	ECPGt_char,(field_name3),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 76 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 76 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc4", i,ECPGd_name,
+ 	ECPGt_char,(field_name4),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 77 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 77 "describe.pgc"
+ 
+ 		printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
+ 			field_name1, field_name2, field_name3, field_name4);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 83 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 83 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 84 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 84 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc3");
+ #line 85 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 85 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc4");
+ #line 86 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 86 "describe.pgc"
+ 
+ 
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
+ #line 88 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 88 "describe.pgc"
+ 
+ 
+ 	/* Test DESCRIBE with a query not producing tuples */
+ 
+ 	strcpy(msg, "allocate");
+ 	ECPGallocate_desc(__LINE__, "desc1");
+ #line 93 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 93 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc2");
+ #line 94 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 94 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc3");
+ #line 95 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 95 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc4");
+ #line 96 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 96 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2);
+ #line 99 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 99 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "describe");
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 102 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 103 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc3", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 104 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc4", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 105 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "get descriptor");
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));
+ 
+ #line 108 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 108 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc2", &(count2));
+ 
+ #line 109 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 109 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc3", &(count3));
+ 
+ #line 110 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 110 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc4", &(count4));
+ 
+ #line 111 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 111 "describe.pgc"
+ 
+ 
+ 	if (!(count1 == count2 && count1 == count3 && count1 == count4))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+ 	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 118 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 118 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+ 	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 119 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 119 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc3", i,ECPGd_name,
+ 	ECPGt_char,(field_name3),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 120 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 120 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc4", i,ECPGd_name,
+ 	ECPGt_char,(field_name4),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 121 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 121 "describe.pgc"
+ 
+ 		printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
+ 			field_name1, field_name2, field_name3, field_name4);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 127 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 127 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 128 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 128 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc3");
+ #line 129 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 129 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc4");
+ #line 130 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 130 "describe.pgc"
+ 
+ 
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
+ #line 132 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 132 "describe.pgc"
+ 
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 138 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 138 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 141 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 141 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 144 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 144 "describe.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/preproc-describe.stderr pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.stderr
*** pgsql.2/src/interfaces/ecpg/test/expected/preproc-describe.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.stderr	2009-12-14 12:42:44.000000000 +0100
***************
*** 0 ****
--- 1,140 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: query: insert into t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 41: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 55: name st_id1; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 88: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 99: name st_id2; query: "SELECT id, t FROM t1 WHERE id = -1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 132: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 138: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 138: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 138: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 141: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/preproc-describe.stdout pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.stdout
*** pgsql.2/src/interfaces/ecpg/test/expected/preproc-describe.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.stdout	2009-12-14 12:42:44.000000000 +0100
***************
*** 0 ****
--- 1,4 ----
+ field_name 1 'id' 2 'id' 3 'id' 4 'id'
+ field_name 1 't' 2 't' 3 't' 4 't'
+ field_name 1 'id' 2 'id' 3 'id' 4 'id'
+ field_name 1 't' 2 't' 3 't' 4 't'
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/sql-describe.c pgsql.3/src/interfaces/ecpg/test/expected/sql-describe.c
*** pgsql.2/src/interfaces/ecpg/test/expected/sql-describe.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/sql-describe.c	2009-12-14 14:06:16.000000000 +0100
***************
*** 0 ****
--- 1,447 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "describe.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 4 "describe.pgc"
+ 
+ 
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+ 
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+ 
+ #include "ecpglib.h"
+ 
+ typedef struct sqlvar_struct
+ {
+ 	short	sqltype;		/* variable type                */
+ 	int	sqllen;			/* length in bytes              */
+ 	char	   *sqldata;		/* pointer to data              */
+ 	short	   *sqlind;		/* pointer to indicator         */
+ 	char	   *sqlname;		/* variable name                */
+ 	char	   *sqlformat;		/* reserved for future use      */
+ 	short	sqlitype;		/* ind variable type            */
+ 	short	sqlilen;		/* ind length in bytes          */
+ 	char	   *sqlidata;		/* ind data pointer             */
+ 	int	sqlxid;			/* extended id type             */
+ 	char	   *sqltypename;	/* extended type name           */
+ 	short	sqltypelen;		/* length of extended type name */
+ 	short	sqlownerlen;		/* length of owner name         */
+ 	short	sqlsourcetype;		/* source type for distinct of built-ins */
+ 	char	   *sqlownername;	/* owner name                   */
+ 	int	sqlsourceid;		/* extended id of source type   */
+ 
+ 	/*
+ 	 * sqlilongdata is new.  It supports data that exceeds the 32k
+ 	 * limit.  sqlilen and sqlidata are for backward compatibility
+ 	 * and they have maximum value of <32K.
+ 	 */
+ 	char	   *sqlilongdata;	/* for data field beyond 32K    */
+ 	int	sqlflags;		/* for internal use only        */
+ 	void	   *sqlreserved;	/* reserved for future use      */
+ } pg_sqlvar_t;
+ 
+ typedef struct sqlda
+ {
+ 	short		sqld;
+ 	pg_sqlvar_t	   *sqlvar;
+ 	char		desc_name[19];	/* descriptor name              */
+ 	short		desc_occ;	/* size of sqlda structure      */
+ 	struct sqlda	   *desc_next;	/* pointer to next sqlda struct */
+ 	void		   *reserved;	/* reserved for future use */
+ } pg_sqlda_t;
+ 
+ #endif /* POSTGRES_SQLDA_H */
+ 
+ #line 5 "describe.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 7 "describe.pgc"
+ 
+ 
+ pg_sqlda_t	*sqlda1, *sqlda2;
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		  
+ 		  
+ 		  
+ 
+ #line 15 "describe.pgc"
+  char * stmt1 = "SELECT id, t FROM t1" ;
+  
+ #line 16 "describe.pgc"
+  char * stmt2 = "SELECT id, t FROM t1 WHERE id = -1" ;
+  
+ #line 17 "describe.pgc"
+  int i , count1 , count2 ;
+  
+ #line 18 "describe.pgc"
+  char field_name1 [ 30 ] = "not set" ;
+  
+ #line 19 "describe.pgc"
+  char field_name2 [ 30 ] = "not set" ;
+ /* exec sql end declare section */
+ #line 20 "describe.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
+ #line 27 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 27 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 30 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 30 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
+ #line 33 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 33 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 36 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 37 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 38 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 39 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 39 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 42 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 42 "describe.pgc"
+ 
+ 
+ 	/*
+ 	 * Test DESCRIBE with a query producing tuples.
+ 	 * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
+ 	 * Informix-compat mode.
+ 	 */
+ 
+ 	strcpy(msg, "allocate");
+ 	ECPGallocate_desc(__LINE__, "desc1");
+ #line 51 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 51 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc2");
+ #line 52 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 52 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 55 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 55 "describe.pgc"
+ 
+ 
+ 	sqlda1 = sqlda2 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 60 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 61 "describe.pgc"
+ 
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_sqlda, &sqlda1, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 63 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_sqlda, &sqlda2, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 64 "describe.pgc"
+ 
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));
+ 
+ #line 70 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 70 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count2));
+ 
+ #line 71 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 71 "describe.pgc"
+ 
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+ 	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 80 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 80 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+ 	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 81 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 81 "describe.pgc"
+ 
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 90 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 90 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 91 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 91 "describe.pgc"
+ 
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
+ #line 95 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 95 "describe.pgc"
+ 
+ 
+ 	/* Test DESCRIBE with a query not producing tuples */
+ 
+ 	strcpy(msg, "allocate");
+ 	ECPGallocate_desc(__LINE__, "desc1");
+ #line 100 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 100 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc2");
+ #line 101 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 101 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2);
+ #line 104 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 104 "describe.pgc"
+ 
+ 
+ 	sqlda1 = sqlda2 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 109 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 110 "describe.pgc"
+ 
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_sqlda, &sqlda1, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 112 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_sqlda, &sqlda2, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 113 "describe.pgc"
+ 
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));
+ 
+ #line 119 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 119 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count2));
+ 
+ #line 120 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 120 "describe.pgc"
+ 
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+ 	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 129 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 129 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+ 	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 130 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 130 "describe.pgc"
+ 
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 139 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 139 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 140 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 140 "describe.pgc"
+ 
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
+ #line 144 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 144 "describe.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 149 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 149 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 152 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 152 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 155 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 155 "describe.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/sql-describe.stderr pgsql.3/src/interfaces/ecpg/test/expected/sql-describe.stderr
*** pgsql.2/src/interfaces/ecpg/test/expected/sql-describe.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/sql-describe.stderr	2009-12-14 14:06:16.000000000 +0100
***************
*** 0 ****
--- 1,100 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: query: insert into t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 42: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 55: name st_id1; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 95: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 104: name st_id2; query: "SELECT id, t FROM t1 WHERE id = -1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 144: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 149: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 152: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/expected/sql-describe.stdout pgsql.3/src/interfaces/ecpg/test/expected/sql-describe.stdout
*** pgsql.2/src/interfaces/ecpg/test/expected/sql-describe.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/sql-describe.stdout	2009-12-14 14:06:16.000000000 +0100
***************
*** 0 ****
--- 1,20 ----
+ 1
+ 	field_name1 'id'
+ 	field_name2 'id'
+ 	sqlda1 'id'
+ 	sqlda2 'id'
+ 2
+ 	field_name1 't'
+ 	field_name2 't'
+ 	sqlda1 't'
+ 	sqlda2 't'
+ 1
+ 	field_name1 'id'
+ 	field_name2 'id'
+ 	sqlda1 'id'
+ 	sqlda2 'id'
+ 2
+ 	field_name1 't'
+ 	field_name2 't'
+ 	sqlda1 't'
+ 	sqlda2 't'
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/sql/describe.pgc pgsql.3/src/interfaces/ecpg/test/sql/describe.pgc
*** pgsql.2/src/interfaces/ecpg/test/sql/describe.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/sql/describe.pgc	2009-12-14 14:03:53.000000000 +0100
***************
*** 0 ****
--- 1,158 ----
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ exec sql include ../regression;
+ exec sql include sqlda.h;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ pg_sqlda_t	*sqlda1, *sqlda2;
+ 
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ 	char	*stmt1 = "SELECT id, t FROM t1";
+ 	char	*stmt2 = "SELECT id, t FROM t1 WHERE id = -1";
+ 	int	i, count1, count2;
+ 	char	field_name1[30] = "not set";
+ 	char	field_name2[30] = "not set";
+ exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table t1(id serial primary key, t text);
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into t1(id, t) values (default, 'a');
+ 	exec sql insert into t1(id, t) values (default, 'b');
+ 	exec sql insert into t1(id, t) values (default, 'c');
+ 	exec sql insert into t1(id, t) values (default, 'd');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/*
+ 	 * Test DESCRIBE with a query producing tuples.
+ 	 * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
+ 	 * Informix-compat mode.
+ 	 */
+ 
+ 	strcpy(msg, "allocate");
+ 	exec sql allocate descriptor desc1;
+ 	exec sql allocate descriptor desc2;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id1 FROM :stmt1;
+ 
+ 	sqlda1 = sqlda2 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	exec sql describe st_id1 into sql descriptor desc1;
+ 	exec sql describe st_id1 using sql descriptor desc2;
+ 
+ 	exec sql describe st_id1 into descriptor sqlda1;
+ 	exec sql describe st_id1 using descriptor sqlda2;
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	exec sql get descriptor desc1 :count1 = count;
+ 	exec sql get descriptor desc1 :count2 = count;
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		exec sql get descriptor desc1 value :i :field_name1 = name;
+ 		exec sql get descriptor desc2 value :i :field_name2 = name;
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate descriptor desc1;
+ 	exec sql deallocate descriptor desc2;
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 
+ 	exec sql deallocate prepare st_id1;
+ 
+ 	/* Test DESCRIBE with a query not producing tuples */
+ 
+ 	strcpy(msg, "allocate");
+ 	exec sql allocate descriptor desc1;
+ 	exec sql allocate descriptor desc2;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id2 FROM :stmt2;
+ 
+ 	sqlda1 = sqlda2 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	exec sql describe st_id2 into sql descriptor desc1;
+ 	exec sql describe st_id2 using sql descriptor desc2;
+ 
+ 	exec sql describe st_id2 into descriptor sqlda1;
+ 	exec sql describe st_id2 using descriptor sqlda2;
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	exec sql get descriptor desc1 :count1 = count;
+ 	exec sql get descriptor desc1 :count2 = count;
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		exec sql get descriptor desc1 value :i :field_name1 = name;
+ 		exec sql get descriptor desc2 value :i :field_name2 = name;
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate descriptor desc1;
+ 	exec sql deallocate descriptor desc2;
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 
+ 	exec sql deallocate prepare st_id2;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table t1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.2/src/interfaces/ecpg/test/sql/Makefile pgsql.3/src/interfaces/ecpg/test/sql/Makefile
*** pgsql.2/src/interfaces/ecpg/test/sql/Makefile	2009-12-14 12:41:24.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/sql/Makefile	2009-12-14 13:59:40.000000000 +0100
*************** TESTS = array array.c \
*** 9,14 ****
--- 9,16 ----
          copystdout copystdout.c \
  	define define.c \
          desc desc.c \
+         sqlda sqlda.c \
+         describe describe.c \
          dyntest dyntest.c \
          dynalloc dynalloc.c \
          dynalloc2 dynalloc2.c \
*************** TESTS = array array.c \
*** 20,26 ****
          parser parser.c \
          quote quote.c \
          show show.c \
-         sqlda sqlda.c \
          insupd insupd.c 
  
  all: $(TESTS)
--- 22,27 ----
#74Boszormenyi Zoltan
zb@cybertec.at
In reply to: Boszormenyi Zoltan (#65)
1 attachment(s)
Re: ECPG patch 4, out-of-scope cursor support in Informix-mode

New version: rebased to current CVS and
fix the rejects caused by the newer SQLDA
and DESCRIBE patches. Note that it's still
compat-mode only, I will send a modified patch
in the next email that is ECPG-wide, so it can be
decided if the feature is wanted in native mode or not.

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

Attachments:

4-pg85-outofscopedeclare-8-ctxdiff.patchtext/x-patch; name=4-pg85-outofscopedeclare-8-ctxdiff.patchDownload
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/descriptor.c pgsql.4/src/interfaces/ecpg/preproc/descriptor.c
*** pgsql.3/src/interfaces/ecpg/preproc/descriptor.c	2009-12-14 12:41:24.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/preproc/descriptor.c	2009-12-14 14:17:39.000000000 +0100
*************** struct variable *
*** 317,323 ****
  descriptor_variable(const char *name, int input)
  {
  	static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN];
! 	static const struct ECPGtype descriptor_type = {ECPGt_descriptor, NULL, NULL, {NULL}, 0};
  	static const struct variable varspace[2] = {
  		{descriptor_names[0], (struct ECPGtype *) & descriptor_type, 0, NULL},
  		{descriptor_names[1], (struct ECPGtype *) & descriptor_type, 0, NULL}
--- 317,323 ----
  descriptor_variable(const char *name, int input)
  {
  	static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN];
! 	static const struct ECPGtype descriptor_type = {ECPGt_descriptor, NULL, NULL, NULL, {NULL}, 0};
  	static const struct variable varspace[2] = {
  		{descriptor_names[0], (struct ECPGtype *) & descriptor_type, 0, NULL},
  		{descriptor_names[1], (struct ECPGtype *) & descriptor_type, 0, NULL}
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/ecpg.addons pgsql.4/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.3/src/interfaces/ecpg/preproc/ecpg.addons	2009-12-14 12:41:24.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/preproc/ecpg.addons	2009-12-14 14:17:39.000000000 +0100
*************** ECPG: DeclareCursorStmtDECLAREcursor_nam
*** 309,319 ****
--- 309,322 ----
  
  		this->next = cur;
  		this->name = $2;
+ 		this->function = (current_function ? mm_strdup(current_function) : NULL);
  		this->connection = connection;
  		this->opened = false;
  		this->command =  cat_str(7, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for"), $7);
  		this->argsinsert = argsinsert;
+ 		this->argsinsert_oos = NULL;
  		this->argsresult = argsresult;
+ 		this->argsresult_oos = NULL;
  		argsinsert = argsresult = NULL;
  		cur = this;
  
*************** ECPG: DeclareCursorStmtDECLAREcursor_nam
*** 330,339 ****
  		{
  			if (braces_open > 0) /* we're in a function */
  			{
! 				$$ = cat_str(4, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), make_str("ECPG_informix_reset_sqlca();"), comment);
  			}
  			else
! 				$$ = cat_str(3, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), comment);
  		}
  		else
  			$$ = comment;
--- 333,342 ----
  		{
  			if (braces_open > 0) /* we're in a function */
  			{
! 				$$ = cat_str(4, adjust_informix(this, true), adjust_informix(this, false), make_str("ECPG_informix_reset_sqlca();"), comment);
  			}
  			else
! 				$$ = cat_str(3, adjust_informix(this, true), adjust_informix(this, false), comment);
  		}
  		else
  			$$ = comment;
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/ecpg.header pgsql.4/src/interfaces/ecpg/preproc/ecpg.header
*** pgsql.3/src/interfaces/ecpg/preproc/ecpg.header	2009-11-06 11:06:24.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/preproc/ecpg.header	2009-12-14 14:17:39.000000000 +0100
***************
*** 33,38 ****
--- 33,39 ----
   */
  int struct_level = 0;
  int braces_open; /* brace level counter */
+ char *current_function;
  int ecpg_informix_var = 0;
  char	*connection = NULL;
  char	*input_filename = NULL;
*************** static char *ECPGstruct_sizeof = NULL;
*** 53,62 ****
  /* for forward declarations we have to store some data as well */
  static char *forward_name = NULL;
  
! struct ECPGtype ecpg_no_indicator = {ECPGt_NO_INDICATOR, NULL, NULL, {NULL}, 0};
  struct variable no_indicator = {"no_indicator", &ecpg_no_indicator, 0, NULL};
  
! struct ECPGtype ecpg_query = {ECPGt_char_variable, NULL, NULL, {NULL}, 0};
  
  /*
   * Handle parsing errors and warnings
--- 54,63 ----
  /* for forward declarations we have to store some data as well */
  static char *forward_name = NULL;
  
! struct ECPGtype ecpg_no_indicator = {ECPGt_NO_INDICATOR, NULL, NULL, NULL, {NULL}, 0};
  struct variable no_indicator = {"no_indicator", &ecpg_no_indicator, 0, NULL};
  
! struct ECPGtype ecpg_query = {ECPGt_char_variable, NULL, NULL, NULL, {NULL}, 0};
  
  /*
   * Handle parsing errors and warnings
*************** create_questionmarks(char *name, bool ar
*** 226,232 ****
  }
  
  static char *
! adjust_informix(struct arguments *list)
  {
  	/* Informix accepts DECLARE with variables that are out of scope when OPEN is called.
   	 * for instance you can declare variables in a function, and then subsequently use them
--- 227,233 ----
  }
  
  static char *
! adjust_informix(struct cursor *cur, bool insert)
  {
  	/* Informix accepts DECLARE with variables that are out of scope when OPEN is called.
   	 * for instance you can declare variables in a function, and then subsequently use them
*************** adjust_informix(struct arguments *list)
*** 240,301 ****
  	 * We have to change the variables to our own struct and just store the pointer instead of the variable
  	 */
  
  	 struct arguments *ptr;
  	 char *result = make_str("");
  
  	 for (ptr = list; ptr != NULL; ptr = ptr->next)
  	 {
  	 	char temp[20]; /* this should be sufficient unless you have 8 byte integers */
  		char *original_var;
  
  	 	/* change variable name to "ECPG_informix_get_var(<counter>)" */
  		original_var = ptr->variable->name;
  		sprintf(temp, "%d))", ecpg_informix_var);
  
! 		if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char && ptr->variable->type->type != ECPGt_unsigned_char && ptr->variable->type->type != ECPGt_string) && atoi(ptr->variable->type->size) > 1)
  		{
! 			ptr->variable = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, make_str("1"), ptr->variable->type->u.element->lineno), ptr->variable->type->size), 0);
  			sprintf(temp, "%d, (", ecpg_informix_var++);
  		}
  		else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char || ptr->variable->type->type == ECPGt_unsigned_char || ptr->variable->type->type == ECPGt_string) && atoi(ptr->variable->type->size) > 1)
  		{
! 			ptr->variable = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->lineno), 0);
! 			sprintf(temp, "%d, (", ecpg_informix_var++);
  		}
  		else
  		{
! 			ptr->variable = new_variable(cat_str(4, make_str("*("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->lineno), 0);
  			sprintf(temp, "%d, &(", ecpg_informix_var++);
  		}
  
  		/* create call to "ECPG_informix_set_var(<counter>, <pointer>. <linen number>)" */
! 		result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var), make_str("), __LINE__);\n"));
  
  		/* now the indicator if there is one */
! 		if (ptr->indicator->type->type != ECPGt_NO_INDICATOR)
  		{
  			/* change variable name to "ECPG_informix_get_var(<counter>)" */
  			original_var = ptr->indicator->name;
  			sprintf(temp, "%d))", ecpg_informix_var);
  
  			/* create call to "ECPG_informix_set_var(<counter>, <pointer>. <linen number>)" */
! 			if (atoi(ptr->indicator->type->size) > 1)
  			{
! 				ptr->indicator = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->lineno), 0);
  				sprintf(temp, "%d, (", ecpg_informix_var++);
  			}
  			else
  			{
! 				ptr->indicator = new_variable(cat_str(4, make_str("*("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->lineno), 0);
  				sprintf(temp, "%d, &(", ecpg_informix_var++);
  			}
  			result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var), make_str("), __LINE__);\n"));
  		}
  	 }
  
  	 return result;
  }
  
  static struct cursor *
  add_additional_variables(char *name, bool insert)
  {
--- 241,379 ----
  	 * We have to change the variables to our own struct and just store the pointer instead of the variable
  	 */
  
+ 	 struct arguments *list;
  	 struct arguments *ptr;
+ 	 struct arguments *newlist = NULL;
+ 	 struct variable *newvar, *newind;
  	 char *result = make_str("");
  
+ 	 list = (insert ? cur->argsinsert : cur->argsresult);
+ 
  	 for (ptr = list; ptr != NULL; ptr = ptr->next)
  	 {
  	 	char temp[20]; /* this should be sufficient unless you have 8 byte integers */
  		char *original_var;
+ 		bool skip_set_var = false;
  
  	 	/* change variable name to "ECPG_informix_get_var(<counter>)" */
  		original_var = ptr->variable->name;
  		sprintf(temp, "%d))", ecpg_informix_var);
  
! 		/* Don't emit ECPGinformix_set_var() calls for global variables */
! 		if (ptr->variable->brace_level == 0)
  		{
! 			newvar = ptr->variable;
! 			skip_set_var = true;
! 		}
! 		else if ((ptr->variable->type->type == ECPGt_char_variable) && (!strncmp(ptr->variable->name, "ECPGprepared_statement", strlen("ECPGprepared_statement"))))
! 		{
! 			newvar = ptr->variable;
! 			skip_set_var = true;
! 		}
! 		else if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char && ptr->variable->type->type != ECPGt_unsigned_char && ptr->variable->type->type != ECPGt_string) && atoi(ptr->variable->type->size) > 1)
! 		{
! 			newvar = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, make_str("1"), ptr->variable->type->u.element->lineno), ptr->variable->type->size), 0);
  			sprintf(temp, "%d, (", ecpg_informix_var++);
  		}
  		else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char || ptr->variable->type->type == ECPGt_unsigned_char || ptr->variable->type->type == ECPGt_string) && atoi(ptr->variable->type->size) > 1)
  		{
! 			newvar = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->lineno), 0);
! 			if (ptr->variable->type->type == ECPGt_varchar)
! 				sprintf(temp, "%d, &(", ecpg_informix_var++);
! 			else
! 				sprintf(temp, "%d, (", ecpg_informix_var++);
! 		}
! 		else if (ptr->variable->type->type == ECPGt_struct || ptr->variable->type->type == ECPGt_union)
! 		{
! 			sprintf(temp, "%d)))", ecpg_informix_var);
! 			newvar = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->variable->type->type_name), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->variable->type->u.members, ptr->variable->type->type, ptr->variable->type->type_name, ptr->variable->type->struct_sizeof), 0);
! 			sprintf(temp, "%d, &(", ecpg_informix_var++);
! 		}
! 		else if (ptr->variable->type->type == ECPGt_array)
! 		{
! 			if (ptr->variable->type->u.element->type == ECPGt_struct || ptr->variable->type->u.element->type == ECPGt_union)
! 			{
! 				sprintf(temp, "%d)))", ecpg_informix_var);
! 				newvar = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->variable->type->u.element->type_name), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->variable->type->u.element->u.members, ptr->variable->type->u.element->type, ptr->variable->type->u.element->type_name, ptr->variable->type->u.element->struct_sizeof), 0);
! 				sprintf(temp, "%d, (", ecpg_informix_var++);
! 			}
! 			else
! 			{
! 				newvar = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, ptr->variable->type->u.element->size, ptr->variable->type->u.element->lineno), ptr->variable->type->size), 0);
! 				sprintf(temp, "%d, &(", ecpg_informix_var++);
! 			}
  		}
  		else
  		{
! 			newvar = new_variable(cat_str(4, make_str("*("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->lineno), 0);
  			sprintf(temp, "%d, &(", ecpg_informix_var++);
  		}
  
  		/* create call to "ECPG_informix_set_var(<counter>, <pointer>. <linen number>)" */
! 		if (!skip_set_var)
! 			result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var), make_str("), __LINE__);\n"));
  
  		/* now the indicator if there is one */
! 		if ((ptr->indicator->type->type == ECPGt_NO_INDICATOR) || (ptr->indicator->brace_level == 0))
! 		{
! 			newind = ptr->indicator;
! 		}
! 		else
  		{
  			/* change variable name to "ECPG_informix_get_var(<counter>)" */
  			original_var = ptr->indicator->name;
  			sprintf(temp, "%d))", ecpg_informix_var);
  
  			/* create call to "ECPG_informix_set_var(<counter>, <pointer>. <linen number>)" */
! 			if (ptr->indicator->type->type == ECPGt_struct || ptr->indicator->type->type == ECPGt_union)
  			{
! 				sprintf(temp, "%d)))", ecpg_informix_var);
! 				newind = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->indicator->type->type_name), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->indicator->type->u.members, ptr->indicator->type->type, ptr->indicator->type->type_name, ptr->indicator->type->struct_sizeof), 0);
! 				sprintf(temp, "%d, &(", ecpg_informix_var++);
! 			}
! 			else if (ptr->indicator->type->type == ECPGt_array)
! 			{
! 				if (ptr->indicator->type->u.element->type == ECPGt_struct || ptr->indicator->type->u.element->type == ECPGt_union)
! 				{
! 					sprintf(temp, "%d)))", ecpg_informix_var);
! 					newind = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->indicator->type->u.element->type_name), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->indicator->type->u.element->u.members, ptr->indicator->type->u.element->type, ptr->indicator->type->u.element->type_name, ptr->indicator->type->u.element->struct_sizeof), 0);
! 					sprintf(temp, "%d, (", ecpg_informix_var++);
! 				}
! 				else
! 				{
! 					newind = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->indicator->type->u.element->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->indicator->type->u.element->type, ptr->indicator->type->u.element->size, ptr->indicator->type->u.element->lineno), ptr->indicator->type->size), 0);
! 					sprintf(temp, "%d, &(", ecpg_informix_var++);
! 				}
! 			}
! 			else if (atoi(ptr->indicator->type->size) > 1)
! 			{
! 				newind = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->lineno), 0);
  				sprintf(temp, "%d, (", ecpg_informix_var++);
  			}
  			else
  			{
! 				newind = new_variable(cat_str(4, make_str("*("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->lineno), 0);
  				sprintf(temp, "%d, &(", ecpg_informix_var++);
  			}
  			result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var), make_str("), __LINE__);\n"));
  		}
+ 
+ 		add_variable_to_tail(&newlist, newvar, newind);
  	 }
  
+ 	 if (insert)
+ 		cur->argsinsert_oos = newlist;
+ 	 else
+ 		cur->argsresult_oos = newlist;
+ 
  	 return result;
  }
  
+ /* This tests whether the cursor was declared and opened in the same function. */
+ #define SAMEFUNC(cur)	\
+ 	((cur->function == NULL) ||		\
+ 	 (cur->function != NULL && !strcmp(cur->function, current_function)))
+ 
  static struct cursor *
  add_additional_variables(char *name, bool insert)
  {
*************** add_additional_variables(char *name, boo
*** 318,329 ****
  	{
  		/* add all those input variables that were given earlier
  		 * note that we have to append here but have to keep the existing order */
! 		for (p = ptr->argsinsert; p; p = p->next)
  			add_variable_to_tail(&argsinsert, p->variable, p->indicator);
  	}
  
  	/* add all those output variables that were given earlier */
! 	for (p = ptr->argsresult; p; p = p->next)
  		add_variable_to_tail(&argsresult, p->variable, p->indicator);
  
  	return ptr;
--- 396,407 ----
  	{
  		/* add all those input variables that were given earlier
  		 * note that we have to append here but have to keep the existing order */
! 		for (p = ((!INFORMIX_MODE || SAMEFUNC(ptr)) ? ptr->argsinsert : ptr->argsinsert_oos); p; p = p->next)
  			add_variable_to_tail(&argsinsert, p->variable, p->indicator);
  	}
  
  	/* add all those output variables that were given earlier */
! 	for (p = ((!INFORMIX_MODE || SAMEFUNC(ptr)) ? ptr->argsresult : ptr->argsresult_oos); p; p = p->next)
  		add_variable_to_tail(&argsresult, p->variable, p->indicator);
  
  	return ptr;
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/ecpg.trailer pgsql.4/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.3/src/interfaces/ecpg/preproc/ecpg.trailer	2009-12-14 12:45:12.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/preproc/ecpg.trailer	2009-12-14 14:17:39.000000000 +0100
*************** statement: ecpgstart at stmt ';'        
*** 16,22 ****
                  | c_thing               { fprintf(yyout, "%s", $1); free($1); }
                  | CPP_LINE              { fprintf(yyout, "%s", $1); free($1); }
                  | '{'                   { braces_open++; fputs("{", yyout); }
!                 | '}'                   { remove_typedefs(braces_open); remove_variables(braces_open--); fputs("}", yyout); }
                  ;
  
  CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
--- 16,32 ----
                  | c_thing               { fprintf(yyout, "%s", $1); free($1); }
                  | CPP_LINE              { fprintf(yyout, "%s", $1); free($1); }
                  | '{'                   { braces_open++; fputs("{", yyout); }
!                 | '}'
! 		{
! 			remove_typedefs(braces_open);
! 			remove_variables(braces_open--);
! 			if (braces_open == 0)
! 			{
! 				free(current_function);
! 				current_function = NULL;
! 			}
! 			fputs("}", yyout);
! 		}
                  ;
  
  CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 281,286 ****
--- 291,297 ----
  			char *cursor_marker = $2[0] == ':' ? make_str("$0") : mm_strdup($2);
  			struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable));
  			const char *con = connection ? connection : "NULL";
+ 			char *comment;
  
  			for (ptr = cur; ptr != NULL; ptr = ptr->next)
  			{
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 294,302 ****
--- 305,315 ----
  			/* initial definition */
  			this->next = cur;
  			this->name = $2;
+ 			this->function = (current_function ? mm_strdup(current_function) : NULL);
  			this->connection = connection;
  			this->command =  cat_str(6, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for $1"));
  			this->argsresult = NULL;
+ 			this->argsresult_oos = NULL;
  
  			thisquery->type = &ecpg_query;
  			thisquery->brace_level = 0;
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 305,310 ****
--- 318,324 ----
  			sprintf(thisquery->name, "ECPGprepared_statement(%s, %s, __LINE__)", con, $7);
  
  			this->argsinsert = NULL;
+ 			this->argsinsert_oos = NULL;
  			if ($2[0] == ':')
  			{
  				struct variable *var = find_variable($2 + 1);
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 315,324 ****
  
  			cur = this;
  
! 			if (INFORMIX_MODE && braces_open > 0) /* we're in a function */
! 				$$ = cat_str(4, make_str("ECPG_informix_reset_sqlca();"), make_str("/*"), mm_strdup(this->command), make_str("*/"));
  			else
! 				$$ = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/"));
  		}
  		;
  
--- 329,345 ----
  
  			cur = this;
  
! 			comment = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/"));
! 
! 			if (INFORMIX_MODE)
! 			{
! 				if (braces_open > 0) /* we're in a function */
! 					$$ = cat_str(4, adjust_informix(this, true), adjust_informix(this, false), make_str("ECPG_informix_reset_sqlca();"), comment);
! 				else
! 					$$ = cat_str(3, adjust_informix(this, true), adjust_informix(this, false), comment);
! 			}
  			else
! 				$$ = comment;
  		}
  		;
  
*************** var_declaration: storage_declaration
*** 402,407 ****
--- 423,429 ----
  		var_type
  		{
  			actual_type[struct_level].type_enum = $2.type_enum;
+ 			actual_type[struct_level].type_str = $2.type_str;
  			actual_type[struct_level].type_dimension = $2.type_dimension;
  			actual_type[struct_level].type_index = $2.type_index;
  			actual_type[struct_level].type_sizeof = $2.type_sizeof;
*************** var_declaration: storage_declaration
*** 415,420 ****
--- 437,443 ----
  		| var_type
  		{
  			actual_type[struct_level].type_enum = $1.type_enum;
+ 			actual_type[struct_level].type_str = $1.type_str;
  			actual_type[struct_level].type_dimension = $1.type_dimension;
  			actual_type[struct_level].type_index = $1.type_index;
  			actual_type[struct_level].type_sizeof = $1.type_sizeof;
*************** variable: opt_pointer ECPGColLabel opt_a
*** 826,834 ****
  				case ECPGt_struct:
  				case ECPGt_union:
  					if (atoi(dimension) < 0)
! 						type = ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_sizeof);
  					else
! 						type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_sizeof), dimension);
  
  					$$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
  					break;
--- 849,857 ----
  				case ECPGt_struct:
  				case ECPGt_union:
  					if (atoi(dimension) < 0)
! 						type = ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_str, actual_type[struct_level].type_sizeof);
  					else
! 						type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_str, actual_type[struct_level].type_sizeof), dimension);
  
  					$$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
  					break;
*************** ECPGVar: SQL_VAR
*** 1307,1315 ****
  					case ECPGt_struct:
  					case ECPGt_union:
  						if (atoi(dimension) < 0)
! 							type = ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_sizeof);
  						else
! 							type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum,$5.type_sizeof), dimension);
  						break;
  
  					case ECPGt_varchar:
--- 1330,1338 ----
  					case ECPGt_struct:
  					case ECPGt_union:
  						if (atoi(dimension) < 0)
! 							type = ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_str, $5.type_sizeof);
  						else
! 							type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_str, $5.type_sizeof), dimension);
  						break;
  
  					case ECPGt_varchar:
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/extern.h pgsql.4/src/interfaces/ecpg/preproc/extern.h
*** pgsql.3/src/interfaces/ecpg/preproc/extern.h	2009-12-14 12:41:24.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/preproc/extern.h	2009-12-14 14:17:39.000000000 +0100
*************** extern int	braces_open,
*** 29,34 ****
--- 29,35 ----
  			ecpg_informix_var,
  			regression_mode,
  			auto_prepare;
+ extern char *current_function;
  extern char *descriptor_index;
  extern char *descriptor_name;
  extern char *connection;
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/pgc.l pgsql.4/src/interfaces/ecpg/preproc/pgc.l
*** pgsql.3/src/interfaces/ecpg/preproc/pgc.l	2009-09-18 08:26:55.000000000 +0200
--- pgsql.4/src/interfaces/ecpg/preproc/pgc.l	2009-12-14 14:17:39.000000000 +0100
*************** static char    *literalbuf = NULL;		/* e
*** 41,46 ****
--- 41,49 ----
  static int		literallen;				/* actual current length */
  static int		literalalloc;			/* current allocated buffer size */
  
+ /* Used for detecting global state together with braces_open */
+ static int		parenths_open;
+ 
  #define startlit()	(literalbuf[0] = '\0', literallen = 0)
  static void addlit(char *ytext, int yleng);
  static void addlitchar (unsigned char);
*************** cppline			{space}*#(.*\\{space})*.*{newl
*** 788,794 ****
  					}
  <C>{identifier} 	{
  						const ScanKeyword		*keyword;
! 							
  						/* Informix uses SQL defines only in SQL space */
  						/* however, some defines have to be taken care of for compatibility */
  						if ((!INFORMIX_MODE || !isinformixdefine()) && !isdefine())
--- 791,807 ----
  					}
  <C>{identifier} 	{
  						const ScanKeyword		*keyword;
! 
! 						/*
! 						 * Try to detect a function name:
! 						 * look for identifiers at the global scope
! 						 * keep the last identifier before the first '(' and '{' */
! 						if (braces_open == 0 && parenths_open == 0)
! 						{
! 							if (current_function)
! 								free(current_function);
! 							current_function = mm_strdup(yytext);
! 						}
  						/* Informix uses SQL defines only in SQL space */
  						/* however, some defines have to be taken care of for compatibility */
  						if ((!INFORMIX_MODE || !isinformixdefine()) && !isdefine())
*************** cppline			{space}*#(.*\\{space})*.*{newl
*** 811,818 ****
  <C>"/"				{ return('/'); }
  <C>"+"				{ return('+'); }
  <C>"-"				{ return('-'); }
! <C>"("				{ return('('); }
! <C>")"				{ return(')'); }
  <C,xskip>{space}		{ ECHO; }
  <C>\{				{ return('{'); }
  <C>\}				{ return('}'); }
--- 824,831 ----
  <C>"/"				{ return('/'); }
  <C>"+"				{ return('+'); }
  <C>"-"				{ return('-'); }
! <C>"("				{ parenths_open++; return('('); }
! <C>")"				{ parenths_open--; return(')'); }
  <C,xskip>{space}		{ ECHO; }
  <C>\{				{ return('{'); }
  <C>\}				{ return('}'); }
*************** void
*** 1178,1183 ****
--- 1191,1198 ----
  lex_init(void)
  {
  	braces_open = 0;
+ 	parenths_open = 0;
+ 	current_function = NULL;
  
  	preproc_tos = 0;
  	yylineno = 1;
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/type.c pgsql.4/src/interfaces/ecpg/preproc/type.c
*** pgsql.3/src/interfaces/ecpg/preproc/type.c	2009-12-14 12:41:24.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/preproc/type.c	2009-12-14 14:17:39.000000000 +0100
*************** ECPGstruct_member_dup(struct ECPGstruct_
*** 46,52 ****
  		{
  			case ECPGt_struct:
  			case ECPGt_union:
! 				type = ECPGmake_struct_type(rm->type->u.members, rm->type->type, rm->type->struct_sizeof);
  				break;
  			case ECPGt_array:
  
--- 46,52 ----
  		{
  			case ECPGt_struct:
  			case ECPGt_union:
! 				type = ECPGmake_struct_type(rm->type->u.members, rm->type->type, rm->type->type_name, rm->type->struct_sizeof);
  				break;
  			case ECPGt_array:
  
*************** ECPGstruct_member_dup(struct ECPGstruct_
*** 55,61 ****
  				 * create the struct too
  				 */
  				if (rm->type->u.element->type == ECPGt_struct)
! 					type = ECPGmake_struct_type(rm->type->u.element->u.members, rm->type->u.element->type, rm->type->u.element->struct_sizeof);
  				else
  					type = ECPGmake_array_type(ECPGmake_simple_type(rm->type->u.element->type, rm->type->u.element->size, rm->type->u.element->lineno), rm->type->size);
  				break;
--- 55,61 ----
  				 * create the struct too
  				 */
  				if (rm->type->u.element->type == ECPGt_struct)
! 					type = ECPGmake_struct_type(rm->type->u.element->u.members, rm->type->u.element->type, rm->type->u.element->type_name, rm->type->u.element->struct_sizeof);
  				else
  					type = ECPGmake_array_type(ECPGmake_simple_type(rm->type->u.element->type, rm->type->u.element->size, rm->type->u.element->lineno), rm->type->size);
  				break;
*************** ECPGmake_simple_type(enum ECPGttype type
*** 98,103 ****
--- 98,104 ----
  	struct ECPGtype *ne = (struct ECPGtype *) mm_alloc(sizeof(struct ECPGtype));
  
  	ne->type = type;
+ 	ne->type_name = NULL;
  	ne->size = size;
  	ne->u.element = NULL;
  	ne->struct_sizeof = NULL;
*************** ECPGmake_array_type(struct ECPGtype * ty
*** 117,126 ****
  }
  
  struct ECPGtype *
! ECPGmake_struct_type(struct ECPGstruct_member * rm, enum ECPGttype type, char *struct_sizeof)
  {
  	struct ECPGtype *ne = ECPGmake_simple_type(type, make_str("1"), 0);
  
  	ne->u.members = ECPGstruct_member_dup(rm);
  	ne->struct_sizeof = struct_sizeof;
  
--- 118,128 ----
  }
  
  struct ECPGtype *
! ECPGmake_struct_type(struct ECPGstruct_member * rm, enum ECPGttype type, char *type_name, char *struct_sizeof)
  {
  	struct ECPGtype *ne = ECPGmake_simple_type(type, make_str("1"), 0);
  
+ 	ne->type_name = mm_strdup(type_name);
  	ne->u.members = ECPGstruct_member_dup(rm);
  	ne->struct_sizeof = struct_sizeof;
  
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/type.h pgsql.4/src/interfaces/ecpg/preproc/type.h
*** pgsql.3/src/interfaces/ecpg/preproc/type.h	2009-06-13 18:25:05.000000000 +0200
--- pgsql.4/src/interfaces/ecpg/preproc/type.h	2009-12-14 14:17:39.000000000 +0100
*************** struct ECPGstruct_member
*** 17,22 ****
--- 17,23 ----
  struct ECPGtype
  {
  	enum ECPGttype type;
+ 	char	   *type_name;			/* For struct and union types it is the struct name */
  	char	   *size;			/* For array it is the number of elements. For
  								 * varchar it is the maxsize of the area. */
  	char	   *struct_sizeof;	/* For a struct this is the sizeof() type as
*************** void		ECPGmake_struct_member(char *, str
*** 36,42 ****
  struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, char *, int);
  struct ECPGtype *ECPGmake_varchar_type(enum ECPGttype, long);
  struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, char *);
! struct ECPGtype *ECPGmake_struct_type(struct ECPGstruct_member *, enum ECPGttype, char *);
  struct ECPGstruct_member *ECPGstruct_member_dup(struct ECPGstruct_member *);
  
  /* Frees a type. */
--- 37,43 ----
  struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, char *, int);
  struct ECPGtype *ECPGmake_varchar_type(enum ECPGttype, long);
  struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, char *);
! struct ECPGtype *ECPGmake_struct_type(struct ECPGstruct_member *, enum ECPGttype, char *, char *);
  struct ECPGstruct_member *ECPGstruct_member_dup(struct ECPGstruct_member *);
  
  /* Frees a type. */
*************** struct _include_path
*** 123,133 ****
--- 124,137 ----
  struct cursor
  {
  	char	   *name;
+ 	char	   *function;
  	char	   *command;
  	char	   *connection;
  	bool		opened;
  	struct arguments *argsinsert;
+ 	struct arguments *argsinsert_oos;
  	struct arguments *argsresult;
+ 	struct arguments *argsresult_oos;
  	struct cursor *next;
  };
  
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/variable.c pgsql.4/src/interfaces/ecpg/preproc/variable.c
*** pgsql.3/src/interfaces/ecpg/preproc/variable.c	2009-11-26 18:57:00.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/preproc/variable.c	2009-12-14 14:17:39.000000000 +0100
*************** find_struct_member(char *name, char *str
*** 47,53 ****
  						return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->type, members->type->u.element->size, members->type->u.element->lineno), members->type->size), brace_level));
  					case ECPGt_struct:
  					case ECPGt_union:
! 						return (new_variable(name, ECPGmake_struct_type(members->type->u.members, members->type->type, members->type->struct_sizeof), brace_level));
  					default:
  						return (new_variable(name, ECPGmake_simple_type(members->type->type, members->type->size, members->type->lineno), brace_level));
  				}
--- 47,53 ----
  						return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->type, members->type->u.element->size, members->type->u.element->lineno), members->type->size), brace_level));
  					case ECPGt_struct:
  					case ECPGt_union:
! 						return (new_variable(name, ECPGmake_struct_type(members->type->u.members, members->type->type, members->type->type_name, members->type->struct_sizeof), brace_level));
  					default:
  						return (new_variable(name, ECPGmake_simple_type(members->type->type, members->type->size, members->type->lineno), brace_level));
  				}
*************** find_struct_member(char *name, char *str
*** 94,100 ****
  								return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->u.element->type, members->type->u.element->u.element->size, members->type->u.element->u.element->lineno), members->type->u.element->size), brace_level));
  							case ECPGt_struct:
  							case ECPGt_union:
! 								return (new_variable(name, ECPGmake_struct_type(members->type->u.element->u.members, members->type->u.element->type, members->type->u.element->struct_sizeof), brace_level));
  							default:
  								return (new_variable(name, ECPGmake_simple_type(members->type->u.element->type, members->type->u.element->size, members->type->u.element->lineno), brace_level));
  						}
--- 94,100 ----
  								return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->u.element->type, members->type->u.element->u.element->size, members->type->u.element->u.element->lineno), members->type->u.element->size), brace_level));
  							case ECPGt_struct:
  							case ECPGt_union:
! 								return (new_variable(name, ECPGmake_struct_type(members->type->u.element->u.members, members->type->u.element->type, members->type->u.element->type_name, members->type->u.element->struct_sizeof), brace_level));
  							default:
  								return (new_variable(name, ECPGmake_simple_type(members->type->u.element->type, members->type->u.element->size, members->type->u.element->lineno), brace_level));
  						}
*************** find_variable(char *name)
*** 235,241 ****
  						return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(p->type->u.element->u.element->type, p->type->u.element->u.element->size, p->type->u.element->u.element->lineno), p->type->u.element->size), p->brace_level));
  					case ECPGt_struct:
  					case ECPGt_union:
! 						return (new_variable(name, ECPGmake_struct_type(p->type->u.element->u.members, p->type->u.element->type, p->type->u.element->struct_sizeof), p->brace_level));
  					default:
  						return (new_variable(name, ECPGmake_simple_type(p->type->u.element->type, p->type->u.element->size, p->type->u.element->lineno), p->brace_level));
  				}
--- 235,241 ----
  						return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(p->type->u.element->u.element->type, p->type->u.element->u.element->size, p->type->u.element->u.element->lineno), p->type->u.element->size), p->brace_level));
  					case ECPGt_struct:
  					case ECPGt_union:
! 						return (new_variable(name, ECPGmake_struct_type(p->type->u.element->u.members, p->type->u.element->type, p->type->u.element->type_name, p->type->u.element->struct_sizeof), p->brace_level));
  					default:
  						return (new_variable(name, ECPGmake_simple_type(p->type->u.element->type, p->type->u.element->size, p->type->u.element->lineno), p->brace_level));
  				}
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/compat_informix/Makefile pgsql.4/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.3/src/interfaces/ecpg/test/compat_informix/Makefile	2009-12-14 14:01:34.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/compat_informix/Makefile	2009-12-14 14:27:20.000000000 +0100
*************** TESTS = test_informix test_informix.c \
*** 18,23 ****
--- 18,25 ----
          rnull rnull.c \
          sqlda sqlda.c \
          describe describe.c \
+         struct struct.c \
+         outofscope outofscope.c \
          charfuncs charfuncs.c
  
  all: $(TESTS)
*************** test_informix2.c: test_informix2.pgc ../
*** 31,36 ****
--- 33,44 ----
  sqlda.c: sqlda.pgc ../regression.h
  	$(ECPG) -o $@ -I$(srcdir) $<
  
+ struct.c: struct.pgc ../regression.h
+ 	$(ECPG) -o $@ -I$(srcdir) $<
+ 
+ outofscope.c: outofscope.pgc ../regression.h
+ 	$(ECPG) -o $@ -I$(srcdir) $<
+ 
  dec_test.c: dec_test.pgc ../regression.h
  	$(ECPG) -o $@ -I$(srcdir) $<
  
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/compat_informix/outofscope.pgc pgsql.4/src/interfaces/ecpg/test/compat_informix/outofscope.pgc
*** pgsql.3/src/interfaces/ecpg/test/compat_informix/outofscope.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/compat_informix/outofscope.pgc	2009-12-14 14:27:46.000000000 +0100
***************
*** 0 ****
--- 1,252 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql include sqlda.h;
+ exec sql include sqltypes.h;
+ 
+ exec sql begin declare section;
+ exec sql include struct.h;
+ exec sql end declare section;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ /* Functions for test 1 */
+ 
+ static void
+ get_var1(MYTYPE **myvar0, MYNULLTYPE **mynullvar0)
+ {
+ 	exec sql begin declare section;
+ 	MYTYPE		*myvar = malloc(sizeof(MYTYPE));
+ 	MYNULLTYPE	*mynullvar = malloc(sizeof(MYNULLTYPE));
+ 	exec sql end declare section;
+ 
+ 	/* Test DECLARE ... SELECT ... INTO with pointers */
+ 
+ 	exec sql declare mycur cursor for select * INTO :myvar :mynullvar from a1;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ 
+ 	*myvar0 = myvar;
+ 	*mynullvar0 = mynullvar;
+ }
+ 
+ static void
+ open_cur1(void)
+ {
+ 	exec sql open mycur;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ get_record1(void)
+ {
+ 	exec sql fetch mycur;
+ 
+ 	if (sqlca.sqlcode != 0 && sqlca.sqlcode != SQLNOTFOUND)
+ 		exit(1);
+ }
+ 
+ static void
+ close_cur1(void)
+ {
+ 	exec sql close mycur;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ /* Functions for test 2 */
+ 
+ pg_sqlda_t	*inp_sqlda, *outp_sqlda;
+ 
+ exec sql begin declare section;
+ char	*stmt2 = "SELECT * FROM a1 WHERE id = ?";
+ char	*curname2 = "mycur";
+ int	id;
+ exec sql end declare section;
+ 
+ static void
+ prepare2(void)
+ {
+ 	exec sql prepare prepared_stmt from :stmt2;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ 
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 	id = 4;
+ }
+ 
+ static void
+ declare2(void)
+ {
+ 	exec sql declare :curname2 cursor for prepared_stmt;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ dealloc_prep2(void)
+ {
+ 	exec sql deallocate prepare prepared_stmt;
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ }
+ 
+ static void
+ open_cur2(void)
+ {
+ 	exec sql open :curname2 using descriptor inp_sqlda;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ close_cur2(void)
+ {
+ 	exec sql close :curname2;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ get_record2(void)
+ {
+ 	exec sql fetch :curname2 into descriptor outp_sqlda;
+ 
+ 	if (sqlca.sqlcode != 0 && sqlca.sqlcode != SQLNOTFOUND)
+ 		exit(1);
+ }
+ 
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (outp_sqlda->sqlvar[i].sqlind && *(outp_sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", outp_sqlda->sqlvar[i].sqlname);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case SQLCHAR:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLINT:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLINT8:
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLFLOAT: 
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLDECIMAL:
+ 			{
+ 				char	val[64];
+ 				dectoasc((dec_t *)sqlda->sqlvar[i].sqldata, val, 64, -1);
+ 				printf("name sqlda descriptor: '%s' value DECIMAL '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ 	MYTYPE		*myvar;
+ 	MYNULLTYPE	*mynullvar;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table a1(id serial primary key, t text, d1 numeric, d2 float8, c character(10));
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, 'a', 1.0, 2, 'a');
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, null, null, null, null);
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, '"a"', -1.0, 'nan'::float8, 'a');
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, 'b', 2.0, 3, 'b');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE */
+ 
+ 	get_var1(&myvar, &mynullvar);
+ 	open_cur1();
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	while (1)
+ 	{
+ 		memset(myvar, 0, sizeof(MYTYPE));
+ 		get_record1();
+ 		if (sqlca.sqlcode == SQLNOTFOUND)
+ 			break;
+ 		printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+ 			myvar->id, mynullvar->id ? " (NULL)" : "",
+ 			myvar->t, mynullvar->t ? " (NULL)" : "",
+ 			myvar->d1, mynullvar->d1 ? " (NULL)" : "",
+ 			myvar->d2, mynullvar->d2 ? " (NULL)" : "",
+ 			myvar->c, mynullvar->c ? " (NULL)" : "");
+ 	}
+ 
+ 	close_cur1();
+ 
+ 	/* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE interaction
+ 	 * with a dynamic cursor and prepared statment using an sqlda
+ 	 */
+ 
+ 	prepare2();
+ 	declare2();
+ 	open_cur2();
+ 
+ 	get_record2();
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	close_cur2();
+ 	dealloc_prep2();
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table a1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/compat_informix/struct.h pgsql.4/src/interfaces/ecpg/test/compat_informix/struct.h
*** pgsql.3/src/interfaces/ecpg/test/compat_informix/struct.h	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/compat_informix/struct.h	2009-12-14 14:17:39.000000000 +0100
***************
*** 0 ****
--- 1,18 ----
+ 
+ struct mytype {
+ 	int	id;
+ 	char	t[64];
+ 	double	d1; /* dec_t */
+ 	double	d2;
+ 	char	c[30];
+ };
+ typedef struct mytype MYTYPE;
+ 
+ struct mynulltype {
+ 	int	id;
+ 	int	t;
+ 	int	d1;
+ 	int	d2;
+ 	int	c;
+ };
+ typedef struct mynulltype MYNULLTYPE;
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/compat_informix/struct.pgc pgsql.4/src/interfaces/ecpg/test/compat_informix/struct.pgc
*** pgsql.3/src/interfaces/ecpg/test/compat_informix/struct.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/compat_informix/struct.pgc	2009-12-14 14:17:39.000000000 +0100
***************
*** 0 ****
--- 1,76 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql begin declare section;
+ exec sql include struct.h;
+ exec sql end declare section;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ int
+ main (void)
+ {
+ 	exec sql begin declare section;
+ 	MYTYPE		myvar;
+ 	MYNULLTYPE	mynullvar;
+ 	exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table a1(id serial primary key, t text, d1 numeric, d2 float8, c character(10));
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, 'a', 1.0, 2, 'a');
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, null, null, null, null);
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, '"a"', -1.0, 'nan'::float8, 'a');
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, 'b', 2.0, 3, 'b');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* Test DECLARE ... SELECT ... INTO with struct type */
+ 
+ 	exec sql declare mycur cursor for select * into :myvar :mynullvar from a1;
+ 	exec sql open mycur;
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	while (1)
+ 	{
+ 		memset(&myvar, 0, sizeof(myvar));
+ 		exec sql fetch mycur;
+ 		printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+ 			myvar.id, mynullvar.id ? " (NULL)" : "",
+ 			myvar.t, mynullvar.t ? " (NULL)" : "",
+ 			myvar.d1, mynullvar.d1 ? " (NULL)" : "",
+ 			myvar.d2, mynullvar.d2 ? " (NULL)" : "",
+ 			myvar.c, mynullvar.c ? " (NULL)" : "");
+ 	}
+ 
+ 	exec sql close mycur;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table a1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/ecpg_schedule pgsql.4/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.3/src/interfaces/ecpg/test/ecpg_schedule	2009-12-14 14:04:58.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/ecpg_schedule	2009-12-14 14:17:39.000000000 +0100
*************** test: compat_informix/rfmtlong
*** 5,10 ****
--- 5,12 ----
  test: compat_informix/rnull
  test: compat_informix/sqlda
  test: compat_informix/describe
+ test: compat_informix/struct
+ test: compat_informix/outofscope
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/ecpg_schedule_tcp pgsql.4/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.3/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-12-14 14:05:07.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-12-14 14:17:39.000000000 +0100
*************** test: compat_informix/rfmtlong
*** 5,10 ****
--- 5,12 ----
  test: compat_informix/rnull
  test: compat_informix/sqlda
  test: compat_informix/describe
+ test: compat_informix/struct
+ test: compat_informix/outofscope
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-outofscope.c pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-outofscope.c
*** pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-outofscope.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-outofscope.c	2009-12-14 14:30:47.000000000 +0100
***************
*** 0 ****
--- 1,605 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "outofscope.pgc"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 6 "outofscope.pgc"
+ 
+ 
+ 
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+ 
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+ 
+ #include "ecpglib.h"
+ 
+ typedef struct sqlvar_struct
+ {
+ 	short	sqltype;		/* variable type                */
+ 	int	sqllen;			/* length in bytes              */
+ 	char	   *sqldata;		/* pointer to data              */
+ 	short	   *sqlind;		/* pointer to indicator         */
+ 	char	   *sqlname;		/* variable name                */
+ 	char	   *sqlformat;		/* reserved for future use      */
+ 	short	sqlitype;		/* ind variable type            */
+ 	short	sqlilen;		/* ind length in bytes          */
+ 	char	   *sqlidata;		/* ind data pointer             */
+ 	int	sqlxid;			/* extended id type             */
+ 	char	   *sqltypename;	/* extended type name           */
+ 	short	sqltypelen;		/* length of extended type name */
+ 	short	sqlownerlen;		/* length of owner name         */
+ 	short	sqlsourcetype;		/* source type for distinct of built-ins */
+ 	char	   *sqlownername;	/* owner name                   */
+ 	int	sqlsourceid;		/* extended id of source type   */
+ 
+ 	/*
+ 	 * sqlilongdata is new.  It supports data that exceeds the 32k
+ 	 * limit.  sqlilen and sqlidata are for backward compatibility
+ 	 * and they have maximum value of <32K.
+ 	 */
+ 	char	   *sqlilongdata;	/* for data field beyond 32K    */
+ 	int	sqlflags;		/* for internal use only        */
+ 	void	   *sqlreserved;	/* reserved for future use      */
+ } pg_sqlvar_t;
+ 
+ typedef struct sqlda
+ {
+ 	short		sqld;
+ 	pg_sqlvar_t	   *sqlvar;
+ 	char		desc_name[19];	/* descriptor name              */
+ 	short		desc_occ;	/* size of sqlda structure      */
+ 	struct sqlda	   *desc_next;	/* pointer to next sqlda struct */
+ 	void		   *reserved;	/* reserved for future use */
+ } pg_sqlda_t;
+ 
+ #endif /* POSTGRES_SQLDA_H */
+ 
+ #line 8 "outofscope.pgc"
+ 
+ 
+ #line 1 "sqltypes.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqltypes.h,v 1.9 2009/06/11 14:49:13 momjian Exp $
+  */
+ #ifndef ECPG_SQLTYPES_H
+ #define ECPG_SQLTYPES_H
+ 
+ #include <limits.h>
+ 
+ #define CCHARTYPE	ECPGt_char
+ #define CSHORTTYPE	ECPGt_short
+ #define CINTTYPE	ECPGt_int
+ #define CLONGTYPE	ECPGt_long
+ #define CFLOATTYPE	ECPGt_float
+ #define CDOUBLETYPE ECPGt_double
+ #define CDECIMALTYPE	ECPGt_decimal
+ #define CFIXCHARTYPE	108
+ #define CSTRINGTYPE ECPGt_char
+ #define CDATETYPE	ECPGt_date
+ #define CMONEYTYPE	111
+ #define CDTIMETYPE	ECPGt_timestamp
+ #define CLOCATORTYPE	113
+ #define CVCHARTYPE	ECPGt_varchar
+ #define CINVTYPE	115
+ #define CFILETYPE	116
+ #define CINT8TYPE	ECPGt_long_long
+ #define CCOLLTYPE		118
+ #define CLVCHARTYPE		119
+ #define CFIXBINTYPE		120
+ #define CVARBINTYPE		121
+ #define CBOOLTYPE		ECPGt_bool
+ #define CROWTYPE		123
+ #define CLVCHARPTRTYPE	124
+ #define CTYPEMAX	25
+ 
+ /*
+  * Values used in sqlda->sqlvar[i]->sqltype
+  */
+ #define	SQLCHAR		ECPGt_char
+ #define	SQLSMINT	ECPGt_short
+ #define	SQLINT		ECPGt_int
+ #define	SQLFLOAT	ECPGt_double
+ #define	SQLSMFLOAT	ECPGt_float
+ #define	SQLDECIMAL	ECPGt_decimal
+ #define	SQLSERIAL	ECPGt_int
+ #define	SQLDATE		ECPGt_date
+ #define	SQLDTIME	ECPGt_timestamp
+ #define	SQLTEXT		ECPGt_char
+ #define	SQLVCHAR	ECPGt_char
+ #define SQLINTERVAL     ECPGt_interval
+ #define	SQLNCHAR	ECPGt_char
+ #define	SQLNVCHAR	ECPGt_char
+ #if (LONG_BIT == 64)
+ #define	SQLINT8		ECPGt_long
+ #define	SQLSERIAL8	ECPGt_long
+ #else
+ #define	SQLINT8		ECPGt_long_long
+ #define	SQLSERIAL8	ECPGt_long_long
+ #endif
+ 
+ #endif   /* ndef ECPG_SQLTYPES_H */
+ 
+ #line 9 "outofscope.pgc"
+ 
+ 
+ /* exec sql begin declare section */
+ 
+ #line 1 "struct.h"
+ 
+   
+ 		
+ 		
+ 		 /* dec_t */
+ 		
+ 		
+ 
+    typedef struct mytype  MYTYPE ;
+ 
+ #line 9 "struct.h"
+ 
+ 
+   
+ 		
+ 		
+ 		
+ 		
+ 		
+ 
+    typedef struct mynulltype  MYNULLTYPE ;
+ 
+ #line 18 "struct.h"
+ 
+ 
+ #line 12 "outofscope.pgc"
+ 
+ struct mytype { 
+ #line 3 "struct.h"
+  int id ;
+  
+ #line 4 "struct.h"
+  char t [ 64 ] ;
+  
+ #line 5 "struct.h"
+  double d1 ;
+  
+ #line 6 "struct.h"
+  double d2 ;
+  
+ #line 7 "struct.h"
+  char c [ 30 ] ;
+  } ; struct mynulltype { 
+ #line 12 "struct.h"
+  int id ;
+  
+ #line 13 "struct.h"
+  int t ;
+  
+ #line 14 "struct.h"
+  int d1 ;
+  
+ #line 15 "struct.h"
+  int d2 ;
+  
+ #line 16 "struct.h"
+  int c ;
+  } ;/* exec sql end declare section */
+ #line 13 "outofscope.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 15 "outofscope.pgc"
+ 
+ 
+ /* Functions for test 1 */
+ 
+ static void
+ get_var1(MYTYPE **myvar0, MYNULLTYPE **mynullvar0)
+ {
+ 	/* exec sql begin declare section */
+ 			  
+ 		  
+ 	
+ #line 23 "outofscope.pgc"
+  MYTYPE * myvar = malloc ( sizeof ( MYTYPE ) ) ;
+  
+ #line 24 "outofscope.pgc"
+  MYNULLTYPE * mynullvar = malloc ( sizeof ( MYNULLTYPE ) ) ;
+ /* exec sql end declare section */
+ #line 25 "outofscope.pgc"
+ 
+ 
+ 	/* Test DECLARE ... SELECT ... INTO with pointers */
+ 
+ 	ECPG_informix_set_var( 0, ( myvar ), __LINE__);\
+  ECPG_informix_set_var( 1, ( mynullvar ), __LINE__);\
+  ECPG_informix_reset_sqlca(); /* declare mycur cursor for select * from a1 */
+ #line 29 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ 
+ 	*myvar0 = myvar;
+ 	*mynullvar0 = mynullvar;
+ }
+ 
+ static void
+ open_cur1(void)
+ {
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT, 
+ 	ECPGt_int,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).t),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).d1),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).d1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).d2),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).d2),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).c),(long)30,(long)1,(30)*sizeof(char), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 41 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ get_record1(void)
+ {
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch mycur", ECPGt_EOIT, 
+ 	ECPGt_int,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).t),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).d1),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).d1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).d2),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).d2),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&((*( MYTYPE  *)(ECPG_informix_get_var( 0))).c),(long)30,(long)1,(30)*sizeof(char), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPG_informix_get_var( 1))).c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 50 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 50 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0 && sqlca.sqlcode != SQLNOTFOUND)
+ 		exit(1);
+ }
+ 
+ static void
+ close_cur1(void)
+ {
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur", ECPGt_EOIT, ECPGt_EORT);
+ #line 59 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 59 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ /* Functions for test 2 */
+ 
+ pg_sqlda_t	*inp_sqlda, *outp_sqlda;
+ 
+ /* exec sql begin declare section */
+ 	  
+ 	  
+ 	
+ 
+ #line 70 "outofscope.pgc"
+  char * stmt2 = "SELECT * FROM a1 WHERE id = ?" ;
+  
+ #line 71 "outofscope.pgc"
+  char * curname2 = "mycur" ;
+  
+ #line 72 "outofscope.pgc"
+  int id ;
+ /* exec sql end declare section */
+ #line 73 "outofscope.pgc"
+ 
+ 
+ static void
+ prepare2(void)
+ {
+ 	{ ECPGprepare(__LINE__, NULL, 0, "prepared_stmt", stmt2);
+ #line 78 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 78 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ 
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 	id = 4;
+ }
+ 
+ static void
+ declare2(void)
+ {
+ 	ECPG_informix_reset_sqlca(); /* declare $0 cursor for $1 */
+ #line 97 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ dealloc_prep2(void)
+ {
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "prepared_stmt");
+ #line 106 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 106 "outofscope.pgc"
+ 
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ }
+ 
+ static void
+ open_cur2(void)
+ {
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for $1", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "prepared_stmt", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 116 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 116 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ close_cur2(void)
+ {
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 125 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 125 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ get_record2(void)
+ {
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 134 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 134 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0 && sqlca.sqlcode != SQLNOTFOUND)
+ 		exit(1);
+ }
+ 
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (outp_sqlda->sqlvar[i].sqlind && *(outp_sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", outp_sqlda->sqlvar[i].sqlname);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case SQLCHAR:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLINT:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLINT8:
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLFLOAT: 
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLDECIMAL:
+ 			{
+ 				char	val[64];
+ 				dectoasc((decimal *)sqlda->sqlvar[i].sqldata, val, 64, -1);
+ 				printf("name sqlda descriptor: '%s' value DECIMAL '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ 	MYTYPE		*myvar;
+ 	MYNULLTYPE	*mynullvar;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0); 
+ #line 186 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 186 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 189 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 189 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
+ #line 192 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 192 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 195 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 195 "outofscope.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null )", ECPGt_EOIT, ECPGt_EORT);
+ #line 196 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 196 "outofscope.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , '\"a\"' , - 1.0 , 'nan' :: float8 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 197 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 197 "outofscope.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 198 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 198 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 201 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 201 "outofscope.pgc"
+ 
+ 
+ 	/* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE */
+ 
+ 	get_var1(&myvar, &mynullvar);
+ 	open_cur1();
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 208 "outofscope.pgc"
+ 
+ 
+ 	while (1)
+ 	{
+ 		memset(myvar, 0, sizeof(MYTYPE));
+ 		get_record1();
+ 		if (sqlca.sqlcode == SQLNOTFOUND)
+ 			break;
+ 		printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+ 			myvar->id, mynullvar->id ? " (NULL)" : "",
+ 			myvar->t, mynullvar->t ? " (NULL)" : "",
+ 			myvar->d1, mynullvar->d1 ? " (NULL)" : "",
+ 			myvar->d2, mynullvar->d2 ? " (NULL)" : "",
+ 			myvar->c, mynullvar->c ? " (NULL)" : "");
+ 	}
+ 
+ 	close_cur1();
+ 
+ 	/* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE interaction
+ 	 * with a dynamic cursor and prepared statment using an sqlda
+ 	 */
+ 
+ 	prepare2();
+ 	declare2();
+ 	open_cur2();
+ 
+ 	get_record2();
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	close_cur2();
+ 	dealloc_prep2();
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table a1", ECPGt_EOIT, ECPGt_EORT);
+ #line 243 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 243 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 246 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 246 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 249 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 249 "outofscope.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stderr pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stderr
*** pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stderr	2009-12-14 14:30:48.000000000 +0100
***************
*** 0 ****
--- 1,204 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 189: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 189: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 189: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 192: query: create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 192: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 192: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 195: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 195: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 195: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 197: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , '"a"' , - 1.0 , 'nan' :: float8 , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 197: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 197: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 198: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 198: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 198: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 201: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: query: declare mycur cursor for select * from a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 41: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: "a" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: -1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 2.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 50: RESULT: b          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 50: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 50: no data found on line 50
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 59: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 59: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 59: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 78: name prepared_stmt; query: "SELECT * FROM a1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: query: declare mycur cursor for SELECT * FROM a1 WHERE id = $1; with 1 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: using PQexecParams
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 116: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 134: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 134: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 134: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 134: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 134: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 134: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 134: RESULT: 2.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 134: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 134: RESULT: b          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 134: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 125: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 125: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 125: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 106: name prepared_stmt
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 243: query: drop table a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 243: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 243: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 246: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stdout pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stdout
*** pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-outofscope.stdout	2009-12-14 14:17:56.000000000 +0100
***************
*** 0 ****
--- 1,9 ----
+ id=1 t='a' d1=1.000000 d2=2.000000 c = 'a         '
+ id=2 t='' (NULL) d1=0.000000 (NULL) d2=0.000000 (NULL) c = '' (NULL)
+ id=3 t='"a"' d1=-1.000000 d2=nan c = 'a         '
+ id=4 t='b' d1=2.000000 d2=3.000000 c = 'b         '
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'b'
+ name sqlda descriptor: 'd1' value DECIMAL '2.0'
+ name sqlda descriptor: 'd2' value 3.000000
+ name sqlda descriptor: 'c' value 'b         '
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-struct.c pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-struct.c
*** pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-struct.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-struct.c	2009-12-14 14:17:56.000000000 +0100
***************
*** 0 ****
--- 1,265 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "struct.pgc"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 5 "struct.pgc"
+ 
+ 
+ /* exec sql begin declare section */
+ 
+ #line 1 "struct.h"
+ 
+   
+ 		
+ 		
+ 		 /* dec_t */
+ 		
+ 		
+ 
+    typedef struct mytype  MYTYPE ;
+ 
+ #line 9 "struct.h"
+ 
+ 
+   
+ 		
+ 		
+ 		
+ 		
+ 		
+ 
+    typedef struct mynulltype  MYNULLTYPE ;
+ 
+ #line 18 "struct.h"
+ 
+ 
+ #line 8 "struct.pgc"
+ 
+ struct mytype { 
+ #line 3 "struct.h"
+  int id ;
+  
+ #line 4 "struct.h"
+  char t [ 64 ] ;
+  
+ #line 5 "struct.h"
+  double d1 ;
+  
+ #line 6 "struct.h"
+  double d2 ;
+  
+ #line 7 "struct.h"
+  char c [ 30 ] ;
+  } ; struct mynulltype { 
+ #line 12 "struct.h"
+  int id ;
+  
+ #line 13 "struct.h"
+  int t ;
+  
+ #line 14 "struct.h"
+  int d1 ;
+  
+ #line 15 "struct.h"
+  int d2 ;
+  
+ #line 16 "struct.h"
+  int c ;
+  } ;/* exec sql end declare section */
+ #line 9 "struct.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 11 "struct.pgc"
+ 
+ 
+ int
+ main (void)
+ {
+ 	/* exec sql begin declare section */
+ 			
+ 		
+ 	
+ #line 17 "struct.pgc"
+  MYTYPE myvar ;
+  
+ #line 18 "struct.pgc"
+  MYNULLTYPE mynullvar ;
+ /* exec sql end declare section */
+ #line 19 "struct.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0); 
+ #line 26 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 26 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 29 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 29 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
+ #line 32 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 32 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 35 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 35 "struct.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null )", ECPGt_EOIT, ECPGt_EORT);
+ #line 36 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "struct.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , '\"a\"' , - 1.0 , 'nan' :: float8 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 37 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "struct.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 38 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 41 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "struct.pgc"
+ 
+ 
+ 	/* Test DECLARE ... SELECT ... INTO with struct type */
+ 
+ 	ECPG_informix_set_var( 0, &( myvar ), __LINE__);\
+  ECPG_informix_set_var( 1, &( mynullvar ), __LINE__);\
+  ECPG_informix_reset_sqlca(); /* declare mycur cursor for select * from a1 */
+ #line 45 "struct.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT, 
+ 	ECPGt_int,&(myvar.id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&(mynullvar.id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&(myvar.t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_int,&(mynullvar.t),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&(myvar.d1),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&(mynullvar.d1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&(myvar.d2),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&(mynullvar.d2),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&(myvar.c),(long)30,(long)1,(30)*sizeof(char), 
+ 	ECPGt_int,&(mynullvar.c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 46 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 46 "struct.pgc"
+ 
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 48 "struct.pgc"
+ 
+ 
+ 	while (1)
+ 	{
+ 		memset(&myvar, 0, sizeof(myvar));
+ 		{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch mycur", ECPGt_EOIT, 
+ 	ECPGt_int,&(myvar.id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&(mynullvar.id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&(myvar.t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_int,&(mynullvar.t),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&(myvar.d1),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&(mynullvar.d1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&(myvar.d2),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&(mynullvar.d2),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&(myvar.c),(long)30,(long)1,(30)*sizeof(char), 
+ 	ECPGt_int,&(mynullvar.c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 53 "struct.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 53 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 53 "struct.pgc"
+ 
+ 		printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+ 			myvar.id, mynullvar.id ? " (NULL)" : "",
+ 			myvar.t, mynullvar.t ? " (NULL)" : "",
+ 			myvar.d1, mynullvar.d1 ? " (NULL)" : "",
+ 			myvar.d2, mynullvar.d2 ? " (NULL)" : "",
+ 			myvar.c, mynullvar.c ? " (NULL)" : "");
+ 	}
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur", ECPGt_EOIT, ECPGt_EORT);
+ #line 62 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 62 "struct.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table a1", ECPGt_EOIT, ECPGt_EORT);
+ #line 67 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 67 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 70 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 70 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 73 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 73 "struct.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-struct.stderr pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-struct.stderr
*** pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-struct.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-struct.stderr	2009-12-14 14:17:56.000000000 +0100
***************
*** 0 ****
--- 1,136 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: query: create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , '"a"' , - 1.0 , 'nan' :: float8 , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 41: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 46: query: declare mycur cursor for select * from a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 46: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 46: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: "a" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: -1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 2.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: b          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 53: no data found on line 53
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 62: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 67: query: drop table a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 67: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 67: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 70: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-struct.stdout pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-struct.stdout
*** pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-struct.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4/src/interfaces/ecpg/test/expected/compat_informix-struct.stdout	2009-12-14 14:17:56.000000000 +0100
***************
*** 0 ****
--- 1,4 ----
+ id=1 t='a' d1=1.000000 d2=2.000000 c = 'a         '
+ id=2 t='' (NULL) d1=0.000000 (NULL) d2=0.000000 (NULL) c = '' (NULL)
+ id=3 t='"a"' d1=-1.000000 d2=nan c = 'a         '
+ id=4 t='b' d1=2.000000 d2=3.000000 c = 'b         '
#75Boszormenyi Zoltan
zb@cybertec.at
In reply to: Boszormenyi Zoltan (#74)
1 attachment(s)
Re: ECPG patch 4.1, out-of-scope cursor support in native mode

Boszormenyi Zoltan �rta:

New version: rebased to current CVS and
fix the rejects caused by the newer SQLDA
and DESCRIBE patches. Note that it's still
compat-mode only, I will send a modified patch
in the next email that is ECPG-wide, so it can be
decided if the feature is wanted in native mode or not.

Attached. Changes against the compat-mode only patch are:
- ECPG_informix_set_var() and ECPG_informix_get_var()
were renamed to ECPGset_var() and ECPGget_var() and
were moved into libecpg. The previous calls are kept
in libecpg_compat.so as wrappers for compatibility reasons.
- adjust_informix() was renamed as adjust_outofscope_cursor_vars()
to indicate its real purpose. The comment at the beginning
of the function is modified to explain why it's useful.

The code produced by this is not too ugly this way in
native mode, only some ECPGset_var() calls are added
when the DECLARE are in the same function as OPEN/FETCH/CLOSE.
Global variables used in DECLARE aren't transformed at all.

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

Attachments:

4.1-pg85-outofscopedeclare-8-ctxdiff.patchtext/x-patch; name=4.1-pg85-outofscopedeclare-8-ctxdiff.patchDownload
diff -dcrpN pgsql.3/src/interfaces/ecpg/compatlib/informix.c pgsql.4.1/src/interfaces/ecpg/compatlib/informix.c
*** pgsql.3/src/interfaces/ecpg/compatlib/informix.c	2009-10-01 20:37:18.000000000 +0200
--- pgsql.4.1/src/interfaces/ecpg/compatlib/informix.c	2009-12-15 12:10:42.000000000 +0100
*************** rtypwidth(int sqltype, int sqllen)
*** 1004,1060 ****
  	return 0;
  }
  
- static struct var_list
- {
- 	int			number;
- 	void	   *pointer;
- 	struct var_list *next;
- }	*ivlist = NULL;
- 
  void
  ECPG_informix_set_var(int number, void *pointer, int lineno)
  {
! 	struct var_list *ptr;
! 
! 	for (ptr = ivlist; ptr != NULL; ptr = ptr->next)
! 	{
! 		if (ptr->number == number)
! 		{
! 			/* already known => just change pointer value */
! 			ptr->pointer = pointer;
! 			return;
! 		}
! 	}
! 
! 	/* a new one has to be added */
! 	ptr = (struct var_list *) calloc(1L, sizeof(struct var_list));
! 	if (!ptr)
! 	{
! 		struct sqlca_t *sqlca = ECPGget_sqlca();
! 
! 		sqlca->sqlcode = ECPG_OUT_OF_MEMORY;
! 		strncpy(sqlca->sqlstate, "YE001", sizeof("YE001"));
! 		snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), "out of memory on line %d", lineno);
! 		sqlca->sqlerrm.sqlerrml = strlen(sqlca->sqlerrm.sqlerrmc);
! 		/* free all memory we have allocated for the user */
! 		ECPGfree_auto_mem();
! 	}
! 	else
! 	{
! 		ptr->number = number;
! 		ptr->pointer = pointer;
! 		ptr->next = ivlist;
! 		ivlist = ptr;
! 	}
  }
  
  void *
  ECPG_informix_get_var(int number)
  {
! 	struct var_list *ptr;
! 
! 	for (ptr = ivlist; ptr != NULL && ptr->number != number; ptr = ptr->next);
! 	return (ptr) ? ptr->pointer : NULL;
  }
  
  void
--- 1004,1019 ----
  	return 0;
  }
  
  void
  ECPG_informix_set_var(int number, void *pointer, int lineno)
  {
! 	ECPGset_var(number, pointer, lineno);
  }
  
  void *
  ECPG_informix_get_var(int number)
  {
! 	return ECPGget_var(number);
  }
  
  void
diff -dcrpN pgsql.3/src/interfaces/ecpg/ecpglib/exports.txt pgsql.4.1/src/interfaces/ecpg/ecpglib/exports.txt
*** pgsql.3/src/interfaces/ecpg/ecpglib/exports.txt	2009-09-21 15:19:11.000000000 +0200
--- pgsql.4.1/src/interfaces/ecpg/ecpglib/exports.txt	2009-12-15 12:00:27.000000000 +0100
*************** ECPGstatus                       23
*** 26,29 ****
  ECPGtrans                        24
  sqlprint                         25
  ECPGget_PGconn			 26
! ECPGtransactionStatus      27
--- 26,31 ----
  ECPGtrans                        24
  sqlprint                         25
  ECPGget_PGconn			 26
! ECPGtransactionStatus		 27
! ECPGset_var			 28
! ECPGget_var			 29
diff -dcrpN pgsql.3/src/interfaces/ecpg/ecpglib/misc.c pgsql.4.1/src/interfaces/ecpg/ecpglib/misc.c
*** pgsql.3/src/interfaces/ecpg/ecpglib/misc.c	2009-11-25 11:56:39.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/ecpglib/misc.c	2009-12-15 12:10:33.000000000 +0100
*************** ecpg_gettext(const char *msgid)
*** 505,507 ****
--- 505,559 ----
  }
  
  #endif   /* ENABLE_NLS */
+ 
+ static struct var_list
+ {
+ 	int		number;
+ 	void	   *pointer;
+ 	struct var_list *next;
+ } *ivlist = NULL;
+ 
+ void
+ ECPGset_var(int number, void *pointer, int lineno)
+ {
+ 	struct var_list *ptr;
+ 
+ 	for (ptr = ivlist; ptr != NULL; ptr = ptr->next)
+ 	{
+ 		if (ptr->number == number)
+ 		{
+ 			/* already known => just change pointer value */
+ 			ptr->pointer = pointer;
+ 			return;
+ 		}
+ 	}
+ 
+ 	/* a new one has to be added */
+ 	ptr = (struct var_list *) calloc(1L, sizeof(struct var_list));
+ 	if (!ptr)
+ 	{
+ 		struct sqlca_t *sqlca = ECPGget_sqlca();
+ 		sqlca->sqlcode = ECPG_OUT_OF_MEMORY;
+ 		strncpy(sqlca->sqlstate, "YE001", sizeof("YE001"));
+ 		snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), "out of memory on line %d", lineno);
+ 		sqlca->sqlerrm.sqlerrml = strlen(sqlca->sqlerrm.sqlerrmc);
+ 		/* free all memory we have allocated for the user */
+ 		ECPGfree_auto_mem();
+ 	}
+ 	else
+ 	{
+ 		ptr->number = number;
+ 		ptr->pointer = pointer;
+ 		ptr->next = ivlist;
+ 		ivlist = ptr;
+ 	}
+ }
+ 
+ void *
+ ECPGget_var(int number)
+ {
+ 	struct var_list *ptr;
+ 
+ 	for (ptr = ivlist; ptr != NULL && ptr->number != number; ptr = ptr->next);
+ 		return (ptr) ? ptr->pointer : NULL;
+ }
diff -dcrpN pgsql.3/src/interfaces/ecpg/include/ecpglib.h pgsql.4.1/src/interfaces/ecpg/include/ecpglib.h
*** pgsql.3/src/interfaces/ecpg/include/ecpglib.h	2009-12-14 12:42:44.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/include/ecpglib.h	2009-12-15 12:01:30.000000000 +0100
*************** void		ECPGset_noind_null(enum ECPGttype,
*** 85,90 ****
--- 85,93 ----
  bool		ECPGis_noind_null(enum ECPGttype, void *);
  bool		ECPGdescribe(int, bool, const char *, const char *, ...);
  
+ void		ECPGset_var(int, void *, int);
+ void	   *ECPGget_var(int number);
+ 
  /* dynamic result allocation */
  void		ECPGfree_auto_mem(void);
  
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/descriptor.c pgsql.4.1/src/interfaces/ecpg/preproc/descriptor.c
*** pgsql.3/src/interfaces/ecpg/preproc/descriptor.c	2009-12-14 12:41:24.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/descriptor.c	2009-12-14 14:17:39.000000000 +0100
*************** struct variable *
*** 317,323 ****
  descriptor_variable(const char *name, int input)
  {
  	static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN];
! 	static const struct ECPGtype descriptor_type = {ECPGt_descriptor, NULL, NULL, {NULL}, 0};
  	static const struct variable varspace[2] = {
  		{descriptor_names[0], (struct ECPGtype *) & descriptor_type, 0, NULL},
  		{descriptor_names[1], (struct ECPGtype *) & descriptor_type, 0, NULL}
--- 317,323 ----
  descriptor_variable(const char *name, int input)
  {
  	static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN];
! 	static const struct ECPGtype descriptor_type = {ECPGt_descriptor, NULL, NULL, NULL, {NULL}, 0};
  	static const struct variable varspace[2] = {
  		{descriptor_names[0], (struct ECPGtype *) & descriptor_type, 0, NULL},
  		{descriptor_names[1], (struct ECPGtype *) & descriptor_type, 0, NULL}
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/ecpg.addons pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.3/src/interfaces/ecpg/preproc/ecpg.addons	2009-12-14 12:41:24.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.addons	2009-12-15 12:15:49.000000000 +0100
*************** ECPG: DeclareCursorStmtDECLAREcursor_nam
*** 309,319 ****
--- 309,322 ----
  
  		this->next = cur;
  		this->name = $2;
+ 		this->function = (current_function ? mm_strdup(current_function) : NULL);
  		this->connection = connection;
  		this->opened = false;
  		this->command =  cat_str(7, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for"), $7);
  		this->argsinsert = argsinsert;
+ 		this->argsinsert_oos = NULL;
  		this->argsresult = argsresult;
+ 		this->argsresult_oos = NULL;
  		argsinsert = argsresult = NULL;
  		cur = this;
  
*************** ECPG: DeclareCursorStmtDECLAREcursor_nam
*** 326,342 ****
  		}
  		comment = cat_str(3, make_str("/*"), c1, make_str("*/"));
  
! 		if (INFORMIX_MODE)
! 		{
! 			if (braces_open > 0) /* we're in a function */
! 			{
! 				$$ = cat_str(4, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), make_str("ECPG_informix_reset_sqlca();"), comment);
! 			}
! 			else
! 				$$ = cat_str(3, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), comment);
! 		}
  		else
! 			$$ = comment;
  	}
  ECPG: ClosePortalStmtCLOSEcursor_name block
  	{
--- 329,345 ----
  		}
  		comment = cat_str(3, make_str("/*"), c1, make_str("*/"));
  
! 		if ((braces_open > 0) && INFORMIX_MODE) /* we're in a function */
! 			$$ = cat_str(4,
! 				adjust_outofscope_cursor_vars(this, true),
! 				adjust_outofscope_cursor_vars(this, false),
! 				make_str("ECPG_informix_reset_sqlca();"),
! 				comment);
  		else
! 			$$ = cat_str(3,
! 				adjust_outofscope_cursor_vars(this, true),
! 				adjust_outofscope_cursor_vars(this, false),
! 				comment);
  	}
  ECPG: ClosePortalStmtCLOSEcursor_name block
  	{
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/ecpg.c pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.c
*** pgsql.3/src/interfaces/ecpg/preproc/ecpg.c	2009-08-07 13:06:28.000000000 +0200
--- pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.c	2009-12-15 12:08:12.000000000 +0100
*************** main(int argc, char *const argv[])
*** 419,426 ****
  				/* and structure member lists */
  				memset(struct_member_list, 0, sizeof(struct_member_list));
  
! 				/* and our variable counter for Informix compatibility */
! 				ecpg_informix_var = 0;
  
  				/* finally the actual connection */
  				connection = NULL;
--- 419,426 ----
  				/* and structure member lists */
  				memset(struct_member_list, 0, sizeof(struct_member_list));
  
! 				/* and our variable counter for out of scope cursors' variables */
! 				ecpg_internal_var = 0;
  
  				/* finally the actual connection */
  				connection = NULL;
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/ecpg.header pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.header
*** pgsql.3/src/interfaces/ecpg/preproc/ecpg.header	2009-11-06 11:06:24.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.header	2009-12-15 12:18:33.000000000 +0100
***************
*** 33,39 ****
   */
  int struct_level = 0;
  int braces_open; /* brace level counter */
! int ecpg_informix_var = 0;
  char	*connection = NULL;
  char	*input_filename = NULL;
  
--- 33,40 ----
   */
  int struct_level = 0;
  int braces_open; /* brace level counter */
! char *current_function;
! int ecpg_internal_var = 0;
  char	*connection = NULL;
  char	*input_filename = NULL;
  
*************** static char *ECPGstruct_sizeof = NULL;
*** 53,62 ****
  /* for forward declarations we have to store some data as well */
  static char *forward_name = NULL;
  
! struct ECPGtype ecpg_no_indicator = {ECPGt_NO_INDICATOR, NULL, NULL, {NULL}, 0};
  struct variable no_indicator = {"no_indicator", &ecpg_no_indicator, 0, NULL};
  
! struct ECPGtype ecpg_query = {ECPGt_char_variable, NULL, NULL, {NULL}, 0};
  
  /*
   * Handle parsing errors and warnings
--- 54,63 ----
  /* for forward declarations we have to store some data as well */
  static char *forward_name = NULL;
  
! struct ECPGtype ecpg_no_indicator = {ECPGt_NO_INDICATOR, NULL, NULL, NULL, {NULL}, 0};
  struct variable no_indicator = {"no_indicator", &ecpg_no_indicator, 0, NULL};
  
! struct ECPGtype ecpg_query = {ECPGt_char_variable, NULL, NULL, NULL, {NULL}, 0};
  
  /*
   * Handle parsing errors and warnings
*************** create_questionmarks(char *name, bool ar
*** 226,301 ****
  }
  
  static char *
! adjust_informix(struct arguments *list)
  {
  	/* Informix accepts DECLARE with variables that are out of scope when OPEN is called.
!  	 * for instance you can declare variables in a function, and then subsequently use them
! 	 * {
! 	 *      declare_vars();
! 	 *      exec sql ... which uses vars declared in the above function
  	 *
! 	 * This breaks standard and leads to some very dangerous programming.
! 	 * Since they do, we have to work around and accept their syntax as well.
! 	 * But we will do so ONLY in Informix mode.
! 	 * We have to change the variables to our own struct and just store the pointer instead of the variable
  	 */
  
! 	 struct arguments *ptr;
! 	 char *result = make_str("");
  
! 	 for (ptr = list; ptr != NULL; ptr = ptr->next)
! 	 {
! 	 	char temp[20]; /* this should be sufficient unless you have 8 byte integers */
  		char *original_var;
  
! 	 	/* change variable name to "ECPG_informix_get_var(<counter>)" */
  		original_var = ptr->variable->name;
! 		sprintf(temp, "%d))", ecpg_informix_var);
  
! 		if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char && ptr->variable->type->type != ECPGt_unsigned_char && ptr->variable->type->type != ECPGt_string) && atoi(ptr->variable->type->size) > 1)
  		{
! 			ptr->variable = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, make_str("1"), ptr->variable->type->u.element->lineno), ptr->variable->type->size), 0);
! 			sprintf(temp, "%d, (", ecpg_informix_var++);
  		}
  		else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char || ptr->variable->type->type == ECPGt_unsigned_char || ptr->variable->type->type == ECPGt_string) && atoi(ptr->variable->type->size) > 1)
  		{
! 			ptr->variable = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->lineno), 0);
! 			sprintf(temp, "%d, (", ecpg_informix_var++);
  		}
  		else
  		{
! 			ptr->variable = new_variable(cat_str(4, make_str("*("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->lineno), 0);
! 			sprintf(temp, "%d, &(", ecpg_informix_var++);
  		}
  
! 		/* create call to "ECPG_informix_set_var(<counter>, <pointer>. <linen number>)" */
! 		result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var), make_str("), __LINE__);\n"));
  
! 		/* now the indicator if there is one */
! 		if (ptr->indicator->type->type != ECPGt_NO_INDICATOR)
  		{
! 			/* change variable name to "ECPG_informix_get_var(<counter>)" */
  			original_var = ptr->indicator->name;
! 			sprintf(temp, "%d))", ecpg_informix_var);
  
! 			/* create call to "ECPG_informix_set_var(<counter>, <pointer>. <linen number>)" */
! 			if (atoi(ptr->indicator->type->size) > 1)
  			{
! 				ptr->indicator = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->lineno), 0);
! 				sprintf(temp, "%d, (", ecpg_informix_var++);
  			}
  			else
  			{
! 				ptr->indicator = new_variable(cat_str(4, make_str("*("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->lineno), 0);
! 				sprintf(temp, "%d, &(", ecpg_informix_var++);
  			}
! 			result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var), make_str("), __LINE__);\n"));
  		}
- 	 }
  
! 	 return result;
  }
  
  static struct cursor *
  add_additional_variables(char *name, bool insert)
  {
--- 227,379 ----
  }
  
  static char *
! adjust_outofscope_cursor_vars(struct cursor *cur, bool insert)
  {
  	/* Informix accepts DECLARE with variables that are out of scope when OPEN is called.
! 	 * For instance you can DECLARE a cursor in one function, and OPEN/FETCH/CLOSE
! 	 * it in other functions. This is very useful for e.g. event-driver programming,
! 	 * but may also lead to dangerous programming. The limitation when this is allowed
! 	 * and doesn's cause problems have to be documented, like the allocated variables
! 	 * must not be realloc()'ed.
  	 *
! 	 * We have to change the variables to our own struct and just store the pointer
! 	 * instead of the variable. Do it only for local variables, not for globals.
  	 */
  
! 	struct arguments *list;
! 	struct arguments *ptr;
! 	struct arguments *newlist = NULL;
! 	struct variable *newvar, *newind;
! 	char *result = make_str("");
  
! 	list = (insert ? cur->argsinsert : cur->argsresult);
! 
! 	for (ptr = list; ptr != NULL; ptr = ptr->next)
! 	{
! 		char temp[20]; /* this should be sufficient unless you have 8 byte integers */
  		char *original_var;
+ 		bool skip_set_var = false;
  
! 		/* change variable name to "ECPGget_var(<counter>)" */
  		original_var = ptr->variable->name;
! 		sprintf(temp, "%d))", ecpg_internal_var);
  
! 		/* Don't emit ECPGset_var() calls for global variables */
! 		if (ptr->variable->brace_level == 0)
  		{
! 			newvar = ptr->variable;
! 			skip_set_var = true;
! 		}
! 		else if ((ptr->variable->type->type == ECPGt_char_variable) && (!strncmp(ptr->variable->name, "ECPGprepared_statement", strlen("ECPGprepared_statement"))))
! 		{
! 			newvar = ptr->variable;
! 			skip_set_var = true;
! 		}
! 		else if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char && ptr->variable->type->type != ECPGt_unsigned_char && ptr->variable->type->type != ECPGt_string) && atoi(ptr->variable->type->size) > 1)
! 		{
! 			newvar = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, make_str("1"), ptr->variable->type->u.element->lineno), ptr->variable->type->size), 0);
! 			sprintf(temp, "%d, (", ecpg_internal_var++);
  		}
  		else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char || ptr->variable->type->type == ECPGt_unsigned_char || ptr->variable->type->type == ECPGt_string) && atoi(ptr->variable->type->size) > 1)
  		{
! 			newvar = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->lineno), 0);
! 			if (ptr->variable->type->type == ECPGt_varchar)
! 				sprintf(temp, "%d, &(", ecpg_internal_var++);
! 			else
! 				sprintf(temp, "%d, (", ecpg_internal_var++);
! 		}
! 		else if (ptr->variable->type->type == ECPGt_struct || ptr->variable->type->type == ECPGt_union)
! 		{
! 			sprintf(temp, "%d)))", ecpg_internal_var);
! 			newvar = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->variable->type->type_name), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->variable->type->u.members, ptr->variable->type->type, ptr->variable->type->type_name, ptr->variable->type->struct_sizeof), 0);
! 			sprintf(temp, "%d, &(", ecpg_internal_var++);
! 		}
! 		else if (ptr->variable->type->type == ECPGt_array)
! 		{
! 			if (ptr->variable->type->u.element->type == ECPGt_struct || ptr->variable->type->u.element->type == ECPGt_union)
! 			{
! 				sprintf(temp, "%d)))", ecpg_internal_var);
! 				newvar = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->variable->type->u.element->type_name), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->variable->type->u.element->u.members, ptr->variable->type->u.element->type, ptr->variable->type->u.element->type_name, ptr->variable->type->u.element->struct_sizeof), 0);
! 				sprintf(temp, "%d, (", ecpg_internal_var++);
! 			}
! 			else
! 			{
! 				newvar = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, ptr->variable->type->u.element->size, ptr->variable->type->u.element->lineno), ptr->variable->type->size), 0);
! 				sprintf(temp, "%d, &(", ecpg_internal_var++);
! 			}
  		}
  		else
  		{
! 			newvar = new_variable(cat_str(4, make_str("*("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->lineno), 0);
! 			sprintf(temp, "%d, &(", ecpg_internal_var++);
  		}
  
! 		/* create call to "ECPGset_var(<counter>, <pointer>. <linen number>)" */
! 		if (!skip_set_var)
! 			result = cat_str(5, result, make_str("ECPGset_var("), mm_strdup(temp), mm_strdup(original_var), make_str("), __LINE__);\n"));
  
! 		/* now the indicator if there is one and it's not a global variable */
! 		if ((ptr->indicator->type->type == ECPGt_NO_INDICATOR) || (ptr->indicator->brace_level == 0))
  		{
! 			newind = ptr->indicator;
! 		}
! 		else
! 		{
! 			/* change variable name to "ECPGget_var(<counter>)" */
  			original_var = ptr->indicator->name;
! 			sprintf(temp, "%d))", ecpg_internal_var);
  
! 			if (ptr->indicator->type->type == ECPGt_struct || ptr->indicator->type->type == ECPGt_union)
  			{
! 				sprintf(temp, "%d)))", ecpg_internal_var);
! 				newind = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->indicator->type->type_name), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->indicator->type->u.members, ptr->indicator->type->type, ptr->indicator->type->type_name, ptr->indicator->type->struct_sizeof), 0);
! 				sprintf(temp, "%d, &(", ecpg_internal_var++);
! 			}
! 			else if (ptr->indicator->type->type == ECPGt_array)
! 			{
! 				if (ptr->indicator->type->u.element->type == ECPGt_struct || ptr->indicator->type->u.element->type == ECPGt_union)
! 				{
! 					sprintf(temp, "%d)))", ecpg_internal_var);
! 					newind = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->indicator->type->u.element->type_name), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->indicator->type->u.element->u.members, ptr->indicator->type->u.element->type, ptr->indicator->type->u.element->type_name, ptr->indicator->type->u.element->struct_sizeof), 0);
! 					sprintf(temp, "%d, (", ecpg_internal_var++);
! 				}
! 				else
! 				{
! 					newind = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->indicator->type->u.element->type)), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->indicator->type->u.element->type, ptr->indicator->type->u.element->size, ptr->indicator->type->u.element->lineno), ptr->indicator->type->size), 0);
! 					sprintf(temp, "%d, &(", ecpg_internal_var++);
! 				}
! 			}
! 			else if (atoi(ptr->indicator->type->size) > 1)
! 			{
! 				newind = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->lineno), 0);
! 				sprintf(temp, "%d, (", ecpg_internal_var++);
  			}
  			else
  			{
! 				newind = new_variable(cat_str(4, make_str("*("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->lineno), 0);
! 				sprintf(temp, "%d, &(", ecpg_internal_var++);
  			}
! 
! 			/* create call to "ECPGset_var(<counter>, <pointer>. <linen number>)" */
! 			result = cat_str(5, result, make_str("ECPGset_var("), mm_strdup(temp), mm_strdup(original_var), make_str("), __LINE__);\n"));
  		}
  
! 		add_variable_to_tail(&newlist, newvar, newind);
! 	}
! 
! 	if (insert)
! 		cur->argsinsert_oos = newlist;
! 	else
! 		cur->argsresult_oos = newlist;
! 
! 	return result;
  }
  
+ /* This tests whether the cursor was declared and opened in the same function. */
+ #define SAMEFUNC(cur)	\
+ 	((cur->function == NULL) ||		\
+ 	 (cur->function != NULL && !strcmp(cur->function, current_function)))
+ 
  static struct cursor *
  add_additional_variables(char *name, bool insert)
  {
*************** add_additional_variables(char *name, boo
*** 318,329 ****
  	{
  		/* add all those input variables that were given earlier
  		 * note that we have to append here but have to keep the existing order */
! 		for (p = ptr->argsinsert; p; p = p->next)
  			add_variable_to_tail(&argsinsert, p->variable, p->indicator);
  	}
  
  	/* add all those output variables that were given earlier */
! 	for (p = ptr->argsresult; p; p = p->next)
  		add_variable_to_tail(&argsresult, p->variable, p->indicator);
  
  	return ptr;
--- 396,407 ----
  	{
  		/* add all those input variables that were given earlier
  		 * note that we have to append here but have to keep the existing order */
! 		for (p = (SAMEFUNC(ptr) ? ptr->argsinsert : ptr->argsinsert_oos); p; p = p->next)
  			add_variable_to_tail(&argsinsert, p->variable, p->indicator);
  	}
  
  	/* add all those output variables that were given earlier */
! 	for (p = (SAMEFUNC(ptr) ? ptr->argsresult : ptr->argsresult_oos); p; p = p->next)
  		add_variable_to_tail(&argsresult, p->variable, p->indicator);
  
  	return ptr;
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/ecpg.trailer pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.3/src/interfaces/ecpg/preproc/ecpg.trailer	2009-12-14 12:45:12.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.trailer	2009-12-15 12:16:18.000000000 +0100
*************** statement: ecpgstart at stmt ';'        
*** 16,22 ****
                  | c_thing               { fprintf(yyout, "%s", $1); free($1); }
                  | CPP_LINE              { fprintf(yyout, "%s", $1); free($1); }
                  | '{'                   { braces_open++; fputs("{", yyout); }
!                 | '}'                   { remove_typedefs(braces_open); remove_variables(braces_open--); fputs("}", yyout); }
                  ;
  
  CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
--- 16,32 ----
                  | c_thing               { fprintf(yyout, "%s", $1); free($1); }
                  | CPP_LINE              { fprintf(yyout, "%s", $1); free($1); }
                  | '{'                   { braces_open++; fputs("{", yyout); }
!                 | '}'
! 		{
! 			remove_typedefs(braces_open);
! 			remove_variables(braces_open--);
! 			if (braces_open == 0)
! 			{
! 				free(current_function);
! 				current_function = NULL;
! 			}
! 			fputs("}", yyout);
! 		}
                  ;
  
  CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 281,286 ****
--- 291,297 ----
  			char *cursor_marker = $2[0] == ':' ? make_str("$0") : mm_strdup($2);
  			struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable));
  			const char *con = connection ? connection : "NULL";
+ 			char *comment;
  
  			for (ptr = cur; ptr != NULL; ptr = ptr->next)
  			{
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 294,302 ****
--- 305,315 ----
  			/* initial definition */
  			this->next = cur;
  			this->name = $2;
+ 			this->function = (current_function ? mm_strdup(current_function) : NULL);
  			this->connection = connection;
  			this->command =  cat_str(6, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for $1"));
  			this->argsresult = NULL;
+ 			this->argsresult_oos = NULL;
  
  			thisquery->type = &ecpg_query;
  			thisquery->brace_level = 0;
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 305,310 ****
--- 318,324 ----
  			sprintf(thisquery->name, "ECPGprepared_statement(%s, %s, __LINE__)", con, $7);
  
  			this->argsinsert = NULL;
+ 			this->argsinsert_oos = NULL;
  			if ($2[0] == ':')
  			{
  				struct variable *var = find_variable($2 + 1);
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 315,324 ****
  
  			cur = this;
  
! 			if (INFORMIX_MODE && braces_open > 0) /* we're in a function */
! 				$$ = cat_str(4, make_str("ECPG_informix_reset_sqlca();"), make_str("/*"), mm_strdup(this->command), make_str("*/"));
  			else
! 				$$ = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/"));
  		}
  		;
  
--- 329,347 ----
  
  			cur = this;
  
! 			comment = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/"));
! 
! 			if ((braces_open > 0) && INFORMIX_MODE) /* we're in a function */
! 				$$ = cat_str(4,
! 					adjust_outofscope_cursor_vars(this, true),
! 					adjust_outofscope_cursor_vars(this, false),
! 					make_str("ECPG_informix_reset_sqlca();"),
! 					comment);
  			else
! 				$$ = cat_str(3,
! 					adjust_outofscope_cursor_vars(this, true),
! 					adjust_outofscope_cursor_vars(this, false),
! 					comment);
  		}
  		;
  
*************** var_declaration: storage_declaration
*** 402,407 ****
--- 425,431 ----
  		var_type
  		{
  			actual_type[struct_level].type_enum = $2.type_enum;
+ 			actual_type[struct_level].type_str = $2.type_str;
  			actual_type[struct_level].type_dimension = $2.type_dimension;
  			actual_type[struct_level].type_index = $2.type_index;
  			actual_type[struct_level].type_sizeof = $2.type_sizeof;
*************** var_declaration: storage_declaration
*** 415,420 ****
--- 439,445 ----
  		| var_type
  		{
  			actual_type[struct_level].type_enum = $1.type_enum;
+ 			actual_type[struct_level].type_str = $1.type_str;
  			actual_type[struct_level].type_dimension = $1.type_dimension;
  			actual_type[struct_level].type_index = $1.type_index;
  			actual_type[struct_level].type_sizeof = $1.type_sizeof;
*************** variable: opt_pointer ECPGColLabel opt_a
*** 826,834 ****
  				case ECPGt_struct:
  				case ECPGt_union:
  					if (atoi(dimension) < 0)
! 						type = ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_sizeof);
  					else
! 						type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_sizeof), dimension);
  
  					$$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
  					break;
--- 851,859 ----
  				case ECPGt_struct:
  				case ECPGt_union:
  					if (atoi(dimension) < 0)
! 						type = ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_str, actual_type[struct_level].type_sizeof);
  					else
! 						type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_str, actual_type[struct_level].type_sizeof), dimension);
  
  					$$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
  					break;
*************** ECPGVar: SQL_VAR
*** 1307,1315 ****
  					case ECPGt_struct:
  					case ECPGt_union:
  						if (atoi(dimension) < 0)
! 							type = ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_sizeof);
  						else
! 							type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum,$5.type_sizeof), dimension);
  						break;
  
  					case ECPGt_varchar:
--- 1332,1340 ----
  					case ECPGt_struct:
  					case ECPGt_union:
  						if (atoi(dimension) < 0)
! 							type = ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_str, $5.type_sizeof);
  						else
! 							type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_str, $5.type_sizeof), dimension);
  						break;
  
  					case ECPGt_varchar:
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/extern.h pgsql.4.1/src/interfaces/ecpg/preproc/extern.h
*** pgsql.3/src/interfaces/ecpg/preproc/extern.h	2009-12-14 12:41:24.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/extern.h	2009-12-15 12:07:20.000000000 +0100
*************** extern int	braces_open,
*** 26,34 ****
  			questionmarks,
  			ret_value,
  			struct_level,
! 			ecpg_informix_var,
  			regression_mode,
  			auto_prepare;
  extern char *descriptor_index;
  extern char *descriptor_name;
  extern char *connection;
--- 26,35 ----
  			questionmarks,
  			ret_value,
  			struct_level,
! 			ecpg_internal_var,
  			regression_mode,
  			auto_prepare;
+ extern char *current_function;
  extern char *descriptor_index;
  extern char *descriptor_name;
  extern char *connection;
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/pgc.l pgsql.4.1/src/interfaces/ecpg/preproc/pgc.l
*** pgsql.3/src/interfaces/ecpg/preproc/pgc.l	2009-09-18 08:26:55.000000000 +0200
--- pgsql.4.1/src/interfaces/ecpg/preproc/pgc.l	2009-12-14 14:17:39.000000000 +0100
*************** static char    *literalbuf = NULL;		/* e
*** 41,46 ****
--- 41,49 ----
  static int		literallen;				/* actual current length */
  static int		literalalloc;			/* current allocated buffer size */
  
+ /* Used for detecting global state together with braces_open */
+ static int		parenths_open;
+ 
  #define startlit()	(literalbuf[0] = '\0', literallen = 0)
  static void addlit(char *ytext, int yleng);
  static void addlitchar (unsigned char);
*************** cppline			{space}*#(.*\\{space})*.*{newl
*** 788,794 ****
  					}
  <C>{identifier} 	{
  						const ScanKeyword		*keyword;
! 							
  						/* Informix uses SQL defines only in SQL space */
  						/* however, some defines have to be taken care of for compatibility */
  						if ((!INFORMIX_MODE || !isinformixdefine()) && !isdefine())
--- 791,807 ----
  					}
  <C>{identifier} 	{
  						const ScanKeyword		*keyword;
! 
! 						/*
! 						 * Try to detect a function name:
! 						 * look for identifiers at the global scope
! 						 * keep the last identifier before the first '(' and '{' */
! 						if (braces_open == 0 && parenths_open == 0)
! 						{
! 							if (current_function)
! 								free(current_function);
! 							current_function = mm_strdup(yytext);
! 						}
  						/* Informix uses SQL defines only in SQL space */
  						/* however, some defines have to be taken care of for compatibility */
  						if ((!INFORMIX_MODE || !isinformixdefine()) && !isdefine())
*************** cppline			{space}*#(.*\\{space})*.*{newl
*** 811,818 ****
  <C>"/"				{ return('/'); }
  <C>"+"				{ return('+'); }
  <C>"-"				{ return('-'); }
! <C>"("				{ return('('); }
! <C>")"				{ return(')'); }
  <C,xskip>{space}		{ ECHO; }
  <C>\{				{ return('{'); }
  <C>\}				{ return('}'); }
--- 824,831 ----
  <C>"/"				{ return('/'); }
  <C>"+"				{ return('+'); }
  <C>"-"				{ return('-'); }
! <C>"("				{ parenths_open++; return('('); }
! <C>")"				{ parenths_open--; return(')'); }
  <C,xskip>{space}		{ ECHO; }
  <C>\{				{ return('{'); }
  <C>\}				{ return('}'); }
*************** void
*** 1178,1183 ****
--- 1191,1198 ----
  lex_init(void)
  {
  	braces_open = 0;
+ 	parenths_open = 0;
+ 	current_function = NULL;
  
  	preproc_tos = 0;
  	yylineno = 1;
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/type.c pgsql.4.1/src/interfaces/ecpg/preproc/type.c
*** pgsql.3/src/interfaces/ecpg/preproc/type.c	2009-12-14 12:41:24.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/type.c	2009-12-14 14:17:39.000000000 +0100
*************** ECPGstruct_member_dup(struct ECPGstruct_
*** 46,52 ****
  		{
  			case ECPGt_struct:
  			case ECPGt_union:
! 				type = ECPGmake_struct_type(rm->type->u.members, rm->type->type, rm->type->struct_sizeof);
  				break;
  			case ECPGt_array:
  
--- 46,52 ----
  		{
  			case ECPGt_struct:
  			case ECPGt_union:
! 				type = ECPGmake_struct_type(rm->type->u.members, rm->type->type, rm->type->type_name, rm->type->struct_sizeof);
  				break;
  			case ECPGt_array:
  
*************** ECPGstruct_member_dup(struct ECPGstruct_
*** 55,61 ****
  				 * create the struct too
  				 */
  				if (rm->type->u.element->type == ECPGt_struct)
! 					type = ECPGmake_struct_type(rm->type->u.element->u.members, rm->type->u.element->type, rm->type->u.element->struct_sizeof);
  				else
  					type = ECPGmake_array_type(ECPGmake_simple_type(rm->type->u.element->type, rm->type->u.element->size, rm->type->u.element->lineno), rm->type->size);
  				break;
--- 55,61 ----
  				 * create the struct too
  				 */
  				if (rm->type->u.element->type == ECPGt_struct)
! 					type = ECPGmake_struct_type(rm->type->u.element->u.members, rm->type->u.element->type, rm->type->u.element->type_name, rm->type->u.element->struct_sizeof);
  				else
  					type = ECPGmake_array_type(ECPGmake_simple_type(rm->type->u.element->type, rm->type->u.element->size, rm->type->u.element->lineno), rm->type->size);
  				break;
*************** ECPGmake_simple_type(enum ECPGttype type
*** 98,103 ****
--- 98,104 ----
  	struct ECPGtype *ne = (struct ECPGtype *) mm_alloc(sizeof(struct ECPGtype));
  
  	ne->type = type;
+ 	ne->type_name = NULL;
  	ne->size = size;
  	ne->u.element = NULL;
  	ne->struct_sizeof = NULL;
*************** ECPGmake_array_type(struct ECPGtype * ty
*** 117,126 ****
  }
  
  struct ECPGtype *
! ECPGmake_struct_type(struct ECPGstruct_member * rm, enum ECPGttype type, char *struct_sizeof)
  {
  	struct ECPGtype *ne = ECPGmake_simple_type(type, make_str("1"), 0);
  
  	ne->u.members = ECPGstruct_member_dup(rm);
  	ne->struct_sizeof = struct_sizeof;
  
--- 118,128 ----
  }
  
  struct ECPGtype *
! ECPGmake_struct_type(struct ECPGstruct_member * rm, enum ECPGttype type, char *type_name, char *struct_sizeof)
  {
  	struct ECPGtype *ne = ECPGmake_simple_type(type, make_str("1"), 0);
  
+ 	ne->type_name = mm_strdup(type_name);
  	ne->u.members = ECPGstruct_member_dup(rm);
  	ne->struct_sizeof = struct_sizeof;
  
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/type.h pgsql.4.1/src/interfaces/ecpg/preproc/type.h
*** pgsql.3/src/interfaces/ecpg/preproc/type.h	2009-06-13 18:25:05.000000000 +0200
--- pgsql.4.1/src/interfaces/ecpg/preproc/type.h	2009-12-14 14:17:39.000000000 +0100
*************** struct ECPGstruct_member
*** 17,22 ****
--- 17,23 ----
  struct ECPGtype
  {
  	enum ECPGttype type;
+ 	char	   *type_name;			/* For struct and union types it is the struct name */
  	char	   *size;			/* For array it is the number of elements. For
  								 * varchar it is the maxsize of the area. */
  	char	   *struct_sizeof;	/* For a struct this is the sizeof() type as
*************** void		ECPGmake_struct_member(char *, str
*** 36,42 ****
  struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, char *, int);
  struct ECPGtype *ECPGmake_varchar_type(enum ECPGttype, long);
  struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, char *);
! struct ECPGtype *ECPGmake_struct_type(struct ECPGstruct_member *, enum ECPGttype, char *);
  struct ECPGstruct_member *ECPGstruct_member_dup(struct ECPGstruct_member *);
  
  /* Frees a type. */
--- 37,43 ----
  struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, char *, int);
  struct ECPGtype *ECPGmake_varchar_type(enum ECPGttype, long);
  struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, char *);
! struct ECPGtype *ECPGmake_struct_type(struct ECPGstruct_member *, enum ECPGttype, char *, char *);
  struct ECPGstruct_member *ECPGstruct_member_dup(struct ECPGstruct_member *);
  
  /* Frees a type. */
*************** struct _include_path
*** 123,133 ****
--- 124,137 ----
  struct cursor
  {
  	char	   *name;
+ 	char	   *function;
  	char	   *command;
  	char	   *connection;
  	bool		opened;
  	struct arguments *argsinsert;
+ 	struct arguments *argsinsert_oos;
  	struct arguments *argsresult;
+ 	struct arguments *argsresult_oos;
  	struct cursor *next;
  };
  
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/variable.c pgsql.4.1/src/interfaces/ecpg/preproc/variable.c
*** pgsql.3/src/interfaces/ecpg/preproc/variable.c	2009-11-26 18:57:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/variable.c	2009-12-14 14:17:39.000000000 +0100
*************** find_struct_member(char *name, char *str
*** 47,53 ****
  						return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->type, members->type->u.element->size, members->type->u.element->lineno), members->type->size), brace_level));
  					case ECPGt_struct:
  					case ECPGt_union:
! 						return (new_variable(name, ECPGmake_struct_type(members->type->u.members, members->type->type, members->type->struct_sizeof), brace_level));
  					default:
  						return (new_variable(name, ECPGmake_simple_type(members->type->type, members->type->size, members->type->lineno), brace_level));
  				}
--- 47,53 ----
  						return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->type, members->type->u.element->size, members->type->u.element->lineno), members->type->size), brace_level));
  					case ECPGt_struct:
  					case ECPGt_union:
! 						return (new_variable(name, ECPGmake_struct_type(members->type->u.members, members->type->type, members->type->type_name, members->type->struct_sizeof), brace_level));
  					default:
  						return (new_variable(name, ECPGmake_simple_type(members->type->type, members->type->size, members->type->lineno), brace_level));
  				}
*************** find_struct_member(char *name, char *str
*** 94,100 ****
  								return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->u.element->type, members->type->u.element->u.element->size, members->type->u.element->u.element->lineno), members->type->u.element->size), brace_level));
  							case ECPGt_struct:
  							case ECPGt_union:
! 								return (new_variable(name, ECPGmake_struct_type(members->type->u.element->u.members, members->type->u.element->type, members->type->u.element->struct_sizeof), brace_level));
  							default:
  								return (new_variable(name, ECPGmake_simple_type(members->type->u.element->type, members->type->u.element->size, members->type->u.element->lineno), brace_level));
  						}
--- 94,100 ----
  								return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->u.element->type, members->type->u.element->u.element->size, members->type->u.element->u.element->lineno), members->type->u.element->size), brace_level));
  							case ECPGt_struct:
  							case ECPGt_union:
! 								return (new_variable(name, ECPGmake_struct_type(members->type->u.element->u.members, members->type->u.element->type, members->type->u.element->type_name, members->type->u.element->struct_sizeof), brace_level));
  							default:
  								return (new_variable(name, ECPGmake_simple_type(members->type->u.element->type, members->type->u.element->size, members->type->u.element->lineno), brace_level));
  						}
*************** find_variable(char *name)
*** 235,241 ****
  						return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(p->type->u.element->u.element->type, p->type->u.element->u.element->size, p->type->u.element->u.element->lineno), p->type->u.element->size), p->brace_level));
  					case ECPGt_struct:
  					case ECPGt_union:
! 						return (new_variable(name, ECPGmake_struct_type(p->type->u.element->u.members, p->type->u.element->type, p->type->u.element->struct_sizeof), p->brace_level));
  					default:
  						return (new_variable(name, ECPGmake_simple_type(p->type->u.element->type, p->type->u.element->size, p->type->u.element->lineno), p->brace_level));
  				}
--- 235,241 ----
  						return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(p->type->u.element->u.element->type, p->type->u.element->u.element->size, p->type->u.element->u.element->lineno), p->type->u.element->size), p->brace_level));
  					case ECPGt_struct:
  					case ECPGt_union:
! 						return (new_variable(name, ECPGmake_struct_type(p->type->u.element->u.members, p->type->u.element->type, p->type->u.element->type_name, p->type->u.element->struct_sizeof), p->brace_level));
  					default:
  						return (new_variable(name, ECPGmake_simple_type(p->type->u.element->type, p->type->u.element->size, p->type->u.element->lineno), p->brace_level));
  				}
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/ecpg_schedule pgsql.4.1/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.3/src/interfaces/ecpg/test/ecpg_schedule	2009-12-14 14:04:58.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/ecpg_schedule	2009-12-15 12:35:33.000000000 +0100
*************** test: preproc/init
*** 24,29 ****
--- 24,31 ----
  test: preproc/strings
  test: preproc/type
  test: preproc/variable
+ test: preproc/struct
+ test: preproc/outofscope
  test: preproc/whenever
  test: sql/array
  test: sql/binary
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/ecpg_schedule_tcp pgsql.4.1/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.3/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-12-14 14:05:07.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-12-15 12:35:49.000000000 +0100
*************** test: preproc/init
*** 24,29 ****
--- 24,31 ----
  test: preproc/strings
  test: preproc/type
  test: preproc/variable
+ test: preproc/struct
+ test: preproc/outofscope
  test: preproc/whenever
  test: sql/array
  test: sql/binary
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c pgsql.4.1/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c
*** pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c	2009-11-11 20:47:12.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c	2009-12-15 12:37:03.000000000 +0100
*************** if (sqlca.sqlcode < 0) dosqlprint ( );}
*** 147,153 ****
  
  
  	sqlca.sqlcode = 100;
! 	ECPG_informix_set_var( 0, &( i ), __LINE__);\
   ECPG_informix_reset_sqlca(); /* declare c cursor for select * from test where i <= $1  */
  #line 49 "test_informix.pgc"
  
--- 147,153 ----
  
  
  	sqlca.sqlcode = 100;
! 	ECPGset_var( 0, &( i ), __LINE__);\
   ECPG_informix_reset_sqlca(); /* declare c cursor for select * from test where i <= $1  */
  #line 49 "test_informix.pgc"
  
*************** if (sqlca.sqlcode < 0) dosqlprint ( );}
*** 245,251 ****
  static void openit(void)
  {
  	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare c cursor for select * from test where i <= $1 ", 
! 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 0))),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 95 "test_informix.pgc"
  
--- 245,251 ----
  static void openit(void)
  {
  	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare c cursor for select * from test where i <= $1 ", 
! 	ECPGt_int,&(*( int  *)(ECPGget_var( 0))),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 95 "test_informix.pgc"
  
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/preproc-cursor.c pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-cursor.c
*** pgsql.3/src/interfaces/ecpg/test/expected/preproc-cursor.c	2009-11-26 16:55:57.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-cursor.c	2009-12-15 12:37:18.000000000 +0100
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 153,159 ****
  	/* Dynamic cursorname test with INTO list in FETCH stmts */
  
  	strcpy(msg, "declare");
! 	/* declare $0 cursor for select id , t from t1 */
  #line 59 "cursor.pgc"
  
  
--- 153,160 ----
  	/* Dynamic cursorname test with INTO list in FETCH stmts */
  
  	strcpy(msg, "declare");
! 	ECPGset_var( 0, &( curname1 ), __LINE__);\
!  /* declare $0 cursor for select id , t from t1 */
  #line 59 "cursor.pgc"
  
  
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 286,292 ****
  	/* Dynamic cursorname test with INTO list in DECLARE stmt */
  
  	strcpy(msg, "declare");
! 	/* declare $0 cursor for select id , t from t1 */
  #line 100 "cursor.pgc"
  
  
--- 287,296 ----
  	/* Dynamic cursorname test with INTO list in DECLARE stmt */
  
  	strcpy(msg, "declare");
! 	ECPGset_var( 3, &( curname2 ), __LINE__);\
!  ECPGset_var( 1, ( t ), __LINE__);\
!  ECPGset_var( 2, &( id ), __LINE__);\
!  /* declare $0 cursor for select id , t from t1 */
  #line 100 "cursor.pgc"
  
  
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 435,441 ****
  
  
  	strcpy(msg, "declare");
! 	/* declare $0 cursor for $1 */
  #line 143 "cursor.pgc"
  
  
--- 439,446 ----
  
  
  	strcpy(msg, "declare");
! 	ECPGset_var( 4, &( curname3 ), __LINE__);\
!  /* declare $0 cursor for $1 */
  #line 143 "cursor.pgc"
  
  
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 590,596 ****
  
  
  	strcpy(msg, "declare");
! 	/* declare $0 cursor for $1 */
  #line 193 "cursor.pgc"
  
  
--- 595,602 ----
  
  
  	strcpy(msg, "declare");
! 	ECPGset_var( 5, &( curname4 ), __LINE__);\
!  /* declare $0 cursor for $1 */
  #line 193 "cursor.pgc"
  
  
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/preproc-outofscope.c pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-outofscope.c
*** pgsql.3/src/interfaces/ecpg/test/expected/preproc-outofscope.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-outofscope.c	2009-12-15 12:40:17.000000000 +0100
***************
*** 0 ****
--- 1,621 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "outofscope.pgc"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ #include <limits.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 7 "outofscope.pgc"
+ 
+ 
+ 
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+ 
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+ 
+ #include "ecpglib.h"
+ 
+ typedef struct sqlvar_struct
+ {
+ 	short	sqltype;		/* variable type                */
+ 	int	sqllen;			/* length in bytes              */
+ 	char	   *sqldata;		/* pointer to data              */
+ 	short	   *sqlind;		/* pointer to indicator         */
+ 	char	   *sqlname;		/* variable name                */
+ 	char	   *sqlformat;		/* reserved for future use      */
+ 	short	sqlitype;		/* ind variable type            */
+ 	short	sqlilen;		/* ind length in bytes          */
+ 	char	   *sqlidata;		/* ind data pointer             */
+ 	int	sqlxid;			/* extended id type             */
+ 	char	   *sqltypename;	/* extended type name           */
+ 	short	sqltypelen;		/* length of extended type name */
+ 	short	sqlownerlen;		/* length of owner name         */
+ 	short	sqlsourcetype;		/* source type for distinct of built-ins */
+ 	char	   *sqlownername;	/* owner name                   */
+ 	int	sqlsourceid;		/* extended id of source type   */
+ 
+ 	/*
+ 	 * sqlilongdata is new.  It supports data that exceeds the 32k
+ 	 * limit.  sqlilen and sqlidata are for backward compatibility
+ 	 * and they have maximum value of <32K.
+ 	 */
+ 	char	   *sqlilongdata;	/* for data field beyond 32K    */
+ 	int	sqlflags;		/* for internal use only        */
+ 	void	   *sqlreserved;	/* reserved for future use      */
+ } pg_sqlvar_t;
+ 
+ typedef struct sqlda
+ {
+ 	short		sqld;
+ 	pg_sqlvar_t	   *sqlvar;
+ 	char		desc_name[19];	/* descriptor name              */
+ 	short		desc_occ;	/* size of sqlda structure      */
+ 	struct sqlda	   *desc_next;	/* pointer to next sqlda struct */
+ 	void		   *reserved;	/* reserved for future use */
+ } pg_sqlda_t;
+ 
+ #endif /* POSTGRES_SQLDA_H */
+ 
+ #line 9 "outofscope.pgc"
+ 
+ 
+ #line 1 "pgtypes_numeric.h"
+ /* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_numeric.h,v 1.16 2006/08/09 07:30:56 meskes Exp $ */
+ 
+ #ifndef PGTYPES_NUMERIC
+ #define PGTYPES_NUMERIC
+ 
+ #define NUMERIC_POS						0x0000
+ #define NUMERIC_NEG						0x4000
+ #define NUMERIC_NAN						0xC000
+ #define NUMERIC_MAX_PRECISION			1000
+ #define NUMERIC_MAX_DISPLAY_SCALE		NUMERIC_MAX_PRECISION
+ #define NUMERIC_MIN_DISPLAY_SCALE		0
+ #define NUMERIC_MIN_SIG_DIGITS			16
+ 
+ #define DECSIZE 30
+ 
+ typedef unsigned char NumericDigit;
+ typedef struct
+ {
+ 	int			ndigits;		/* number of digits in digits[] - can be 0! */
+ 	int			weight;			/* weight of first digit */
+ 	int			rscale;			/* result scale */
+ 	int			dscale;			/* display scale */
+ 	int			sign;			/* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
+ 	NumericDigit *buf;			/* start of alloc'd space for digits[] */
+ 	NumericDigit *digits;		/* decimal digits */
+ } numeric;
+ 
+ typedef struct
+ {
+ 	int			ndigits;		/* number of digits in digits[] - can be 0! */
+ 	int			weight;			/* weight of first digit */
+ 	int			rscale;			/* result scale */
+ 	int			dscale;			/* display scale */
+ 	int			sign;			/* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
+ 	NumericDigit digits[DECSIZE];		/* decimal digits */
+ } decimal;
+ 
+ #ifdef __cplusplus
+ extern		"C"
+ {
+ #endif
+ 
+ numeric    *PGTYPESnumeric_new(void);
+ decimal    *PGTYPESdecimal_new(void);
+ void		PGTYPESnumeric_free(numeric *);
+ void		PGTYPESdecimal_free(decimal *);
+ numeric    *PGTYPESnumeric_from_asc(char *, char **);
+ char	   *PGTYPESnumeric_to_asc(numeric *, int);
+ int			PGTYPESnumeric_add(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_sub(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_mul(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_div(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_cmp(numeric *, numeric *);
+ int			PGTYPESnumeric_from_int(signed int, numeric *);
+ int			PGTYPESnumeric_from_long(signed long int, numeric *);
+ int			PGTYPESnumeric_copy(numeric *, numeric *);
+ int			PGTYPESnumeric_from_double(double, numeric *);
+ int			PGTYPESnumeric_to_double(numeric *, double *);
+ int			PGTYPESnumeric_to_int(numeric *, int *);
+ int			PGTYPESnumeric_to_long(numeric *, long *);
+ int			PGTYPESnumeric_to_decimal(numeric *, decimal *);
+ int			PGTYPESnumeric_from_decimal(decimal *, numeric *);
+ 
+ #ifdef __cplusplus
+ }
+ #endif
+ 
+ #endif   /* PGTYPES_NUMERIC */
+ 
+ #line 10 "outofscope.pgc"
+ 
+ 
+ /* exec sql begin declare section */
+ 
+ #line 1 "struct.h"
+ 
+   
+ 		
+ 		
+ 		 /* dec_t */
+ 		
+ 		
+ 
+    typedef struct mytype  MYTYPE ;
+ 
+ #line 9 "struct.h"
+ 
+ 
+   
+ 		
+ 		
+ 		
+ 		
+ 		
+ 
+    typedef struct mynulltype  MYNULLTYPE ;
+ 
+ #line 18 "struct.h"
+ 
+ 
+ #line 13 "outofscope.pgc"
+ 
+ struct mytype { 
+ #line 3 "struct.h"
+  int id ;
+  
+ #line 4 "struct.h"
+  char t [ 64 ] ;
+  
+ #line 5 "struct.h"
+  double d1 ;
+  
+ #line 6 "struct.h"
+  double d2 ;
+  
+ #line 7 "struct.h"
+  char c [ 30 ] ;
+  } ; struct mynulltype { 
+ #line 12 "struct.h"
+  int id ;
+  
+ #line 13 "struct.h"
+  int t ;
+  
+ #line 14 "struct.h"
+  int d1 ;
+  
+ #line 15 "struct.h"
+  int d2 ;
+  
+ #line 16 "struct.h"
+  int c ;
+  } ;/* exec sql end declare section */
+ #line 14 "outofscope.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 16 "outofscope.pgc"
+ 
+ 
+ /* Functions for test 1 */
+ 
+ static void
+ get_var1(MYTYPE **myvar0, MYNULLTYPE **mynullvar0)
+ {
+ 	/* exec sql begin declare section */
+ 			  
+ 		  
+ 	
+ #line 24 "outofscope.pgc"
+  MYTYPE * myvar = malloc ( sizeof ( MYTYPE ) ) ;
+  
+ #line 25 "outofscope.pgc"
+  MYNULLTYPE * mynullvar = malloc ( sizeof ( MYNULLTYPE ) ) ;
+ /* exec sql end declare section */
+ #line 26 "outofscope.pgc"
+ 
+ 
+ 	/* Test DECLARE ... SELECT ... INTO with pointers */
+ 
+ 	ECPGset_var( 0, ( myvar ), __LINE__);\
+  ECPGset_var( 1, ( mynullvar ), __LINE__);\
+  /* declare mycur cursor for select * from a1 */
+ #line 30 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ 
+ 	*myvar0 = myvar;
+ 	*mynullvar0 = mynullvar;
+ }
+ 
+ static void
+ open_cur1(void)
+ {
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT, 
+ 	ECPGt_int,&((*( MYTYPE  *)(ECPGget_var( 0))).id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&((*( MYTYPE  *)(ECPGget_var( 0))).t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).t),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&((*( MYTYPE  *)(ECPGget_var( 0))).d1),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).d1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&((*( MYTYPE  *)(ECPGget_var( 0))).d2),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).d2),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&((*( MYTYPE  *)(ECPGget_var( 0))).c),(long)30,(long)1,(30)*sizeof(char), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 42 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 42 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ get_record1(void)
+ {
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch mycur", ECPGt_EOIT, 
+ 	ECPGt_int,&((*( MYTYPE  *)(ECPGget_var( 0))).id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&((*( MYTYPE  *)(ECPGget_var( 0))).t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).t),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&((*( MYTYPE  *)(ECPGget_var( 0))).d1),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).d1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&((*( MYTYPE  *)(ECPGget_var( 0))).d2),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).d2),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&((*( MYTYPE  *)(ECPGget_var( 0))).c),(long)30,(long)1,(30)*sizeof(char), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 51 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 51 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0 && sqlca.sqlcode != ECPG_NOT_FOUND)
+ 		exit(1);
+ }
+ 
+ static void
+ close_cur1(void)
+ {
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur", ECPGt_EOIT, ECPGt_EORT);
+ #line 60 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 60 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ /* Functions for test 2 */
+ 
+ pg_sqlda_t	*inp_sqlda, *outp_sqlda;
+ 
+ /* exec sql begin declare section */
+ 	  
+ 	  
+ 	
+ 
+ #line 71 "outofscope.pgc"
+  char * stmt2 = "SELECT * FROM a1 WHERE id = ?" ;
+  
+ #line 72 "outofscope.pgc"
+  char * curname2 = "mycur" ;
+  
+ #line 73 "outofscope.pgc"
+  int id ;
+ /* exec sql end declare section */
+ #line 74 "outofscope.pgc"
+ 
+ 
+ static void
+ prepare2(void)
+ {
+ 	{ ECPGprepare(__LINE__, NULL, 0, "prepared_stmt", stmt2);
+ #line 79 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 79 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ 
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 	id = 4;
+ }
+ 
+ static void
+ declare2(void)
+ {
+ 	/* declare $0 cursor for $1 */
+ #line 98 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ dealloc_prep2(void)
+ {
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "prepared_stmt");
+ #line 107 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 107 "outofscope.pgc"
+ 
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ }
+ 
+ static void
+ open_cur2(void)
+ {
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for $1", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "prepared_stmt", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 117 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 117 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ close_cur2(void)
+ {
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 126 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 126 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ get_record2(void)
+ {
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 135 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 135 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0 && sqlca.sqlcode != ECPG_NOT_FOUND)
+ 		exit(1);
+ }
+ 
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (outp_sqlda->sqlvar[i].sqlind && *(outp_sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", outp_sqlda->sqlvar[i].sqlname);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case ECPGt_char:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_int:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ #if (LONG_BIT == 64) /* Defined via <limits.h> */
+ 		case ECPGt_long:
+ #else
+ # if (LONG_BIT = 32)
+ 		case ECPGt_long_long:
+ # else
+ #  error Neither "long" nor "long long" are 64-bit
+ # endif
+ #endif
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_double: 
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_numeric:
+ 			{
+ 				char	*val;
+ 				val = PGTYPESnumeric_to_asc((numeric*)sqlda->sqlvar[i].sqldata, -1);
+ 				printf("name sqlda descriptor: '%s' value NUMERIC '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ 				free(val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ 	MYTYPE		*myvar;
+ 	MYNULLTYPE	*mynullvar;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
+ #line 196 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 196 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 199 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 199 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
+ #line 202 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 202 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 205 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 205 "outofscope.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null )", ECPGt_EOIT, ECPGt_EORT);
+ #line 206 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 206 "outofscope.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , '\"a\"' , - 1.0 , 'nan' :: float8 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 207 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 207 "outofscope.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 208 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 208 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 211 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 211 "outofscope.pgc"
+ 
+ 
+ 	/* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE */
+ 
+ 	get_var1(&myvar, &mynullvar);
+ 	open_cur1();
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 218 "outofscope.pgc"
+ 
+ 
+ 	while (1)
+ 	{
+ 		memset(myvar, 0, sizeof(MYTYPE));
+ 		get_record1();
+ 		if (sqlca.sqlcode == ECPG_NOT_FOUND)
+ 			break;
+ 		printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+ 			myvar->id, mynullvar->id ? " (NULL)" : "",
+ 			myvar->t, mynullvar->t ? " (NULL)" : "",
+ 			myvar->d1, mynullvar->d1 ? " (NULL)" : "",
+ 			myvar->d2, mynullvar->d2 ? " (NULL)" : "",
+ 			myvar->c, mynullvar->c ? " (NULL)" : "");
+ 	}
+ 
+ 	close_cur1();
+ 
+ 	/* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE interaction
+ 	 * with a dynamic cursor and prepared statment using an sqlda
+ 	 */
+ 
+ 	prepare2();
+ 	declare2();
+ 	open_cur2();
+ 
+ 	get_record2();
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	close_cur2();
+ 	dealloc_prep2();
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table a1", ECPGt_EOIT, ECPGt_EORT);
+ #line 253 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 253 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 256 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 256 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 259 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 259 "outofscope.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr
*** pgsql.3/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr	2009-12-15 12:40:04.000000000 +0100
***************
*** 0 ****
--- 1,206 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 202: query: create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 202: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 202: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 205: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 205: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 205: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 206: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 206: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 206: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 207: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , '"a"' , - 1.0 , 'nan' :: float8 , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 207: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 207: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 208: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 208: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 208: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 211: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 42: query: declare mycur cursor for select * from a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 42: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 42: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: "a" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: -1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: 2.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: b          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 51: no data found on line 51
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 60: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 60: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 60: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 79: name prepared_stmt; query: "SELECT * FROM a1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 117: query: declare mycur cursor for SELECT * FROM a1 WHERE id = $1; with 1 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 117: using PQexecParams
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 117: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 117: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 135: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 135: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 135: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 135: RESULT: b          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 135: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 126: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 126: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 126: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 107: name prepared_stmt
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 253: query: drop table a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 253: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 253: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 256: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/preproc-outofscope.stdout pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-outofscope.stdout
*** pgsql.3/src/interfaces/ecpg/test/expected/preproc-outofscope.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-outofscope.stdout	2009-12-15 12:39:46.000000000 +0100
***************
*** 0 ****
--- 1,9 ----
+ id=1 t='a' d1=1.000000 d2=2.000000 c = 'a         '
+ id=2 t='' (NULL) d1=0.000000 (NULL) d2=0.000000 (NULL) c = '' (NULL)
+ id=3 t='"a"' d1=-1.000000 d2=nan c = 'a         '
+ id=4 t='b' d1=2.000000 d2=3.000000 c = 'b         '
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'b'
+ name sqlda descriptor: 'd1' value NUMERIC '2.0'
+ name sqlda descriptor: 'd2' value 3.000000
+ name sqlda descriptor: 'c' value 'b         '
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/preproc-struct.c pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-struct.c
*** pgsql.3/src/interfaces/ecpg/test/expected/preproc-struct.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-struct.c	2009-12-15 12:38:38.000000000 +0100
***************
*** 0 ****
--- 1,263 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "struct.pgc"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 5 "struct.pgc"
+ 
+ 
+ /* exec sql begin declare section */
+ 
+ #line 1 "struct.h"
+ 
+   
+ 		
+ 		
+ 		 /* dec_t */
+ 		
+ 		
+ 
+    typedef struct mytype  MYTYPE ;
+ 
+ #line 9 "struct.h"
+ 
+ 
+   
+ 		
+ 		
+ 		
+ 		
+ 		
+ 
+    typedef struct mynulltype  MYNULLTYPE ;
+ 
+ #line 18 "struct.h"
+ 
+ 
+ #line 8 "struct.pgc"
+ 
+ struct mytype { 
+ #line 3 "struct.h"
+  int id ;
+  
+ #line 4 "struct.h"
+  char t [ 64 ] ;
+  
+ #line 5 "struct.h"
+  double d1 ;
+  
+ #line 6 "struct.h"
+  double d2 ;
+  
+ #line 7 "struct.h"
+  char c [ 30 ] ;
+  } ; struct mynulltype { 
+ #line 12 "struct.h"
+  int id ;
+  
+ #line 13 "struct.h"
+  int t ;
+  
+ #line 14 "struct.h"
+  int d1 ;
+  
+ #line 15 "struct.h"
+  int d2 ;
+  
+ #line 16 "struct.h"
+  int c ;
+  } ;/* exec sql end declare section */
+ #line 9 "struct.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 11 "struct.pgc"
+ 
+ 
+ int
+ main (void)
+ {
+ 	/* exec sql begin declare section */
+ 			
+ 		
+ 	
+ #line 17 "struct.pgc"
+  MYTYPE myvar ;
+  
+ #line 18 "struct.pgc"
+  MYNULLTYPE mynullvar ;
+ /* exec sql end declare section */
+ #line 19 "struct.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
+ #line 26 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 26 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 29 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 29 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
+ #line 32 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 32 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 35 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 35 "struct.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null )", ECPGt_EOIT, ECPGt_EORT);
+ #line 36 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "struct.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , '\"a\"' , - 1.0 , 'nan' :: float8 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 37 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "struct.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 38 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 41 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "struct.pgc"
+ 
+ 
+ 	/* Test DECLARE ... SELECT ... INTO with struct type */
+ 
+ 	ECPGset_var( 0, &( myvar ), __LINE__);\
+  ECPGset_var( 1, &( mynullvar ), __LINE__);\
+  /* declare mycur cursor for select * from a1 */
+ #line 45 "struct.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT, 
+ 	ECPGt_int,&(myvar.id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&(mynullvar.id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&(myvar.t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_int,&(mynullvar.t),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&(myvar.d1),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&(mynullvar.d1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&(myvar.d2),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&(mynullvar.d2),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&(myvar.c),(long)30,(long)1,(30)*sizeof(char), 
+ 	ECPGt_int,&(mynullvar.c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 46 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 46 "struct.pgc"
+ 
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 48 "struct.pgc"
+ 
+ 
+ 	while (1)
+ 	{
+ 		memset(&myvar, 0, sizeof(myvar));
+ 		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch mycur", ECPGt_EOIT, 
+ 	ECPGt_int,&(myvar.id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&(mynullvar.id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&(myvar.t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_int,&(mynullvar.t),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&(myvar.d1),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&(mynullvar.d1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&(myvar.d2),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&(mynullvar.d2),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&(myvar.c),(long)30,(long)1,(30)*sizeof(char), 
+ 	ECPGt_int,&(mynullvar.c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 53 "struct.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 53 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 53 "struct.pgc"
+ 
+ 		printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+ 			myvar.id, mynullvar.id ? " (NULL)" : "",
+ 			myvar.t, mynullvar.t ? " (NULL)" : "",
+ 			myvar.d1, mynullvar.d1 ? " (NULL)" : "",
+ 			myvar.d2, mynullvar.d2 ? " (NULL)" : "",
+ 			myvar.c, mynullvar.c ? " (NULL)" : "");
+ 	}
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur", ECPGt_EOIT, ECPGt_EORT);
+ #line 62 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 62 "struct.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table a1", ECPGt_EOIT, ECPGt_EORT);
+ #line 67 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 67 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 70 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 70 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 73 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 73 "struct.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/preproc-struct.stderr pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-struct.stderr
*** pgsql.3/src/interfaces/ecpg/test/expected/preproc-struct.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-struct.stderr	2009-12-14 14:17:56.000000000 +0100
***************
*** 0 ****
--- 1,136 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: query: create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , '"a"' , - 1.0 , 'nan' :: float8 , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 41: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 46: query: declare mycur cursor for select * from a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 46: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 46: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: "a" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: -1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 2.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: b          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 53: no data found on line 53
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 62: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 67: query: drop table a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 67: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 67: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 70: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/preproc-struct.stdout pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-struct.stdout
*** pgsql.3/src/interfaces/ecpg/test/expected/preproc-struct.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-struct.stdout	2009-12-14 14:17:56.000000000 +0100
***************
*** 0 ****
--- 1,4 ----
+ id=1 t='a' d1=1.000000 d2=2.000000 c = 'a         '
+ id=2 t='' (NULL) d1=0.000000 (NULL) d2=0.000000 (NULL) c = '' (NULL)
+ id=3 t='"a"' d1=-1.000000 d2=nan c = 'a         '
+ id=4 t='b' d1=2.000000 d2=3.000000 c = 'b         '
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/sql-binary.c pgsql.4.1/src/interfaces/ecpg/test/expected/sql-binary.c
*** pgsql.3/src/interfaces/ecpg/test/expected/sql-binary.c	2009-08-07 13:06:28.000000000 +0200
--- pgsql.4.1/src/interfaces/ecpg/test/expected/sql-binary.c	2009-12-15 12:41:04.000000000 +0100
*************** main (void)
*** 107,113 ****
        exit (sqlca.sqlcode);
      }
  
!   /* declare C cursor for select name , accs , byte from empl where idnum = $1  */
  #line 58 "binary.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select name , accs , byte from empl where idnum = $1 ", 
--- 107,114 ----
        exit (sqlca.sqlcode);
      }
  
!   ECPGset_var( 0, &( empl.idnum ), __LINE__);\
!  /* declare C cursor for select name , accs , byte from empl where idnum = $1  */
  #line 58 "binary.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select name , accs , byte from empl where idnum = $1 ", 
*************** main (void)
*** 133,139 ****
    printf ("name=%s, accs=%d byte=%s\n", empl.name, empl.accs, empl.byte);
  
    memset(empl.name, 0, 21L);
!   /* declare B binary cursor for select name , accs , byte from empl where idnum = $1  */
  #line 70 "binary.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare B binary cursor for select name , accs , byte from empl where idnum = $1 ", 
--- 134,141 ----
    printf ("name=%s, accs=%d byte=%s\n", empl.name, empl.accs, empl.byte);
  
    memset(empl.name, 0, 21L);
!   ECPGset_var( 1, &( empl.idnum ), __LINE__);\
!  /* declare B binary cursor for select name , accs , byte from empl where idnum = $1  */
  #line 70 "binary.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare B binary cursor for select name , accs , byte from empl where idnum = $1 ", 
*************** main (void)
*** 166,172 ****
  	printf("(%o)", (unsigned char)empl.byte[i]);
    printf("\n");
  
!   /* declare A binary cursor for select byte from empl where idnum = $1  */
  #line 87 "binary.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare A binary cursor for select byte from empl where idnum = $1 ", 
--- 168,175 ----
  	printf("(%o)", (unsigned char)empl.byte[i]);
    printf("\n");
  
!   ECPGset_var( 2, &( empl.idnum ), __LINE__);\
!  /* declare A binary cursor for select byte from empl where idnum = $1  */
  #line 87 "binary.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare A binary cursor for select byte from empl where idnum = $1 ", 
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/preproc/Makefile pgsql.4.1/src/interfaces/ecpg/test/preproc/Makefile
*** pgsql.3/src/interfaces/ecpg/test/preproc/Makefile	2009-12-14 13:59:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/preproc/Makefile	2009-12-15 12:22:31.000000000 +0100
*************** TESTS = array_of_struct array_of_struct.
*** 11,16 ****
--- 11,18 ----
  	define define.c \
  	init init.c \
  	strings strings.c \
+ 	struct struct.c \
+ 	outofscope outofscope.c \
  	type type.c \
  	variable variable.c \
  	whenever whenever.c
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/preproc/outofscope.pgc pgsql.4.1/src/interfaces/ecpg/test/preproc/outofscope.pgc
*** pgsql.3/src/interfaces/ecpg/test/preproc/outofscope.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/preproc/outofscope.pgc	2009-12-15 12:39:00.000000000 +0100
***************
*** 0 ****
--- 1,262 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ #include <limits.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql include sqlda.h;
+ exec sql include pgtypes_numeric.h;
+ 
+ exec sql begin declare section;
+ exec sql include struct.h;
+ exec sql end declare section;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ /* Functions for test 1 */
+ 
+ static void
+ get_var1(MYTYPE **myvar0, MYNULLTYPE **mynullvar0)
+ {
+ 	exec sql begin declare section;
+ 	MYTYPE		*myvar = malloc(sizeof(MYTYPE));
+ 	MYNULLTYPE	*mynullvar = malloc(sizeof(MYNULLTYPE));
+ 	exec sql end declare section;
+ 
+ 	/* Test DECLARE ... SELECT ... INTO with pointers */
+ 
+ 	exec sql declare mycur cursor for select * INTO :myvar :mynullvar from a1;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ 
+ 	*myvar0 = myvar;
+ 	*mynullvar0 = mynullvar;
+ }
+ 
+ static void
+ open_cur1(void)
+ {
+ 	exec sql open mycur;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ get_record1(void)
+ {
+ 	exec sql fetch mycur;
+ 
+ 	if (sqlca.sqlcode != 0 && sqlca.sqlcode != ECPG_NOT_FOUND)
+ 		exit(1);
+ }
+ 
+ static void
+ close_cur1(void)
+ {
+ 	exec sql close mycur;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ /* Functions for test 2 */
+ 
+ pg_sqlda_t	*inp_sqlda, *outp_sqlda;
+ 
+ exec sql begin declare section;
+ char	*stmt2 = "SELECT * FROM a1 WHERE id = ?";
+ char	*curname2 = "mycur";
+ int	id;
+ exec sql end declare section;
+ 
+ static void
+ prepare2(void)
+ {
+ 	exec sql prepare prepared_stmt from :stmt2;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ 
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 	id = 4;
+ }
+ 
+ static void
+ declare2(void)
+ {
+ 	exec sql declare :curname2 cursor for prepared_stmt;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ dealloc_prep2(void)
+ {
+ 	exec sql deallocate prepare prepared_stmt;
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ }
+ 
+ static void
+ open_cur2(void)
+ {
+ 	exec sql open :curname2 using descriptor inp_sqlda;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ close_cur2(void)
+ {
+ 	exec sql close :curname2;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ get_record2(void)
+ {
+ 	exec sql fetch :curname2 into descriptor outp_sqlda;
+ 
+ 	if (sqlca.sqlcode != 0 && sqlca.sqlcode != ECPG_NOT_FOUND)
+ 		exit(1);
+ }
+ 
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (outp_sqlda->sqlvar[i].sqlind && *(outp_sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", outp_sqlda->sqlvar[i].sqlname);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case ECPGt_char:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_int:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ #if (LONG_BIT == 64) /* Defined via <limits.h> */
+ 		case ECPGt_long:
+ #else
+ # if (LONG_BIT = 32)
+ 		case ECPGt_long_long:
+ # else
+ #  error Neither "long" nor "long long" are 64-bit
+ # endif
+ #endif
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_double: 
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_numeric:
+ 			{
+ 				char	*val;
+ 				val = PGTYPESnumeric_to_asc((numeric*)sqlda->sqlvar[i].sqldata, -1);
+ 				printf("name sqlda descriptor: '%s' value NUMERIC '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ 				free(val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ 	MYTYPE		*myvar;
+ 	MYNULLTYPE	*mynullvar;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table a1(id serial primary key, t text, d1 numeric, d2 float8, c character(10));
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, 'a', 1.0, 2, 'a');
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, null, null, null, null);
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, '"a"', -1.0, 'nan'::float8, 'a');
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, 'b', 2.0, 3, 'b');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE */
+ 
+ 	get_var1(&myvar, &mynullvar);
+ 	open_cur1();
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	while (1)
+ 	{
+ 		memset(myvar, 0, sizeof(MYTYPE));
+ 		get_record1();
+ 		if (sqlca.sqlcode == ECPG_NOT_FOUND)
+ 			break;
+ 		printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+ 			myvar->id, mynullvar->id ? " (NULL)" : "",
+ 			myvar->t, mynullvar->t ? " (NULL)" : "",
+ 			myvar->d1, mynullvar->d1 ? " (NULL)" : "",
+ 			myvar->d2, mynullvar->d2 ? " (NULL)" : "",
+ 			myvar->c, mynullvar->c ? " (NULL)" : "");
+ 	}
+ 
+ 	close_cur1();
+ 
+ 	/* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE interaction
+ 	 * with a dynamic cursor and prepared statment using an sqlda
+ 	 */
+ 
+ 	prepare2();
+ 	declare2();
+ 	open_cur2();
+ 
+ 	get_record2();
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	close_cur2();
+ 	dealloc_prep2();
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table a1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/preproc/struct.h pgsql.4.1/src/interfaces/ecpg/test/preproc/struct.h
*** pgsql.3/src/interfaces/ecpg/test/preproc/struct.h	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/preproc/struct.h	2009-12-14 14:17:39.000000000 +0100
***************
*** 0 ****
--- 1,18 ----
+ 
+ struct mytype {
+ 	int	id;
+ 	char	t[64];
+ 	double	d1; /* dec_t */
+ 	double	d2;
+ 	char	c[30];
+ };
+ typedef struct mytype MYTYPE;
+ 
+ struct mynulltype {
+ 	int	id;
+ 	int	t;
+ 	int	d1;
+ 	int	d2;
+ 	int	c;
+ };
+ typedef struct mynulltype MYNULLTYPE;
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/preproc/struct.pgc pgsql.4.1/src/interfaces/ecpg/test/preproc/struct.pgc
*** pgsql.3/src/interfaces/ecpg/test/preproc/struct.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/preproc/struct.pgc	2009-12-14 14:17:39.000000000 +0100
***************
*** 0 ****
--- 1,76 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql begin declare section;
+ exec sql include struct.h;
+ exec sql end declare section;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ int
+ main (void)
+ {
+ 	exec sql begin declare section;
+ 	MYTYPE		myvar;
+ 	MYNULLTYPE	mynullvar;
+ 	exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table a1(id serial primary key, t text, d1 numeric, d2 float8, c character(10));
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, 'a', 1.0, 2, 'a');
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, null, null, null, null);
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, '"a"', -1.0, 'nan'::float8, 'a');
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, 'b', 2.0, 3, 'b');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* Test DECLARE ... SELECT ... INTO with struct type */
+ 
+ 	exec sql declare mycur cursor for select * into :myvar :mynullvar from a1;
+ 	exec sql open mycur;
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	while (1)
+ 	{
+ 		memset(&myvar, 0, sizeof(myvar));
+ 		exec sql fetch mycur;
+ 		printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+ 			myvar.id, mynullvar.id ? " (NULL)" : "",
+ 			myvar.t, mynullvar.t ? " (NULL)" : "",
+ 			myvar.d1, mynullvar.d1 ? " (NULL)" : "",
+ 			myvar.d2, mynullvar.d2 ? " (NULL)" : "",
+ 			myvar.c, mynullvar.c ? " (NULL)" : "");
+ 	}
+ 
+ 	exec sql close mycur;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table a1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
#76Boszormenyi Zoltan
zb@cybertec.at
In reply to: Boszormenyi Zoltan (#75)
1 attachment(s)
Re: ECPG patch N+1, fix auto-prepare

Hi,

here's another patch that aims to fix auto-prepare.

The reason is, that in the project porting from Informix,
a small test case that used a cursor and two small SELECTs
issued for every record retrieved by the cursor showed that
for this case, the ESQL compiled binary finished about 60%
faster then the ECPG compiled counterpart running against
PostgreSQL. The cursor retrieved a little over 60'000 records.

We have modified the test code to prepare the two SELECTs
and now the new test code was faster then the ESQL/Informix
code, parsing and planning the two small SELECTs had such
an accumulated runtime effect.

Then we looked at ECPG and discovered that it already has
the auto-prepare feature, and tried it using "ecpg -r prepare".

However, it turned out that the auto-prepare feature is
over-zealous, it tries to prepare statements that are rejected
by the server, returning -400 (ECPG_PGSQL). One example is

char *sqlstr = "SELECT ...";

EXEC SQL PREPARE stmt1 FROM :sqlstr;
EXEC SQL DECLARE cur1 CURSOR FOR stmt1;

The attached patch is an attempt to make the preprocessor
only pass ECPGst_prepnormal when it's definitely appropriate,
i.e. only for DELETE, INSERT, UPDATE and SELECT(-like)
statements in the grammar.

Comments?

Best regards,
Zolt�n B�sz�rm�nyi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

Attachments:

6-pg85-fix-autoprepare-1-ctxdiff.patchtext/x-patch; name=6-pg85-fix-autoprepare-1-ctxdiff.patchDownload
diff -dcrpN pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.addons pgsql.6/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.addons	2009-12-15 12:15:49.000000000 +0100
--- pgsql.6/src/interfaces/ecpg/preproc/ecpg.addons	2009-12-15 13:18:05.000000000 +0100
*************** ECPG: stmtClosePortalStmt block
*** 15,21 ****
  			}
  		}
  
! 		output_statement($1, 0, ECPGst_normal);
  	}
  ECPG: stmtDeallocateStmt block
  	{
--- 15,21 ----
  			}
  		}
  
! 		output_statement($1, 0, ECPGst_normal, false);
  	}
  ECPG: stmtDeallocateStmt block
  	{
*************** ECPG: stmtDeallocateStmt block
*** 26,46 ****
  	}
  ECPG: stmtDeclareCursorStmt block
  	{ output_simple_statement($1); }
- ECPG: stmtDeleteStmt block
  ECPG: stmtDiscardStmt block
  ECPG: stmtFetchStmt block
  ECPG: stmtInsertStmt block
  ECPG: stmtSelectStmt block
  ECPG: stmtUpdateStmt block
! 	{ output_statement($1, 1, ECPGst_normal); }
  ECPG: stmtExecuteStmt block
! 	{ output_statement($1, 1, ECPGst_execute); }
  ECPG: stmtPrepareStmt block
  	{
  		if ($1.type == NULL || strlen($1.type) == 0)
  			output_prepare_statement($1.name, $1.stmt);
! 		else	
! 			output_statement(cat_str(5, make_str("prepare"), $1.name, $1.type, make_str("as"), $1.stmt), 0, ECPGst_normal);
  	}
  ECPG: stmtTransactionStmt block
  	{
--- 26,47 ----
  	}
  ECPG: stmtDeclareCursorStmt block
  	{ output_simple_statement($1); }
  ECPG: stmtDiscardStmt block
  ECPG: stmtFetchStmt block
+ 	{ output_statement($1, 1, ECPGst_normal, false); }
+ ECPG: stmtDeleteStmt block
  ECPG: stmtInsertStmt block
  ECPG: stmtSelectStmt block
  ECPG: stmtUpdateStmt block
! 	{ output_statement($1, 1, ECPGst_normal, auto_prepare); }
  ECPG: stmtExecuteStmt block
! 	{ output_statement($1, 1, ECPGst_execute, false); }
  ECPG: stmtPrepareStmt block
  	{
  		if ($1.type == NULL || strlen($1.type) == 0)
  			output_prepare_statement($1.name, $1.stmt);
! 		else
! 			output_statement(cat_str(5, make_str("prepare"), $1.name, $1.type, make_str("as"), $1.stmt), 0, ECPGst_normal, false);
  	}
  ECPG: stmtTransactionStmt block
  	{
*************** ECPG: stmtViewStmt rule
*** 101,107 ****
  		whenever_action(2);
  		free($1);
  	}
! 	| ECPGExecuteImmediateStmt	{ output_statement($1, 0, ECPGst_exec_immediate); }
  	| ECPGFree
  	{
  		const char *con = connection ? connection : "NULL";
--- 102,108 ----
  		whenever_action(2);
  		free($1);
  	}
! 	| ECPGExecuteImmediateStmt	{ output_statement($1, 0, ECPGst_exec_immediate, false); }
  	| ECPGFree
  	{
  		const char *con = connection ? connection : "NULL";
*************** ECPG: stmtViewStmt rule
*** 133,139 ****
  		if ((ptr = add_additional_variables($1, true)) != NULL)
  		{
  			connection = ptr->connection ? mm_strdup(ptr->connection) : NULL;
! 			output_statement(mm_strdup(ptr->command), 0, 0);
  			ptr->opened = true;
  		}
  	}
--- 134,140 ----
  		if ((ptr = add_additional_variables($1, true)) != NULL)
  		{
  			connection = ptr->connection ? mm_strdup(ptr->connection) : NULL;
! 			output_statement(mm_strdup(ptr->command), 0, ECPGst_normal, false);
  			ptr->opened = true;
  		}
  	}
diff -dcrpN pgsql.4.1/src/interfaces/ecpg/preproc/extern.h pgsql.6/src/interfaces/ecpg/preproc/extern.h
*** pgsql.4.1/src/interfaces/ecpg/preproc/extern.h	2009-12-15 12:07:20.000000000 +0100
--- pgsql.6/src/interfaces/ecpg/preproc/extern.h	2009-12-15 13:46:55.000000000 +0100
*************** extern const char *get_dtype(enum ECPGdt
*** 64,70 ****
  extern void lex_init(void);
  extern char *make_str(const char *);
  extern void output_line_number(void);
! extern void output_statement(char *, int, enum ECPG_statement_type);
  extern void output_prepare_statement(char *, char *);
  extern void output_deallocate_prepare_statement(char *);
  extern void output_simple_statement(char *);
--- 64,70 ----
  extern void lex_init(void);
  extern char *make_str(const char *);
  extern void output_line_number(void);
! extern void output_statement(char *, int, enum ECPG_statement_type, int);
  extern void output_prepare_statement(char *, char *);
  extern void output_deallocate_prepare_statement(char *);
  extern void output_simple_statement(char *);
diff -dcrpN pgsql.4.1/src/interfaces/ecpg/preproc/output.c pgsql.6/src/interfaces/ecpg/preproc/output.c
*** pgsql.4.1/src/interfaces/ecpg/preproc/output.c	2009-06-13 18:25:05.000000000 +0200
--- pgsql.6/src/interfaces/ecpg/preproc/output.c	2009-12-15 13:12:37.000000000 +0100
*************** hashline_number(void)
*** 106,112 ****
  }
  
  void
! output_statement(char *stmt, int whenever_mode, enum ECPG_statement_type st)
  {
  
  	fprintf(yyout, "{ ECPGdo(__LINE__, %d, %d, %s, %d, ", compat, force_indicator, connection ? connection : "NULL", questionmarks);
--- 106,112 ----
  }
  
  void
! output_statement(char *stmt, int whenever_mode, enum ECPG_statement_type st, int auto_prepare)
  {
  
  	fprintf(yyout, "{ ECPGdo(__LINE__, %d, %d, %s, %d, ", compat, force_indicator, connection ? connection : "NULL", questionmarks);
diff -dcrpN pgsql.4.1/src/interfaces/ecpg/preproc/parse.pl pgsql.6/src/interfaces/ecpg/preproc/parse.pl
*** pgsql.4.1/src/interfaces/ecpg/preproc/parse.pl	2009-11-26 18:57:00.000000000 +0100
--- pgsql.6/src/interfaces/ecpg/preproc/parse.pl	2009-12-15 13:23:06.000000000 +0100
*************** sub dump_fields {
*** 441,447 ****
  	# we're in the stmt: rule
  	if ($len) {
  	    # or just the statement ...
! 	    &add_to_buffer('rules', " { output_statement(\$1, 0, ECPGst_normal); }");
  	}
  	else {
  	    &add_to_buffer('rules', " { \$\$ = NULL; }");
--- 441,447 ----
  	# we're in the stmt: rule
  	if ($len) {
  	    # or just the statement ...
! 	    &add_to_buffer('rules', " { output_statement(\$1, 0, ECPGst_normal, false); }");
  	}
  	else {
  	    &add_to_buffer('rules', " { \$\$ = NULL; }");
diff -dcrpN pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-autoprep.c pgsql.6/src/interfaces/ecpg/test/expected/preproc-autoprep.c
*** pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-autoprep.c	2009-05-25 12:08:49.000000000 +0200
--- pgsql.6/src/interfaces/ecpg/test/expected/preproc-autoprep.c	2009-12-15 13:43:11.000000000 +0100
***************
*** 26,143 ****
  int main() {
    /* exec sql begin declare section */
    	     
    
  #line 10 "autoprep.pgc"
   int item [ 4 ] , ind [ 4 ] , i = 1 ;
! /* exec sql end declare section */
  #line 11 "autoprep.pgc"
  
  
    ECPGdebug(1, stderr);
    { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); }
! #line 14 "autoprep.pgc"
  
  
    /* exec sql whenever sql_warning  sqlprint ; */
! #line 16 "autoprep.pgc"
  
    /* exec sql whenever sqlerror  sqlprint ; */
! #line 17 "autoprep.pgc"
  
  
!   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "create table T ( Item1 int , Item2 int )", ECPGt_EOIT, ECPGt_EORT);
! #line 19 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 19 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 19 "autoprep.pgc"
  
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , null )", ECPGt_EOIT, ECPGt_EORT);
! #line 21 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 21 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 21 "autoprep.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , $1  )", 
  	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
! #line 22 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 22 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 22 "autoprep.pgc"
  
    i++;
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , $1  )", 
  	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
! #line 24 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 24 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 24 "autoprep.pgc"
  
    { ECPGprepare(__LINE__, NULL, 0, "i", " insert into T values ( 1 , 2 ) ");
! #line 25 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 25 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 25 "autoprep.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, 1, "i", ECPGt_EOIT, ECPGt_EORT);
! #line 26 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 26 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 26 "autoprep.pgc"
  
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "select Item2 from T order by Item2 nulls last", ECPGt_EOIT, 
  	ECPGt_int,(item),(long)1,(long)4,sizeof(int), 
  	ECPGt_int,(ind),(long)1,(long)4,sizeof(int), ECPGt_EORT);
! #line 28 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 28 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 28 "autoprep.pgc"
  
  
    for (i=0; i<4; i++)
    	printf("item[%d] = %d\n", i, ind[i] ? -1 : item[i]);
  
    /* declare C cursor for select Item1 from T */
- #line 33 "autoprep.pgc"
- 
- 
-   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "declare C cursor for select Item1 from T", ECPGt_EOIT, ECPGt_EORT);
- #line 35 "autoprep.pgc"
- 
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
  #line 35 "autoprep.pgc"
  
- if (sqlca.sqlcode < 0) sqlprint();}
- #line 35 "autoprep.pgc"
  
! 
!   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "fetch 1 in C", ECPGt_EOIT, 
! 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
! 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 37 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
--- 26,139 ----
  int main() {
    /* exec sql begin declare section */
    	     
+ 	  
+ 	   
    
  #line 10 "autoprep.pgc"
   int item [ 4 ] , ind [ 4 ] , i = 1 ;
!  
  #line 11 "autoprep.pgc"
+  int item1 , ind1 ;
+  
+ #line 12 "autoprep.pgc"
+  char sqlstr [ 64 ] = "SELECT item2 FROM T ORDER BY item2 NULLS LAST" ;
+ /* exec sql end declare section */
+ #line 13 "autoprep.pgc"
  
  
    ECPGdebug(1, stderr);
    { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); }
! #line 16 "autoprep.pgc"
  
  
    /* exec sql whenever sql_warning  sqlprint ; */
! #line 18 "autoprep.pgc"
  
    /* exec sql whenever sqlerror  sqlprint ; */
! #line 19 "autoprep.pgc"
  
  
!   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table T ( Item1 int , Item2 int )", ECPGt_EOIT, ECPGt_EORT);
! #line 21 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 21 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 21 "autoprep.pgc"
  
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , null )", ECPGt_EOIT, ECPGt_EORT);
! #line 23 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 23 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 23 "autoprep.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , $1  )", 
  	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
! #line 24 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 24 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 24 "autoprep.pgc"
  
    i++;
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , $1  )", 
  	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
! #line 26 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 26 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 26 "autoprep.pgc"
  
    { ECPGprepare(__LINE__, NULL, 0, "i", " insert into T values ( 1 , 2 ) ");
! #line 27 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 27 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 27 "autoprep.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, 1, "i", ECPGt_EOIT, ECPGt_EORT);
! #line 28 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 28 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 28 "autoprep.pgc"
  
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "select Item2 from T order by Item2 nulls last", ECPGt_EOIT, 
  	ECPGt_int,(item),(long)1,(long)4,sizeof(int), 
  	ECPGt_int,(ind),(long)1,(long)4,sizeof(int), ECPGt_EORT);
! #line 30 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 30 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 30 "autoprep.pgc"
  
  
    for (i=0; i<4; i++)
    	printf("item[%d] = %d\n", i, ind[i] ? -1 : item[i]);
  
    /* declare C cursor for select Item1 from T */
  #line 35 "autoprep.pgc"
  
  
!   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select Item1 from T", ECPGt_EOIT, ECPGt_EORT);
  #line 37 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
*************** if (sqlca.sqlwarn[0] == 'W') sqlprint();
*** 146,164 ****
  if (sqlca.sqlcode < 0) sqlprint();}
  #line 37 "autoprep.pgc"
  
-   printf("i = %d\n", i);
  
!   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "close C", ECPGt_EOIT, ECPGt_EORT);
! #line 40 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 40 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 40 "autoprep.pgc"
  
  
!   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "drop table T", ECPGt_EOIT, ECPGt_EORT);
  #line 42 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
--- 142,162 ----
  if (sqlca.sqlcode < 0) sqlprint();}
  #line 37 "autoprep.pgc"
  
  
!   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in C", ECPGt_EOIT, 
! 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
! 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
! #line 39 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 39 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 39 "autoprep.pgc"
  
+   printf("i = %d\n", i);
  
!   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT);
  #line 42 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 168,174 ****
  #line 42 "autoprep.pgc"
  
  
!   { ECPGdisconnect(__LINE__, "ALL");
  #line 44 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
--- 166,172 ----
  #line 42 "autoprep.pgc"
  
  
!   { ECPGprepare(__LINE__, NULL, 0, "stmt1", sqlstr);
  #line 44 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 178,182 ****
--- 176,251 ----
  #line 44 "autoprep.pgc"
  
  
+   /* declare cur1 cursor for $1 */
+ #line 46 "autoprep.pgc"
+ 
+ 
+   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur1 cursor for $1", 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 48 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 48 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 48 "autoprep.pgc"
+ 
+ 
+   /* exec sql whenever not found  break ; */
+ #line 50 "autoprep.pgc"
+ 
+ 
+   i = 0;
+   while (1)
+   {
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur1", ECPGt_EOIT, 
+ 	ECPGt_int,&(item1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&(ind1),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 55 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 55 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 55 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 55 "autoprep.pgc"
+ 
+ 	printf("item[%d] = %d\n", i, ind1 ? -1 : item1);
+ 	i++;
+   }
+ 
+   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur1", ECPGt_EOIT, ECPGt_EORT);
+ #line 60 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 60 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 60 "autoprep.pgc"
+ 
+ 
+   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table T", ECPGt_EOIT, ECPGt_EORT);
+ #line 62 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 62 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 62 "autoprep.pgc"
+ 
+ 
+   { ECPGdisconnect(__LINE__, "ALL");
+ #line 64 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 64 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 64 "autoprep.pgc"
+ 
+ 
    return 0;
  }
diff -dcrpN pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr pgsql.6/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr
*** pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr	2008-12-30 15:28:02.000000000 +0100
--- pgsql.6/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr	2009-12-15 13:43:21.000000000 +0100
***************
*** 2,131 ****
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 19: statement not in cache; inserting
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 19: name ecpg1; query: "create table T ( Item1 int , Item2 int )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 19: query: create table T ( Item1 int , Item2 int ); with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 19: using PQexecPrepared for "create table T ( Item1 int , Item2 int )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 19: OK: CREATE TABLE
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 21: statement not in cache; inserting
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 21: name ecpg2; query: "insert into T values ( 1 , null )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 21: query: insert into T values ( 1 , null ); with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 21: using PQexecPrepared for "insert into T values ( 1 , null )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 21: OK: INSERT 0 1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 22: statement not in cache; inserting
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 22: name ecpg3; query: "insert into T values ( 1 , $1  )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 22: query: insert into T values ( 1 , $1  ); with 1 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 22: using PQexecPrepared for "insert into T values ( 1 , $1  )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: free_params on line 22: parameter 1 = 1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 22: OK: INSERT 0 1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 24: statement found in cache; entry 1640
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 24: query: insert into T values ( 1 , $1  ); with 1 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 24: using PQexecPrepared for "insert into T values ( 1 , $1  )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: free_params on line 24: parameter 1 = 2
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 24: OK: INSERT 0 1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 25: name i; query: " insert into T values ( 1 , 2 ) "
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 26: query:  insert into T values ( 1 , 2 ) ; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 26: using PQexecPrepared for " insert into T values ( 1 , 2 ) "
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 26: OK: INSERT 0 1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 28: statement not in cache; inserting
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 28: name ecpg4; query: "select Item2 from T order by Item2 nulls last"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 28: query: select Item2 from T order by Item2 nulls last; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 28: using PQexecPrepared for "select Item2 from T order by Item2 nulls last"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 28: correctly got 4 tuples with 1 fields
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 28: RESULT: 1 offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 28: RESULT: 2 offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 28: RESULT: 2 offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 28: RESULT:  offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 35: statement not in cache; inserting
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 35: name ecpg5; query: "declare C cursor for select Item1 from T"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 35: query: declare C cursor for select Item1 from T; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 35: using PQexecPrepared for "declare C cursor for select Item1 from T"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 35: OK: DECLARE CURSOR
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 37: statement not in cache; inserting
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 37: name ecpg6; query: "fetch 1 in C"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 37: query: fetch 1 in C; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 37: using PQexecPrepared for "fetch 1 in C"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 37: correctly got 1 tuples with 1 fields
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 37: RESULT: 1 offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 40: statement not in cache; inserting
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 40: name ecpg7; query: "close C"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 40: query: close C; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 40: using PQexecPrepared for "close C"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 40: OK: CLOSE CURSOR
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 42: statement not in cache; inserting
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 42: name ecpg8; query: "drop table T"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 42: query: drop table T; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 42: using PQexecPrepared for "drop table T"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 42: OK: DROP TABLE
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGdeallocate on line 0: name ecpg8
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGdeallocate on line 0: name ecpg7
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGdeallocate on line 0: name ecpg6
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGdeallocate on line 0: name ecpg5
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGdeallocate on line 0: name ecpg4
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGdeallocate on line 0: name i
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ECPGdeallocate on line 0: name ecpg3
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ECPGdeallocate on line 0: name ecpg2
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ECPGdeallocate on line 0: name ecpg1
--- 2,157 ----
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 21: query: create table T ( Item1 int , Item2 int ); with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 21: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 21: OK: CREATE TABLE
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 23: statement not in cache; inserting
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 23: name ecpg1; query: "insert into T values ( 1 , null )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 23: query: insert into T values ( 1 , null ); with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 23: using PQexecPrepared for "insert into T values ( 1 , null )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 23: OK: INSERT 0 1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 24: statement not in cache; inserting
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 24: name ecpg2; query: "insert into T values ( 1 , $1  )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 24: query: insert into T values ( 1 , $1  ); with 1 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 24: using PQexecPrepared for "insert into T values ( 1 , $1  )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: free_params on line 24: parameter 1 = 1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 24: OK: INSERT 0 1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 26: statement found in cache; entry 1640
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 26: query: insert into T values ( 1 , $1  ); with 1 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 26: using PQexecPrepared for "insert into T values ( 1 , $1  )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: free_params on line 26: parameter 1 = 2
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 26: OK: INSERT 0 1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 27: name i; query: " insert into T values ( 1 , 2 ) "
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 28: query:  insert into T values ( 1 , 2 ) ; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 28: using PQexecPrepared for " insert into T values ( 1 , 2 ) "
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 28: OK: INSERT 0 1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 30: statement not in cache; inserting
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 30: name ecpg3; query: "select Item2 from T order by Item2 nulls last"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 30: query: select Item2 from T order by Item2 nulls last; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 30: using PQexecPrepared for "select Item2 from T order by Item2 nulls last"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 30: correctly got 4 tuples with 1 fields
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 30: RESULT: 1 offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 30: RESULT: 2 offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 30: RESULT: 2 offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 30: RESULT:  offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 37: query: declare C cursor for select Item1 from T; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 37: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 37: OK: DECLARE CURSOR
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 39: query: fetch 1 in C; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 39: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 39: correctly got 1 tuples with 1 fields
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 39: RESULT: 1 offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 42: query: close C; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 42: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 42: OK: CLOSE CURSOR
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 44: name stmt1; query: "SELECT item2 FROM T ORDER BY item2 NULLS LAST"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 48: query: declare cur1 cursor for SELECT item2 FROM T ORDER BY item2 NULLS LAST; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 48: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 48: OK: DECLARE CURSOR
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: correctly got 1 tuples with 1 fields
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 55: RESULT: 1 offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: correctly got 1 tuples with 1 fields
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 55: RESULT: 2 offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: correctly got 1 tuples with 1 fields
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 55: RESULT: 2 offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: correctly got 1 tuples with 1 fields
! [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 55: RESULT:  offset: -1; array: yes
! [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
! [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: using PQexec
! [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: correctly got 0 tuples with 1 fields
! [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: raising sqlcode 100 on line 55: no data found on line 55
! [NO_PID]: sqlca: code: 100, state: 02000
! [NO_PID]: ecpg_execute on line 60: query: close cur1; with 0 parameter(s) on connection regress1
! [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 60: using PQexec
! [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 60: OK: CLOSE CURSOR
! [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 62: query: drop table T; with 0 parameter(s) on connection regress1
! [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 62: using PQexec
! [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 62: OK: DROP TABLE
! [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGdeallocate on line 0: name stmt1
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ECPGdeallocate on line 0: name ecpg3
  [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 0: name i
+ [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ECPGdeallocate on line 0: name ecpg2
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ECPGdeallocate on line 0: name ecpg1
diff -dcrpN pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-autoprep.stdout pgsql.6/src/interfaces/ecpg/test/expected/preproc-autoprep.stdout
*** pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-autoprep.stdout	2007-08-14 12:01:53.000000000 +0200
--- pgsql.6/src/interfaces/ecpg/test/expected/preproc-autoprep.stdout	2009-12-15 13:43:22.000000000 +0100
*************** item[1] = 2
*** 3,5 ****
--- 3,9 ----
  item[2] = 2
  item[3] = -1
  i = 1
+ item[0] = 1
+ item[1] = 2
+ item[2] = 2
+ item[3] = -1
diff -dcrpN pgsql.4.1/src/interfaces/ecpg/test/preproc/autoprep.pgc pgsql.6/src/interfaces/ecpg/test/preproc/autoprep.pgc
*** pgsql.4.1/src/interfaces/ecpg/test/preproc/autoprep.pgc	2009-05-25 12:08:49.000000000 +0200
--- pgsql.6/src/interfaces/ecpg/test/preproc/autoprep.pgc	2009-12-15 13:38:55.000000000 +0100
*************** EXEC SQL INCLUDE ../regression;
*** 8,13 ****
--- 8,15 ----
  int main() {
    EXEC SQL BEGIN DECLARE SECTION;
    	int item[4], ind[4], i = 1;
+ 	int item1, ind1;
+ 	char sqlstr[64] = "SELECT item2 FROM T ORDER BY item2 NULLS LAST";
    EXEC SQL END DECLARE SECTION;
  
    ECPGdebug(1, stderr);
*************** int main() {
*** 39,44 ****
--- 41,64 ----
  
    EXEC SQL CLOSE C;
  
+   EXEC SQL PREPARE stmt1 FROM :sqlstr;
+ 
+   EXEC SQL DECLARE cur1 CURSOR FOR stmt1;
+ 
+   EXEC SQL OPEN cur1;
+ 
+   EXEC SQL WHENEVER NOT FOUND DO BREAK;
+ 
+   i = 0;
+   while (1)
+   {
+ 	EXEC SQL FETCH cur1 INTO :item1:ind1;
+ 	printf("item[%d] = %d\n", i, ind1 ? -1 : item1);
+ 	i++;
+   }
+ 
+   EXEC SQL CLOSE cur1;
+ 
    EXEC SQL DROP TABLE T;
  
    EXEC SQL DISCONNECT ALL;
#77Michael Meskes
meskes@postgresql.org
In reply to: Boszormenyi Zoltan (#76)
Re: ECPG patch N+1, fix auto-prepare

On Tue, Dec 15, 2009 at 02:19:19PM +0100, Boszormenyi Zoltan wrote:

here's another patch that aims to fix auto-prepare.
...
--- pgsql.6/src/interfaces/ecpg/preproc/output.c	2009-12-15 13:12:37.000000000 +0100
*************** hashline_number(void)
*** 106,112 ****
}

void
! output_statement(char *stmt, int whenever_mode, enum ECPG_statement_type st)
{

fprintf(yyout, "{ ECPGdo(__LINE__, %d, %d, %s, %d, ", compat, force_indicator, connection ? connection : "NULL", questionmarks);
--- 106,112 ----
}

void
! output_statement(char *stmt, int whenever_mode, enum ECPG_statement_type st, int auto_prepare)
{

fprintf(yyout, "{ ECPGdo(__LINE__, %d, %d, %s, %d, ", compat, force_indicator, connection ? connection : "NULL", questionmarks);

Why do you add another argument to output_statement? You should easily be able
to use the existing ECPG_statement_type argument for this. How about changing
ECPGst_normal to ECPGst_normal and ECPGst_nonprep or something like this? Or
did I miss something?

Besides I don't think it's a good idea to create a local variable overriding a
global one with the same name.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ: 179140304, AIM/Yahoo/Skype: michaelmeskes, Jabber: meskes@jabber.org
VfL Borussia! Forca Barca! Go SF 49ers! Use: Debian GNU/Linux, PostgreSQL

#78Boszormenyi Zoltan
zb@cybertec.at
In reply to: Michael Meskes (#77)
1 attachment(s)
Re: ECPG patch N+1, fix auto-prepare

Michael Meskes �rta:

On Tue, Dec 15, 2009 at 02:19:19PM +0100, Boszormenyi Zoltan wrote:

here's another patch that aims to fix auto-prepare.
...
--- pgsql.6/src/interfaces/ecpg/preproc/output.c	2009-12-15 13:12:37.000000000 +0100
*************** hashline_number(void)
*** 106,112 ****
}

void
! output_statement(char *stmt, int whenever_mode, enum ECPG_statement_type st)
{

fprintf(yyout, "{ ECPGdo(__LINE__, %d, %d, %s, %d, ", compat, force_indicator, connection ? connection : "NULL", questionmarks);
--- 106,112 ----
}

void
! output_statement(char *stmt, int whenever_mode, enum ECPG_statement_type st, int auto_prepare)
{

fprintf(yyout, "{ ECPGdo(__LINE__, %d, %d, %s, %d, ", compat, force_indicator, connection ? connection : "NULL", questionmarks);

Why do you add another argument to output_statement? You should easily be able
to use the existing ECPG_statement_type argument for this. How about changing
ECPGst_normal to ECPGst_normal and ECPGst_nonprep or something like this? Or
did I miss something?

Besides I don't think it's a good idea to create a local variable overriding a
global one with the same name.

OK, here's another approach. output_statement()'s interface
is kept as the original, and not this function decides which
value it uses. I also introduced
static char *ecpg_statement_type_name[]
for the textual names of the ECPGst_* symbols to keep the
preprocessed code readable, and minimize the impact on the
regression tests. So output_statement() always emits
ECPGst_* symbols in the preprocessed code instead of
ECPGst_normal/prepnormal and numeric value for the
other two cases. This way only 7 regression tests' source
has changed instead of 45... There are less
1 -> ECPGst_execute and
2 -> ECPGst_exec_immediate
changes than
ECPGst_normal -> 0
changes would have been if I chose emitting the numeric value.

Is it acceptable?

Best regards,
Zolt�n B�sz�rm�nyi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

Attachments:

6-pg85-fix-autoprepare-2-ctxdiff.patchtext/x-patch; name=6-pg85-fix-autoprepare-2-ctxdiff.patchDownload
diff -dcrpN pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.addons pgsql.6/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.addons	2009-12-15 12:15:49.000000000 +0100
--- pgsql.6/src/interfaces/ecpg/preproc/ecpg.addons	2009-12-15 17:41:21.000000000 +0100
*************** ECPG: stmtDeallocateStmt block
*** 26,38 ****
  	}
  ECPG: stmtDeclareCursorStmt block
  	{ output_simple_statement($1); }
- ECPG: stmtDeleteStmt block
  ECPG: stmtDiscardStmt block
  ECPG: stmtFetchStmt block
  ECPG: stmtInsertStmt block
  ECPG: stmtSelectStmt block
  ECPG: stmtUpdateStmt block
! 	{ output_statement($1, 1, ECPGst_normal); }
  ECPG: stmtExecuteStmt block
  	{ output_statement($1, 1, ECPGst_execute); }
  ECPG: stmtPrepareStmt block
--- 26,39 ----
  	}
  ECPG: stmtDeclareCursorStmt block
  	{ output_simple_statement($1); }
  ECPG: stmtDiscardStmt block
  ECPG: stmtFetchStmt block
+ 	{ output_statement($1, 1, ECPGst_normal); }
+ ECPG: stmtDeleteStmt block
  ECPG: stmtInsertStmt block
  ECPG: stmtSelectStmt block
  ECPG: stmtUpdateStmt block
! 	{ output_statement($1, 1, auto_prepare ? ECPGst_prepnormal : ECPGst_normal); }
  ECPG: stmtExecuteStmt block
  	{ output_statement($1, 1, ECPGst_execute); }
  ECPG: stmtPrepareStmt block
*************** ECPG: stmtViewStmt rule
*** 133,139 ****
  		if ((ptr = add_additional_variables($1, true)) != NULL)
  		{
  			connection = ptr->connection ? mm_strdup(ptr->connection) : NULL;
! 			output_statement(mm_strdup(ptr->command), 0, 0);
  			ptr->opened = true;
  		}
  	}
--- 134,140 ----
  		if ((ptr = add_additional_variables($1, true)) != NULL)
  		{
  			connection = ptr->connection ? mm_strdup(ptr->connection) : NULL;
! 			output_statement(mm_strdup(ptr->command), 0, ECPGst_normal);
  			ptr->opened = true;
  		}
  	}
diff -dcrpN pgsql.4.1/src/interfaces/ecpg/preproc/output.c pgsql.6/src/interfaces/ecpg/preproc/output.c
*** pgsql.4.1/src/interfaces/ecpg/preproc/output.c	2009-06-13 18:25:05.000000000 +0200
--- pgsql.6/src/interfaces/ecpg/preproc/output.c	2009-12-15 17:21:03.000000000 +0100
*************** hashline_number(void)
*** 105,127 ****
  	return EMPTY;
  }
  
  void
  output_statement(char *stmt, int whenever_mode, enum ECPG_statement_type st)
  {
  
  	fprintf(yyout, "{ ECPGdo(__LINE__, %d, %d, %s, %d, ", compat, force_indicator, connection ? connection : "NULL", questionmarks);
! 	if (st == ECPGst_normal)
  	{
! 		if (auto_prepare)
! 			fputs("ECPGst_prepnormal, \"", yyout);
! 		else
! 			fputs("ECPGst_normal, \"", yyout);
! 
  		output_escaped_str(stmt, false);
  		fputs("\", ", yyout);
  	}
  	else
! 		fprintf(yyout, "%d, %s, ", st, stmt);
  
  	/* dump variables to C file */
  	dump_variables(argsinsert, 1);
--- 105,130 ----
  	return EMPTY;
  }
  
+ static char *ecpg_statement_type_name[] = {
+ 	"ECPGst_normal",
+ 	"ECPGst_execute",
+ 	"ECPGst_exec_immediate",
+ 	"ECPGst_prepnormal"
+ };
+ 
  void
  output_statement(char *stmt, int whenever_mode, enum ECPG_statement_type st)
  {
  
  	fprintf(yyout, "{ ECPGdo(__LINE__, %d, %d, %s, %d, ", compat, force_indicator, connection ? connection : "NULL", questionmarks);
! 	if (st == ECPGst_normal || st == ECPGst_prepnormal)
  	{
! 		fprintf(yyout, "%s, \"", ecpg_statement_type_name[st]);
  		output_escaped_str(stmt, false);
  		fputs("\", ", yyout);
  	}
  	else
! 		fprintf(yyout, "%s, %s, ", ecpg_statement_type_name[st], stmt);
  
  	/* dump variables to C file */
  	dump_variables(argsinsert, 1);
diff -dcrpN pgsql.4.1/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c pgsql.6/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
*** pgsql.4.1/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c	2009-12-14 12:41:24.000000000 +0100
--- pgsql.6/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c	2009-12-15 17:31:04.000000000 +0100
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 429,435 ****
  
  
  	strcpy(msg, "execute");
! 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, 1, "st_id3", 
  	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
  	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
--- 429,435 ----
  
  
  	strcpy(msg, "execute");
! 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_execute, "st_id3", 
  	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
  	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 490,496 ****
  
  
  	strcpy(msg, "execute");
! 	{ ECPGdo(__LINE__, 1, 1, "con2", 0, 1, "st_id4", 
  	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
  	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
--- 490,496 ----
  
  
  	strcpy(msg, "execute");
! 	{ ECPGdo(__LINE__, 1, 1, "con2", 0, ECPGst_execute, "st_id4", 
  	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
  	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
diff -dcrpN pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-autoprep.c pgsql.6/src/interfaces/ecpg/test/expected/preproc-autoprep.c
*** pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-autoprep.c	2009-05-25 12:08:49.000000000 +0200
--- pgsql.6/src/interfaces/ecpg/test/expected/preproc-autoprep.c	2009-12-15 17:31:05.000000000 +0100
***************
*** 26,143 ****
  int main() {
    /* exec sql begin declare section */
    	     
    
  #line 10 "autoprep.pgc"
   int item [ 4 ] , ind [ 4 ] , i = 1 ;
! /* exec sql end declare section */
  #line 11 "autoprep.pgc"
  
  
    ECPGdebug(1, stderr);
    { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); }
! #line 14 "autoprep.pgc"
  
  
    /* exec sql whenever sql_warning  sqlprint ; */
! #line 16 "autoprep.pgc"
  
    /* exec sql whenever sqlerror  sqlprint ; */
! #line 17 "autoprep.pgc"
  
  
!   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "create table T ( Item1 int , Item2 int )", ECPGt_EOIT, ECPGt_EORT);
! #line 19 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 19 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 19 "autoprep.pgc"
  
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , null )", ECPGt_EOIT, ECPGt_EORT);
! #line 21 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 21 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 21 "autoprep.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , $1  )", 
  	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
! #line 22 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 22 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 22 "autoprep.pgc"
  
    i++;
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , $1  )", 
  	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
! #line 24 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 24 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 24 "autoprep.pgc"
  
    { ECPGprepare(__LINE__, NULL, 0, "i", " insert into T values ( 1 , 2 ) ");
! #line 25 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 25 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 25 "autoprep.pgc"
  
!   { ECPGdo(__LINE__, 0, 1, NULL, 0, 1, "i", ECPGt_EOIT, ECPGt_EORT);
! #line 26 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 26 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 26 "autoprep.pgc"
  
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "select Item2 from T order by Item2 nulls last", ECPGt_EOIT, 
  	ECPGt_int,(item),(long)1,(long)4,sizeof(int), 
  	ECPGt_int,(ind),(long)1,(long)4,sizeof(int), ECPGt_EORT);
! #line 28 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 28 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 28 "autoprep.pgc"
  
  
    for (i=0; i<4; i++)
    	printf("item[%d] = %d\n", i, ind[i] ? -1 : item[i]);
  
    /* declare C cursor for select Item1 from T */
- #line 33 "autoprep.pgc"
- 
- 
-   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "declare C cursor for select Item1 from T", ECPGt_EOIT, ECPGt_EORT);
- #line 35 "autoprep.pgc"
- 
- if (sqlca.sqlwarn[0] == 'W') sqlprint();
- #line 35 "autoprep.pgc"
- 
- if (sqlca.sqlcode < 0) sqlprint();}
  #line 35 "autoprep.pgc"
  
  
!   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "fetch 1 in C", ECPGt_EOIT, 
! 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
! 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
  #line 37 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
--- 26,139 ----
  int main() {
    /* exec sql begin declare section */
    	     
+ 	  
+ 	   
    
  #line 10 "autoprep.pgc"
   int item [ 4 ] , ind [ 4 ] , i = 1 ;
!  
  #line 11 "autoprep.pgc"
+  int item1 , ind1 ;
+  
+ #line 12 "autoprep.pgc"
+  char sqlstr [ 64 ] = "SELECT item2 FROM T ORDER BY item2 NULLS LAST" ;
+ /* exec sql end declare section */
+ #line 13 "autoprep.pgc"
  
  
    ECPGdebug(1, stderr);
    { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); }
! #line 16 "autoprep.pgc"
  
  
    /* exec sql whenever sql_warning  sqlprint ; */
! #line 18 "autoprep.pgc"
  
    /* exec sql whenever sqlerror  sqlprint ; */
! #line 19 "autoprep.pgc"
  
  
!   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table T ( Item1 int , Item2 int )", ECPGt_EOIT, ECPGt_EORT);
! #line 21 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 21 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 21 "autoprep.pgc"
  
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , null )", ECPGt_EOIT, ECPGt_EORT);
! #line 23 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 23 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 23 "autoprep.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , $1  )", 
  	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
! #line 24 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 24 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 24 "autoprep.pgc"
  
    i++;
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , $1  )", 
  	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
! #line 26 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 26 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 26 "autoprep.pgc"
  
    { ECPGprepare(__LINE__, NULL, 0, "i", " insert into T values ( 1 , 2 ) ");
! #line 27 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 27 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 27 "autoprep.pgc"
  
!   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "i", ECPGt_EOIT, ECPGt_EORT);
! #line 28 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 28 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 28 "autoprep.pgc"
  
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "select Item2 from T order by Item2 nulls last", ECPGt_EOIT, 
  	ECPGt_int,(item),(long)1,(long)4,sizeof(int), 
  	ECPGt_int,(ind),(long)1,(long)4,sizeof(int), ECPGt_EORT);
! #line 30 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 30 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 30 "autoprep.pgc"
  
  
    for (i=0; i<4; i++)
    	printf("item[%d] = %d\n", i, ind[i] ? -1 : item[i]);
  
    /* declare C cursor for select Item1 from T */
  #line 35 "autoprep.pgc"
  
  
!   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select Item1 from T", ECPGt_EOIT, ECPGt_EORT);
  #line 37 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
*************** if (sqlca.sqlwarn[0] == 'W') sqlprint();
*** 146,164 ****
  if (sqlca.sqlcode < 0) sqlprint();}
  #line 37 "autoprep.pgc"
  
-   printf("i = %d\n", i);
  
!   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "close C", ECPGt_EOIT, ECPGt_EORT);
! #line 40 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 40 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 40 "autoprep.pgc"
  
  
!   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "drop table T", ECPGt_EOIT, ECPGt_EORT);
  #line 42 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
--- 142,162 ----
  if (sqlca.sqlcode < 0) sqlprint();}
  #line 37 "autoprep.pgc"
  
  
!   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in C", ECPGt_EOIT, 
! 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
! 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
! #line 39 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
! #line 39 "autoprep.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
! #line 39 "autoprep.pgc"
  
+   printf("i = %d\n", i);
  
!   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT);
  #line 42 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 168,174 ****
  #line 42 "autoprep.pgc"
  
  
!   { ECPGdisconnect(__LINE__, "ALL");
  #line 44 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
--- 166,172 ----
  #line 42 "autoprep.pgc"
  
  
!   { ECPGprepare(__LINE__, NULL, 0, "stmt1", sqlstr);
  #line 44 "autoprep.pgc"
  
  if (sqlca.sqlwarn[0] == 'W') sqlprint();
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 178,182 ****
--- 176,251 ----
  #line 44 "autoprep.pgc"
  
  
+   /* declare cur1 cursor for $1 */
+ #line 46 "autoprep.pgc"
+ 
+ 
+   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur1 cursor for $1", 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 48 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 48 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 48 "autoprep.pgc"
+ 
+ 
+   /* exec sql whenever not found  break ; */
+ #line 50 "autoprep.pgc"
+ 
+ 
+   i = 0;
+   while (1)
+   {
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur1", ECPGt_EOIT, 
+ 	ECPGt_int,&(item1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&(ind1),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 55 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 55 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 55 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 55 "autoprep.pgc"
+ 
+ 	printf("item[%d] = %d\n", i, ind1 ? -1 : item1);
+ 	i++;
+   }
+ 
+   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur1", ECPGt_EOIT, ECPGt_EORT);
+ #line 60 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 60 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 60 "autoprep.pgc"
+ 
+ 
+   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table T", ECPGt_EOIT, ECPGt_EORT);
+ #line 62 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 62 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 62 "autoprep.pgc"
+ 
+ 
+   { ECPGdisconnect(__LINE__, "ALL");
+ #line 64 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 64 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 64 "autoprep.pgc"
+ 
+ 
    return 0;
  }
diff -dcrpN pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr pgsql.6/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr
*** pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr	2008-12-30 15:28:02.000000000 +0100
--- pgsql.6/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr	2009-12-15 13:43:21.000000000 +0100
***************
*** 2,131 ****
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 19: statement not in cache; inserting
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 19: name ecpg1; query: "create table T ( Item1 int , Item2 int )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 19: query: create table T ( Item1 int , Item2 int ); with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 19: using PQexecPrepared for "create table T ( Item1 int , Item2 int )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 19: OK: CREATE TABLE
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 21: statement not in cache; inserting
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 21: name ecpg2; query: "insert into T values ( 1 , null )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 21: query: insert into T values ( 1 , null ); with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 21: using PQexecPrepared for "insert into T values ( 1 , null )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 21: OK: INSERT 0 1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 22: statement not in cache; inserting
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 22: name ecpg3; query: "insert into T values ( 1 , $1  )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 22: query: insert into T values ( 1 , $1  ); with 1 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 22: using PQexecPrepared for "insert into T values ( 1 , $1  )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: free_params on line 22: parameter 1 = 1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 22: OK: INSERT 0 1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 24: statement found in cache; entry 1640
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 24: query: insert into T values ( 1 , $1  ); with 1 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 24: using PQexecPrepared for "insert into T values ( 1 , $1  )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: free_params on line 24: parameter 1 = 2
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 24: OK: INSERT 0 1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 25: name i; query: " insert into T values ( 1 , 2 ) "
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 26: query:  insert into T values ( 1 , 2 ) ; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 26: using PQexecPrepared for " insert into T values ( 1 , 2 ) "
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 26: OK: INSERT 0 1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 28: statement not in cache; inserting
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 28: name ecpg4; query: "select Item2 from T order by Item2 nulls last"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 28: query: select Item2 from T order by Item2 nulls last; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 28: using PQexecPrepared for "select Item2 from T order by Item2 nulls last"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 28: correctly got 4 tuples with 1 fields
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 28: RESULT: 1 offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 28: RESULT: 2 offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 28: RESULT: 2 offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 28: RESULT:  offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 35: statement not in cache; inserting
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 35: name ecpg5; query: "declare C cursor for select Item1 from T"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 35: query: declare C cursor for select Item1 from T; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 35: using PQexecPrepared for "declare C cursor for select Item1 from T"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 35: OK: DECLARE CURSOR
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 37: statement not in cache; inserting
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 37: name ecpg6; query: "fetch 1 in C"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 37: query: fetch 1 in C; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 37: using PQexecPrepared for "fetch 1 in C"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 37: correctly got 1 tuples with 1 fields
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 37: RESULT: 1 offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 40: statement not in cache; inserting
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 40: name ecpg7; query: "close C"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 40: query: close C; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 40: using PQexecPrepared for "close C"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 40: OK: CLOSE CURSOR
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 42: statement not in cache; inserting
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 42: name ecpg8; query: "drop table T"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 42: query: drop table T; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 42: using PQexecPrepared for "drop table T"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 42: OK: DROP TABLE
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGdeallocate on line 0: name ecpg8
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGdeallocate on line 0: name ecpg7
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGdeallocate on line 0: name ecpg6
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGdeallocate on line 0: name ecpg5
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGdeallocate on line 0: name ecpg4
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGdeallocate on line 0: name i
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ECPGdeallocate on line 0: name ecpg3
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ECPGdeallocate on line 0: name ecpg2
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ECPGdeallocate on line 0: name ecpg1
--- 2,157 ----
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 21: query: create table T ( Item1 int , Item2 int ); with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 21: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 21: OK: CREATE TABLE
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 23: statement not in cache; inserting
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 23: name ecpg1; query: "insert into T values ( 1 , null )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 23: query: insert into T values ( 1 , null ); with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 23: using PQexecPrepared for "insert into T values ( 1 , null )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 23: OK: INSERT 0 1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 24: statement not in cache; inserting
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 24: name ecpg2; query: "insert into T values ( 1 , $1  )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 24: query: insert into T values ( 1 , $1  ); with 1 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 24: using PQexecPrepared for "insert into T values ( 1 , $1  )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: free_params on line 24: parameter 1 = 1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 24: OK: INSERT 0 1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 26: statement found in cache; entry 1640
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 26: query: insert into T values ( 1 , $1  ); with 1 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 26: using PQexecPrepared for "insert into T values ( 1 , $1  )"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: free_params on line 26: parameter 1 = 2
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 26: OK: INSERT 0 1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 27: name i; query: " insert into T values ( 1 , 2 ) "
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 28: query:  insert into T values ( 1 , 2 ) ; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 28: using PQexecPrepared for " insert into T values ( 1 , 2 ) "
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 28: OK: INSERT 0 1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_auto_prepare on line 30: statement not in cache; inserting
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 30: name ecpg3; query: "select Item2 from T order by Item2 nulls last"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 30: query: select Item2 from T order by Item2 nulls last; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 30: using PQexecPrepared for "select Item2 from T order by Item2 nulls last"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 30: correctly got 4 tuples with 1 fields
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 30: RESULT: 1 offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 30: RESULT: 2 offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 30: RESULT: 2 offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 30: RESULT:  offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 37: query: declare C cursor for select Item1 from T; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 37: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 37: OK: DECLARE CURSOR
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 39: query: fetch 1 in C; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 39: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 39: correctly got 1 tuples with 1 fields
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 39: RESULT: 1 offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 42: query: close C; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 42: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 42: OK: CLOSE CURSOR
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGprepare on line 44: name stmt1; query: "SELECT item2 FROM T ORDER BY item2 NULLS LAST"
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 48: query: declare cur1 cursor for SELECT item2 FROM T ORDER BY item2 NULLS LAST; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 48: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 48: OK: DECLARE CURSOR
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: correctly got 1 tuples with 1 fields
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 55: RESULT: 1 offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: correctly got 1 tuples with 1 fields
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 55: RESULT: 2 offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: correctly got 1 tuples with 1 fields
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 55: RESULT: 2 offset: -1; array: yes
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: using PQexec
  [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: correctly got 1 tuples with 1 fields
! [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_get_data on line 55: RESULT:  offset: -1; array: yes
! [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
! [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: using PQexec
! [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 55: correctly got 0 tuples with 1 fields
! [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: raising sqlcode 100 on line 55: no data found on line 55
! [NO_PID]: sqlca: code: 100, state: 02000
! [NO_PID]: ecpg_execute on line 60: query: close cur1; with 0 parameter(s) on connection regress1
! [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 60: using PQexec
! [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 60: OK: CLOSE CURSOR
! [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 62: query: drop table T; with 0 parameter(s) on connection regress1
! [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 62: using PQexec
! [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ecpg_execute on line 62: OK: DROP TABLE
! [NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: ECPGdeallocate on line 0: name stmt1
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ECPGdeallocate on line 0: name ecpg3
  [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 0: name i
+ [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ECPGdeallocate on line 0: name ecpg2
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ECPGdeallocate on line 0: name ecpg1
diff -dcrpN pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-autoprep.stdout pgsql.6/src/interfaces/ecpg/test/expected/preproc-autoprep.stdout
*** pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-autoprep.stdout	2007-08-14 12:01:53.000000000 +0200
--- pgsql.6/src/interfaces/ecpg/test/expected/preproc-autoprep.stdout	2009-12-15 13:43:22.000000000 +0100
*************** item[1] = 2
*** 3,5 ****
--- 3,9 ----
  item[2] = 2
  item[3] = -1
  i = 1
+ item[0] = 1
+ item[1] = 2
+ item[2] = 2
+ item[3] = -1
diff -dcrpN pgsql.4.1/src/interfaces/ecpg/test/expected/sql-desc.c pgsql.6/src/interfaces/ecpg/test/expected/sql-desc.c
*** pgsql.4.1/src/interfaces/ecpg/test/expected/sql-desc.c	2008-12-30 15:28:02.000000000 +0100
--- pgsql.6/src/interfaces/ecpg/test/expected/sql-desc.c	2009-12-15 17:31:05.000000000 +0100
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 133,139 ****
  #line 33 "desc.pgc"
  
  
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, 1, "foo1", 
  	ECPGt_descriptor, "indesc", 0L, 0L, 0L, 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 35 "desc.pgc"
--- 133,139 ----
  #line 33 "desc.pgc"
  
  
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "foo1", 
  	ECPGt_descriptor, "indesc", 0L, 0L, 0L, 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 35 "desc.pgc"
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 160,166 ****
  #line 38 "desc.pgc"
  
  
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, 1, "foo1", 
  	ECPGt_descriptor, "indesc", 0L, 0L, 0L, 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 40 "desc.pgc"
--- 160,166 ----
  #line 38 "desc.pgc"
  
  
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "foo1", 
  	ECPGt_descriptor, "indesc", 0L, 0L, 0L, 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 40 "desc.pgc"
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 187,193 ****
  #line 43 "desc.pgc"
  
  
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, 1, "Foo-1", 
  	ECPGt_descriptor, "indesc", 0L, 0L, 0L, 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 45 "desc.pgc"
--- 187,193 ----
  #line 43 "desc.pgc"
  
  
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "Foo-1", 
  	ECPGt_descriptor, "indesc", 0L, 0L, 0L, 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 45 "desc.pgc"
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 221,227 ****
  #line 50 "desc.pgc"
  
  
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, 1, "foo2", 
  	ECPGt_descriptor, "indesc", 0L, 0L, 0L, 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
  	ECPGt_descriptor, "outdesc", 0L, 0L, 0L, 
--- 221,227 ----
  #line 50 "desc.pgc"
  
  
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "foo2", 
  	ECPGt_descriptor, "indesc", 0L, 0L, 0L, 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
  	ECPGt_descriptor, "outdesc", 0L, 0L, 0L, 
diff -dcrpN pgsql.4.1/src/interfaces/ecpg/test/expected/sql-execute.c pgsql.6/src/interfaces/ecpg/test/expected/sql-execute.c
*** pgsql.4.1/src/interfaces/ecpg/test/expected/sql-execute.c	2008-12-30 15:28:02.000000000 +0100
--- pgsql.6/src/interfaces/ecpg/test/expected/sql-execute.c	2009-12-15 17:31:06.000000000 +0100
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 78,84 ****
  
  
  	sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 1, 'f')");
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, 2, command, ECPGt_EOIT, ECPGt_EORT);
  #line 29 "execute.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
--- 78,84 ----
  
  
  	sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 1, 'f')");
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_exec_immediate, command, ECPGt_EOIT, ECPGt_EORT);
  #line 29 "execute.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 86,92 ****
  
  
  	sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 2, 't')");
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, 2, command, ECPGt_EOIT, ECPGt_EORT);
  #line 32 "execute.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
--- 86,92 ----
  
  
  	sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 2, 't')");
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_exec_immediate, command, ECPGt_EOIT, ECPGt_EORT);
  #line 32 "execute.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 94,100 ****
  
  
  	sprintf(command, "insert into test (name, amount, letter) select name, amount+10, letter from test");
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, 2, command, ECPGt_EOIT, ECPGt_EORT);
  #line 35 "execute.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
--- 94,100 ----
  
  
  	sprintf(command, "insert into test (name, amount, letter) select name, amount+10, letter from test");
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_exec_immediate, command, ECPGt_EOIT, ECPGt_EORT);
  #line 35 "execute.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 110,116 ****
  if (sqlca.sqlcode < 0) sqlprint();}
  #line 40 "execute.pgc"
  
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, 1, "i", 
  	ECPGt_int,&(increment),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 41 "execute.pgc"
--- 110,116 ----
  if (sqlca.sqlcode < 0) sqlprint();}
  #line 40 "execute.pgc"
  
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "i", 
  	ECPGt_int,&(increment),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 41 "execute.pgc"
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 268,274 ****
  if (sqlca.sqlcode < 0) sqlprint();}
  #line 93 "execute.pgc"
  
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, 1, "f", 
  	ECPGt_const,"2",(long)1,(long)1,strlen("2"), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
  	ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), 
--- 268,274 ----
  if (sqlca.sqlcode < 0) sqlprint();}
  #line 93 "execute.pgc"
  
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "f", 
  	ECPGt_const,"2",(long)1,(long)1,strlen("2"), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
  	ECPGt_char,(name),(long)8,(long)8,(8)*sizeof(char), 
diff -dcrpN pgsql.4.1/src/interfaces/ecpg/test/expected/sql-oldexec.c pgsql.6/src/interfaces/ecpg/test/expected/sql-oldexec.c
*** pgsql.4.1/src/interfaces/ecpg/test/expected/sql-oldexec.c	2008-12-30 15:28:02.000000000 +0100
--- pgsql.6/src/interfaces/ecpg/test/expected/sql-oldexec.c	2009-12-15 17:31:07.000000000 +0100
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 78,84 ****
  
  
  	sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 1, 'f')");
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 1, 2, command, ECPGt_EOIT, ECPGt_EORT);
  #line 29 "oldexec.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
--- 78,84 ----
  
  
  	sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 1, 'f')");
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_exec_immediate, command, ECPGt_EOIT, ECPGt_EORT);
  #line 29 "oldexec.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 86,92 ****
  
  
  	sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 2, 't')");
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 1, 2, command, ECPGt_EOIT, ECPGt_EORT);
  #line 32 "oldexec.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
--- 86,92 ----
  
  
  	sprintf(command, "insert into test (name, amount, letter) values ('db: ''r1''', 2, 't')");
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_exec_immediate, command, ECPGt_EOIT, ECPGt_EORT);
  #line 32 "oldexec.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 94,100 ****
  
  
  	sprintf(command, "insert into test (name, amount, letter) select name, amount+10, letter from test");
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 1, 2, command, ECPGt_EOIT, ECPGt_EORT);
  #line 35 "oldexec.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
--- 94,100 ----
  
  
  	sprintf(command, "insert into test (name, amount, letter) select name, amount+10, letter from test");
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_exec_immediate, command, ECPGt_EOIT, ECPGt_EORT);
  #line 35 "oldexec.pgc"
  
  if (sqlca.sqlcode < 0) sqlprint();}
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 110,116 ****
  if (sqlca.sqlcode < 0) sqlprint();}
  #line 40 "oldexec.pgc"
  
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 1, 1, "i", 
  	ECPGt_int,&(increment),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 41 "oldexec.pgc"
--- 110,116 ----
  if (sqlca.sqlcode < 0) sqlprint();}
  #line 40 "oldexec.pgc"
  
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 1, ECPGst_execute, "i", 
  	ECPGt_int,&(increment),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 41 "oldexec.pgc"
diff -dcrpN pgsql.4.1/src/interfaces/ecpg/test/expected/sql-sqlda.c pgsql.6/src/interfaces/ecpg/test/expected/sql-sqlda.c
*** pgsql.4.1/src/interfaces/ecpg/test/expected/sql-sqlda.c	2009-12-14 12:41:24.000000000 +0100
--- pgsql.6/src/interfaces/ecpg/test/expected/sql-sqlda.c	2009-12-15 17:31:06.000000000 +0100
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 437,443 ****
  
  
  	strcpy(msg, "execute");
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, 1, "st_id3", 
  	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
  	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
--- 437,443 ----
  
  
  	strcpy(msg, "execute");
! 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "st_id3", 
  	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
  	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 498,504 ****
  
  
  	strcpy(msg, "execute");
! 	{ ECPGdo(__LINE__, 0, 1, "con2", 0, 1, "st_id4", 
  	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
  	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
--- 498,504 ----
  
  
  	strcpy(msg, "execute");
! 	{ ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_execute, "st_id4", 
  	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
  	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
diff -dcrpN pgsql.4.1/src/interfaces/ecpg/test/expected/thread-prep.c pgsql.6/src/interfaces/ecpg/test/expected/thread-prep.c
*** pgsql.4.1/src/interfaces/ecpg/test/expected/thread-prep.c	2009-05-25 12:08:49.000000000 +0200
--- pgsql.6/src/interfaces/ecpg/test/expected/thread-prep.c	2009-12-15 17:31:07.000000000 +0100
*************** if (sqlca.sqlcode < 0) sqlprint();}
*** 167,173 ****
  if (sqlca.sqlcode < 0) sqlprint();}
  #line 51 "prep.pgc"
  
! 		{ ECPGdo(__LINE__, 0, 1, NULL, 0, 1, "i", 
  	ECPGt_int,&(value),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 52 "prep.pgc"
--- 167,173 ----
  if (sqlca.sqlcode < 0) sqlprint();}
  #line 51 "prep.pgc"
  
! 		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "i", 
  	ECPGt_int,&(value),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 52 "prep.pgc"
diff -dcrpN pgsql.4.1/src/interfaces/ecpg/test/preproc/autoprep.pgc pgsql.6/src/interfaces/ecpg/test/preproc/autoprep.pgc
*** pgsql.4.1/src/interfaces/ecpg/test/preproc/autoprep.pgc	2009-05-25 12:08:49.000000000 +0200
--- pgsql.6/src/interfaces/ecpg/test/preproc/autoprep.pgc	2009-12-15 13:38:55.000000000 +0100
*************** EXEC SQL INCLUDE ../regression;
*** 8,13 ****
--- 8,15 ----
  int main() {
    EXEC SQL BEGIN DECLARE SECTION;
    	int item[4], ind[4], i = 1;
+ 	int item1, ind1;
+ 	char sqlstr[64] = "SELECT item2 FROM T ORDER BY item2 NULLS LAST";
    EXEC SQL END DECLARE SECTION;
  
    ECPGdebug(1, stderr);
*************** int main() {
*** 39,44 ****
--- 41,64 ----
  
    EXEC SQL CLOSE C;
  
+   EXEC SQL PREPARE stmt1 FROM :sqlstr;
+ 
+   EXEC SQL DECLARE cur1 CURSOR FOR stmt1;
+ 
+   EXEC SQL OPEN cur1;
+ 
+   EXEC SQL WHENEVER NOT FOUND DO BREAK;
+ 
+   i = 0;
+   while (1)
+   {
+ 	EXEC SQL FETCH cur1 INTO :item1:ind1;
+ 	printf("item[%d] = %d\n", i, ind1 ? -1 : item1);
+ 	i++;
+   }
+ 
+   EXEC SQL CLOSE cur1;
+ 
    EXEC SQL DROP TABLE T;
  
    EXEC SQL DISCONNECT ALL;
#79Michael Meskes
meskes@postgresql.org
In reply to: Boszormenyi Zoltan (#78)
Re: ECPG patch N+1, fix auto-prepare

OK, here's another approach. output_statement()'s interface
is kept as the original, and not this function decides which

I still think this could be solved more easily.

value it uses. I also introduced
static char *ecpg_statement_type_name[]
for the textual names of the ECPGst_* symbols to keep the
preprocessed code readable, and minimize the impact on the
regression tests. So output_statement() always emits
ECPGst_* symbols in the preprocessed code instead of
ECPGst_normal/prepnormal and numeric value for the
other two cases. This way only 7 regression tests' source
has changed instead of 45... There are less
1 -> ECPGst_execute and
2 -> ECPGst_exec_immediate
changes than
ECPGst_normal -> 0
changes would have been if I chose emitting the numeric value.

Is it acceptable?

Yes sure.

I changed some small parts of your patch (see above) and will commit in a few
minutes. Just running regression tests.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ: 179140304, AIM/Yahoo/Skype: michaelmeskes, Jabber: meskes@jabber.org
VfL Borussia! Forca Barca! Go SF 49ers! Use: Debian GNU/Linux, PostgreSQL

#80Boszormenyi Zoltan
zb@cybertec.at
In reply to: Michael Meskes (#79)
Re: ECPG patch N+1, fix auto-prepare

Michael Meskes �rta:

OK, here's another approach. output_statement()'s interface
is kept as the original, and not this function decides which

I still think this could be solved more easily.

Thanks very much for committing it.

But I don't understand your change. My code was:

=====================================
ecpg.addons:
ECPG: stmtDeleteStmt block
ECPG: stmtInsertStmt block
ECPG: stmtSelectStmt block
ECPG: stmtUpdateStmt block
{ output_statement($1, 1, auto_prepare ? ECPGst_prepnormal :
ECPGst_normal); }
=====================================
output.c:
static char *ecpg_statement_type_name[] = {
"ECPGst_normal",
"ECPGst_execute",
"ECPGst_exec_immediate",
"ECPGst_prepnormal"
};

void
output_statement(char *stmt, int whenever_mode, enum ECPG_statement_type st)
{

fprintf(yyout, "{ ECPGdo(__LINE__, %d, %d, %s, %d, ", compat,
force_indicator, connection ? connection : "NULL", questionmarks);
if (st == ECPGst_normal || st == ECPGst_prepnormal)
{
fprintf(yyout, "%s, \"", ecpg_statement_type_name[st]);
output_escaped_str(stmt, false);
fputs("\", ", yyout);
}
else
fprintf(yyout, "%s, %s, ", ecpg_statement_type_name[st],
stmt);
=====================================

So the ECPGst_normal vs. prepnormal is decided at the caller
and output_statement() is simplified a bit vs the original.

Your code is:

=====================================
ecpg.addons:
ECPG: stmtDeleteStmt block
ECPG: stmtInsertStmt block
ECPG: stmtSelectStmt block
ECPG: stmtUpdateStmt block
{ output_statement($1, 1, ECPGst_prepnormal); }
=====================================
output.c:
static char *ecpg_statement_type_name[] = {
"ECPGst_normal",
"ECPGst_execute",
"ECPGst_exec_immediate",
"ECPGst_prepnormal"
};

void
output_statement(char *stmt, int whenever_mode, enum ECPG_statement_type st)
{
fprintf(yyout, "{ ECPGdo(__LINE__, %d, %d, %s, %d, ", compat,
force_indicator, connection ? connection : "NULL", questionmarks);
if (st == ECPGst_execute || st == ECPGst_exec_immediate)
{
fprintf(yyout, "%s, %s, ", ecpg_statement_type_name[st],
stmt);
}
else
{
if (st == ECPGst_prepnormal && auto_prepare)
fputs("ECPGst_prepnormal, \"", yyout);
else
fputs("ECPGst_normal, \"", yyout);

output_escaped_str(stmt, false);
fputs("\", ", yyout);
}
=====================================

Your code in ecpg.addons calls output_statement()
unconditionally with ECPGst_prepnormal and
output_statement() decides what to do with the
"auto_prepare" global variable. Your code doesn't
seem more readable than mine, but does the same
with the currently existing callers.

value it uses. I also introduced
static char *ecpg_statement_type_name[]
for the textual names of the ECPGst_* symbols to keep the
preprocessed code readable, and minimize the impact on the
regression tests. So output_statement() always emits
ECPGst_* symbols in the preprocessed code instead of
ECPGst_normal/prepnormal and numeric value for the
other two cases. This way only 7 regression tests' source
has changed instead of 45... There are less
1 -> ECPGst_execute and
2 -> ECPGst_exec_immediate
changes than
ECPGst_normal -> 0
changes would have been if I chose emitting the numeric value.

Is it acceptable?

Yes sure.

I changed some small parts of your patch (see above) and will commit in a few
minutes. Just running regression tests.

Okay, I have to rebase my SQLDA and DESCRIBE
patches again, since the regression tests' results may
have changed beause of this patch. I will post them soon.

Again, thanks for committing it.

Best regards,
Zolt�n B�sz�rm�nyi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

#81Michael Meskes
meskes@postgresql.org
In reply to: Boszormenyi Zoltan (#80)
Re: ECPG patch N+1, fix auto-prepare

On Wed, Dec 16, 2009 at 11:54:41AM +0100, Boszormenyi Zoltan wrote:

Your code in ecpg.addons calls output_statement()
unconditionally with ECPGst_prepnormal and
output_statement() decides what to do with the
"auto_prepare" global variable. Your code doesn't
seem more readable than mine, but does the same
with the currently existing callers.

It better should do the same. :-)

Maybe finding it simpler this way just comes from me being used to the way this
part of the source code works. It's essantially the same, I only moved that one
auto_prepare test out of the parser.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ: 179140304, AIM/Yahoo/Skype: michaelmeskes, Jabber: meskes@jabber.org
VfL Borussia! Forca Barca! Go SF 49ers! Use: Debian GNU/Linux, PostgreSQL

#82Boszormenyi Zoltan
zb@cybertec.at
In reply to: Boszormenyi Zoltan (#72)
1 attachment(s)
Re: ECPG patch 2, SQLDA support

Rebased to current CVS HEAD after my auto-prepare fix
was added. The new regression tests' C source has changed
because of this.

The other two patches don't need re-posting, as
they apply with minimal fuzz and no rejects and
their regression tests work as-is.

Best regards,
Zoltán Böszörményi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

Attachments:

2-pg85-sqlda-18-ctxdiff.patchtext/x-patch; name=2-pg85-sqlda-18-ctxdiff.patchDownload
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/execute.c pgsql.2/src/interfaces/ecpg/ecpglib/execute.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/execute.c	2009-09-03 14:37:34.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/ecpglib/execute.c	2009-12-16 14:03:43.000000000 +0100
***************
*** 25,30 ****
--- 25,31 ----
  #include "ecpgerrno.h"
  #include "extern.h"
  #include "sqlca.h"
+ #include "sqlda.h"
  #include "sql3types.h"
  #include "pgtypes_numeric.h"
  #include "pgtypes_date.h"
*************** ecpg_store_input(const int lineno, const
*** 1033,1038 ****
--- 1034,1040 ----
  				break;
  
  			case ECPGt_descriptor:
+ 			case ECPGt_sqlda:
  				break;
  
  			default:
*************** ecpg_execute(struct statement * stmt)
*** 1172,1177 ****
--- 1174,1234 ----
  			if (desc->count == desc_counter)
  				desc_counter = 0;
  		}
+ 		else if (var->type == ECPGt_sqlda)
+ 		{
+ 			pg_sqlda_t	   *sqlda = *(pg_sqlda_t **)var->pointer;
+ 			struct variable	desc_inlist;
+ 			int		i;
+ 
+ 			if (sqlda == NULL)
+ 				return false;
+ 
+ 			desc_counter++;
+ 			for (i = 0; i < sqlda->sqld; i++)
+ 			{
+ 				if (i + 1 == desc_counter)
+ 				{
+ 					desc_inlist.type = sqlda->sqlvar[i].sqltype;
+ 					desc_inlist.value = sqlda->sqlvar[i].sqldata;
+ 					desc_inlist.pointer = &(sqlda->sqlvar[i].sqldata);
+ 					switch (desc_inlist.type)
+ 					{
+ 						case ECPGt_char:
+ 						case ECPGt_varchar:
+ 							desc_inlist.varcharsize = strlen(sqlda->sqlvar[i].sqldata);
+ 							break;
+ 						default:
+ 							desc_inlist.varcharsize = 0;
+ 							break;
+ 					}
+ 					desc_inlist.arrsize = 1;
+ 					desc_inlist.offset = 0;
+ 					if (sqlda->sqlvar[i].sqlind)
+ 					{
+ 						desc_inlist.ind_type = ECPGt_short;
+ 						/* ECPG expects indicator value < 0 */
+ 						if (*(sqlda->sqlvar[i].sqlind))
+ 							*(sqlda->sqlvar[i].sqlind) = -1;
+ 						desc_inlist.ind_value = sqlda->sqlvar[i].sqlind;
+ 						desc_inlist.ind_pointer = &(sqlda->sqlvar[i].sqlind);
+ 						desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = 1;
+ 						desc_inlist.ind_offset = 0;
+ 					}
+ 					else
+ 					{
+ 						desc_inlist.ind_type = ECPGt_NO_INDICATOR;
+ 						desc_inlist.ind_value = desc_inlist.ind_pointer = NULL;
+ 						desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = desc_inlist.ind_offset = 0;
+ 					}
+ 					if (!ecpg_store_input(stmt->lineno, stmt->force_indicator, &desc_inlist, &tobeinserted, false))
+ 						return false;
+ 
+ 					break;
+ 				}
+ 			}
+ 			if (sqlda->sqld == desc_counter)
+ 				desc_counter = 0;
+ 		}
  		else
  		{
  			if (!ecpg_store_input(stmt->lineno, stmt->force_indicator, var, &tobeinserted, false))
*************** ecpg_execute(struct statement * stmt)
*** 1353,1358 ****
--- 1410,1467 ----
  				}
  				var = var->next;
  			}
+ 			else if (var != NULL && var->type == ECPGt_sqlda)
+ 			{
+ 				pg_sqlda_t	  **_sqlda = (pg_sqlda_t **)var->pointer;
+ 				pg_sqlda_t	   *sqlda = *_sqlda;
+ 				pg_sqlda_t	   *sqlda_new;
+ 				int		i;
+ 
+ 				/* If we are passed in a previously existing sqlda (chain) then free it. */
+ 				while (sqlda)
+ 				{
+ 					sqlda_new = sqlda->desc_next;
+ 					free(sqlda);
+ 					sqlda = sqlda_new;
+ 				}
+ 				*_sqlda = sqlda = sqlda_new = NULL;
+ 				for (i = ntuples - 1; i >= 0; i--)
+ 				{
+ 					/* Build a new sqlda structure. Note that only fetching 1 record is supported */
+ 					sqlda_new = ecpg_build_sqlda_for_PGresult(stmt->lineno, results, i, stmt->compat);
+ 
+ 					if (!sqlda_new)
+ 					{
+ 						/* cleanup all SQLDAs we created up */
+ 						while (sqlda)
+ 						{
+ 							sqlda_new = sqlda->desc_next;
+ 							free(sqlda);
+ 							sqlda = sqlda_new;
+ 						}
+ 						*_sqlda = NULL;
+ 
+ 						ecpg_log("ecpg_execute on line %d: out of memory allocating a new sqlda\n", stmt->lineno);
+ 						status = false;
+ 						break;
+ 					}
+ 					else
+ 					{
+ 						ecpg_log("ecpg_execute on line %d: new sqlda was built\n", stmt->lineno);
+ 
+ 						*_sqlda = sqlda_new;
+ 
+ 						ecpg_set_sqlda_from_PGresult(stmt->lineno, _sqlda, results, i, stmt->compat);
+ 						ecpg_log("ecpg_execute on line %d: putting result (1 tuple %d fields) into sqlda descriptor\n",
+ 								stmt->lineno, PQnfields(results));
+ 
+ 						sqlda_new->desc_next = sqlda;
+ 						sqlda = sqlda_new;
+ 					}
+ 				}
+ 
+ 				var = var->next;
+ 			}
  			else
  				for (act_field = 0; act_field < nfields && status; act_field++)
  				{
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/extern.h pgsql.2/src/interfaces/ecpg/ecpglib/extern.h
*** pgsql.orig/src/interfaces/ecpg/ecpglib/extern.h	2009-05-25 12:08:48.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/ecpglib/extern.h	2009-12-16 14:03:43.000000000 +0100
***************
*** 6,11 ****
--- 6,12 ----
  #include "postgres_fe.h"
  #include "libpq-fe.h"
  #include "sqlca.h"
+ #include "sqlda.h"
  #include "ecpg_config.h"
  #ifndef CHAR_BIT
  #include <limits.h>
*************** bool		ecpg_init(const struct connection 
*** 129,134 ****
--- 130,136 ----
  char	   *ecpg_strdup(const char *, int);
  const char *ecpg_type_name(enum ECPGttype);
  int			ecpg_dynamic_type(Oid);
+ int			sqlda_dynamic_type(Oid, enum COMPAT_MODE);
  void		ecpg_free_auto_mem(void);
  void		ecpg_clear_auto_mem(void);
  
*************** void		ecpg_log(const char *format,...);
*** 149,154 ****
--- 151,159 ----
  bool		ecpg_auto_prepare(int, const char *, const int, char **, const char *);
  void		ecpg_init_sqlca(struct sqlca_t * sqlca);
  
+ pg_sqlda_t *ecpg_build_sqlda_for_PGresult(int, PGresult *, int, enum COMPAT_MODE);
+ void		ecpg_set_sqlda_from_PGresult(int, pg_sqlda_t **, const PGresult *, int, enum COMPAT_MODE);
+ 
  /* SQLSTATE values generated or processed by ecpglib (intentionally
   * not exported -- users should refer to the codes directly) */
  
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/Makefile pgsql.2/src/interfaces/ecpg/ecpglib/Makefile
*** pgsql.orig/src/interfaces/ecpg/ecpglib/Makefile	2009-07-13 11:16:41.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/ecpglib/Makefile	2009-12-16 14:03:43.000000000 +0100
*************** override CFLAGS += $(PTHREAD_CFLAGS)
*** 24,30 ****
  # Need to recompile any libpgport object files
  LIBS := $(filter-out -lpgport, $(LIBS))
  
! OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
  	connect.o misc.o path.o pgstrcasecmp.o \
  	$(filter snprintf.o strlcpy.o, $(LIBOBJS))
  
--- 24,30 ----
  # Need to recompile any libpgport object files
  LIBS := $(filter-out -lpgport, $(LIBS))
  
! OBJS= execute.o typename.o descriptor.o sqlda.o data.o error.o prepare.o memory.o \
  	connect.o misc.o path.o pgstrcasecmp.o \
  	$(filter snprintf.o strlcpy.o, $(LIBOBJS))
  
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/sqlda.c pgsql.2/src/interfaces/ecpg/ecpglib/sqlda.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/sqlda.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/ecpglib/sqlda.c	2009-12-16 14:03:43.000000000 +0100
***************
*** 0 ****
--- 1,387 ----
+ /*
+  * SQLDA support routines
+  *
+  * The allocated memory area pointed by an sqlda pointer
+  * contains both the metadata and the data, so freeing up
+  * is a simple free(sqlda) as expected by the ESQL/C examples.
+  */
+ 
+ #define POSTGRES_ECPG_INTERNAL
+ #include "postgres_fe.h"
+ #include "pg_type.h"
+ 
+ #include <inttypes.h>
+ #include <dlfcn.h>
+ 
+ #include "ecpg-pthread-win32.h"
+ #include "decimal.h"
+ #include "ecpgtype.h"
+ #include "ecpglib.h"
+ #include "ecpgerrno.h"
+ #include "extern.h"
+ #include "sqlca.h"
+ #include "sqlda.h"
+ 
+ /*
+  * Compute the next variable's offset with
+  * the current variable's size and alignment.
+  * 
+  *
+  * Returns:
+  * - the current variable's offset in *current
+  * - the next variable's offset in *next
+  */
+ static void
+ ecpg_sqlda_align_add_size(long offset, int alignment, int size, long *current, long *next)
+ {
+ 	if (offset % alignment)
+ 		offset += alignment - (offset % alignment);
+ 	if (current)
+ 		*current = offset;
+ 	offset += size;
+ 	if (next)
+ 		*next = offset;
+ }
+ 
+ static long
+ ecpg_sqlda_empty_size(const PGresult *res)
+ {
+ 	long	offset;
+ 	int	i;
+ 	int	sqld = PQnfields(res);
+ 
+ 	/* Initial size to store main structure and field structures */
+ 	offset = sizeof(pg_sqlda_t) + sqld * sizeof(pg_sqlvar_t);
+ 
+ 	/* Add space for field names */
+ 	for (i = 0; i < sqld; i++)
+ 		offset += strlen(PQfname(res, i)) + 1;
+ 
+ 	/* Add padding to the first field value */
+ 	ecpg_sqlda_align_add_size(offset, sizeof(int), 0, &offset, NULL);
+ 
+ 	return offset;
+ }
+ 
+ static long
+ ecpg_sqlda_total_size(const PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ 	int	i;
+ 	int	sqld = PQnfields(res);
+ 	long	offset, next_offset;
+ 
+ 	offset = ecpg_sqlda_empty_size(res);
+ 
+ 	if (row < 0)
+ 		return offset;
+ 
+ 	/* Add space for the field values */
+ 	for (i = 0; i < sqld; i++)
+ 	{
+ 		enum ECPGttype type = sqlda_dynamic_type(PQftype(res, i), compat);
+ 		switch (type)
+ 		{
+ 			case ECPGt_short:
+ 			case ECPGt_unsigned_short:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_int:
+ 			case ECPGt_unsigned_int:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_long:
+ 			case ECPGt_unsigned_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_long_long:
+ 			case ECPGt_unsigned_long_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_bool:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_float:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_double:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_decimal:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_numeric:
+ 				/*
+ 				 * Let's align both the numeric struct and the digits array to int
+ 				 * Unfortunately we need to do double work here to compute the size
+ 				 * of the space needed for the numeric structure.
+ 				 */
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset1 %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				if (!PQgetisnull(res, row, i))
+ 				{
+ 					char	   *val = PQgetvalue(res, row, i);
+ 					numeric	   *num;
+ 
+ 					num = PGTYPESnumeric_from_asc(val, NULL);
+ 					if (!num)
+ 						break;
+ 					ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
+ 					ecpg_log("%s type %s offset2 %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 					PGTYPESnumeric_free(num);
+ 				}
+ 				break;
+ 			case ECPGt_date:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(date), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_timestamp:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(timestamp), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_interval:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(interval), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_char:
+ 			case ECPGt_unsigned_char:
+ 			case ECPGt_string:
+ 			default:
+ 			{
+ 				long	datalen = strlen(PQgetvalue(res, row, i)) + 1;
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			}
+ 		}
+ 		offset = next_offset;
+ 	}
+ 	return offset;
+ }
+ 
+ /*
+  * Build pg_sqlda_t (metadata only) from PGresult
+  * leaving enough space for the field values in
+  * the given row number
+  */
+ pg_sqlda_t *
+ ecpg_build_sqlda_for_PGresult(int line, PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ 	pg_sqlda_t *sqlda;
+ 	pg_sqlvar_t*sqlvar;
+ 	char	   *fname;
+ 	long		size;
+ 	int		sqld;
+ 	int		i;
+ 
+ 	size = ecpg_sqlda_total_size(res, row, compat);
+ 	sqlda = (pg_sqlda_t *)ecpg_alloc(size, line);
+ 	if (!sqlda)
+ 		return NULL;
+ 
+ 	memset(sqlda, 0, size);
+ 	sqlvar = (pg_sqlvar_t *)(sqlda + 1);
+ 	sqld = PQnfields(res);
+ 	fname = (char *)(sqlvar + sqld);
+ 
+ 	sqlda->sqld = sqld;
+ 	sqlda->desc_occ = size; /* cheat here, keep the full allocated size */
+ 	sqlda->sqlvar = sqlvar;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		sqlda->sqlvar[i].sqltype = sqlda_dynamic_type(PQftype(res, i), compat);
+ 		strcpy(fname, PQfname(res, i));
+ 		sqlda->sqlvar[i].sqlname = fname;
+ 		fname += strlen(sqlda->sqlvar[i].sqlname) + 1;
+ 		sqlda->sqlvar[i].sqlformat = (char *)(long)PQfformat(res, i);
+ 		sqlda->sqlvar[i].sqlxid = PQftype(res, i);
+ 		sqlda->sqlvar[i].sqltypelen = PQfsize(res, i);
+ 	}
+ 
+ 	return sqlda;
+ }
+ 
+ /*
+  * Sets values from PGresult.
+  */
+ static int2	value_is_null = -1;
+ static int2	value_is_not_null = 0;
+ 
+ void
+ ecpg_set_sqlda_from_PGresult(int lineno, pg_sqlda_t **_sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ 	pg_sqlda_t *sqlda = (*_sqlda);
+ 	int		i;
+ 	long		offset, next_offset;
+ 
+ 	/* Offset for the first field value */
+ 	offset = ecpg_sqlda_empty_size(res);
+ 
+ 	if (row < 0)
+ 		return;
+ 
+ 	/*
+ 	 * Set sqlvar[i]->sqldata pointers and convert values to correct format
+ 	 */
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		int	isnull;
+ 		int	datalen;
+ 		bool	set_data = true;
+ 
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 			case ECPGt_short:
+ 			case ECPGt_unsigned_short:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(short);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_int:
+ 			case ECPGt_unsigned_int:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(int);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_long:
+ 			case ECPGt_unsigned_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(long);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_long_long:
+ 			case ECPGt_unsigned_long_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(long long);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_bool:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(bool);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_float:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(float);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_double:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(double);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_decimal:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(decimal);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_numeric:
+ 			{
+ 				numeric	   *num;
+ 				char	   *val;
+ 
+ 				set_data = false;
+ 
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(numeric);
+ 				ecpg_log("%s type %s offset1 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 
+ 				if (PQgetisnull(res, row, i))
+ 				{
+ 					ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
+ 					break;
+ 				}
+ 
+ 				val = PQgetvalue(res, row, i);
+ 				num = PGTYPESnumeric_from_asc(val, NULL);
+ 				if (!num)
+ 				{
+ 					ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
+ 					break;
+ 				}
+ 
+ 				memcpy(sqlda->sqlvar[i].sqldata, num, sizeof(numeric));
+ 
+ 				ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
+ 				memcpy((char *)sqlda + offset, num->buf, num->ndigits + 1);
+ 				ecpg_log("%s type %s offset2 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 
+ 				((numeric *)sqlda->sqlvar[i].sqldata)->buf = (NumericDigit *)sqlda + offset;
+ 				((numeric *)sqlda->sqlvar[i].sqldata)->digits = (NumericDigit *)sqlda + offset + (num->digits - num->buf);
+ 
+ 				PGTYPESnumeric_free(num);
+ 
+ 				break;
+ 			}
+ 			case ECPGt_date:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(date), sizeof(date), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(date);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_timestamp:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(timestamp), sizeof(timestamp), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(timestamp);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_interval:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int64_t), sizeof(interval), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(interval);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_char:
+ 			case ECPGt_unsigned_char:
+ 			case ECPGt_string:
+ 			default:
+ 				datalen = strlen(PQgetvalue(res, row, i)) + 1;
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = datalen;
+ 				if (datalen > 32768)
+ 					sqlda->sqlvar[i].sqlilongdata = sqlda->sqlvar[i].sqldata;
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 		}
+ 
+ 		isnull = PQgetisnull(res, row, i);
+ 		ecpg_log("%s row %d col %d %s\n", __FUNCTION__, row, i, isnull ? "IS NULL" : "IS NOT NULL");
+ 		sqlda->sqlvar[i].sqlind = isnull ? &value_is_null : &value_is_not_null;
+ 		sqlda->sqlvar[i].sqlitype = ECPGt_short;
+ 		sqlda->sqlvar[i].sqlilen = sizeof(short);
+ 		if (!isnull)
+ 		{
+ 			if (set_data)
+ 				ecpg_get_data(res, row, i, lineno,
+ 						sqlda->sqlvar[i].sqltype, ECPGt_NO_INDICATOR,
+ 						sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
+ 						ECPG_ARRAY_NONE, ECPG_COMPAT_INFORMIX, false);
+ 		}
+ 		else
+ 		{
+ 			if (INFORMIX_MODE(compat))
+ 				ECPGset_noind_null(sqlda->sqlvar[i].sqltype, sqlda->sqlvar[i].sqldata);
+ 		}
+ 
+ 		offset = next_offset;
+ 	}
+ }
+ 
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/typename.c pgsql.2/src/interfaces/ecpg/ecpglib/typename.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/typename.c	2009-08-07 13:06:28.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/ecpglib/typename.c	2009-12-16 14:03:43.000000000 +0100
***************
*** 7,12 ****
--- 7,13 ----
  #include "ecpgtype.h"
  #include "ecpglib.h"
  #include "extern.h"
+ #include "sqltypes.h"
  #include "sql3types.h"
  #include "pg_type.h"
  
*************** ecpg_dynamic_type(Oid type)
*** 100,102 ****
--- 101,142 ----
  			return -(int) type;
  	}
  }
+ 
+ int
+ sqlda_dynamic_type(Oid type, enum COMPAT_MODE compat)
+ {
+ 	switch (type)
+ 	{
+ 		case CHAROID:
+ 		case VARCHAROID:
+ 		case BPCHAROID:
+ 		case TEXTOID:
+ 			return ECPGt_char;
+ 		case INT2OID:
+ 			return ECPGt_short;
+ 		case INT4OID:
+ 			return ECPGt_int;
+ 		case FLOAT8OID:
+ 			return ECPGt_double;
+ 		case FLOAT4OID:
+ 			return ECPGt_float;
+ 		case NUMERICOID:
+ 			return INFORMIX_MODE(compat) ? ECPGt_decimal : ECPGt_numeric;
+ 		case DATEOID:
+ 			return ECPGt_date;
+ 		case TIMESTAMPOID:
+ 		case TIMESTAMPTZOID:
+ 			return ECPGt_timestamp;
+ 		case INTERVALOID:
+ 			return ECPGt_interval;
+ 		case INT8OID:
+ #ifdef HAVE_LONG_LONG_INT_64
+ 			return ECPGt_long_long;
+ #endif
+ #ifdef HAVE_LONG_INT_64
+ 			return ECPGt_long;
+ #endif
+ 		default:
+ 			return (-type);
+ 	}
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/ecpgtype.h pgsql.2/src/interfaces/ecpg/include/ecpgtype.h
*** pgsql.orig/src/interfaces/ecpg/include/ecpgtype.h	2009-08-07 13:06:28.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/include/ecpgtype.h	2009-12-16 14:03:43.000000000 +0100
*************** enum ECPGttype
*** 62,68 ****
  	ECPGt_EOIT,					/* End of insert types. */
  	ECPGt_EORT,					/* End of result types. */
  	ECPGt_NO_INDICATOR,			/* no indicator */
! 	ECPGt_string                            /* trimmed (char *) type */
  };
  
   /* descriptor items */
--- 62,69 ----
  	ECPGt_EOIT,					/* End of insert types. */
  	ECPGt_EORT,					/* End of result types. */
  	ECPGt_NO_INDICATOR,			/* no indicator */
! 	ECPGt_string,				/* trimmed (char *) type */
! 	ECPGt_sqlda				/* C struct descriptor */
  };
  
   /* descriptor items */
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/Makefile pgsql.2/src/interfaces/ecpg/include/Makefile
*** pgsql.orig/src/interfaces/ecpg/include/Makefile	2009-10-27 20:36:17.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/include/Makefile	2009-12-16 14:03:43.000000000 +0100
*************** install: all installdirs install-headers
*** 14,21 ****
  
  .PHONY: install-headers
  ecpg_headers = ecpgerrno.h ecpglib.h ecpgtype.h sqlca.h sql3types.h ecpg_informix.h \
! 	pgtypes_error.h pgtypes_numeric.h pgtypes_timestamp.h pgtypes_date.h pgtypes_interval.h
! informix_headers = datetime.h decimal.h sqltypes.h sqlda.h
  
  install-headers: $(ecpg_headers) $(informix_headers)
  	$(INSTALL_DATA) $(addprefix $(srcdir)/,$(ecpg_headers)) '$(DESTDIR)$(includedir)/'
--- 14,22 ----
  
  .PHONY: install-headers
  ecpg_headers = ecpgerrno.h ecpglib.h ecpgtype.h sqlca.h sql3types.h ecpg_informix.h \
! 	pgtypes_error.h pgtypes_numeric.h pgtypes_timestamp.h pgtypes_date.h pgtypes_interval.h \
! 	sqlda.h
! informix_headers = datetime.h decimal.h sqltypes.h
  
  install-headers: $(ecpg_headers) $(informix_headers)
  	$(INSTALL_DATA) $(addprefix $(srcdir)/,$(ecpg_headers)) '$(DESTDIR)$(includedir)/'
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/sqlda.h pgsql.2/src/interfaces/ecpg/include/sqlda.h
*** pgsql.orig/src/interfaces/ecpg/include/sqlda.h	2009-06-13 18:25:05.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/include/sqlda.h	2009-12-16 14:03:43.000000000 +0100
***************
*** 1,3 ****
--- 1,49 ----
  /*
   * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
   */
+ 
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+ 
+ #include "ecpglib.h"
+ 
+ typedef struct sqlvar_struct
+ {
+ 	short	sqltype;		/* variable type                */
+ 	int	sqllen;			/* length in bytes              */
+ 	char	   *sqldata;		/* pointer to data              */
+ 	short	   *sqlind;		/* pointer to indicator         */
+ 	char	   *sqlname;		/* variable name                */
+ 	char	   *sqlformat;		/* reserved for future use      */
+ 	short	sqlitype;		/* ind variable type            */
+ 	short	sqlilen;		/* ind length in bytes          */
+ 	char	   *sqlidata;		/* ind data pointer             */
+ 	int	sqlxid;			/* extended id type             */
+ 	char	   *sqltypename;	/* extended type name           */
+ 	short	sqltypelen;		/* length of extended type name */
+ 	short	sqlownerlen;		/* length of owner name         */
+ 	short	sqlsourcetype;		/* source type for distinct of built-ins */
+ 	char	   *sqlownername;	/* owner name                   */
+ 	int	sqlsourceid;		/* extended id of source type   */
+ 
+ 	/*
+ 	 * sqlilongdata is new.  It supports data that exceeds the 32k
+ 	 * limit.  sqlilen and sqlidata are for backward compatibility
+ 	 * and they have maximum value of <32K.
+ 	 */
+ 	char	   *sqlilongdata;	/* for data field beyond 32K    */
+ 	int	sqlflags;		/* for internal use only        */
+ 	void	   *sqlreserved;	/* reserved for future use      */
+ } pg_sqlvar_t;
+ 
+ typedef struct sqlda
+ {
+ 	short		sqld;
+ 	pg_sqlvar_t	   *sqlvar;
+ 	char		desc_name[19];	/* descriptor name              */
+ 	short		desc_occ;	/* size of sqlda structure      */
+ 	struct sqlda	   *desc_next;	/* pointer to next sqlda struct */
+ 	void		   *reserved;	/* reserved for future use */
+ } pg_sqlda_t;
+ 
+ #endif /* POSTGRES_SQLDA_H */
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/sqltypes.h pgsql.2/src/interfaces/ecpg/include/sqltypes.h
*** pgsql.orig/src/interfaces/ecpg/include/sqltypes.h	2009-06-13 18:25:05.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/include/sqltypes.h	2009-12-16 14:03:43.000000000 +0100
***************
*** 4,9 ****
--- 4,11 ----
  #ifndef ECPG_SQLTYPES_H
  #define ECPG_SQLTYPES_H
  
+ #include <limits.h>
+ 
  #define CCHARTYPE	ECPGt_char
  #define CSHORTTYPE	ECPGt_short
  #define CINTTYPE	ECPGt_int
***************
*** 30,33 ****
--- 32,60 ----
  #define CLVCHARPTRTYPE	124
  #define CTYPEMAX	25
  
+ /*
+  * Values used in sqlda->sqlvar[i]->sqltype
+  */
+ #define	SQLCHAR		ECPGt_char
+ #define	SQLSMINT	ECPGt_short
+ #define	SQLINT		ECPGt_int
+ #define	SQLFLOAT	ECPGt_double
+ #define	SQLSMFLOAT	ECPGt_float
+ #define	SQLDECIMAL	ECPGt_decimal
+ #define	SQLSERIAL	ECPGt_int
+ #define	SQLDATE		ECPGt_date
+ #define	SQLDTIME	ECPGt_timestamp
+ #define	SQLTEXT		ECPGt_char
+ #define	SQLVCHAR	ECPGt_char
+ #define SQLINTERVAL     ECPGt_interval
+ #define	SQLNCHAR	ECPGt_char
+ #define	SQLNVCHAR	ECPGt_char
+ #if (LONG_BIT == 64)
+ #define	SQLINT8		ECPGt_long
+ #define	SQLSERIAL8	ECPGt_long
+ #else
+ #define	SQLINT8		ECPGt_long_long
+ #define	SQLSERIAL8	ECPGt_long_long
+ #endif
+ 
  #endif   /* ndef ECPG_SQLTYPES_H */
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/descriptor.c pgsql.2/src/interfaces/ecpg/preproc/descriptor.c
*** pgsql.orig/src/interfaces/ecpg/preproc/descriptor.c	2009-01-30 17:28:46.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/preproc/descriptor.c	2009-12-16 14:03:43.000000000 +0100
*************** descriptor_variable(const char *name, in
*** 326,328 ****
--- 326,347 ----
  	strlcpy(descriptor_names[input], name, sizeof(descriptor_names[input]));
  	return (struct variable *) & varspace[input];
  }
+ 
+ struct variable *
+ sqlda_variable(const char *name)
+ {
+ 	struct variable *p = (struct variable *) mm_alloc(sizeof(struct variable));
+ 
+ 	p->name = mm_strdup(name);
+ 	p->type = (struct ECPGtype *) mm_alloc(sizeof(struct ECPGtype));
+ 	p->type->type = ECPGt_sqlda;
+ 	p->type->size = NULL;
+ 	p->type->struct_sizeof = NULL;
+ 	p->type->u.element = NULL;
+ 	p->type->lineno = 0;
+ 	p->brace_level = 0;
+ 	p->next = NULL;
+ 
+ 	return p;
+ }
+ 
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.addons pgsql.2/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.addons	2009-12-16 11:30:27.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/preproc/ecpg.addons	2009-12-16 14:03:43.000000000 +0100
*************** ECPG: VariableShowStmtSHOWALL block
*** 409,437 ****
  		$$ = EMPTY;
  	}
  ECPG: FetchStmtMOVEfetch_args rule
! 	| FETCH fetch_args ecpg_into
  	{
  		$$ = cat2_str(make_str("fetch"), $2);
  	}
! 	| FETCH FORWARD cursor_name opt_ecpg_into
  	{
  		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
  		add_additional_variables($3, false);
  		$$ = cat_str(2, make_str("fetch forward"), cursor_marker);
  	}
! 	| FETCH FORWARD from_in cursor_name opt_ecpg_into
  	{
  		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
  		add_additional_variables($4, false);
  		$$ = cat_str(2, make_str("fetch forward from"), cursor_marker);
  	}
! 	| FETCH BACKWARD cursor_name opt_ecpg_into
  	{
  		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
  		add_additional_variables($3, false);
  		$$ = cat_str(2, make_str("fetch backward"), cursor_marker);
  	}
! 	| FETCH BACKWARD from_in cursor_name opt_ecpg_into
  	{
  		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
  		add_additional_variables($4, false);
--- 409,437 ----
  		$$ = EMPTY;
  	}
  ECPG: FetchStmtMOVEfetch_args rule
! 	| FETCH fetch_args ecpg_fetch_into
  	{
  		$$ = cat2_str(make_str("fetch"), $2);
  	}
! 	| FETCH FORWARD cursor_name opt_ecpg_fetch_into
  	{
  		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
  		add_additional_variables($3, false);
  		$$ = cat_str(2, make_str("fetch forward"), cursor_marker);
  	}
! 	| FETCH FORWARD from_in cursor_name opt_ecpg_fetch_into
  	{
  		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
  		add_additional_variables($4, false);
  		$$ = cat_str(2, make_str("fetch forward from"), cursor_marker);
  	}
! 	| FETCH BACKWARD cursor_name opt_ecpg_fetch_into
  	{
  		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
  		add_additional_variables($3, false);
  		$$ = cat_str(2, make_str("fetch backward"), cursor_marker);
  	}
! 	| FETCH BACKWARD from_in cursor_name opt_ecpg_fetch_into
  	{
  		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
  		add_additional_variables($4, false);
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.trailer pgsql.2/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.trailer	2009-11-26 18:57:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/preproc/ecpg.trailer	2009-12-16 14:03:43.000000000 +0100
*************** ecpg_using:	USING using_list 	{ $$ = EMP
*** 970,991 ****
  		| using_descriptor      { $$ = $1; }
  		;
  
! using_descriptor: USING opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
  		{
  			add_variable_to_head(&argsinsert, descriptor_variable($4,0), &no_indicator);
  			$$ = EMPTY;
  		}
  		;
  
! into_descriptor: INTO opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
  		{
  			add_variable_to_head(&argsresult, descriptor_variable($4,1), &no_indicator);
  			$$ = EMPTY;
  		}
  		;
  
- opt_sql: /*EMPTY*/ | SQL_SQL;
- 
  using_list: UsingValue | UsingValue ',' using_list;
  
  UsingValue: UsingConst
--- 970,999 ----
  		| using_descriptor      { $$ = $1; }
  		;
  
! using_descriptor: USING SQL_SQL SQL_DESCRIPTOR quoted_ident_stringvar
  		{
  			add_variable_to_head(&argsinsert, descriptor_variable($4,0), &no_indicator);
  			$$ = EMPTY;
  		}
+ 		| USING SQL_DESCRIPTOR name
+ 		{
+ 			add_variable_to_head(&argsinsert, sqlda_variable($3), &no_indicator);
+ 			$$ = EMPTY;
+ 		}
  		;
  
! into_descriptor: INTO SQL_SQL SQL_DESCRIPTOR quoted_ident_stringvar
  		{
  			add_variable_to_head(&argsresult, descriptor_variable($4,1), &no_indicator);
  			$$ = EMPTY;
  		}
+ 		| INTO SQL_DESCRIPTOR name
+ 		{
+ 			add_variable_to_head(&argsresult, sqlda_variable($3), &no_indicator);
+ 			$$ = EMPTY;
+ 		}
  		;
  
  using_list: UsingValue | UsingValue ',' using_list;
  
  UsingValue: UsingConst
*************** ecpg_into: INTO into_list	{ $$ = EMPTY; 
*** 1806,1813 ****
          | into_descriptor	{ $$ = $1; }
  	;
  
! opt_ecpg_into:	/* EMPTY */	{ $$ = EMPTY; }
! 	| ecpg_into		{ $$ = $1; }
  	;
  
  %%
--- 1814,1836 ----
          | into_descriptor	{ $$ = $1; }
  	;
  
! ecpg_fetch_into: ecpg_into	{ $$ = $1; }
! 	| using_descriptor
! 	{
! 		struct variable *var;
! 
! 		if (!INFORMIX_MODE)
! 			mmerror(PARSE_ERROR, ET_ERROR, "Not in Informix compatibility mode");
! 
! 		var = argsinsert->variable;
! 		remove_variable_from_list(&argsinsert, var);
! 		add_variable_to_head(&argsresult, var, &no_indicator);
! 		$$ = $1;
! 	}
! 	;
! 
! opt_ecpg_fetch_into:	/* EMPTY */	{ $$ = EMPTY; }
! 	| ecpg_fetch_into		{ $$ = $1; }
  	;
  
  %%
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.type pgsql.2/src/interfaces/ecpg/preproc/ecpg.type
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.type	2009-11-26 18:57:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/preproc/ecpg.type	2009-12-16 14:03:43.000000000 +0100
***************
*** 61,66 ****
--- 61,67 ----
  %type <str> ecpg_ident
  %type <str> ecpg_interval
  %type <str> ecpg_into
+ %type <str> ecpg_fetch_into
  %type <str> ecpg_param
  %type <str> ecpg_sconst
  %type <str> ecpg_using
***************
*** 76,82 ****
  %type <str> opt_bit_field
  %type <str> opt_connection_name
  %type <str> opt_database_name
! %type <str> opt_ecpg_into
  %type <str> opt_ecpg_using
  %type <str> opt_initializer
  %type <str> opt_options
--- 77,83 ----
  %type <str> opt_bit_field
  %type <str> opt_connection_name
  %type <str> opt_database_name
! %type <str> opt_ecpg_fetch_into
  %type <str> opt_ecpg_using
  %type <str> opt_initializer
  %type <str> opt_options
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/extern.h pgsql.2/src/interfaces/ecpg/preproc/extern.h
*** pgsql.orig/src/interfaces/ecpg/preproc/extern.h	2009-11-26 18:57:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/preproc/extern.h	2009-12-16 14:03:43.000000000 +0100
*************** extern void add_descriptor(char *, char 
*** 88,93 ****
--- 88,94 ----
  extern void drop_descriptor(char *, char *);
  extern struct descriptor *lookup_descriptor(char *, char *);
  extern struct variable *descriptor_variable(const char *name, int input);
+ extern struct variable *sqlda_variable(const char *name);
  extern void add_variable_to_head(struct arguments **, struct variable *, struct variable *);
  extern void add_variable_to_tail(struct arguments **, struct variable *, struct variable *);
  extern void remove_variable_from_list(struct arguments ** list, struct variable * var);
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/type.c pgsql.2/src/interfaces/ecpg/preproc/type.c
*** pgsql.orig/src/interfaces/ecpg/preproc/type.c	2009-09-03 12:25:47.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/preproc/type.c	2009-12-16 14:03:43.000000000 +0100
*************** get_type(enum ECPGttype type)
*** 194,199 ****
--- 194,202 ----
  		case ECPGt_descriptor:
  			return ("ECPGt_descriptor");
  			break;
+ 		case ECPGt_sqlda:
+ 			return ("ECPGt_sqlda");
+ 			break;
  		case ECPGt_date:
  			return ("ECPGt_date");
  			break;
*************** ECPGdump_a_simple(FILE *o, const char *n
*** 328,333 ****
--- 331,338 ----
  	else if (type == ECPGt_descriptor)
  		/* remember that name here already contains quotes (if needed) */
  		fprintf(o, "\n\tECPGt_descriptor, %s, 0L, 0L, 0L, ", name);
+ 	else if (type == ECPGt_sqlda)
+ 		fprintf(o, "\n\tECPGt_sqlda, &%s, 0L, 0L, 0L, ", name);
  	else
  	{
  		char	   *variable = (char *) mm_alloc(strlen(name) + ((prefix == NULL) ? 0 : strlen(prefix)) + 4);
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/compat_informix/Makefile pgsql.2/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.orig/src/interfaces/ecpg/test/compat_informix/Makefile	2006-09-19 17:36:08.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/test/compat_informix/Makefile	2009-12-16 14:03:43.000000000 +0100
*************** TESTS = test_informix test_informix.c \
*** 16,21 ****
--- 16,22 ----
          rfmtdate rfmtdate.c \
          rfmtlong rfmtlong.c \
          rnull rnull.c \
+         sqlda sqlda.c \
          charfuncs charfuncs.c
  
  all: $(TESTS)
*************** test_informix.c: test_informix.pgc ../re
*** 26,31 ****
--- 27,35 ----
  test_informix2.c: test_informix2.pgc ../regression.h
  	$(ECPG) -o $@ -I$(srcdir) $<
  
+ sqlda.c: sqlda.pgc ../regression.h
+ 	$(ECPG) -o $@ -I$(srcdir) $<
+ 
  dec_test.c: dec_test.pgc ../regression.h
  	$(ECPG) -o $@ -I$(srcdir) $<
  
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/compat_informix/sqlda.pgc pgsql.2/src/interfaces/ecpg/test/compat_informix/sqlda.pgc
*** pgsql.orig/src/interfaces/ecpg/test/compat_informix/sqlda.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/compat_informix/sqlda.pgc	2009-12-16 14:03:43.000000000 +0100
***************
*** 0 ****
--- 1,248 ----
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql include sqlda.h;
+ exec sql include sqltypes.h;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ /* These shouldn't be under DECLARE SECTION */
+ pg_sqlda_t	*inp_sqlda, *outp_sqlda;
+ 
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (sqlda->sqlvar[i].sqlind && *(sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", sqlda->sqlvar[i].sqlname);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case SQLCHAR:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLINT:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLINT8:
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLFLOAT:
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLDECIMAL:
+ 			{
+ 				char    val[64];
+ 				dectoasc((dec_t *)sqlda->sqlvar[i].sqldata, val, 64, -1);
+ 				printf("name sqlda descriptor: '%s' value DECIMAL '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ 	char	*stmt1 = "SELECT * FROM t1";
+ 	char	*stmt2 = "SELECT * FROM t1 WHERE id = ?";
+ 	int	rec;
+ 	int	id;
+ exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1 as regress1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table t1(
+ 		id integer,
+ 		t text,
+ 		d1 numeric,
+ 		d2 float8,
+ 		c char(10));
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into t1 values
+ 		(1, 'a', 1.0, 1, 'a'),
+ 		(2, null, null, null, null),
+ 		(3, '"c"', -3, 'nan'::float8, 'c'),
+ 		(4, 'd', 4.0, 4, 'd');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* SQLDA test for getting all records from a table */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id1 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare mycur1 cursor for st_id1;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open mycur1;
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		exec sql fetch 1 from mycur1 into descriptor outp_sqlda; 
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	exec sql whenever not found continue;
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close mycur1;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id1;
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting all records from a table
+ 	   using the Informix-specific FETCH ... USING DESCRIPTOR
+ 	 */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id2 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare mycur2 cursor for st_id2;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open mycur2;
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		exec sql fetch from mycur2 using descriptor outp_sqlda;
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	exec sql whenever not found continue;
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close mycur2;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id2;
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor */
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id3 FROM :stmt2;
+ 
+ 	strcpy(msg, "execute");
+ 	exec sql execute st_id3 using descriptor inp_sqlda into descriptor outp_sqlda;
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id3;
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor
+ 	 * on a named connection
+ 	 */
+ 
+ 	exec sql connect to REGRESSDB1 as con2;
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql at con2 prepare st_id4 FROM :stmt2;
+ 
+ 	strcpy(msg, "execute");
+ 	exec sql at con2 execute st_id4 using descriptor inp_sqlda into descriptor outp_sqlda;
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql at con2 commit;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id4;
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	strcpy(msg, "disconnect");
+ 	exec sql disconnect con2;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table t1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect");
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule pgsql.2/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule	2009-11-26 18:57:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/ecpg_schedule	2009-12-16 14:03:43.000000000 +0100
*************** test: compat_informix/charfuncs
*** 3,8 ****
--- 3,9 ----
  test: compat_informix/rfmtdate
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
+ test: compat_informix/sqlda
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: sql/code100
*** 29,34 ****
--- 30,36 ----
  test: sql/copystdout
  test: sql/define
  test: sql/desc
+ test: sql/sqlda
  test: sql/dynalloc
  test: sql/dynalloc2
  test: sql/dyntest
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule_tcp pgsql.2/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-11-26 18:57:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-12-16 14:03:43.000000000 +0100
*************** test: compat_informix/charfuncs
*** 3,8 ****
--- 3,9 ----
  test: compat_informix/rfmtdate
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
+ test: compat_informix/sqlda
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: sql/code100
*** 29,34 ****
--- 30,36 ----
  test: sql/copystdout
  test: sql/define
  test: sql/desc
+ test: sql/sqlda
  test: sql/dynalloc
  test: sql/dynalloc2
  test: sql/dyntest
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c	2009-12-16 14:12:11.000000000 +0100
***************
*** 0 ****
--- 1,561 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "sqlda.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 5 "sqlda.pgc"
+ 
+ 
+ 
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+ 
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+ 
+ #include "ecpglib.h"
+ 
+ typedef struct sqlvar_struct
+ {
+ 	short	sqltype;		/* variable type                */
+ 	int	sqllen;			/* length in bytes              */
+ 	char	   *sqldata;		/* pointer to data              */
+ 	short	   *sqlind;		/* pointer to indicator         */
+ 	char	   *sqlname;		/* variable name                */
+ 	char	   *sqlformat;		/* reserved for future use      */
+ 	short	sqlitype;		/* ind variable type            */
+ 	short	sqlilen;		/* ind length in bytes          */
+ 	char	   *sqlidata;		/* ind data pointer             */
+ 	int	sqlxid;			/* extended id type             */
+ 	char	   *sqltypename;	/* extended type name           */
+ 	short	sqltypelen;		/* length of extended type name */
+ 	short	sqlownerlen;		/* length of owner name         */
+ 	short	sqlsourcetype;		/* source type for distinct of built-ins */
+ 	char	   *sqlownername;	/* owner name                   */
+ 	int	sqlsourceid;		/* extended id of source type   */
+ 
+ 	/*
+ 	 * sqlilongdata is new.  It supports data that exceeds the 32k
+ 	 * limit.  sqlilen and sqlidata are for backward compatibility
+ 	 * and they have maximum value of <32K.
+ 	 */
+ 	char	   *sqlilongdata;	/* for data field beyond 32K    */
+ 	int	sqlflags;		/* for internal use only        */
+ 	void	   *sqlreserved;	/* reserved for future use      */
+ } pg_sqlvar_t;
+ 
+ typedef struct sqlda
+ {
+ 	short		sqld;
+ 	pg_sqlvar_t	   *sqlvar;
+ 	char		desc_name[19];	/* descriptor name              */
+ 	short		desc_occ;	/* size of sqlda structure      */
+ 	struct sqlda	   *desc_next;	/* pointer to next sqlda struct */
+ 	void		   *reserved;	/* reserved for future use */
+ } pg_sqlda_t;
+ 
+ #endif /* POSTGRES_SQLDA_H */
+ 
+ #line 7 "sqlda.pgc"
+ 
+ 
+ #line 1 "sqltypes.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqltypes.h,v 1.9 2009/06/11 14:49:13 momjian Exp $
+  */
+ #ifndef ECPG_SQLTYPES_H
+ #define ECPG_SQLTYPES_H
+ 
+ #include <limits.h>
+ 
+ #define CCHARTYPE	ECPGt_char
+ #define CSHORTTYPE	ECPGt_short
+ #define CINTTYPE	ECPGt_int
+ #define CLONGTYPE	ECPGt_long
+ #define CFLOATTYPE	ECPGt_float
+ #define CDOUBLETYPE ECPGt_double
+ #define CDECIMALTYPE	ECPGt_decimal
+ #define CFIXCHARTYPE	108
+ #define CSTRINGTYPE ECPGt_char
+ #define CDATETYPE	ECPGt_date
+ #define CMONEYTYPE	111
+ #define CDTIMETYPE	ECPGt_timestamp
+ #define CLOCATORTYPE	113
+ #define CVCHARTYPE	ECPGt_varchar
+ #define CINVTYPE	115
+ #define CFILETYPE	116
+ #define CINT8TYPE	ECPGt_long_long
+ #define CCOLLTYPE		118
+ #define CLVCHARTYPE		119
+ #define CFIXBINTYPE		120
+ #define CVARBINTYPE		121
+ #define CBOOLTYPE		ECPGt_bool
+ #define CROWTYPE		123
+ #define CLVCHARPTRTYPE	124
+ #define CTYPEMAX	25
+ 
+ /*
+  * Values used in sqlda->sqlvar[i]->sqltype
+  */
+ #define	SQLCHAR		ECPGt_char
+ #define	SQLSMINT	ECPGt_short
+ #define	SQLINT		ECPGt_int
+ #define	SQLFLOAT	ECPGt_double
+ #define	SQLSMFLOAT	ECPGt_float
+ #define	SQLDECIMAL	ECPGt_decimal
+ #define	SQLSERIAL	ECPGt_int
+ #define	SQLDATE		ECPGt_date
+ #define	SQLDTIME	ECPGt_timestamp
+ #define	SQLTEXT		ECPGt_char
+ #define	SQLVCHAR	ECPGt_char
+ #define SQLINTERVAL     ECPGt_interval
+ #define	SQLNCHAR	ECPGt_char
+ #define	SQLNVCHAR	ECPGt_char
+ #if (LONG_BIT == 64)
+ #define	SQLINT8		ECPGt_long
+ #define	SQLSERIAL8	ECPGt_long
+ #else
+ #define	SQLINT8		ECPGt_long_long
+ #define	SQLSERIAL8	ECPGt_long_long
+ #endif
+ 
+ #endif   /* ndef ECPG_SQLTYPES_H */
+ 
+ #line 8 "sqlda.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 10 "sqlda.pgc"
+ 
+ 
+ /* These shouldn't be under DECLARE SECTION */
+ pg_sqlda_t	*inp_sqlda, *outp_sqlda;
+ 
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (sqlda->sqlvar[i].sqlind && *(sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", sqlda->sqlvar[i].sqlname);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case SQLCHAR:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLINT:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLINT8:
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLFLOAT:
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLDECIMAL:
+ 			{
+ 				char    val[64];
+ 				dectoasc((decimal *)sqlda->sqlvar[i].sqldata, val, 64, -1);
+ 				printf("name sqlda descriptor: '%s' value DECIMAL '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		
+ 		
+ 
+ #line 54 "sqlda.pgc"
+  char * stmt1 = "SELECT * FROM t1" ;
+  
+ #line 55 "sqlda.pgc"
+  char * stmt2 = "SELECT * FROM t1 WHERE id = ?" ;
+  
+ #line 56 "sqlda.pgc"
+  int rec ;
+  
+ #line 57 "sqlda.pgc"
+  int id ;
+ /* exec sql end declare section */
+ #line 58 "sqlda.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , "regress1", 0); 
+ #line 65 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 65 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 68 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 68 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
+ #line 76 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 76 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 3 , '\"c\"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 83 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 83 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 86 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 86 "sqlda.pgc"
+ 
+ 
+ 	/* SQLDA test for getting all records from a table */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 93 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 93 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	ECPG_informix_reset_sqlca(); /* declare mycur1 cursor for $1 */
+ #line 96 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1", 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 99 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 99 "sqlda.pgc"
+ 
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 101 "sqlda.pgc"
+ 
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 107 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 107 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 107 "sqlda.pgc"
+  
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	/* exec sql whenever not found  continue ; */
+ #line 113 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT);
+ #line 116 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 116 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
+ #line 119 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 119 "sqlda.pgc"
+ 
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting all records from a table
+ 	   using the Informix-specific FETCH ... USING DESCRIPTOR
+ 	 */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
+ #line 130 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 130 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	ECPG_informix_reset_sqlca(); /* declare mycur2 cursor for $1 */
+ #line 133 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1", 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 136 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 136 "sqlda.pgc"
+ 
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 138 "sqlda.pgc"
+ 
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from mycur2", ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 144 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 144 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 144 "sqlda.pgc"
+ 
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	/* exec sql whenever not found  continue ; */
+ #line 150 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT);
+ #line 153 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 153 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id2");
+ #line 156 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 156 "sqlda.pgc"
+ 
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor */
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id3", stmt2);
+ #line 179 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 179 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "execute");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_execute, "st_id3", 
+ 	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 182 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 182 "sqlda.pgc"
+ 
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id3");
+ #line 187 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 187 "sqlda.pgc"
+ 
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor
+ 	 * on a named connection
+ 	 */
+ 
+ 	{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , "con2", 0); 
+ #line 197 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 197 "sqlda.pgc"
+ 
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, "con2", 0, "st_id4", stmt2);
+ #line 216 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 216 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "execute");
+ 	{ ECPGdo(__LINE__, 1, 1, "con2", 0, ECPGst_execute, "st_id4", 
+ 	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 219 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 219 "sqlda.pgc"
+ 
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, "con2", "commit");
+ #line 224 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 224 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id4");
+ #line 227 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 227 "sqlda.pgc"
+ 
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	strcpy(msg, "disconnect");
+ 	{ ECPGdisconnect(__LINE__, "con2");
+ #line 234 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 234 "sqlda.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 239 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 239 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 242 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 242 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect");
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 245 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 245 "sqlda.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr	2009-12-16 14:03:43.000000000 +0100
***************
*** 0 ****
--- 1,584 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 68: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 68: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 68: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 71: query: create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 71: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 71: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 79: query: insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 3 , '"c"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 79: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 79: OK: INSERT 0 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 86: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 93: name st_id1; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 99: query: declare mycur1 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 99: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 99: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: "c" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: -3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: c          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 107: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 107: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 107: no data found on line 107
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 116: query: close mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 119: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 130: name st_id2; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 136: query: declare mycur2 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 136: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 136: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: "c" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: -3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: c          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 144: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 144: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 144: no data found on line 144
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 153: query: close mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 153: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 156: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 179: name st_id3; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 182: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 182: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 182: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 182: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 182: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 182: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 182: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 182: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 182: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 182: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 182: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 187: name st_id3
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 216: name st_id4; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection con2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 219: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 219: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 219: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 224: action "commit"; connection "con2"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 227: name st_id4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection con2 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 239: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 239: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 239: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 242: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout	2009-12-16 14:03:43.000000000 +0100
***************
*** 0 ****
--- 1,60 ----
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value DECIMAL '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a         '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value DECIMAL '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c         '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value DECIMAL '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a         '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value DECIMAL '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c         '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.c pgsql.2/src/interfaces/ecpg/test/expected/sql-sqlda.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/expected/sql-sqlda.c	2009-12-16 14:12:23.000000000 +0100
***************
*** 0 ****
--- 1,569 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "sqlda.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ #include <limits.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 6 "sqlda.pgc"
+ 
+ 
+ 
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+ 
+ #ifndef POSTGRES_SQLDA_H
+ #define POSTGRES_SQLDA_H
+ 
+ #include "ecpglib.h"
+ 
+ typedef struct sqlvar_struct
+ {
+ 	short	sqltype;		/* variable type                */
+ 	int	sqllen;			/* length in bytes              */
+ 	char	   *sqldata;		/* pointer to data              */
+ 	short	   *sqlind;		/* pointer to indicator         */
+ 	char	   *sqlname;		/* variable name                */
+ 	char	   *sqlformat;		/* reserved for future use      */
+ 	short	sqlitype;		/* ind variable type            */
+ 	short	sqlilen;		/* ind length in bytes          */
+ 	char	   *sqlidata;		/* ind data pointer             */
+ 	int	sqlxid;			/* extended id type             */
+ 	char	   *sqltypename;	/* extended type name           */
+ 	short	sqltypelen;		/* length of extended type name */
+ 	short	sqlownerlen;		/* length of owner name         */
+ 	short	sqlsourcetype;		/* source type for distinct of built-ins */
+ 	char	   *sqlownername;	/* owner name                   */
+ 	int	sqlsourceid;		/* extended id of source type   */
+ 
+ 	/*
+ 	 * sqlilongdata is new.  It supports data that exceeds the 32k
+ 	 * limit.  sqlilen and sqlidata are for backward compatibility
+ 	 * and they have maximum value of <32K.
+ 	 */
+ 	char	   *sqlilongdata;	/* for data field beyond 32K    */
+ 	int	sqlflags;		/* for internal use only        */
+ 	void	   *sqlreserved;	/* reserved for future use      */
+ } pg_sqlvar_t;
+ 
+ typedef struct sqlda
+ {
+ 	short		sqld;
+ 	pg_sqlvar_t	   *sqlvar;
+ 	char		desc_name[19];	/* descriptor name              */
+ 	short		desc_occ;	/* size of sqlda structure      */
+ 	struct sqlda	   *desc_next;	/* pointer to next sqlda struct */
+ 	void		   *reserved;	/* reserved for future use */
+ } pg_sqlda_t;
+ 
+ #endif /* POSTGRES_SQLDA_H */
+ 
+ #line 8 "sqlda.pgc"
+ 
+ 
+ #line 1 "pgtypes_numeric.h"
+ /* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_numeric.h,v 1.16 2006/08/09 07:30:56 meskes Exp $ */
+ 
+ #ifndef PGTYPES_NUMERIC
+ #define PGTYPES_NUMERIC
+ 
+ #define NUMERIC_POS						0x0000
+ #define NUMERIC_NEG						0x4000
+ #define NUMERIC_NAN						0xC000
+ #define NUMERIC_MAX_PRECISION			1000
+ #define NUMERIC_MAX_DISPLAY_SCALE		NUMERIC_MAX_PRECISION
+ #define NUMERIC_MIN_DISPLAY_SCALE		0
+ #define NUMERIC_MIN_SIG_DIGITS			16
+ 
+ #define DECSIZE 30
+ 
+ typedef unsigned char NumericDigit;
+ typedef struct
+ {
+ 	int			ndigits;		/* number of digits in digits[] - can be 0! */
+ 	int			weight;			/* weight of first digit */
+ 	int			rscale;			/* result scale */
+ 	int			dscale;			/* display scale */
+ 	int			sign;			/* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
+ 	NumericDigit *buf;			/* start of alloc'd space for digits[] */
+ 	NumericDigit *digits;		/* decimal digits */
+ } numeric;
+ 
+ typedef struct
+ {
+ 	int			ndigits;		/* number of digits in digits[] - can be 0! */
+ 	int			weight;			/* weight of first digit */
+ 	int			rscale;			/* result scale */
+ 	int			dscale;			/* display scale */
+ 	int			sign;			/* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
+ 	NumericDigit digits[DECSIZE];		/* decimal digits */
+ } decimal;
+ 
+ #ifdef __cplusplus
+ extern		"C"
+ {
+ #endif
+ 
+ numeric    *PGTYPESnumeric_new(void);
+ decimal    *PGTYPESdecimal_new(void);
+ void		PGTYPESnumeric_free(numeric *);
+ void		PGTYPESdecimal_free(decimal *);
+ numeric    *PGTYPESnumeric_from_asc(char *, char **);
+ char	   *PGTYPESnumeric_to_asc(numeric *, int);
+ int			PGTYPESnumeric_add(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_sub(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_mul(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_div(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_cmp(numeric *, numeric *);
+ int			PGTYPESnumeric_from_int(signed int, numeric *);
+ int			PGTYPESnumeric_from_long(signed long int, numeric *);
+ int			PGTYPESnumeric_copy(numeric *, numeric *);
+ int			PGTYPESnumeric_from_double(double, numeric *);
+ int			PGTYPESnumeric_to_double(numeric *, double *);
+ int			PGTYPESnumeric_to_int(numeric *, int *);
+ int			PGTYPESnumeric_to_long(numeric *, long *);
+ int			PGTYPESnumeric_to_decimal(numeric *, decimal *);
+ int			PGTYPESnumeric_from_decimal(decimal *, numeric *);
+ 
+ #ifdef __cplusplus
+ }
+ #endif
+ 
+ #endif   /* PGTYPES_NUMERIC */
+ 
+ #line 9 "sqlda.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 11 "sqlda.pgc"
+ 
+ 
+ /* These shouldn't be under DECLARE SECTION */
+ pg_sqlda_t	*inp_sqlda, *outp_sqlda, *outp_sqlda1;
+ 
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (sqlda->sqlvar[i].sqlind && *(sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", sqlda->sqlvar[i].sqlname);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case ECPGt_char:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_int:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ #if (LONG_BIT == 64) /* Defined via <limits.h> */
+ 		case ECPGt_long:
+ #else
+ # if (LONG_BIT = 32)
+ 		case ECPGt_long_long:
+ # else
+ #  error Neither "long" nor "long long" are 64-bit
+ # endif
+ #endif
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_double:
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_numeric:
+ 			{
+ 				char    *val;
+ 
+ 				val = PGTYPESnumeric_to_asc((numeric*)sqlda->sqlvar[i].sqldata, -1);
+ 				printf("name sqlda descriptor: '%s' value NUMERIC '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ 				free(val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		
+ 		
+ 
+ #line 65 "sqlda.pgc"
+  char * stmt1 = "SELECT * FROM t1" ;
+  
+ #line 66 "sqlda.pgc"
+  char * stmt2 = "SELECT * FROM t1 WHERE id = ?" ;
+  
+ #line 67 "sqlda.pgc"
+  int rec ;
+  
+ #line 68 "sqlda.pgc"
+  int id ;
+ /* exec sql end declare section */
+ #line 69 "sqlda.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , "regress1", 0); 
+ #line 76 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 76 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 79 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 79 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
+ #line 87 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 87 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 3 , '\"c\"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 94 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 94 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 97 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 97 "sqlda.pgc"
+ 
+ 
+ 	/* SQLDA test for getting all records from a table */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 104 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 104 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	/* declare mycur1 cursor for $1 */
+ #line 107 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1", 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 110 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 110 "sqlda.pgc"
+ 
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 112 "sqlda.pgc"
+ 
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 118 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 118 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 118 "sqlda.pgc"
+  
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	/* exec sql whenever not found  continue ; */
+ #line 124 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT);
+ #line 127 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 127 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
+ #line 130 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 130 "sqlda.pgc"
+ 
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting ALL records into the sqlda list */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
+ #line 139 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 139 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	/* declare mycur2 cursor for $1 */
+ #line 142 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1", 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 145 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 145 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch all from mycur2", ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 148 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 148 "sqlda.pgc"
+ 
+ 
+ 	outp_sqlda1 = outp_sqlda;
+ 	rec = 0;
+ 	while (outp_sqlda1)
+ 	{
+ 		pg_sqlda_t	*ptr;
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda1);
+ 
+ 		ptr = outp_sqlda1;
+ 		outp_sqlda1 = outp_sqlda1->desc_next;
+ 		free(ptr);
+ 	}
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT);
+ #line 164 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 164 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
+ #line 167 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 167 "sqlda.pgc"
+ 
+ 
+ 	/* SQLDA test for getting one record using an input descriptor */
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id3", stmt2);
+ #line 188 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 188 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "execute");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "st_id3", 
+ 	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 191 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 191 "sqlda.pgc"
+ 
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id3");
+ #line 196 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 196 "sqlda.pgc"
+ 
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor
+ 	 * on a named connection
+ 	 */
+ 
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , "con2", 0); 
+ #line 206 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 206 "sqlda.pgc"
+ 
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, "con2", 0, "st_id4", stmt2);
+ #line 225 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 225 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "execute");
+ 	{ ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_execute, "st_id4", 
+ 	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 228 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 228 "sqlda.pgc"
+ 
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, "con2", "commit");
+ #line 233 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 233 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id4");
+ #line 236 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 236 "sqlda.pgc"
+ 
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	strcpy(msg, "disconnect");
+ 	{ ECPGdisconnect(__LINE__, "con2");
+ #line 243 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 243 "sqlda.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 248 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 248 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 251 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 251 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect");
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 254 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 254 "sqlda.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.stderr pgsql.2/src/interfaces/ecpg/test/expected/sql-sqlda.stderr
*** pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/expected/sql-sqlda.stderr	2009-12-16 14:03:43.000000000 +0100
***************
*** 0 ****
--- 1,574 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 79: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 79: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 79: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: query: create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 82: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: query: insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 3 , '"c"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 90: OK: INSERT 0 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 97: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 104: name st_id1; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: query: declare mycur1 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 110: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: "c" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: c          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 118: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 118: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 118: no data found on line 118
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 127: query: close mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 127: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 127: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 130: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 139: name st_id2; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 145: query: declare mycur2 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 145: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 145: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: query: fetch all from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: correctly got 4 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 3 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 3 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 3 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 3 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 3 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 2 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 2 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: "c" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 2 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 2 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 2 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: c          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 1 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 1 col 1 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 1 col 2 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 1 col 3 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 1 col 4 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 148: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 148: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 164: query: close mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 164: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 164: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 167: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 188: name st_id3; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 191: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 191: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 191: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 191: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 191: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 191: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 191: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 191: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 191: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 191: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 196: name st_id3
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 225: name st_id4; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection con2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 228: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_sqlda_total_size type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 228: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 228: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset1 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type numeric offset2 720
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type double offset 728
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 228: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult type char offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_sqlda_from_PGresult row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 228: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 228: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 233: action "commit"; connection "con2"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 236: name st_id4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection con2 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 248: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 248: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 248: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 251: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.stdout pgsql.2/src/interfaces/ecpg/test/expected/sql-sqlda.stdout
*** pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/expected/sql-sqlda.stdout	2009-12-16 14:03:43.000000000 +0100
***************
*** 0 ****
--- 1,60 ----
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value NUMERIC '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a         '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value NUMERIC '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c         '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value NUMERIC '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value NUMERIC '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a         '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value NUMERIC '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c         '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value NUMERIC '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value NUMERIC '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value NUMERIC '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/desc.pgc pgsql.2/src/interfaces/ecpg/test/sql/desc.pgc
*** pgsql.orig/src/interfaces/ecpg/test/sql/desc.pgc	2007-08-14 12:01:54.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/test/sql/desc.pgc	2009-12-16 14:03:43.000000000 +0100
*************** main(void)
*** 32,61 ****
  	EXEC SQL PREPARE foo2 FROM :stmt2;
  	EXEC SQL PREPARE foo3 FROM :stmt3;
  
! 	EXEC SQL EXECUTE foo1 USING DESCRIPTOR indesc;
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2null, DATA = :val2;
  
! 	EXEC SQL EXECUTE foo1 USING DESCRIPTOR indesc;
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 3;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val1, DATA = 'this is a long test';
  
! 	EXEC SQL EXECUTE "Foo-1" USING DESCRIPTOR indesc;
  
  	EXEC SQL DEALLOCATE "Foo-1";
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = :val1;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2i, DATA = :val2;
  
! 	EXEC SQL EXECUTE foo2 USING DESCRIPTOR indesc INTO DESCRIPTOR outdesc;
  
  	EXEC SQL GET DESCRIPTOR outdesc VALUE 1 :val2output = DATA;
  	printf("output = %s\n", val2output);
  
  	EXEC SQL DECLARE c1 CURSOR FOR foo2;
! 	EXEC SQL OPEN c1 USING DESCRIPTOR indesc;
  
  	EXEC SQL FETCH next FROM c1 INTO :val1output:ind1, :val2output:ind2;
  	printf("val1=%d (ind1: %d) val2=%s (ind2: %d)\n",
--- 32,61 ----
  	EXEC SQL PREPARE foo2 FROM :stmt2;
  	EXEC SQL PREPARE foo3 FROM :stmt3;
  
! 	EXEC SQL EXECUTE foo1 USING SQL DESCRIPTOR indesc;
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2null, DATA = :val2;
  
! 	EXEC SQL EXECUTE foo1 USING SQL DESCRIPTOR indesc;
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 3;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val1, DATA = 'this is a long test';
  
! 	EXEC SQL EXECUTE "Foo-1" USING SQL DESCRIPTOR indesc;
  
  	EXEC SQL DEALLOCATE "Foo-1";
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = :val1;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2i, DATA = :val2;
  
! 	EXEC SQL EXECUTE foo2 USING SQL DESCRIPTOR indesc INTO SQL DESCRIPTOR outdesc;
  
  	EXEC SQL GET DESCRIPTOR outdesc VALUE 1 :val2output = DATA;
  	printf("output = %s\n", val2output);
  
  	EXEC SQL DECLARE c1 CURSOR FOR foo2;
! 	EXEC SQL OPEN c1 USING SQL DESCRIPTOR indesc;
  
  	EXEC SQL FETCH next FROM c1 INTO :val1output:ind1, :val2output:ind2;
  	printf("val1=%d (ind1: %d) val2=%s (ind2: %d)\n",
*************** main(void)
*** 67,73 ****
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
  
  	EXEC SQL DECLARE c2 CURSOR FOR foo3;
! 	EXEC SQL OPEN c2 USING DESCRIPTOR indesc;
  
  	EXEC SQL FETCH next FROM c2 INTO :val1output, :val2output :val2i;
  	printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output);
--- 67,73 ----
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
  
  	EXEC SQL DECLARE c2 CURSOR FOR foo3;
! 	EXEC SQL OPEN c2 USING SQL DESCRIPTOR indesc;
  
  	EXEC SQL FETCH next FROM c2 INTO :val1output, :val2output :val2i;
  	printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output);
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/dynalloc2.pgc pgsql.2/src/interfaces/ecpg/test/sql/dynalloc2.pgc
*** pgsql.orig/src/interfaces/ecpg/test/sql/dynalloc2.pgc	2006-08-19 15:42:40.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/test/sql/dynalloc2.pgc	2009-12-16 14:03:43.000000000 +0100
*************** int main(void)
*** 30,36 ****
     exec sql insert into test values (NULL, NULL);
  
     exec sql allocate descriptor mydesc;
!    exec sql select * into descriptor mydesc from test;
     exec sql get descriptor mydesc :colnum=COUNT;
     exec sql get descriptor mydesc value 1 :ip1=DATA, :ipointer1=INDICATOR;
     exec sql get descriptor mydesc value 2 :cp2=DATA, :ipointer2=INDICATOR;
--- 30,36 ----
     exec sql insert into test values (NULL, NULL);
  
     exec sql allocate descriptor mydesc;
!    exec sql select * into sql descriptor mydesc from test;
     exec sql get descriptor mydesc :colnum=COUNT;
     exec sql get descriptor mydesc value 1 :ip1=DATA, :ipointer1=INDICATOR;
     exec sql get descriptor mydesc value 2 :cp2=DATA, :ipointer2=INDICATOR;
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/dynalloc.pgc pgsql.2/src/interfaces/ecpg/test/sql/dynalloc.pgc
*** pgsql.orig/src/interfaces/ecpg/test/sql/dynalloc.pgc	2006-08-19 15:42:40.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/test/sql/dynalloc.pgc	2009-12-16 14:03:43.000000000 +0100
*************** int main(void)
*** 39,45 ****
     exec sql insert into test (b, c, d, e, f, g, h, i) values (2.446456, NULL, 'v', 'c', '2003-03-03 12:33:07 PDT', false, NULL, NULL);
  
     exec sql allocate descriptor mydesc;
!    exec sql select a,b,c,d,e,f,g,h,i into descriptor mydesc from test order by a;
     exec sql get descriptor mydesc value 1 :d1=DATA, :i1=INDICATOR;
     exec sql get descriptor mydesc value 2 :d2=DATA, :i2=INDICATOR;
     exec sql get descriptor mydesc value 3 :d3=DATA, :i3=INDICATOR;
--- 39,45 ----
     exec sql insert into test (b, c, d, e, f, g, h, i) values (2.446456, NULL, 'v', 'c', '2003-03-03 12:33:07 PDT', false, NULL, NULL);
  
     exec sql allocate descriptor mydesc;
!    exec sql select a,b,c,d,e,f,g,h,i into sql descriptor mydesc from test order by a;
     exec sql get descriptor mydesc value 1 :d1=DATA, :i1=INDICATOR;
     exec sql get descriptor mydesc value 2 :d2=DATA, :i2=INDICATOR;
     exec sql get descriptor mydesc value 3 :d3=DATA, :i3=INDICATOR;
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/Makefile pgsql.2/src/interfaces/ecpg/test/sql/Makefile
*** pgsql.orig/src/interfaces/ecpg/test/sql/Makefile	2007-08-14 12:01:54.000000000 +0200
--- pgsql.2/src/interfaces/ecpg/test/sql/Makefile	2009-12-16 14:03:43.000000000 +0100
*************** TESTS = array array.c \
*** 20,25 ****
--- 20,26 ----
          parser parser.c \
          quote quote.c \
          show show.c \
+         sqlda sqlda.c \
          insupd insupd.c 
  
  all: $(TESTS)
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/sqlda.pgc pgsql.2/src/interfaces/ecpg/test/sql/sqlda.pgc
*** pgsql.orig/src/interfaces/ecpg/test/sql/sqlda.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2/src/interfaces/ecpg/test/sql/sqlda.pgc	2009-12-16 14:03:43.000000000 +0100
***************
*** 0 ****
--- 1,257 ----
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ #include <limits.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql include sqlda.h;
+ exec sql include pgtypes_numeric.h;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ /* These shouldn't be under DECLARE SECTION */
+ pg_sqlda_t	*inp_sqlda, *outp_sqlda, *outp_sqlda1;
+ 
+ static void
+ dump_sqlda(pg_sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (sqlda->sqlvar[i].sqlind && *(sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", sqlda->sqlvar[i].sqlname);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case ECPGt_char:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_int:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ #if (LONG_BIT == 64) /* Defined via <limits.h> */
+ 		case ECPGt_long:
+ #else
+ # if (LONG_BIT = 32)
+ 		case ECPGt_long_long:
+ # else
+ #  error Neither "long" nor "long long" are 64-bit
+ # endif
+ #endif
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_double:
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_numeric:
+ 			{
+ 				char    *val;
+ 
+ 				val = PGTYPESnumeric_to_asc((numeric*)sqlda->sqlvar[i].sqldata, -1);
+ 				printf("name sqlda descriptor: '%s' value NUMERIC '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ 				free(val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ 	char	*stmt1 = "SELECT * FROM t1";
+ 	char	*stmt2 = "SELECT * FROM t1 WHERE id = ?";
+ 	int	rec;
+ 	int	id;
+ exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1 as regress1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table t1(
+ 		id integer,
+ 		t text,
+ 		d1 numeric,
+ 		d2 float8,
+ 		c char(10));
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into t1 values
+ 		(1, 'a', 1.0, 1, 'a'),
+ 		(2, null, null, null, null),
+ 		(3, '"c"', -3, 'nan'::float8, 'c'),
+ 		(4, 'd', 4.0, 4, 'd');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* SQLDA test for getting all records from a table */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id1 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare mycur1 cursor for st_id1;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open mycur1;
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		exec sql fetch 1 from mycur1 into descriptor outp_sqlda; 
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	exec sql whenever not found continue;
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close mycur1;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id1;
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting ALL records into the sqlda list */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id2 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare mycur2 cursor for st_id2;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open mycur2;
+ 
+ 	strcpy(msg, "fetch");
+ 	exec sql fetch all from mycur2 into descriptor outp_sqlda;
+ 
+ 	outp_sqlda1 = outp_sqlda;
+ 	rec = 0;
+ 	while (outp_sqlda1)
+ 	{
+ 		pg_sqlda_t	*ptr;
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda1);
+ 
+ 		ptr = outp_sqlda1;
+ 		outp_sqlda1 = outp_sqlda1->desc_next;
+ 		free(ptr);
+ 	}
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close mycur2;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id2;
+ 
+ 	/* SQLDA test for getting one record using an input descriptor */
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id3 FROM :stmt2;
+ 
+ 	strcpy(msg, "execute");
+ 	exec sql execute st_id3 using descriptor inp_sqlda into descriptor outp_sqlda;
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id3;
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor
+ 	 * on a named connection
+ 	 */
+ 
+ 	exec sql connect to REGRESSDB1 as con2;
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (pg_sqlda_t *)malloc(sizeof(pg_sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(pg_sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(pg_sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(pg_sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql at con2 prepare st_id4 FROM :stmt2;
+ 
+ 	strcpy(msg, "execute");
+ 	exec sql at con2 execute st_id4 using descriptor inp_sqlda into descriptor outp_sqlda;
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql at con2 commit;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id4;
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	strcpy(msg, "disconnect");
+ 	exec sql disconnect con2;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table t1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect");
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
#83Boszormenyi Zoltan
zb@cybertec.at
In reply to: Boszormenyi Zoltan (#82)
1 attachment(s)
ECPG SQLDA support

Hi,

new patch attached.

Per Michael's request, a DB2 / Sybase compatible
SQLDA structure is implemented for ECPG's native mode.
The Informix-compatible structure is only for compat mode.
The sqlda.h header switches between the two different
structures depending on a new #define introduced in
and added to the generated C source by the preprocessor
in compat-mode. Also, per discussion with Michael,
FETCH ... USING DESCRIPTOR sqlda
is also accepted by the grammar in native mode, too.

Best regards,
Zoltán Böszörményi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

Attachments:

2-pg85-sqlda-19-ctxdiff.patchtext/x-patch; name=2-pg85-sqlda-19-ctxdiff.patchDownload
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/execute.c pgsql.2.1/src/interfaces/ecpg/ecpglib/execute.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/execute.c	2009-09-03 14:37:34.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/ecpglib/execute.c	2010-01-04 14:51:44.000000000 +0100
***************
*** 25,30 ****
--- 25,32 ----
  #include "ecpgerrno.h"
  #include "extern.h"
  #include "sqlca.h"
+ #include "sqlda-native.h"
+ #include "sqlda-compat.h"
  #include "sql3types.h"
  #include "pgtypes_numeric.h"
  #include "pgtypes_date.h"
*************** ecpg_store_input(const int lineno, const
*** 1033,1038 ****
--- 1035,1041 ----
  				break;
  
  			case ECPGt_descriptor:
+ 			case ECPGt_sqlda:
  				break;
  
  			default:
*************** ecpg_execute(struct statement * stmt)
*** 1172,1177 ****
--- 1175,1294 ----
  			if (desc->count == desc_counter)
  				desc_counter = 0;
  		}
+ 		else if (var->type == ECPGt_sqlda)
+ 		{
+ 			if (INFORMIX_MODE(stmt->compat))
+ 			{
+ 				struct sqlda_compat	   *sqlda = *(struct sqlda_compat **)var->pointer;
+ 				struct variable	desc_inlist;
+ 				int		i;
+ 
+ 				if (sqlda == NULL)
+ 					return false;
+ 
+ 				desc_counter++;
+ 				for (i = 0; i < sqlda->sqld; i++)
+ 				{
+ 					if (i + 1 == desc_counter)
+ 					{
+ 						desc_inlist.type = sqlda->sqlvar[i].sqltype;
+ 						desc_inlist.value = sqlda->sqlvar[i].sqldata;
+ 						desc_inlist.pointer = &(sqlda->sqlvar[i].sqldata);
+ 						switch (desc_inlist.type)
+ 						{
+ 							case ECPGt_char:
+ 							case ECPGt_varchar:
+ 								desc_inlist.varcharsize = strlen(sqlda->sqlvar[i].sqldata);
+ 								break;
+ 							default:
+ 								desc_inlist.varcharsize = 0;
+ 								break;
+ 						}
+ 						desc_inlist.arrsize = 1;
+ 						desc_inlist.offset = 0;
+ 						if (sqlda->sqlvar[i].sqlind)
+ 						{
+ 							desc_inlist.ind_type = ECPGt_short;
+ 							/* ECPG expects indicator value < 0 */
+ 							if (*(sqlda->sqlvar[i].sqlind))
+ 								*(sqlda->sqlvar[i].sqlind) = -1;
+ 							desc_inlist.ind_value = sqlda->sqlvar[i].sqlind;
+ 							desc_inlist.ind_pointer = &(sqlda->sqlvar[i].sqlind);
+ 							desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = 1;
+ 							desc_inlist.ind_offset = 0;
+ 						}
+ 						else
+ 						{
+ 							desc_inlist.ind_type = ECPGt_NO_INDICATOR;
+ 							desc_inlist.ind_value = desc_inlist.ind_pointer = NULL;
+ 							desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = desc_inlist.ind_offset = 0;
+ 						}
+ 						if (!ecpg_store_input(stmt->lineno, stmt->force_indicator, &desc_inlist, &tobeinserted, false))
+ 							return false;
+ 
+ 						break;
+ 					}
+ 				}
+ 				if (sqlda->sqld == desc_counter)
+ 					desc_counter = 0;
+ 			}
+ 			else
+ 			{
+ 				struct sqlda_struct	   *sqlda = *(struct sqlda_struct **)var->pointer;
+ 				struct variable	desc_inlist;
+ 				int		i;
+ 
+ 				if (sqlda == NULL)
+ 					return false;
+ 
+ 				desc_counter++;
+ 				for (i = 0; i < sqlda->sqln; i++)
+ 				{
+ 					if (i + 1 == desc_counter)
+ 					{
+ 						desc_inlist.type = sqlda->sqlvar[i].sqltype;
+ 						desc_inlist.value = sqlda->sqlvar[i].sqldata;
+ 						desc_inlist.pointer = &(sqlda->sqlvar[i].sqldata);
+ 						switch (desc_inlist.type)
+ 						{
+ 							case ECPGt_char:
+ 							case ECPGt_varchar:
+ 								desc_inlist.varcharsize = strlen(sqlda->sqlvar[i].sqldata);
+ 								break;
+ 							default:
+ 								desc_inlist.varcharsize = 0;
+ 								break;
+ 						}
+ 						desc_inlist.arrsize = 1;
+ 						desc_inlist.offset = 0;
+ 						if (sqlda->sqlvar[i].sqlind)
+ 						{
+ 							desc_inlist.ind_type = ECPGt_short;
+ 							/* ECPG expects indicator value < 0 */
+ 							if (*(sqlda->sqlvar[i].sqlind))
+ 								*(sqlda->sqlvar[i].sqlind) = -1;
+ 							desc_inlist.ind_value = sqlda->sqlvar[i].sqlind;
+ 							desc_inlist.ind_pointer = &(sqlda->sqlvar[i].sqlind);
+ 							desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = 1;
+ 							desc_inlist.ind_offset = 0;
+ 						}
+ 						else
+ 						{
+ 							desc_inlist.ind_type = ECPGt_NO_INDICATOR;
+ 							desc_inlist.ind_value = desc_inlist.ind_pointer = NULL;
+ 							desc_inlist.ind_varcharsize = desc_inlist.ind_arrsize = desc_inlist.ind_offset = 0;
+ 						}
+ 						if (!ecpg_store_input(stmt->lineno, stmt->force_indicator, &desc_inlist, &tobeinserted, false))
+ 							return false;
+ 
+ 						break;
+ 					}
+ 				}
+ 				if (sqlda->sqln == desc_counter)
+ 					desc_counter = 0;
+ 			}
+ 
+ 		}
  		else
  		{
  			if (!ecpg_store_input(stmt->lineno, stmt->force_indicator, var, &tobeinserted, false))
*************** ecpg_execute(struct statement * stmt)
*** 1353,1358 ****
--- 1470,1580 ----
  				}
  				var = var->next;
  			}
+ 			else if (var != NULL && var->type == ECPGt_sqlda)
+ 			{
+ 				if (INFORMIX_MODE(stmt->compat))
+ 				{
+ 					struct sqlda_compat  **_sqlda = (struct sqlda_compat **)var->pointer;
+ 					struct sqlda_compat   *sqlda = *_sqlda;
+ 					struct sqlda_compat   *sqlda_new;
+ 					int		i;
+ 
+ 					/* If we are passed in a previously existing sqlda (chain) then free it. */
+ 					while (sqlda)
+ 					{
+ 						sqlda_new = sqlda->desc_next;
+ 						free(sqlda);
+ 						sqlda = sqlda_new;
+ 					}
+ 					*_sqlda = sqlda = sqlda_new = NULL;
+ 					for (i = ntuples - 1; i >= 0; i--)
+ 					{
+ 						/* Build a new sqlda structure. Note that only fetching 1 record is supported */
+ 						sqlda_new = ecpg_build_compat_sqlda(stmt->lineno, results, i, stmt->compat);
+ 
+ 						if (!sqlda_new)
+ 						{
+ 							/* cleanup all SQLDAs we created up */
+ 							while (sqlda)
+ 							{
+ 								sqlda_new = sqlda->desc_next;
+ 								free(sqlda);
+ 								sqlda = sqlda_new;
+ 							}
+ 							*_sqlda = NULL;
+ 
+ 							ecpg_log("ecpg_execute on line %d: out of memory allocating a new sqlda\n", stmt->lineno);
+ 							status = false;
+ 							break;
+ 						}
+ 						else
+ 						{
+ 							ecpg_log("ecpg_execute on line %d: new sqlda was built\n", stmt->lineno);
+ 
+ 							*_sqlda = sqlda_new;
+ 
+ 							ecpg_set_compat_sqlda(stmt->lineno, _sqlda, results, i, stmt->compat);
+ 							ecpg_log("ecpg_execute on line %d: putting result (1 tuple %d fields) into sqlda descriptor\n",
+ 									stmt->lineno, PQnfields(results));
+ 
+ 							sqlda_new->desc_next = sqlda;
+ 							sqlda = sqlda_new;
+ 						}
+ 					}
+ 				}
+ 				else
+ 				{
+ 					struct sqlda_struct  **_sqlda = (struct sqlda_struct **)var->pointer;
+ 					struct sqlda_struct   *sqlda = *_sqlda;
+ 					struct sqlda_struct   *sqlda_new;
+ 					int		i;
+ 
+ 					/* If we are passed in a previously existing sqlda (chain) then free it. */
+ 					while (sqlda)
+ 					{
+ 						sqlda_new = sqlda->desc_next;
+ 						free(sqlda);
+ 						sqlda = sqlda_new;
+ 					}
+ 					*_sqlda = sqlda = sqlda_new = NULL;
+ 					for (i = ntuples - 1; i >= 0; i--)
+ 					{
+ 						/* Build a new sqlda structure. Note that only fetching 1 record is supported */
+ 						sqlda_new = ecpg_build_native_sqlda(stmt->lineno, results, i, stmt->compat);
+ 
+ 						if (!sqlda_new)
+ 						{
+ 							/* cleanup all SQLDAs we created up */
+ 							while (sqlda)
+ 							{
+ 								sqlda_new = sqlda->desc_next;
+ 								free(sqlda);
+ 								sqlda = sqlda_new;
+ 							}
+ 							*_sqlda = NULL;
+ 
+ 							ecpg_log("ecpg_execute on line %d: out of memory allocating a new sqlda\n", stmt->lineno);
+ 							status = false;
+ 							break;
+ 						}
+ 						else
+ 						{
+ 							ecpg_log("ecpg_execute on line %d: new sqlda was built\n", stmt->lineno);
+ 
+ 							*_sqlda = sqlda_new;
+ 
+ 							ecpg_set_native_sqlda(stmt->lineno, _sqlda, results, i, stmt->compat);
+ 							ecpg_log("ecpg_execute on line %d: putting result (1 tuple %d fields) into sqlda descriptor\n",
+ 									stmt->lineno, PQnfields(results));
+ 
+ 							sqlda_new->desc_next = sqlda;
+ 							sqlda = sqlda_new;
+ 						}
+ 					}
+ 				}
+ 
+ 				var = var->next;
+ 			}
  			else
  				for (act_field = 0; act_field < nfields && status; act_field++)
  				{
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/extern.h pgsql.2.1/src/interfaces/ecpg/ecpglib/extern.h
*** pgsql.orig/src/interfaces/ecpg/ecpglib/extern.h	2009-05-25 12:08:48.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/ecpglib/extern.h	2010-01-01 16:25:58.000000000 +0100
***************
*** 6,11 ****
--- 6,13 ----
  #include "postgres_fe.h"
  #include "libpq-fe.h"
  #include "sqlca.h"
+ #include "sqlda-native.h"
+ #include "sqlda-compat.h"
  #include "ecpg_config.h"
  #ifndef CHAR_BIT
  #include <limits.h>
*************** bool		ecpg_init(const struct connection 
*** 129,134 ****
--- 131,137 ----
  char	   *ecpg_strdup(const char *, int);
  const char *ecpg_type_name(enum ECPGttype);
  int			ecpg_dynamic_type(Oid);
+ int			sqlda_dynamic_type(Oid, enum COMPAT_MODE);
  void		ecpg_free_auto_mem(void);
  void		ecpg_clear_auto_mem(void);
  
*************** void		ecpg_log(const char *format,...);
*** 149,154 ****
--- 152,162 ----
  bool		ecpg_auto_prepare(int, const char *, const int, char **, const char *);
  void		ecpg_init_sqlca(struct sqlca_t * sqlca);
  
+ struct sqlda_compat *ecpg_build_compat_sqlda(int, PGresult *, int, enum COMPAT_MODE);
+ void		ecpg_set_compat_sqlda(int, struct sqlda_compat **, const PGresult *, int, enum COMPAT_MODE);
+ struct sqlda_struct *ecpg_build_native_sqlda(int, PGresult *, int, enum COMPAT_MODE);
+ void		ecpg_set_native_sqlda(int, struct sqlda_struct **, const PGresult *, int, enum COMPAT_MODE);
+ 
  /* SQLSTATE values generated or processed by ecpglib (intentionally
   * not exported -- users should refer to the codes directly) */
  
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/Makefile pgsql.2.1/src/interfaces/ecpg/ecpglib/Makefile
*** pgsql.orig/src/interfaces/ecpg/ecpglib/Makefile	2009-07-13 11:16:41.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/ecpglib/Makefile	2010-01-01 14:35:36.000000000 +0100
*************** override CFLAGS += $(PTHREAD_CFLAGS)
*** 24,30 ****
  # Need to recompile any libpgport object files
  LIBS := $(filter-out -lpgport, $(LIBS))
  
! OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
  	connect.o misc.o path.o pgstrcasecmp.o \
  	$(filter snprintf.o strlcpy.o, $(LIBOBJS))
  
--- 24,30 ----
  # Need to recompile any libpgport object files
  LIBS := $(filter-out -lpgport, $(LIBS))
  
! OBJS= execute.o typename.o descriptor.o sqlda.o data.o error.o prepare.o memory.o \
  	connect.o misc.o path.o pgstrcasecmp.o \
  	$(filter snprintf.o strlcpy.o, $(LIBOBJS))
  
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/sqlda.c pgsql.2.1/src/interfaces/ecpg/ecpglib/sqlda.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/sqlda.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/ecpglib/sqlda.c	2010-01-04 17:48:14.000000000 +0100
***************
*** 0 ****
--- 1,617 ----
+ /*
+  * SQLDA support routines
+  *
+  * The allocated memory area pointed by an sqlda pointer
+  * contains both the metadata and the data, so freeing up
+  * is a simple free(sqlda) as expected by the ESQL/C examples.
+  */
+ 
+ #define POSTGRES_ECPG_INTERNAL
+ #include "postgres_fe.h"
+ #include "pg_type.h"
+ 
+ #include <inttypes.h>
+ #include <dlfcn.h>
+ 
+ #include "ecpg-pthread-win32.h"
+ #include "decimal.h"
+ #include "ecpgtype.h"
+ #include "ecpglib.h"
+ #include "ecpgerrno.h"
+ #include "extern.h"
+ #include "sqlca.h"
+ #include "sqlda-native.h"
+ #include "sqlda-compat.h"
+ 
+ /*
+  * Compute the next variable's offset with
+  * the current variable's size and alignment.
+  * 
+  *
+  * Returns:
+  * - the current variable's offset in *current
+  * - the next variable's offset in *next
+  */
+ static void
+ ecpg_sqlda_align_add_size(long offset, int alignment, int size, long *current, long *next)
+ {
+ 	if (offset % alignment)
+ 		offset += alignment - (offset % alignment);
+ 	if (current)
+ 		*current = offset;
+ 	offset += size;
+ 	if (next)
+ 		*next = offset;
+ }
+ 
+ static long
+ sqlda_compat_empty_size(const PGresult *res)
+ {
+ 	long	offset;
+ 	int	i;
+ 	int	sqld = PQnfields(res);
+ 
+ 	/* Initial size to store main structure and field structures */
+ 	offset = sizeof(struct sqlda_compat) + sqld * sizeof(struct sqlvar_compat);
+ 
+ 	/* Add space for field names */
+ 	for (i = 0; i < sqld; i++)
+ 		offset += strlen(PQfname(res, i)) + 1;
+ 
+ 	/* Add padding to the first field value */
+ 	ecpg_sqlda_align_add_size(offset, sizeof(int), 0, &offset, NULL);
+ 
+ 	return offset;
+ }
+ 
+ static long
+ sqlda_common_total_size(const PGresult *res, int row, enum COMPAT_MODE compat, long offset)
+ {
+ 	int	sqld = PQnfields(res);
+ 	int	i;
+ 	long	next_offset;
+ 
+ 	/* Add space for the field values */
+ 	for (i = 0; i < sqld; i++)
+ 	{
+ 		enum ECPGttype type = sqlda_dynamic_type(PQftype(res, i), compat);
+ 		switch (type)
+ 		{
+ 			case ECPGt_short:
+ 			case ECPGt_unsigned_short:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_int:
+ 			case ECPGt_unsigned_int:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_long:
+ 			case ECPGt_unsigned_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_long_long:
+ 			case ECPGt_unsigned_long_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_bool:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_float:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_double:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_decimal:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_numeric:
+ 				/*
+ 				 * Let's align both the numeric struct and the digits array to int
+ 				 * Unfortunately we need to do double work here to compute the size
+ 				 * of the space needed for the numeric structure.
+ 				 */
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset1 %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				if (!PQgetisnull(res, row, i))
+ 				{
+ 					char	   *val = PQgetvalue(res, row, i);
+ 					numeric	   *num;
+ 
+ 					num = PGTYPESnumeric_from_asc(val, NULL);
+ 					if (!num)
+ 						break;
+ 					ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
+ 					ecpg_log("%s type %s offset2 %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 					PGTYPESnumeric_free(num);
+ 				}
+ 				break;
+ 			case ECPGt_date:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(date), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_timestamp:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(timestamp), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_interval:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(interval), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_char:
+ 			case ECPGt_unsigned_char:
+ 			case ECPGt_string:
+ 			default:
+ 			{
+ 				long	datalen = strlen(PQgetvalue(res, row, i)) + 1;
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			}
+ 		}
+ 		offset = next_offset;
+ 	}
+ 	return offset;
+ }
+ 
+ 
+ static long
+ sqlda_compat_total_size(const PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ 	long	offset;
+ 
+ 	offset = sqlda_compat_empty_size(res);
+ 
+ 	if (row < 0)
+ 		return offset;
+ 
+ 	offset = sqlda_common_total_size(res, row, compat, offset);
+ 	return offset;
+ }
+ 
+ static long
+ sqlda_native_empty_size(const PGresult *res)
+ {
+ 	long	offset;
+ 	int	sqld = PQnfields(res);
+ 
+ 	/* Initial size to store main structure and field structures */
+ 	offset = sizeof(struct sqlda_struct) + (sqld - 1) * sizeof(struct sqlvar_struct);
+ 
+ 	/* Add padding to the first field value */
+ 	ecpg_sqlda_align_add_size(offset, sizeof(int), 0, &offset, NULL);
+ 
+ 	return offset;
+ }
+ 
+ static long
+ sqlda_native_total_size(const PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ 	long	offset;
+ 
+ 	offset = sqlda_native_empty_size(res);
+ 
+ 	if (row < 0)
+ 		return offset;
+ 
+ 	offset = sqlda_common_total_size(res, row, compat, offset);
+ 	return offset;
+ }
+ 
+ /*
+  * Build "struct sqlda_compat" (metadata only) from PGresult
+  * leaving enough space for the field values in
+  * the given row number
+  */
+ struct sqlda_compat *
+ ecpg_build_compat_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ 	struct sqlda_compat *sqlda;
+ 	struct sqlvar_compat *sqlvar;
+ 	char	   *fname;
+ 	long		size;
+ 	int		sqld;
+ 	int		i;
+ 
+ 	size = sqlda_compat_total_size(res, row, compat);
+ 	sqlda = (struct sqlda_compat *)ecpg_alloc(size, line);
+ 	if (!sqlda)
+ 		return NULL;
+ 
+ 	memset(sqlda, 0, size);
+ 	sqlvar = (struct sqlvar_compat *)(sqlda + 1);
+ 	sqld = PQnfields(res);
+ 	fname = (char *)(sqlvar + sqld);
+ 
+ 	sqlda->sqld = sqld;
+ 	ecpg_log("%s sqld = %d\n", __FUNCTION__, sqld);
+ 	sqlda->desc_occ = size; /* cheat here, keep the full allocated size */
+ 	sqlda->sqlvar = sqlvar;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		sqlda->sqlvar[i].sqltype = sqlda_dynamic_type(PQftype(res, i), compat);
+ 		strcpy(fname, PQfname(res, i));
+ 		sqlda->sqlvar[i].sqlname = fname;
+ 		fname += strlen(sqlda->sqlvar[i].sqlname) + 1;
+ 		sqlda->sqlvar[i].sqlformat = (char *)(long)PQfformat(res, i);
+ 		sqlda->sqlvar[i].sqlxid = PQftype(res, i);
+ 		sqlda->sqlvar[i].sqltypelen = PQfsize(res, i);
+ 	}
+ 
+ 	return sqlda;
+ }
+ 
+ /*
+  * Sets values from PGresult.
+  */
+ static int2	value_is_null = -1;
+ static int2	value_is_not_null = 0;
+ 
+ void
+ ecpg_set_compat_sqlda(int lineno, struct sqlda_compat **_sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ 	struct sqlda_compat *sqlda = (*_sqlda);
+ 	int		i;
+ 	long		offset, next_offset;
+ 
+ 	if (row < 0)
+ 		return;
+ 
+ 	/* Offset for the first field value */
+ 	offset = sqlda_compat_empty_size(res);
+ 
+ 	/*
+ 	 * Set sqlvar[i]->sqldata pointers and convert values to correct format
+ 	 */
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		int	isnull;
+ 		int	datalen;
+ 		bool	set_data = true;
+ 
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 			case ECPGt_short:
+ 			case ECPGt_unsigned_short:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(short);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_int:
+ 			case ECPGt_unsigned_int:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(int);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_long:
+ 			case ECPGt_unsigned_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(long);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_long_long:
+ 			case ECPGt_unsigned_long_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(long long);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_bool:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(bool);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_float:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(float);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_double:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(double);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_decimal:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(decimal);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_numeric:
+ 			{
+ 				numeric	   *num;
+ 				char	   *val;
+ 
+ 				set_data = false;
+ 
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(numeric);
+ 				ecpg_log("%s type %s offset1 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 
+ 				if (PQgetisnull(res, row, i))
+ 				{
+ 					ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
+ 					break;
+ 				}
+ 
+ 				val = PQgetvalue(res, row, i);
+ 				num = PGTYPESnumeric_from_asc(val, NULL);
+ 				if (!num)
+ 				{
+ 					ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
+ 					break;
+ 				}
+ 
+ 				memcpy(sqlda->sqlvar[i].sqldata, num, sizeof(numeric));
+ 
+ 				ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
+ 				memcpy((char *)sqlda + offset, num->buf, num->ndigits + 1);
+ 				ecpg_log("%s type %s offset2 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 
+ 				((numeric *)sqlda->sqlvar[i].sqldata)->buf = (NumericDigit *)sqlda + offset;
+ 				((numeric *)sqlda->sqlvar[i].sqldata)->digits = (NumericDigit *)sqlda + offset + (num->digits - num->buf);
+ 
+ 				PGTYPESnumeric_free(num);
+ 
+ 				break;
+ 			}
+ 			case ECPGt_date:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(date), sizeof(date), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(date);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_timestamp:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(timestamp), sizeof(timestamp), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(timestamp);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_interval:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int64_t), sizeof(interval), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(interval);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_char:
+ 			case ECPGt_unsigned_char:
+ 			case ECPGt_string:
+ 			default:
+ 				datalen = strlen(PQgetvalue(res, row, i)) + 1;
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = datalen;
+ 				if (datalen > 32768)
+ 					sqlda->sqlvar[i].sqlilongdata = sqlda->sqlvar[i].sqldata;
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 		}
+ 
+ 		isnull = PQgetisnull(res, row, i);
+ 		ecpg_log("%s row %d col %d %s\n", __FUNCTION__, row, i, isnull ? "IS NULL" : "IS NOT NULL");
+ 		sqlda->sqlvar[i].sqlind = isnull ? &value_is_null : &value_is_not_null;
+ 		sqlda->sqlvar[i].sqlitype = ECPGt_short;
+ 		sqlda->sqlvar[i].sqlilen = sizeof(short);
+ 		if (!isnull)
+ 		{
+ 			if (set_data)
+ 				ecpg_get_data(res, row, i, lineno,
+ 						sqlda->sqlvar[i].sqltype, ECPGt_NO_INDICATOR,
+ 						sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
+ 						ECPG_ARRAY_NONE, compat, false);
+ 		}
+ 		else
+ 			ECPGset_noind_null(sqlda->sqlvar[i].sqltype, sqlda->sqlvar[i].sqldata);
+ 
+ 		offset = next_offset;
+ 	}
+ }
+ 
+ struct sqlda_struct *
+ ecpg_build_native_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ 	struct sqlda_struct *sqlda;
+ 	long		size;
+ 	int		i;
+ 
+ 	size = sqlda_native_total_size(res, row, compat);
+ 	sqlda = (struct sqlda_struct *)ecpg_alloc(size, line);
+ 	if (!sqlda)
+ 		return NULL;
+ 
+ 	memset(sqlda, 0, size);
+ 
+ 	sprintf(sqlda->sqldaid, "SQLDA  ");
+ 	sqlda->sqld = sqlda->sqln = PQnfields(res);
+ 	ecpg_log("%s sqld = %d\n", __FUNCTION__, sqlda->sqld);
+ 	sqlda->sqldabc = sizeof(struct sqlda_struct) + (sqlda->sqld - 1) * sizeof(struct sqlvar_struct);
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		char	   *fname;
+ 
+ 		sqlda->sqlvar[i].sqltype = sqlda_dynamic_type(PQftype(res, i), compat);
+ 		fname = PQfname(res, i);
+ 		sqlda->sqlvar[i].sqlname.length = strlen(fname);
+ 		strcpy(sqlda->sqlvar[i].sqlname.data, fname);
+ 	}
+ 
+ 	return sqlda;
+ }
+ 
+ void
+ ecpg_set_native_sqlda(int lineno, struct sqlda_struct **_sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ 	struct sqlda_struct *sqlda = (*_sqlda);
+ 	int		i;
+ 	long		offset, next_offset;
+ 
+ 	if (row < 0)
+ 		return;
+ 
+ 	/* Offset for the first field value */
+ 	offset = sqlda_native_empty_size(res);
+ 
+ 	/*
+ 	 * Set sqlvar[i]->sqldata pointers and convert values to correct format
+ 	 */
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		int	isnull;
+ 		int	datalen;
+ 		bool	set_data = true;
+ 
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 			case ECPGt_short:
+ 			case ECPGt_unsigned_short:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(short);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_int:
+ 			case ECPGt_unsigned_int:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(int);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_long:
+ 			case ECPGt_unsigned_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(long);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_long_long:
+ 			case ECPGt_unsigned_long_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(long long);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_bool:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(bool);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_float:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(float);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_double:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(double);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_decimal:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(decimal);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_numeric:
+ 			{
+ 				numeric	   *num;
+ 				char	   *val;
+ 
+ 				set_data = false;
+ 
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(numeric);
+ 				ecpg_log("%s type %s offset1 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 
+ 				if (PQgetisnull(res, row, i))
+ 				{
+ 					ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
+ 					break;
+ 				}
+ 
+ 				val = PQgetvalue(res, row, i);
+ 				num = PGTYPESnumeric_from_asc(val, NULL);
+ 				if (!num)
+ 				{
+ 					ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
+ 					break;
+ 				}
+ 
+ 				memcpy(sqlda->sqlvar[i].sqldata, num, sizeof(numeric));
+ 
+ 				ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
+ 				memcpy((char *)sqlda + offset, num->buf, num->ndigits + 1);
+ 				ecpg_log("%s type %s offset2 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 
+ 				((numeric *)sqlda->sqlvar[i].sqldata)->buf = (NumericDigit *)sqlda + offset;
+ 				((numeric *)sqlda->sqlvar[i].sqldata)->digits = (NumericDigit *)sqlda + offset + (num->digits - num->buf);
+ 
+ 				PGTYPESnumeric_free(num);
+ 
+ 				break;
+ 			}
+ 			case ECPGt_date:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(date), sizeof(date), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(date);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_timestamp:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(timestamp), sizeof(timestamp), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(timestamp);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_interval:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int64_t), sizeof(interval), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(interval);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_char:
+ 			case ECPGt_unsigned_char:
+ 			case ECPGt_string:
+ 			default:
+ 				datalen = strlen(PQgetvalue(res, row, i)) + 1;
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = datalen;
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 		}
+ 
+ 		isnull = PQgetisnull(res, row, i);
+ 		ecpg_log("%s row %d col %d %s\n", __FUNCTION__, row, i, isnull ? "IS NULL" : "IS NOT NULL");
+ 		sqlda->sqlvar[i].sqlind = isnull ? &value_is_null : &value_is_not_null;
+ 		if (!isnull)
+ 		{
+ 			if (set_data)
+ 				ecpg_get_data(res, row, i, lineno,
+ 						sqlda->sqlvar[i].sqltype, ECPGt_NO_INDICATOR,
+ 						sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
+ 						ECPG_ARRAY_NONE, compat, false);
+ 		}
+ 
+ 		offset = next_offset;
+ 	}
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/sqlda.c~ pgsql.2.1/src/interfaces/ecpg/ecpglib/sqlda.c~
*** pgsql.orig/src/interfaces/ecpg/ecpglib/sqlda.c~	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/ecpglib/sqlda.c~	2010-01-04 17:48:14.000000000 +0100
***************
*** 0 ****
--- 1,616 ----
+ /*
+  * SQLDA support routines
+  *
+  * The allocated memory area pointed by an sqlda pointer
+  * contains both the metadata and the data, so freeing up
+  * is a simple free(sqlda) as expected by the ESQL/C examples.
+  */
+ 
+ #define POSTGRES_ECPG_INTERNAL
+ #include "postgres_fe.h"
+ #include "pg_type.h"
+ 
+ #include <inttypes.h>
+ #include <dlfcn.h>
+ 
+ #include "ecpg-pthread-win32.h"
+ #include "decimal.h"
+ #include "ecpgtype.h"
+ #include "ecpglib.h"
+ #include "ecpgerrno.h"
+ #include "extern.h"
+ #include "sqlca.h"
+ #include "sqlda-native.h"
+ #include "sqlda-compat.h"
+ 
+ /*
+  * Compute the next variable's offset with
+  * the current variable's size and alignment.
+  * 
+  *
+  * Returns:
+  * - the current variable's offset in *current
+  * - the next variable's offset in *next
+  */
+ static void
+ ecpg_sqlda_align_add_size(long offset, int alignment, int size, long *current, long *next)
+ {
+ 	if (offset % alignment)
+ 		offset += alignment - (offset % alignment);
+ 	if (current)
+ 		*current = offset;
+ 	offset += size;
+ 	if (next)
+ 		*next = offset;
+ }
+ 
+ static long
+ sqlda_compat_empty_size(const PGresult *res)
+ {
+ 	long	offset;
+ 	int	i;
+ 	int	sqld = PQnfields(res);
+ 
+ 	/* Initial size to store main structure and field structures */
+ 	offset = sizeof(struct sqlda_compat) + sqld * sizeof(struct sqlvar_compat);
+ 
+ 	/* Add space for field names */
+ 	for (i = 0; i < sqld; i++)
+ 		offset += strlen(PQfname(res, i)) + 1;
+ 
+ 	/* Add padding to the first field value */
+ 	ecpg_sqlda_align_add_size(offset, sizeof(int), 0, &offset, NULL);
+ 
+ 	return offset;
+ }
+ 
+ static long
+ sqlda_common_total_size(const PGresult *res, int row, enum COMPAT_MODE compat, long offset)
+ {
+ 	int	sqld = PQnfields(res);
+ 	int	i;
+ 	long	next_offset;
+ 
+ 	/* Add space for the field values */
+ 	for (i = 0; i < sqld; i++)
+ 	{
+ 		enum ECPGttype type = sqlda_dynamic_type(PQftype(res, i), compat);
+ 		switch (type)
+ 		{
+ 			case ECPGt_short:
+ 			case ECPGt_unsigned_short:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_int:
+ 			case ECPGt_unsigned_int:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_long:
+ 			case ECPGt_unsigned_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_long_long:
+ 			case ECPGt_unsigned_long_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_bool:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_float:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_double:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_decimal:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_numeric:
+ 				/*
+ 				 * Let's align both the numeric struct and the digits array to int
+ 				 * Unfortunately we need to do double work here to compute the size
+ 				 * of the space needed for the numeric structure.
+ 				 */
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset1 %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				if (!PQgetisnull(res, row, i))
+ 				{
+ 					char	   *val = PQgetvalue(res, row, i);
+ 					numeric	   *num;
+ 
+ 					num = PGTYPESnumeric_from_asc(val, NULL);
+ 					if (!num)
+ 						break;
+ 					ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
+ 					ecpg_log("%s type %s offset2 %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 					PGTYPESnumeric_free(num);
+ 				}
+ 				break;
+ 			case ECPGt_date:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(date), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_timestamp:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(timestamp), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_interval:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(interval), &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			case ECPGt_char:
+ 			case ECPGt_unsigned_char:
+ 			case ECPGt_string:
+ 			default:
+ 			{
+ 				long	datalen = strlen(PQgetvalue(res, row, i)) + 1;
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
+ 				break;
+ 			}
+ 		}
+ 		offset = next_offset;
+ 	}
+ 	return offset;
+ }
+ 
+ 
+ static long
+ sqlda_compat_total_size(const PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ 	long	offset;
+ 
+ 	offset = sqlda_compat_empty_size(res);
+ 
+ 	if (row < 0)
+ 		return offset;
+ 
+ 	offset = sqlda_common_total_size(res, row, compat, offset);
+ 	return offset;
+ }
+ 
+ static long
+ sqlda_native_empty_size(const PGresult *res)
+ {
+ 	long	offset;
+ 	int	sqld = PQnfields(res);
+ 
+ 	/* Initial size to store main structure and field structures */
+ 	offset = sizeof(struct sqlda_struct) + (sqld - 1) * sizeof(struct sqlvar_struct);
+ 
+ 	/* Add padding to the first field value */
+ 	ecpg_sqlda_align_add_size(offset, sizeof(int), 0, &offset, NULL);
+ 
+ 	return offset;
+ }
+ 
+ static long
+ sqlda_native_total_size(const PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ 	long	offset;
+ 
+ 	offset = sqlda_native_empty_size(res);
+ 
+ 	if (row < 0)
+ 		return offset;
+ 
+ 	offset = sqlda_common_total_size(res, row, compat, offset);
+ 	return offset;
+ }
+ 
+ /*
+  * Build "struct sqlda_compat" (metadata only) from PGresult
+  * leaving enough space for the field values in
+  * the given row number
+  */
+ struct sqlda_compat *
+ ecpg_build_compat_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ 	struct sqlda_compat *sqlda;
+ 	struct sqlvar_compat *sqlvar;
+ 	char	   *fname;
+ 	long		size;
+ 	int		sqld;
+ 	int		i;
+ 
+ 	size = sqlda_compat_total_size(res, row, compat);
+ 	sqlda = (struct sqlda_compat *)ecpg_alloc(size, line);
+ 	if (!sqlda)
+ 		return NULL;
+ 
+ 	memset(sqlda, 0, size);
+ 	sqlvar = (struct sqlvar_compat *)(sqlda + 1);
+ 	sqld = PQnfields(res);
+ 	fname = (char *)(sqlvar + sqld);
+ 
+ 	sqlda->sqld = sqld;
+ 	sqlda->desc_occ = size; /* cheat here, keep the full allocated size */
+ 	sqlda->sqlvar = sqlvar;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		sqlda->sqlvar[i].sqltype = sqlda_dynamic_type(PQftype(res, i), compat);
+ 		strcpy(fname, PQfname(res, i));
+ 		sqlda->sqlvar[i].sqlname = fname;
+ 		fname += strlen(sqlda->sqlvar[i].sqlname) + 1;
+ 		sqlda->sqlvar[i].sqlformat = (char *)(long)PQfformat(res, i);
+ 		sqlda->sqlvar[i].sqlxid = PQftype(res, i);
+ 		sqlda->sqlvar[i].sqltypelen = PQfsize(res, i);
+ 	}
+ 
+ 	return sqlda;
+ }
+ 
+ /*
+  * Sets values from PGresult.
+  */
+ static int2	value_is_null = -1;
+ static int2	value_is_not_null = 0;
+ 
+ void
+ ecpg_set_compat_sqlda(int lineno, struct sqlda_compat **_sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ 	struct sqlda_compat *sqlda = (*_sqlda);
+ 	int		i;
+ 	long		offset, next_offset;
+ 
+ 	if (row < 0)
+ 		return;
+ 
+ 	/* Offset for the first field value */
+ 	offset = sqlda_compat_empty_size(res);
+ 
+ 	/*
+ 	 * Set sqlvar[i]->sqldata pointers and convert values to correct format
+ 	 */
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		int	isnull;
+ 		int	datalen;
+ 		bool	set_data = true;
+ 
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 			case ECPGt_short:
+ 			case ECPGt_unsigned_short:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(short);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_int:
+ 			case ECPGt_unsigned_int:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(int);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_long:
+ 			case ECPGt_unsigned_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(long);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_long_long:
+ 			case ECPGt_unsigned_long_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(long long);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_bool:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(bool);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_float:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(float);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_double:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(double);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_decimal:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(decimal);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_numeric:
+ 			{
+ 				numeric	   *num;
+ 				char	   *val;
+ 
+ 				set_data = false;
+ 
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(numeric);
+ 				ecpg_log("%s type %s offset1 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 
+ 				if (PQgetisnull(res, row, i))
+ 				{
+ 					ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
+ 					break;
+ 				}
+ 
+ 				val = PQgetvalue(res, row, i);
+ 				num = PGTYPESnumeric_from_asc(val, NULL);
+ 				if (!num)
+ 				{
+ 					ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
+ 					break;
+ 				}
+ 
+ 				memcpy(sqlda->sqlvar[i].sqldata, num, sizeof(numeric));
+ 
+ 				ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
+ 				memcpy((char *)sqlda + offset, num->buf, num->ndigits + 1);
+ 				ecpg_log("%s type %s offset2 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 
+ 				((numeric *)sqlda->sqlvar[i].sqldata)->buf = (NumericDigit *)sqlda + offset;
+ 				((numeric *)sqlda->sqlvar[i].sqldata)->digits = (NumericDigit *)sqlda + offset + (num->digits - num->buf);
+ 
+ 				PGTYPESnumeric_free(num);
+ 
+ 				break;
+ 			}
+ 			case ECPGt_date:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(date), sizeof(date), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(date);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_timestamp:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(timestamp), sizeof(timestamp), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(timestamp);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_interval:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int64_t), sizeof(interval), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(interval);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_char:
+ 			case ECPGt_unsigned_char:
+ 			case ECPGt_string:
+ 			default:
+ 				datalen = strlen(PQgetvalue(res, row, i)) + 1;
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = datalen;
+ 				if (datalen > 32768)
+ 					sqlda->sqlvar[i].sqlilongdata = sqlda->sqlvar[i].sqldata;
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 		}
+ 
+ 		isnull = PQgetisnull(res, row, i);
+ 		ecpg_log("%s row %d col %d %s\n", __FUNCTION__, row, i, isnull ? "IS NULL" : "IS NOT NULL");
+ 		sqlda->sqlvar[i].sqlind = isnull ? &value_is_null : &value_is_not_null;
+ 		sqlda->sqlvar[i].sqlitype = ECPGt_short;
+ 		sqlda->sqlvar[i].sqlilen = sizeof(short);
+ 		if (!isnull)
+ 		{
+ 			if (set_data)
+ 				ecpg_get_data(res, row, i, lineno,
+ 						sqlda->sqlvar[i].sqltype, ECPGt_NO_INDICATOR,
+ 						sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
+ 						ECPG_ARRAY_NONE, compat, false);
+ 		}
+ 		else
+ 			ECPGset_noind_null(sqlda->sqlvar[i].sqltype, sqlda->sqlvar[i].sqldata);
+ 
+ 		offset = next_offset;
+ 	}
+ }
+ 
+ struct sqlda_struct *
+ ecpg_build_native_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ 	struct sqlda_struct *sqlda;
+ 	long		size;
+ 	int		sqld;
+ 	int		i;
+ 
+ 	size = sqlda_native_total_size(res, row, compat);
+ 	sqlda = (struct sqlda_struct *)ecpg_alloc(size, line);
+ 	if (!sqlda)
+ 		return NULL;
+ 
+ 	memset(sqlda, 0, size);
+ 	sqld = PQnfields(res);
+ 
+ 	sprintf(sqlda->sqldaid, "SQLDA  ");
+ 	sqlda->sqld = sqlda->sqln = sqld;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		char	   *fname;
+ 
+ 		sqlda->sqlvar[i].sqltype = sqlda_dynamic_type(PQftype(res, i), compat);
+ 		fname = PQfname(res, i);
+ 		sqlda->sqlvar[i].sqlname.length = strlen(fname);
+ 		strcpy(sqlda->sqlvar[i].sqlname.data, fname);
+ 	}
+ 
+ 	return sqlda;
+ }
+ 
+ void
+ ecpg_set_native_sqlda(int lineno, struct sqlda_struct **_sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)
+ {
+ 	struct sqlda_struct *sqlda = (*_sqlda);
+ 	int		i;
+ 	long		offset, next_offset;
+ 
+ 	if (row < 0)
+ 		return;
+ 
+ 	/* Offset for the first field value */
+ 	offset = sqlda_native_empty_size(res);
+ 
+ 	/*
+ 	 * Set sqlvar[i]->sqldata pointers and convert values to correct format
+ 	 */
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		int	isnull;
+ 		int	datalen;
+ 		bool	set_data = true;
+ 
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 			case ECPGt_short:
+ 			case ECPGt_unsigned_short:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(short);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_int:
+ 			case ECPGt_unsigned_int:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(int);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_long:
+ 			case ECPGt_unsigned_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(long);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_long_long:
+ 			case ECPGt_unsigned_long_long:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(long long);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_bool:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(bool);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_float:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(float);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_double:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(double);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_decimal:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(decimal);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_numeric:
+ 			{
+ 				numeric	   *num;
+ 				char	   *val;
+ 
+ 				set_data = false;
+ 
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(numeric);
+ 				ecpg_log("%s type %s offset1 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 
+ 				if (PQgetisnull(res, row, i))
+ 				{
+ 					ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
+ 					break;
+ 				}
+ 
+ 				val = PQgetvalue(res, row, i);
+ 				num = PGTYPESnumeric_from_asc(val, NULL);
+ 				if (!num)
+ 				{
+ 					ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
+ 					break;
+ 				}
+ 
+ 				memcpy(sqlda->sqlvar[i].sqldata, num, sizeof(numeric));
+ 
+ 				ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
+ 				memcpy((char *)sqlda + offset, num->buf, num->ndigits + 1);
+ 				ecpg_log("%s type %s offset2 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 
+ 				((numeric *)sqlda->sqlvar[i].sqldata)->buf = (NumericDigit *)sqlda + offset;
+ 				((numeric *)sqlda->sqlvar[i].sqldata)->digits = (NumericDigit *)sqlda + offset + (num->digits - num->buf);
+ 
+ 				PGTYPESnumeric_free(num);
+ 
+ 				break;
+ 			}
+ 			case ECPGt_date:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(date), sizeof(date), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(date);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_timestamp:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(timestamp), sizeof(timestamp), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(timestamp);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_interval:
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int64_t), sizeof(interval), &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = sizeof(interval);
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 			case ECPGt_char:
+ 			case ECPGt_unsigned_char:
+ 			case ECPGt_string:
+ 			default:
+ 				datalen = strlen(PQgetvalue(res, row, i)) + 1;
+ 				ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
+ 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
+ 				sqlda->sqlvar[i].sqllen = datalen;
+ 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
+ 				break;
+ 		}
+ 
+ 		isnull = PQgetisnull(res, row, i);
+ 		ecpg_log("%s row %d col %d %s\n", __FUNCTION__, row, i, isnull ? "IS NULL" : "IS NOT NULL");
+ 		sqlda->sqlvar[i].sqlind = isnull ? &value_is_null : &value_is_not_null;
+ 		if (!isnull)
+ 		{
+ 			if (set_data)
+ 				ecpg_get_data(res, row, i, lineno,
+ 						sqlda->sqlvar[i].sqltype, ECPGt_NO_INDICATOR,
+ 						sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
+ 						ECPG_ARRAY_NONE, compat, false);
+ 		}
+ 
+ 		offset = next_offset;
+ 	}
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/typename.c pgsql.2.1/src/interfaces/ecpg/ecpglib/typename.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/typename.c	2009-08-07 13:06:28.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/ecpglib/typename.c	2010-01-01 14:35:36.000000000 +0100
***************
*** 7,12 ****
--- 7,13 ----
  #include "ecpgtype.h"
  #include "ecpglib.h"
  #include "extern.h"
+ #include "sqltypes.h"
  #include "sql3types.h"
  #include "pg_type.h"
  
*************** ecpg_dynamic_type(Oid type)
*** 100,102 ****
--- 101,142 ----
  			return -(int) type;
  	}
  }
+ 
+ int
+ sqlda_dynamic_type(Oid type, enum COMPAT_MODE compat)
+ {
+ 	switch (type)
+ 	{
+ 		case CHAROID:
+ 		case VARCHAROID:
+ 		case BPCHAROID:
+ 		case TEXTOID:
+ 			return ECPGt_char;
+ 		case INT2OID:
+ 			return ECPGt_short;
+ 		case INT4OID:
+ 			return ECPGt_int;
+ 		case FLOAT8OID:
+ 			return ECPGt_double;
+ 		case FLOAT4OID:
+ 			return ECPGt_float;
+ 		case NUMERICOID:
+ 			return INFORMIX_MODE(compat) ? ECPGt_decimal : ECPGt_numeric;
+ 		case DATEOID:
+ 			return ECPGt_date;
+ 		case TIMESTAMPOID:
+ 		case TIMESTAMPTZOID:
+ 			return ECPGt_timestamp;
+ 		case INTERVALOID:
+ 			return ECPGt_interval;
+ 		case INT8OID:
+ #ifdef HAVE_LONG_LONG_INT_64
+ 			return ECPGt_long_long;
+ #endif
+ #ifdef HAVE_LONG_INT_64
+ 			return ECPGt_long;
+ #endif
+ 		default:
+ 			return (-type);
+ 	}
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/ecpgtype.h pgsql.2.1/src/interfaces/ecpg/include/ecpgtype.h
*** pgsql.orig/src/interfaces/ecpg/include/ecpgtype.h	2009-08-07 13:06:28.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/include/ecpgtype.h	2010-01-01 14:35:36.000000000 +0100
*************** enum ECPGttype
*** 62,68 ****
  	ECPGt_EOIT,					/* End of insert types. */
  	ECPGt_EORT,					/* End of result types. */
  	ECPGt_NO_INDICATOR,			/* no indicator */
! 	ECPGt_string                            /* trimmed (char *) type */
  };
  
   /* descriptor items */
--- 62,69 ----
  	ECPGt_EOIT,					/* End of insert types. */
  	ECPGt_EORT,					/* End of result types. */
  	ECPGt_NO_INDICATOR,			/* no indicator */
! 	ECPGt_string,				/* trimmed (char *) type */
! 	ECPGt_sqlda				/* C struct descriptor */
  };
  
   /* descriptor items */
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/Makefile pgsql.2.1/src/interfaces/ecpg/include/Makefile
*** pgsql.orig/src/interfaces/ecpg/include/Makefile	2009-10-27 20:36:17.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/include/Makefile	2010-01-01 15:03:34.000000000 +0100
*************** install: all installdirs install-headers
*** 14,21 ****
  
  .PHONY: install-headers
  ecpg_headers = ecpgerrno.h ecpglib.h ecpgtype.h sqlca.h sql3types.h ecpg_informix.h \
! 	pgtypes_error.h pgtypes_numeric.h pgtypes_timestamp.h pgtypes_date.h pgtypes_interval.h
! informix_headers = datetime.h decimal.h sqltypes.h sqlda.h
  
  install-headers: $(ecpg_headers) $(informix_headers)
  	$(INSTALL_DATA) $(addprefix $(srcdir)/,$(ecpg_headers)) '$(DESTDIR)$(includedir)/'
--- 14,22 ----
  
  .PHONY: install-headers
  ecpg_headers = ecpgerrno.h ecpglib.h ecpgtype.h sqlca.h sql3types.h ecpg_informix.h \
! 	pgtypes_error.h pgtypes_numeric.h pgtypes_timestamp.h pgtypes_date.h pgtypes_interval.h \
! 	sqlda.h sqlda-compat.h sqlda-native.h
! informix_headers = datetime.h decimal.h sqltypes.h
  
  install-headers: $(ecpg_headers) $(informix_headers)
  	$(INSTALL_DATA) $(addprefix $(srcdir)/,$(ecpg_headers)) '$(DESTDIR)$(includedir)/'
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/sqlda-compat.h pgsql.2.1/src/interfaces/ecpg/include/sqlda-compat.h
*** pgsql.orig/src/interfaces/ecpg/include/sqlda-compat.h	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/include/sqlda-compat.h	2010-01-01 15:01:20.000000000 +0100
***************
*** 0 ****
--- 1,47 ----
+ /*
+  * pgsql/src/interfaces/ecpg/include/sqlda-infx-compat.h
+  */
+ 
+ #ifndef ECPG_SQLDA_COMPAT_H
+ #define ECPG_SQLDA_COMPAT_H
+ 
+ struct sqlvar_compat
+ {
+ 	short	sqltype;		/* variable type                */
+ 	int	sqllen;			/* length in bytes              */
+ 	char	   *sqldata;		/* pointer to data              */
+ 	short	   *sqlind;		/* pointer to indicator         */
+ 	char	   *sqlname;		/* variable name                */
+ 	char	   *sqlformat;		/* reserved for future use      */
+ 	short	sqlitype;		/* ind variable type            */
+ 	short	sqlilen;		/* ind length in bytes          */
+ 	char	   *sqlidata;		/* ind data pointer             */
+ 	int	sqlxid;			/* extended id type             */
+ 	char	   *sqltypename;	/* extended type name           */
+ 	short	sqltypelen;		/* length of extended type name */
+ 	short	sqlownerlen;		/* length of owner name         */
+ 	short	sqlsourcetype;		/* source type for distinct of built-ins */
+ 	char	   *sqlownername;	/* owner name                   */
+ 	int	sqlsourceid;		/* extended id of source type   */
+ 
+ 	/*
+ 	 * sqlilongdata is new.  It supports data that exceeds the 32k
+ 	 * limit.  sqlilen and sqlidata are for backward compatibility
+ 	 * and they have maximum value of <32K.
+ 	 */
+ 	char	   *sqlilongdata;	/* for data field beyond 32K    */
+ 	int	sqlflags;		/* for internal use only        */
+ 	void	   *sqlreserved;	/* reserved for future use      */
+ };
+ 
+ struct sqlda_compat
+ {
+ 	short		sqld;
+ 	struct sqlvar_compat *sqlvar;
+ 	char		desc_name[19];	/* descriptor name              */
+ 	short		desc_occ;	/* size of sqlda structure      */
+ 	struct sqlda_compat *desc_next;	/* pointer to next sqlda struct */
+ 	void		   *reserved;	/* reserved for future use */
+ };
+ 
+ #endif /* ECPG_SQLDA_COMPAT_H */
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/sqlda.h pgsql.2.1/src/interfaces/ecpg/include/sqlda.h
*** pgsql.orig/src/interfaces/ecpg/include/sqlda.h	2009-06-13 18:25:05.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/include/sqlda.h	2010-01-04 12:56:38.000000000 +0100
***************
*** 1,3 ****
--- 1,22 ----
  /*
   * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
   */
+ 
+ #ifndef ECPG_SQLDA_H
+ #define ECPG_SQLDA_H
+ 
+ #ifdef ECPG_INFORMIX_COMPAT
+ 
+ #include "sqlda-compat.h"
+ typedef struct sqlvar_compat	sqlvar_t;
+ typedef struct sqlda_compat	sqlda_t;
+ 
+ #else
+ 
+ #include "sqlda-native.h"
+ typedef struct sqlvar_struct	sqlvar_t;
+ typedef struct sqlda_struct	sqlda_t;
+ 
+ #endif
+ 
+ #endif /* ECPG_SQLDA_H */
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/sqlda-native.h pgsql.2.1/src/interfaces/ecpg/include/sqlda-native.h
*** pgsql.orig/src/interfaces/ecpg/include/sqlda-native.h	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/include/sqlda-native.h	2010-01-04 13:18:23.000000000 +0100
***************
*** 0 ****
--- 1,35 ----
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+ 
+ #ifndef ECPG_SQLDA_NATIVE_H
+ #define ECPG_SQLDA_NATIVE_H
+ 
+ #include "postgres_fe.h"
+ 
+ struct sqlname
+ {
+ 	short		length;
+ 	char		data[NAMEDATALEN];
+ };
+ 
+ struct sqlvar_struct
+ {
+ 	short		sqltype;
+ 	short		sqllen;
+ 	char	   *sqldata;
+ 	short	   *sqlind;
+ 	struct sqlname sqlname;
+ };
+ 
+ struct sqlda_struct
+ {
+ 	char		sqldaid[8];
+ 	long		sqldabc;
+ 	short		sqln;
+ 	short		sqld;
+ 	struct sqlda_struct *desc_next;
+ 	struct sqlvar_struct	sqlvar[1];
+ };
+ 
+ #endif /* ECPG_SQLDA_NATIVE_H */
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/sqltypes.h pgsql.2.1/src/interfaces/ecpg/include/sqltypes.h
*** pgsql.orig/src/interfaces/ecpg/include/sqltypes.h	2009-06-13 18:25:05.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/include/sqltypes.h	2010-01-01 14:35:36.000000000 +0100
***************
*** 4,9 ****
--- 4,11 ----
  #ifndef ECPG_SQLTYPES_H
  #define ECPG_SQLTYPES_H
  
+ #include <limits.h>
+ 
  #define CCHARTYPE	ECPGt_char
  #define CSHORTTYPE	ECPGt_short
  #define CINTTYPE	ECPGt_int
***************
*** 30,33 ****
--- 32,60 ----
  #define CLVCHARPTRTYPE	124
  #define CTYPEMAX	25
  
+ /*
+  * Values used in sqlda->sqlvar[i]->sqltype
+  */
+ #define	SQLCHAR		ECPGt_char
+ #define	SQLSMINT	ECPGt_short
+ #define	SQLINT		ECPGt_int
+ #define	SQLFLOAT	ECPGt_double
+ #define	SQLSMFLOAT	ECPGt_float
+ #define	SQLDECIMAL	ECPGt_decimal
+ #define	SQLSERIAL	ECPGt_int
+ #define	SQLDATE		ECPGt_date
+ #define	SQLDTIME	ECPGt_timestamp
+ #define	SQLTEXT		ECPGt_char
+ #define	SQLVCHAR	ECPGt_char
+ #define SQLINTERVAL     ECPGt_interval
+ #define	SQLNCHAR	ECPGt_char
+ #define	SQLNVCHAR	ECPGt_char
+ #if (LONG_BIT == 64)
+ #define	SQLINT8		ECPGt_long
+ #define	SQLSERIAL8	ECPGt_long
+ #else
+ #define	SQLINT8		ECPGt_long_long
+ #define	SQLSERIAL8	ECPGt_long_long
+ #endif
+ 
  #endif   /* ndef ECPG_SQLTYPES_H */
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/descriptor.c pgsql.2.1/src/interfaces/ecpg/preproc/descriptor.c
*** pgsql.orig/src/interfaces/ecpg/preproc/descriptor.c	2009-01-30 17:28:46.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/preproc/descriptor.c	2010-01-01 14:35:36.000000000 +0100
*************** descriptor_variable(const char *name, in
*** 326,328 ****
--- 326,347 ----
  	strlcpy(descriptor_names[input], name, sizeof(descriptor_names[input]));
  	return (struct variable *) & varspace[input];
  }
+ 
+ struct variable *
+ sqlda_variable(const char *name)
+ {
+ 	struct variable *p = (struct variable *) mm_alloc(sizeof(struct variable));
+ 
+ 	p->name = mm_strdup(name);
+ 	p->type = (struct ECPGtype *) mm_alloc(sizeof(struct ECPGtype));
+ 	p->type->type = ECPGt_sqlda;
+ 	p->type->size = NULL;
+ 	p->type->struct_sizeof = NULL;
+ 	p->type->u.element = NULL;
+ 	p->type->lineno = 0;
+ 	p->brace_level = 0;
+ 	p->next = NULL;
+ 
+ 	return p;
+ }
+ 
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.addons pgsql.2.1/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.addons	2009-12-16 11:30:27.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/preproc/ecpg.addons	2010-01-01 14:35:36.000000000 +0100
*************** ECPG: VariableShowStmtSHOWALL block
*** 409,437 ****
  		$$ = EMPTY;
  	}
  ECPG: FetchStmtMOVEfetch_args rule
! 	| FETCH fetch_args ecpg_into
  	{
  		$$ = cat2_str(make_str("fetch"), $2);
  	}
! 	| FETCH FORWARD cursor_name opt_ecpg_into
  	{
  		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
  		add_additional_variables($3, false);
  		$$ = cat_str(2, make_str("fetch forward"), cursor_marker);
  	}
! 	| FETCH FORWARD from_in cursor_name opt_ecpg_into
  	{
  		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
  		add_additional_variables($4, false);
  		$$ = cat_str(2, make_str("fetch forward from"), cursor_marker);
  	}
! 	| FETCH BACKWARD cursor_name opt_ecpg_into
  	{
  		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
  		add_additional_variables($3, false);
  		$$ = cat_str(2, make_str("fetch backward"), cursor_marker);
  	}
! 	| FETCH BACKWARD from_in cursor_name opt_ecpg_into
  	{
  		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
  		add_additional_variables($4, false);
--- 409,437 ----
  		$$ = EMPTY;
  	}
  ECPG: FetchStmtMOVEfetch_args rule
! 	| FETCH fetch_args ecpg_fetch_into
  	{
  		$$ = cat2_str(make_str("fetch"), $2);
  	}
! 	| FETCH FORWARD cursor_name opt_ecpg_fetch_into
  	{
  		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
  		add_additional_variables($3, false);
  		$$ = cat_str(2, make_str("fetch forward"), cursor_marker);
  	}
! 	| FETCH FORWARD from_in cursor_name opt_ecpg_fetch_into
  	{
  		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
  		add_additional_variables($4, false);
  		$$ = cat_str(2, make_str("fetch forward from"), cursor_marker);
  	}
! 	| FETCH BACKWARD cursor_name opt_ecpg_fetch_into
  	{
  		char *cursor_marker = $3[0] == ':' ? make_str("$0") : $3;
  		add_additional_variables($3, false);
  		$$ = cat_str(2, make_str("fetch backward"), cursor_marker);
  	}
! 	| FETCH BACKWARD from_in cursor_name opt_ecpg_fetch_into
  	{
  		char *cursor_marker = $4[0] == ':' ? make_str("$0") : $4;
  		add_additional_variables($4, false);
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.c pgsql.2.1/src/interfaces/ecpg/preproc/ecpg.c
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.c	2009-08-07 13:06:28.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/preproc/ecpg.c	2010-01-01 14:43:43.000000000 +0100
*************** main(int argc, char *const argv[])
*** 446,451 ****
--- 446,454 ----
  					fprintf(yyout, "/* End of automatic include section */\n");
  				}
  
+ 				if (INFORMIX_MODE)
+ 					fprintf(yyout, "#define ECPG_INFORMIX_COMPAT 1\n");
+ 
  				if (regression_mode)
  					fprintf(yyout, "#define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))\n");
  
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.trailer pgsql.2.1/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.trailer	2009-11-26 18:57:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/preproc/ecpg.trailer	2010-01-01 16:28:15.000000000 +0100
*************** ecpg_using:	USING using_list 	{ $$ = EMP
*** 970,991 ****
  		| using_descriptor      { $$ = $1; }
  		;
  
! using_descriptor: USING opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
  		{
  			add_variable_to_head(&argsinsert, descriptor_variable($4,0), &no_indicator);
  			$$ = EMPTY;
  		}
  		;
  
! into_descriptor: INTO opt_sql SQL_DESCRIPTOR quoted_ident_stringvar
  		{
  			add_variable_to_head(&argsresult, descriptor_variable($4,1), &no_indicator);
  			$$ = EMPTY;
  		}
  		;
  
- opt_sql: /*EMPTY*/ | SQL_SQL;
- 
  using_list: UsingValue | UsingValue ',' using_list;
  
  UsingValue: UsingConst
--- 970,999 ----
  		| using_descriptor      { $$ = $1; }
  		;
  
! using_descriptor: USING SQL_SQL SQL_DESCRIPTOR quoted_ident_stringvar
  		{
  			add_variable_to_head(&argsinsert, descriptor_variable($4,0), &no_indicator);
  			$$ = EMPTY;
  		}
+ 		| USING SQL_DESCRIPTOR name
+ 		{
+ 			add_variable_to_head(&argsinsert, sqlda_variable($3), &no_indicator);
+ 			$$ = EMPTY;
+ 		}
  		;
  
! into_descriptor: INTO SQL_SQL SQL_DESCRIPTOR quoted_ident_stringvar
  		{
  			add_variable_to_head(&argsresult, descriptor_variable($4,1), &no_indicator);
  			$$ = EMPTY;
  		}
+ 		| INTO SQL_DESCRIPTOR name
+ 		{
+ 			add_variable_to_head(&argsresult, sqlda_variable($3), &no_indicator);
+ 			$$ = EMPTY;
+ 		}
  		;
  
  using_list: UsingValue | UsingValue ',' using_list;
  
  UsingValue: UsingConst
*************** ecpg_into: INTO into_list	{ $$ = EMPTY; 
*** 1806,1813 ****
          | into_descriptor	{ $$ = $1; }
  	;
  
! opt_ecpg_into:	/* EMPTY */	{ $$ = EMPTY; }
! 	| ecpg_into		{ $$ = $1; }
  	;
  
  %%
--- 1814,1833 ----
          | into_descriptor	{ $$ = $1; }
  	;
  
! ecpg_fetch_into: ecpg_into	{ $$ = $1; }
! 	| using_descriptor
! 	{
! 		struct variable *var;
! 
! 		var = argsinsert->variable;
! 		remove_variable_from_list(&argsinsert, var);
! 		add_variable_to_head(&argsresult, var, &no_indicator);
! 		$$ = $1;
! 	}
! 	;
! 
! opt_ecpg_fetch_into:	/* EMPTY */	{ $$ = EMPTY; }
! 	| ecpg_fetch_into		{ $$ = $1; }
  	;
  
  %%
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.type pgsql.2.1/src/interfaces/ecpg/preproc/ecpg.type
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.type	2009-11-26 18:57:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/preproc/ecpg.type	2010-01-01 14:35:36.000000000 +0100
***************
*** 61,66 ****
--- 61,67 ----
  %type <str> ecpg_ident
  %type <str> ecpg_interval
  %type <str> ecpg_into
+ %type <str> ecpg_fetch_into
  %type <str> ecpg_param
  %type <str> ecpg_sconst
  %type <str> ecpg_using
***************
*** 76,82 ****
  %type <str> opt_bit_field
  %type <str> opt_connection_name
  %type <str> opt_database_name
! %type <str> opt_ecpg_into
  %type <str> opt_ecpg_using
  %type <str> opt_initializer
  %type <str> opt_options
--- 77,83 ----
  %type <str> opt_bit_field
  %type <str> opt_connection_name
  %type <str> opt_database_name
! %type <str> opt_ecpg_fetch_into
  %type <str> opt_ecpg_using
  %type <str> opt_initializer
  %type <str> opt_options
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/extern.h pgsql.2.1/src/interfaces/ecpg/preproc/extern.h
*** pgsql.orig/src/interfaces/ecpg/preproc/extern.h	2009-11-26 18:57:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/preproc/extern.h	2010-01-01 14:35:36.000000000 +0100
*************** extern void add_descriptor(char *, char 
*** 88,93 ****
--- 88,94 ----
  extern void drop_descriptor(char *, char *);
  extern struct descriptor *lookup_descriptor(char *, char *);
  extern struct variable *descriptor_variable(const char *name, int input);
+ extern struct variable *sqlda_variable(const char *name);
  extern void add_variable_to_head(struct arguments **, struct variable *, struct variable *);
  extern void add_variable_to_tail(struct arguments **, struct variable *, struct variable *);
  extern void remove_variable_from_list(struct arguments ** list, struct variable * var);
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/type.c pgsql.2.1/src/interfaces/ecpg/preproc/type.c
*** pgsql.orig/src/interfaces/ecpg/preproc/type.c	2009-09-03 12:25:47.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/preproc/type.c	2010-01-01 14:35:36.000000000 +0100
*************** get_type(enum ECPGttype type)
*** 194,199 ****
--- 194,202 ----
  		case ECPGt_descriptor:
  			return ("ECPGt_descriptor");
  			break;
+ 		case ECPGt_sqlda:
+ 			return ("ECPGt_sqlda");
+ 			break;
  		case ECPGt_date:
  			return ("ECPGt_date");
  			break;
*************** ECPGdump_a_simple(FILE *o, const char *n
*** 328,333 ****
--- 331,338 ----
  	else if (type == ECPGt_descriptor)
  		/* remember that name here already contains quotes (if needed) */
  		fprintf(o, "\n\tECPGt_descriptor, %s, 0L, 0L, 0L, ", name);
+ 	else if (type == ECPGt_sqlda)
+ 		fprintf(o, "\n\tECPGt_sqlda, &%s, 0L, 0L, 0L, ", name);
  	else
  	{
  		char	   *variable = (char *) mm_alloc(strlen(name) + ((prefix == NULL) ? 0 : strlen(prefix)) + 4);
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/compat_informix/Makefile pgsql.2.1/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.orig/src/interfaces/ecpg/test/compat_informix/Makefile	2006-09-19 17:36:08.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/test/compat_informix/Makefile	2010-01-01 14:35:36.000000000 +0100
*************** TESTS = test_informix test_informix.c \
*** 16,21 ****
--- 16,22 ----
          rfmtdate rfmtdate.c \
          rfmtlong rfmtlong.c \
          rnull rnull.c \
+         sqlda sqlda.c \
          charfuncs charfuncs.c
  
  all: $(TESTS)
*************** test_informix.c: test_informix.pgc ../re
*** 26,31 ****
--- 27,35 ----
  test_informix2.c: test_informix2.pgc ../regression.h
  	$(ECPG) -o $@ -I$(srcdir) $<
  
+ sqlda.c: sqlda.pgc ../regression.h
+ 	$(ECPG) -o $@ -I$(srcdir) $<
+ 
  dec_test.c: dec_test.pgc ../regression.h
  	$(ECPG) -o $@ -I$(srcdir) $<
  
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/compat_informix/sqlda.pgc pgsql.2.1/src/interfaces/ecpg/test/compat_informix/sqlda.pgc
*** pgsql.orig/src/interfaces/ecpg/test/compat_informix/sqlda.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/compat_informix/sqlda.pgc	2010-01-04 14:25:46.000000000 +0100
***************
*** 0 ****
--- 1,254 ----
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql include sqlda.h;
+ exec sql include sqltypes.h;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ /* These shouldn't be under DECLARE SECTION */
+ sqlda_t	*inp_sqlda, *outp_sqlda;
+ 
+ static void
+ dump_sqlda(sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	if (sqlda == NULL)
+ 	{
+ 		printf("dump_sqlda called with NULL sqlda\n");
+ 		return;
+ 	}
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (sqlda->sqlvar[i].sqlind && *(sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", sqlda->sqlvar[i].sqlname);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case SQLCHAR:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLINT:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLINT8:
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLFLOAT:
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLDECIMAL:
+ 			{
+ 				char    val[64];
+ 				dectoasc((dec_t *)sqlda->sqlvar[i].sqldata, val, 64, -1);
+ 				printf("name sqlda descriptor: '%s' value DECIMAL '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ 	char	*stmt1 = "SELECT * FROM t1";
+ 	char	*stmt2 = "SELECT * FROM t1 WHERE id = ?";
+ 	int	rec;
+ 	int	id;
+ exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1 as regress1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table t1(
+ 		id integer,
+ 		t text,
+ 		d1 numeric,
+ 		d2 float8,
+ 		c char(10));
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into t1 values
+ 		(1, 'a', 1.0, 1, 'a'),
+ 		(2, null, null, null, null),
+ 		(3, '"c"', -3, 'nan'::float8, 'c'),
+ 		(4, 'd', 4.0, 4, 'd');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* SQLDA test for getting all records from a table */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id1 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare mycur1 cursor for st_id1;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open mycur1;
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		exec sql fetch 1 from mycur1 into descriptor outp_sqlda; 
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	exec sql whenever not found continue;
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close mycur1;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id1;
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting all records from a table
+ 	   using the Informix-specific FETCH ... USING DESCRIPTOR
+ 	 */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id2 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare mycur2 cursor for st_id2;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open mycur2;
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		exec sql fetch from mycur2 using descriptor outp_sqlda;
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	exec sql whenever not found continue;
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close mycur2;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id2;
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor */
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id3 FROM :stmt2;
+ 
+ 	strcpy(msg, "execute");
+ 	exec sql execute st_id3 using descriptor inp_sqlda into descriptor outp_sqlda;
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id3;
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor
+ 	 * on a named connection
+ 	 */
+ 
+ 	exec sql connect to REGRESSDB1 as con2;
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql at con2 prepare st_id4 FROM :stmt2;
+ 
+ 	strcpy(msg, "execute");
+ 	exec sql at con2 execute st_id4 using descriptor inp_sqlda into descriptor outp_sqlda;
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql at con2 commit;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id4;
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	strcpy(msg, "disconnect");
+ 	exec sql disconnect con2;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table t1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect");
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule pgsql.2.1/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule	2009-11-26 18:57:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/ecpg_schedule	2010-01-01 14:35:36.000000000 +0100
*************** test: compat_informix/charfuncs
*** 3,8 ****
--- 3,9 ----
  test: compat_informix/rfmtdate
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
+ test: compat_informix/sqlda
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: sql/code100
*** 29,34 ****
--- 30,36 ----
  test: sql/copystdout
  test: sql/define
  test: sql/desc
+ test: sql/sqlda
  test: sql/dynalloc
  test: sql/dynalloc2
  test: sql/dyntest
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule_tcp pgsql.2.1/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule_tcp	2009-11-26 18:57:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/ecpg_schedule_tcp	2010-01-01 14:35:36.000000000 +0100
*************** test: compat_informix/charfuncs
*** 3,8 ****
--- 3,9 ----
  test: compat_informix/rfmtdate
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
+ test: compat_informix/sqlda
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: sql/code100
*** 29,34 ****
--- 30,36 ----
  test: sql/copystdout
  test: sql/define
  test: sql/desc
+ test: sql/sqlda
  test: sql/dynalloc
  test: sql/dynalloc2
  test: sql/dyntest
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-charfuncs.c pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-charfuncs.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-charfuncs.c	2008-02-18 13:50:14.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-charfuncs.c	2010-01-04 13:49:39.000000000 +0100
***************
*** 6,11 ****
--- 6,12 ----
  /* Needed for informix compatibility */
  #include <ecpg_informix.h>
  /* End of automatic include section */
+ #define ECPG_INFORMIX_COMPAT 1
  #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
  
  #line 1 "charfuncs.pgc"
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-dec_test.c pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-dec_test.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-dec_test.c	2008-02-18 13:50:14.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-dec_test.c	2010-01-04 13:49:28.000000000 +0100
***************
*** 6,11 ****
--- 6,12 ----
  /* Needed for informix compatibility */
  #include <ecpg_informix.h>
  /* End of automatic include section */
+ #define ECPG_INFORMIX_COMPAT 1
  #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
  
  #line 1 "dec_test.pgc"
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-rfmtdate.c pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-rfmtdate.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-rfmtdate.c	2008-02-18 13:50:14.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-rfmtdate.c	2010-01-04 13:49:54.000000000 +0100
***************
*** 6,11 ****
--- 6,12 ----
  /* Needed for informix compatibility */
  #include <ecpg_informix.h>
  /* End of automatic include section */
+ #define ECPG_INFORMIX_COMPAT 1
  #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
  
  #line 1 "rfmtdate.pgc"
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-rfmtlong.c pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-rfmtlong.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-rfmtlong.c	2008-02-18 13:50:14.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-rfmtlong.c	2010-01-04 13:50:00.000000000 +0100
***************
*** 6,11 ****
--- 6,12 ----
  /* Needed for informix compatibility */
  #include <ecpg_informix.h>
  /* End of automatic include section */
+ #define ECPG_INFORMIX_COMPAT 1
  #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
  
  #line 1 "rfmtlong.pgc"
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-rnull.c pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-rnull.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-rnull.c	2008-12-30 15:28:02.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-rnull.c	2010-01-04 13:50:12.000000000 +0100
***************
*** 6,11 ****
--- 6,12 ----
  /* Needed for informix compatibility */
  #include <ecpg_informix.h>
  /* End of automatic include section */
+ #define ECPG_INFORMIX_COMPAT 1
  #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
  
  #line 1 "rnull.pgc"
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-sqlda.c	2010-01-04 14:30:22.000000000 +0100
***************
*** 0 ****
--- 1,541 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPG_INFORMIX_COMPAT 1
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "sqlda.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 5 "sqlda.pgc"
+ 
+ 
+ 
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+ 
+ #ifndef ECPG_SQLDA_H
+ #define ECPG_SQLDA_H
+ 
+ #ifdef ECPG_INFORMIX_COMPAT
+ 
+ #include "sqlda-compat.h"
+ typedef struct sqlvar_compat	sqlvar_t;
+ typedef struct sqlda_compat	sqlda_t;
+ 
+ #else
+ 
+ #include "sqlda-native.h"
+ typedef struct sqlvar_struct	sqlvar_t;
+ typedef struct sqlda_struct	sqlda_t;
+ 
+ #endif
+ 
+ #endif /* ECPG_SQLDA_H */
+ 
+ #line 7 "sqlda.pgc"
+ 
+ 
+ #line 1 "sqltypes.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqltypes.h,v 1.9 2009/06/11 14:49:13 momjian Exp $
+  */
+ #ifndef ECPG_SQLTYPES_H
+ #define ECPG_SQLTYPES_H
+ 
+ #include <limits.h>
+ 
+ #define CCHARTYPE	ECPGt_char
+ #define CSHORTTYPE	ECPGt_short
+ #define CINTTYPE	ECPGt_int
+ #define CLONGTYPE	ECPGt_long
+ #define CFLOATTYPE	ECPGt_float
+ #define CDOUBLETYPE ECPGt_double
+ #define CDECIMALTYPE	ECPGt_decimal
+ #define CFIXCHARTYPE	108
+ #define CSTRINGTYPE ECPGt_char
+ #define CDATETYPE	ECPGt_date
+ #define CMONEYTYPE	111
+ #define CDTIMETYPE	ECPGt_timestamp
+ #define CLOCATORTYPE	113
+ #define CVCHARTYPE	ECPGt_varchar
+ #define CINVTYPE	115
+ #define CFILETYPE	116
+ #define CINT8TYPE	ECPGt_long_long
+ #define CCOLLTYPE		118
+ #define CLVCHARTYPE		119
+ #define CFIXBINTYPE		120
+ #define CVARBINTYPE		121
+ #define CBOOLTYPE		ECPGt_bool
+ #define CROWTYPE		123
+ #define CLVCHARPTRTYPE	124
+ #define CTYPEMAX	25
+ 
+ /*
+  * Values used in sqlda->sqlvar[i]->sqltype
+  */
+ #define	SQLCHAR		ECPGt_char
+ #define	SQLSMINT	ECPGt_short
+ #define	SQLINT		ECPGt_int
+ #define	SQLFLOAT	ECPGt_double
+ #define	SQLSMFLOAT	ECPGt_float
+ #define	SQLDECIMAL	ECPGt_decimal
+ #define	SQLSERIAL	ECPGt_int
+ #define	SQLDATE		ECPGt_date
+ #define	SQLDTIME	ECPGt_timestamp
+ #define	SQLTEXT		ECPGt_char
+ #define	SQLVCHAR	ECPGt_char
+ #define SQLINTERVAL     ECPGt_interval
+ #define	SQLNCHAR	ECPGt_char
+ #define	SQLNVCHAR	ECPGt_char
+ #if (LONG_BIT == 64)
+ #define	SQLINT8		ECPGt_long
+ #define	SQLSERIAL8	ECPGt_long
+ #else
+ #define	SQLINT8		ECPGt_long_long
+ #define	SQLSERIAL8	ECPGt_long_long
+ #endif
+ 
+ #endif   /* ndef ECPG_SQLTYPES_H */
+ 
+ #line 8 "sqlda.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 10 "sqlda.pgc"
+ 
+ 
+ /* These shouldn't be under DECLARE SECTION */
+ sqlda_t	*inp_sqlda, *outp_sqlda;
+ 
+ static void
+ dump_sqlda(sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	if (sqlda == NULL)
+ 	{
+ 		printf("dump_sqlda called with NULL sqlda\n");
+ 		return;
+ 	}
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (sqlda->sqlvar[i].sqlind && *(sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", sqlda->sqlvar[i].sqlname);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case SQLCHAR:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLINT:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLINT8:
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLFLOAT:
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case SQLDECIMAL:
+ 			{
+ 				char    val[64];
+ 				dectoasc((decimal *)sqlda->sqlvar[i].sqldata, val, 64, -1);
+ 				printf("name sqlda descriptor: '%s' value DECIMAL '%s'\n", sqlda->sqlvar[i].sqlname, val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		
+ 		
+ 
+ #line 60 "sqlda.pgc"
+  char * stmt1 = "SELECT * FROM t1" ;
+  
+ #line 61 "sqlda.pgc"
+  char * stmt2 = "SELECT * FROM t1 WHERE id = ?" ;
+  
+ #line 62 "sqlda.pgc"
+  int rec ;
+  
+ #line 63 "sqlda.pgc"
+  int id ;
+ /* exec sql end declare section */
+ #line 64 "sqlda.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , "regress1", 0); 
+ #line 71 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 71 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 74 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 74 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
+ #line 82 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 82 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 3 , '\"c\"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 89 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 89 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 92 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 92 "sqlda.pgc"
+ 
+ 
+ 	/* SQLDA test for getting all records from a table */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 99 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 99 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	ECPG_informix_reset_sqlca(); /* declare mycur1 cursor for $1 */
+ #line 102 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1", 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 105 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 105 "sqlda.pgc"
+ 
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 107 "sqlda.pgc"
+ 
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 113 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 113 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 113 "sqlda.pgc"
+  
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	/* exec sql whenever not found  continue ; */
+ #line 119 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT);
+ #line 122 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 122 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
+ #line 125 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 125 "sqlda.pgc"
+ 
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting all records from a table
+ 	   using the Informix-specific FETCH ... USING DESCRIPTOR
+ 	 */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
+ #line 136 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 136 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	ECPG_informix_reset_sqlca(); /* declare mycur2 cursor for $1 */
+ #line 139 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1", 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 142 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 142 "sqlda.pgc"
+ 
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 144 "sqlda.pgc"
+ 
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch from mycur2", ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 150 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 150 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 150 "sqlda.pgc"
+ 
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	/* exec sql whenever not found  continue ; */
+ #line 156 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT);
+ #line 159 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 159 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id2");
+ #line 162 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 162 "sqlda.pgc"
+ 
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor */
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id3", stmt2);
+ #line 185 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 185 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "execute");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_execute, "st_id3", 
+ 	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 188 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 188 "sqlda.pgc"
+ 
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id3");
+ #line 193 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 193 "sqlda.pgc"
+ 
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor
+ 	 * on a named connection
+ 	 */
+ 
+ 	{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , "con2", 0); 
+ #line 203 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 203 "sqlda.pgc"
+ 
+ 
+ 	/* Input sqlda has to be built manually */
+ 	inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(sqlda_t));
+ 	inp_sqlda->sqld = 1;
+ 	inp_sqlda->sqlvar = malloc(sizeof(sqlvar_t));
+ 	memset(inp_sqlda->sqlvar, 0, sizeof(sqlvar_t));
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = SQLINT;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, "con2", 0, "st_id4", stmt2);
+ #line 222 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 222 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "execute");
+ 	{ ECPGdo(__LINE__, 1, 1, "con2", 0, ECPGst_execute, "st_id4", 
+ 	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 225 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 225 "sqlda.pgc"
+ 
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, "con2", "commit");
+ #line 230 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 230 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id4");
+ #line 233 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 233 "sqlda.pgc"
+ 
+ 
+ 	free(inp_sqlda->sqlvar);
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	strcpy(msg, "disconnect");
+ 	{ ECPGdisconnect(__LINE__, "con2");
+ #line 240 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 240 "sqlda.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 245 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 245 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 248 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 248 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect");
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 251 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 251 "sqlda.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stderr	2010-01-04 18:18:27.000000000 +0100
***************
*** 0 ****
--- 1,604 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 74: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 74: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 74: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 77: query: create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 77: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 77: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: query: insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 3 , '"c"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: OK: INSERT 0 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 92: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 99: name st_id1; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 105: query: declare mycur1 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 105: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 105: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 1 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 2 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 3 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 4 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: "c" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: -3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: c          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 113: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 113: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 113: no data found on line 113
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 122: query: close mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 122: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 122: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 125: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 136: name st_id2; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 142: query: declare mycur2 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 142: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 142: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 1 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 2 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 3 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 4 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: "c" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: -3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: c          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 150: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: query: fetch from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 150: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 150: no data found on line 150
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 159: query: close mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 159: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 159: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 162: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 185: name st_id3; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 188: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 188: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 188: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 188: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 188: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 188: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 188: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 188: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 188: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 188: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 188: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 193: name st_id3
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 222: name st_id4; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 225: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection con2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 225: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 225: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 225: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 225: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type int offset 672
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 225: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 676
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 225: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type decimal offset 680
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 225: RESULT: 4.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type double offset 736
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 225: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda type char offset 744
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_compat_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 225: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 225: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 230: action "commit"; connection "con2"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 233: name st_id4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection con2 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 245: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 245: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 245: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 248: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-sqlda.stdout	2010-01-01 14:35:36.000000000 +0100
***************
*** 0 ****
--- 1,60 ----
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value DECIMAL '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a         '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value DECIMAL '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c         '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value DECIMAL '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a         '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value DECIMAL '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c         '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value DECIMAL '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-test_informix2.c pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-test_informix2.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-test_informix2.c	2008-12-30 15:28:02.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-test_informix2.c	2010-01-04 13:51:27.000000000 +0100
***************
*** 6,11 ****
--- 6,12 ----
  /* Needed for informix compatibility */
  #include <ecpg_informix.h>
  /* End of automatic include section */
+ #define ECPG_INFORMIX_COMPAT 1
  #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
  
  #line 1 "test_informix2.pgc"
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c	2009-11-11 20:47:12.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c	2010-01-04 13:51:27.000000000 +0100
***************
*** 6,11 ****
--- 6,12 ----
  /* Needed for informix compatibility */
  #include <ecpg_informix.h>
  /* End of automatic include section */
+ #define ECPG_INFORMIX_COMPAT 1
  #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
  
  #line 1 "test_informix.pgc"
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.c pgsql.2.1/src/interfaces/ecpg/test/expected/sql-sqlda.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/sql-sqlda.c	2010-01-04 14:52:41.000000000 +0100
***************
*** 0 ****
--- 1,548 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "sqlda.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ #include <limits.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 6 "sqlda.pgc"
+ 
+ 
+ 
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+ 
+ #ifndef ECPG_SQLDA_H
+ #define ECPG_SQLDA_H
+ 
+ #ifdef ECPG_INFORMIX_COMPAT
+ 
+ #include "sqlda-compat.h"
+ typedef struct sqlvar_compat	sqlvar_t;
+ typedef struct sqlda_compat	sqlda_t;
+ 
+ #else
+ 
+ #include "sqlda-native.h"
+ typedef struct sqlvar_struct	sqlvar_t;
+ typedef struct sqlda_struct	sqlda_t;
+ 
+ #endif
+ 
+ #endif /* ECPG_SQLDA_H */
+ 
+ #line 8 "sqlda.pgc"
+ 
+ 
+ #line 1 "pgtypes_numeric.h"
+ /* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_numeric.h,v 1.16 2006/08/09 07:30:56 meskes Exp $ */
+ 
+ #ifndef PGTYPES_NUMERIC
+ #define PGTYPES_NUMERIC
+ 
+ #define NUMERIC_POS						0x0000
+ #define NUMERIC_NEG						0x4000
+ #define NUMERIC_NAN						0xC000
+ #define NUMERIC_MAX_PRECISION			1000
+ #define NUMERIC_MAX_DISPLAY_SCALE		NUMERIC_MAX_PRECISION
+ #define NUMERIC_MIN_DISPLAY_SCALE		0
+ #define NUMERIC_MIN_SIG_DIGITS			16
+ 
+ #define DECSIZE 30
+ 
+ typedef unsigned char NumericDigit;
+ typedef struct
+ {
+ 	int			ndigits;		/* number of digits in digits[] - can be 0! */
+ 	int			weight;			/* weight of first digit */
+ 	int			rscale;			/* result scale */
+ 	int			dscale;			/* display scale */
+ 	int			sign;			/* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
+ 	NumericDigit *buf;			/* start of alloc'd space for digits[] */
+ 	NumericDigit *digits;		/* decimal digits */
+ } numeric;
+ 
+ typedef struct
+ {
+ 	int			ndigits;		/* number of digits in digits[] - can be 0! */
+ 	int			weight;			/* weight of first digit */
+ 	int			rscale;			/* result scale */
+ 	int			dscale;			/* display scale */
+ 	int			sign;			/* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
+ 	NumericDigit digits[DECSIZE];		/* decimal digits */
+ } decimal;
+ 
+ #ifdef __cplusplus
+ extern		"C"
+ {
+ #endif
+ 
+ numeric    *PGTYPESnumeric_new(void);
+ decimal    *PGTYPESdecimal_new(void);
+ void		PGTYPESnumeric_free(numeric *);
+ void		PGTYPESdecimal_free(decimal *);
+ numeric    *PGTYPESnumeric_from_asc(char *, char **);
+ char	   *PGTYPESnumeric_to_asc(numeric *, int);
+ int			PGTYPESnumeric_add(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_sub(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_mul(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_div(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_cmp(numeric *, numeric *);
+ int			PGTYPESnumeric_from_int(signed int, numeric *);
+ int			PGTYPESnumeric_from_long(signed long int, numeric *);
+ int			PGTYPESnumeric_copy(numeric *, numeric *);
+ int			PGTYPESnumeric_from_double(double, numeric *);
+ int			PGTYPESnumeric_to_double(numeric *, double *);
+ int			PGTYPESnumeric_to_int(numeric *, int *);
+ int			PGTYPESnumeric_to_long(numeric *, long *);
+ int			PGTYPESnumeric_to_decimal(numeric *, decimal *);
+ int			PGTYPESnumeric_from_decimal(decimal *, numeric *);
+ 
+ #ifdef __cplusplus
+ }
+ #endif
+ 
+ #endif   /* PGTYPES_NUMERIC */
+ 
+ #line 9 "sqlda.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 11 "sqlda.pgc"
+ 
+ 
+ /* These shouldn't be under DECLARE SECTION */
+ sqlda_t	*inp_sqlda, *outp_sqlda, *outp_sqlda1;
+ 
+ static void
+ dump_sqlda(sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	if (sqlda == NULL)
+ 	{
+ 		printf("dump_sqlda called with NULL sqlda\n");
+ 		return;
+ 	}
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (sqlda->sqlvar[i].sqlind && *(sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", sqlda->sqlvar[i].sqlname.data);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case ECPGt_char:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname.data, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_int:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname.data, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ #if (LONG_BIT == 64) /* Defined via <limits.h> */
+ 		case ECPGt_long:
+ #else
+ # if (LONG_BIT = 32)
+ 		case ECPGt_long_long:
+ # else
+ #  error Neither "long" nor "long long" are 64-bit
+ # endif
+ #endif
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname.data, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_double:
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname.data, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_numeric:
+ 			{
+ 				char    *val;
+ 
+ 				val = PGTYPESnumeric_to_asc((numeric*)sqlda->sqlvar[i].sqldata, -1);
+ 				printf("name sqlda descriptor: '%s' value NUMERIC '%s'\n", sqlda->sqlvar[i].sqlname.data, val);
+ 				free(val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		
+ 		
+ 
+ #line 71 "sqlda.pgc"
+  char * stmt1 = "SELECT * FROM t1" ;
+  
+ #line 72 "sqlda.pgc"
+  char * stmt2 = "SELECT * FROM t1 WHERE id = ?" ;
+  
+ #line 73 "sqlda.pgc"
+  int rec ;
+  
+ #line 74 "sqlda.pgc"
+  int id ;
+ /* exec sql end declare section */
+ #line 75 "sqlda.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , "regress1", 0); 
+ #line 82 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 82 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 85 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 85 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
+ #line 93 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 93 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 3 , '\"c\"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 100 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 100 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 103 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 103 "sqlda.pgc"
+ 
+ 
+ 	/* SQLDA test for getting all records from a table */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 110 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 110 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	/* declare mycur1 cursor for $1 */
+ #line 113 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1", 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 116 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 116 "sqlda.pgc"
+ 
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 118 "sqlda.pgc"
+ 
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 from mycur1", ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 124 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 124 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 124 "sqlda.pgc"
+  
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	/* exec sql whenever not found  continue ; */
+ #line 130 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur1", ECPGt_EOIT, ECPGt_EORT);
+ #line 133 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 133 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
+ #line 136 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 136 "sqlda.pgc"
+ 
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting ALL records into the sqlda list */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);
+ #line 145 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 145 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "declare");
+ 	/* declare mycur2 cursor for $1 */
+ #line 148 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "open");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1", 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "st_id2", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 151 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 151 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "fetch");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch all from mycur2", ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 154 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 154 "sqlda.pgc"
+ 
+ 
+ 	outp_sqlda1 = outp_sqlda;
+ 	rec = 0;
+ 	while (outp_sqlda1)
+ 	{
+ 		sqlda_t	*ptr;
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda1);
+ 
+ 		ptr = outp_sqlda1;
+ 		outp_sqlda1 = outp_sqlda1->desc_next;
+ 		free(ptr);
+ 	}
+ 
+ 	strcpy(msg, "close");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur2", ECPGt_EOIT, ECPGt_EORT);
+ #line 170 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 170 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
+ #line 173 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 173 "sqlda.pgc"
+ 
+ 
+ 	/* SQLDA test for getting one record using an input descriptor */
+ 
+ 	/*
+ 	 * Input sqlda has to be built manually
+ 	 * sqlda_t contains 1 sqlvar_t structure already.
+ 	 */
+ 	inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(sqlda_t));
+ 	inp_sqlda->sqln = 1;
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id3", stmt2);
+ #line 195 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 195 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "execute");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "st_id3", 
+ 	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 198 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 198 "sqlda.pgc"
+ 
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id3");
+ #line 203 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 203 "sqlda.pgc"
+ 
+ 
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor
+ 	 * on a named connection
+ 	 */
+ 
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , "con2", 0); 
+ #line 212 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 212 "sqlda.pgc"
+ 
+ 
+ 	/*
+ 	 * Input sqlda has to be built manually
+ 	 * sqlda_t contains 1 sqlvar_t structure already.
+ 	 */
+ 	inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(sqlda_t));
+ 	inp_sqlda->sqln = 1;
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, "con2", 0, "st_id4", stmt2);
+ #line 232 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 232 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "execute");
+ 	{ ECPGdo(__LINE__, 0, 1, "con2", 0, ECPGst_execute, "st_id4", 
+ 	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 235 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 235 "sqlda.pgc"
+ 
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, "con2", "commit");
+ #line 240 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 240 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "deallocate");
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id4");
+ #line 243 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 243 "sqlda.pgc"
+ 
+ 
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	strcpy(msg, "disconnect");
+ 	{ ECPGdisconnect(__LINE__, "con2");
+ #line 249 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 249 "sqlda.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 254 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 254 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 257 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 257 "sqlda.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect");
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 260 "sqlda.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 260 "sqlda.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.stderr pgsql.2.1/src/interfaces/ecpg/test/expected/sql-sqlda.stderr
*** pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/sql-sqlda.stderr	2010-01-04 18:18:46.000000000 +0100
***************
*** 0 ****
--- 1,594 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 88: query: create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 88: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 88: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 96: query: insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' ) , ( 2 , null , null , null , null ) , ( 3 , '"c"' , - 3 , 'nan' :: float8 , 'c' ) , ( 4 , 'd' , 4.0 , 4 , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 96: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 96: OK: INSERT 0 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 103: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 110: name st_id1; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: query: declare mycur1 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 1 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 2 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type double offset 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 3 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 4 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: "c" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: c          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 124: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: query: fetch 1 from mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 124: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 124: no data found on line 124
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 133: query: close mycur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 133: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 133: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 136: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 145: name st_id2; query: "SELECT * FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 151: query: declare mycur2 cursor for SELECT * FROM t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 151: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 151: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 154: query: fetch all from mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 154: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 154: correctly got 4 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 154: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 3 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 3 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 3 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 3 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 3 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 154: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 154: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 2 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 2 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: "c" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 2 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 2 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 2 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: c          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 154: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 154: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 1 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 1 col 1 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 1 col 2 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type double offset 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 1 col 3 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 1 col 4 IS NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 154: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 154: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 154: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 154: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 170: query: close mycur2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 170: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 170: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 173: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 195: name st_id3; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 198: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 198: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 198: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 198: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 198: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 198: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 198: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 198: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 198: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 198: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 203: name st_id3
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 232: name st_id4; query: "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 235: query: SELECT * FROM t1 WHERE id = $1; with 1 parameter(s) on connection con2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 235: using PQexecPrepared for "SELECT * FROM t1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 235: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 235: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 235: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 235: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 235: RESULT: d offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 235: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 235: RESULT: d          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 235: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 240: action "commit"; connection "con2"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 243: name st_id4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection con2 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 254: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 254: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 254: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 257: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.stdout pgsql.2.1/src/interfaces/ecpg/test/expected/sql-sqlda.stdout
*** pgsql.orig/src/interfaces/ecpg/test/expected/sql-sqlda.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/expected/sql-sqlda.stdout	2010-01-01 14:35:36.000000000 +0100
***************
*** 0 ****
--- 1,60 ----
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value NUMERIC '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a         '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value NUMERIC '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c         '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value NUMERIC '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ FETCH RECORD 1
+ name sqlda descriptor: 'id' value 1
+ name sqlda descriptor: 't' value 'a'
+ name sqlda descriptor: 'd1' value NUMERIC '1.0'
+ name sqlda descriptor: 'd2' value 1.000000
+ name sqlda descriptor: 'c' value 'a         '
+ FETCH RECORD 2
+ name sqlda descriptor: 'id' value 2
+ name sqlda descriptor: 't' value NULL'
+ name sqlda descriptor: 'd1' value NULL'
+ name sqlda descriptor: 'd2' value NULL'
+ name sqlda descriptor: 'c' value NULL'
+ FETCH RECORD 3
+ name sqlda descriptor: 'id' value 3
+ name sqlda descriptor: 't' value '"c"'
+ name sqlda descriptor: 'd1' value NUMERIC '-3'
+ name sqlda descriptor: 'd2' value nan
+ name sqlda descriptor: 'c' value 'c         '
+ FETCH RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value NUMERIC '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value NUMERIC '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
+ EXECUTE RECORD 4
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'd'
+ name sqlda descriptor: 'd1' value NUMERIC '4.0'
+ name sqlda descriptor: 'd2' value 4.000000
+ name sqlda descriptor: 'c' value 'd         '
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/desc.pgc pgsql.2.1/src/interfaces/ecpg/test/sql/desc.pgc
*** pgsql.orig/src/interfaces/ecpg/test/sql/desc.pgc	2007-08-14 12:01:54.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/test/sql/desc.pgc	2010-01-01 14:35:36.000000000 +0100
*************** main(void)
*** 32,61 ****
  	EXEC SQL PREPARE foo2 FROM :stmt2;
  	EXEC SQL PREPARE foo3 FROM :stmt3;
  
! 	EXEC SQL EXECUTE foo1 USING DESCRIPTOR indesc;
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2null, DATA = :val2;
  
! 	EXEC SQL EXECUTE foo1 USING DESCRIPTOR indesc;
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 3;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val1, DATA = 'this is a long test';
  
! 	EXEC SQL EXECUTE "Foo-1" USING DESCRIPTOR indesc;
  
  	EXEC SQL DEALLOCATE "Foo-1";
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = :val1;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2i, DATA = :val2;
  
! 	EXEC SQL EXECUTE foo2 USING DESCRIPTOR indesc INTO DESCRIPTOR outdesc;
  
  	EXEC SQL GET DESCRIPTOR outdesc VALUE 1 :val2output = DATA;
  	printf("output = %s\n", val2output);
  
  	EXEC SQL DECLARE c1 CURSOR FOR foo2;
! 	EXEC SQL OPEN c1 USING DESCRIPTOR indesc;
  
  	EXEC SQL FETCH next FROM c1 INTO :val1output:ind1, :val2output:ind2;
  	printf("val1=%d (ind1: %d) val2=%s (ind2: %d)\n",
--- 32,61 ----
  	EXEC SQL PREPARE foo2 FROM :stmt2;
  	EXEC SQL PREPARE foo3 FROM :stmt3;
  
! 	EXEC SQL EXECUTE foo1 USING SQL DESCRIPTOR indesc;
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2null, DATA = :val2;
  
! 	EXEC SQL EXECUTE foo1 USING SQL DESCRIPTOR indesc;
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 3;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val1, DATA = 'this is a long test';
  
! 	EXEC SQL EXECUTE "Foo-1" USING SQL DESCRIPTOR indesc;
  
  	EXEC SQL DEALLOCATE "Foo-1";
  
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = :val1;
  	EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2i, DATA = :val2;
  
! 	EXEC SQL EXECUTE foo2 USING SQL DESCRIPTOR indesc INTO SQL DESCRIPTOR outdesc;
  
  	EXEC SQL GET DESCRIPTOR outdesc VALUE 1 :val2output = DATA;
  	printf("output = %s\n", val2output);
  
  	EXEC SQL DECLARE c1 CURSOR FOR foo2;
! 	EXEC SQL OPEN c1 USING SQL DESCRIPTOR indesc;
  
  	EXEC SQL FETCH next FROM c1 INTO :val1output:ind1, :val2output:ind2;
  	printf("val1=%d (ind1: %d) val2=%s (ind2: %d)\n",
*************** main(void)
*** 67,73 ****
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
  
  	EXEC SQL DECLARE c2 CURSOR FOR foo3;
! 	EXEC SQL OPEN c2 USING DESCRIPTOR indesc;
  
  	EXEC SQL FETCH next FROM c2 INTO :val1output, :val2output :val2i;
  	printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output);
--- 67,73 ----
  	EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
  
  	EXEC SQL DECLARE c2 CURSOR FOR foo3;
! 	EXEC SQL OPEN c2 USING SQL DESCRIPTOR indesc;
  
  	EXEC SQL FETCH next FROM c2 INTO :val1output, :val2output :val2i;
  	printf("val1=%d val2=%s\n", val1output, val2i ? "null" : val2output);
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/dynalloc2.pgc pgsql.2.1/src/interfaces/ecpg/test/sql/dynalloc2.pgc
*** pgsql.orig/src/interfaces/ecpg/test/sql/dynalloc2.pgc	2006-08-19 15:42:40.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/test/sql/dynalloc2.pgc	2010-01-01 14:35:36.000000000 +0100
*************** int main(void)
*** 30,36 ****
     exec sql insert into test values (NULL, NULL);
  
     exec sql allocate descriptor mydesc;
!    exec sql select * into descriptor mydesc from test;
     exec sql get descriptor mydesc :colnum=COUNT;
     exec sql get descriptor mydesc value 1 :ip1=DATA, :ipointer1=INDICATOR;
     exec sql get descriptor mydesc value 2 :cp2=DATA, :ipointer2=INDICATOR;
--- 30,36 ----
     exec sql insert into test values (NULL, NULL);
  
     exec sql allocate descriptor mydesc;
!    exec sql select * into sql descriptor mydesc from test;
     exec sql get descriptor mydesc :colnum=COUNT;
     exec sql get descriptor mydesc value 1 :ip1=DATA, :ipointer1=INDICATOR;
     exec sql get descriptor mydesc value 2 :cp2=DATA, :ipointer2=INDICATOR;
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/dynalloc.pgc pgsql.2.1/src/interfaces/ecpg/test/sql/dynalloc.pgc
*** pgsql.orig/src/interfaces/ecpg/test/sql/dynalloc.pgc	2006-08-19 15:42:40.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/test/sql/dynalloc.pgc	2010-01-01 14:35:36.000000000 +0100
*************** int main(void)
*** 39,45 ****
     exec sql insert into test (b, c, d, e, f, g, h, i) values (2.446456, NULL, 'v', 'c', '2003-03-03 12:33:07 PDT', false, NULL, NULL);
  
     exec sql allocate descriptor mydesc;
!    exec sql select a,b,c,d,e,f,g,h,i into descriptor mydesc from test order by a;
     exec sql get descriptor mydesc value 1 :d1=DATA, :i1=INDICATOR;
     exec sql get descriptor mydesc value 2 :d2=DATA, :i2=INDICATOR;
     exec sql get descriptor mydesc value 3 :d3=DATA, :i3=INDICATOR;
--- 39,45 ----
     exec sql insert into test (b, c, d, e, f, g, h, i) values (2.446456, NULL, 'v', 'c', '2003-03-03 12:33:07 PDT', false, NULL, NULL);
  
     exec sql allocate descriptor mydesc;
!    exec sql select a,b,c,d,e,f,g,h,i into sql descriptor mydesc from test order by a;
     exec sql get descriptor mydesc value 1 :d1=DATA, :i1=INDICATOR;
     exec sql get descriptor mydesc value 2 :d2=DATA, :i2=INDICATOR;
     exec sql get descriptor mydesc value 3 :d3=DATA, :i3=INDICATOR;
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/Makefile pgsql.2.1/src/interfaces/ecpg/test/sql/Makefile
*** pgsql.orig/src/interfaces/ecpg/test/sql/Makefile	2007-08-14 12:01:54.000000000 +0200
--- pgsql.2.1/src/interfaces/ecpg/test/sql/Makefile	2010-01-01 14:35:36.000000000 +0100
*************** TESTS = array array.c \
*** 20,25 ****
--- 20,26 ----
          parser parser.c \
          quote quote.c \
          show show.c \
+         sqlda sqlda.c \
          insupd insupd.c 
  
  all: $(TESTS)
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/sql/sqlda.pgc pgsql.2.1/src/interfaces/ecpg/test/sql/sqlda.pgc
*** pgsql.orig/src/interfaces/ecpg/test/sql/sqlda.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.2.1/src/interfaces/ecpg/test/sql/sqlda.pgc	2010-01-04 14:36:24.000000000 +0100
***************
*** 0 ****
--- 1,263 ----
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ #include <limits.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql include sqlda.h;
+ exec sql include pgtypes_numeric.h;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ /* These shouldn't be under DECLARE SECTION */
+ sqlda_t	*inp_sqlda, *outp_sqlda, *outp_sqlda1;
+ 
+ static void
+ dump_sqlda(sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	if (sqlda == NULL)
+ 	{
+ 		printf("dump_sqlda called with NULL sqlda\n");
+ 		return;
+ 	}
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (sqlda->sqlvar[i].sqlind && *(sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", sqlda->sqlvar[i].sqlname.data);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case ECPGt_char:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname.data, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_int:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname.data, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ #if (LONG_BIT == 64) /* Defined via <limits.h> */
+ 		case ECPGt_long:
+ #else
+ # if (LONG_BIT = 32)
+ 		case ECPGt_long_long:
+ # else
+ #  error Neither "long" nor "long long" are 64-bit
+ # endif
+ #endif
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname.data, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_double:
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname.data, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_numeric:
+ 			{
+ 				char    *val;
+ 
+ 				val = PGTYPESnumeric_to_asc((numeric*)sqlda->sqlvar[i].sqldata, -1);
+ 				printf("name sqlda descriptor: '%s' value NUMERIC '%s'\n", sqlda->sqlvar[i].sqlname.data, val);
+ 				free(val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ 	char	*stmt1 = "SELECT * FROM t1";
+ 	char	*stmt2 = "SELECT * FROM t1 WHERE id = ?";
+ 	int	rec;
+ 	int	id;
+ exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1 as regress1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table t1(
+ 		id integer,
+ 		t text,
+ 		d1 numeric,
+ 		d2 float8,
+ 		c char(10));
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into t1 values
+ 		(1, 'a', 1.0, 1, 'a'),
+ 		(2, null, null, null, null),
+ 		(3, '"c"', -3, 'nan'::float8, 'c'),
+ 		(4, 'd', 4.0, 4, 'd');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* SQLDA test for getting all records from a table */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id1 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare mycur1 cursor for st_id1;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open mycur1;
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	rec = 0;
+ 	while (1)
+ 	{
+ 		strcpy(msg, "fetch");
+ 		exec sql fetch 1 from mycur1 into descriptor outp_sqlda; 
+ 
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda);
+ 	}
+ 
+ 	exec sql whenever not found continue;
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close mycur1;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id1;
+ 
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting ALL records into the sqlda list */
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id2 from :stmt1;
+ 
+ 	strcpy(msg, "declare");
+ 	exec sql declare mycur2 cursor for st_id2;
+ 
+ 	strcpy(msg, "open");
+ 	exec sql open mycur2;
+ 
+ 	strcpy(msg, "fetch");
+ 	exec sql fetch all from mycur2 into descriptor outp_sqlda;
+ 
+ 	outp_sqlda1 = outp_sqlda;
+ 	rec = 0;
+ 	while (outp_sqlda1)
+ 	{
+ 		sqlda_t	*ptr;
+ 		printf("FETCH RECORD %d\n", ++rec);
+ 		dump_sqlda(outp_sqlda1);
+ 
+ 		ptr = outp_sqlda1;
+ 		outp_sqlda1 = outp_sqlda1->desc_next;
+ 		free(ptr);
+ 	}
+ 
+ 	strcpy(msg, "close");
+ 	exec sql close mycur2;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id2;
+ 
+ 	/* SQLDA test for getting one record using an input descriptor */
+ 
+ 	/*
+ 	 * Input sqlda has to be built manually
+ 	 * sqlda_t contains 1 sqlvar_t structure already.
+ 	 */
+ 	inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(sqlda_t));
+ 	inp_sqlda->sqln = 1;
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id3 FROM :stmt2;
+ 
+ 	strcpy(msg, "execute");
+ 	exec sql execute st_id3 using descriptor inp_sqlda into descriptor outp_sqlda;
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id3;
+ 
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	/* SQLDA test for getting one record using an input descriptor
+ 	 * on a named connection
+ 	 */
+ 
+ 	exec sql connect to REGRESSDB1 as con2;
+ 
+ 	/*
+ 	 * Input sqlda has to be built manually
+ 	 * sqlda_t contains 1 sqlvar_t structure already.
+ 	 */
+ 	inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(sqlda_t));
+ 	inp_sqlda->sqln = 1;
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 
+ 	printf("EXECUTE RECORD 4\n");
+ 
+ 	id = 4;
+ 
+ 	outp_sqlda = NULL;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql at con2 prepare st_id4 FROM :stmt2;
+ 
+ 	strcpy(msg, "execute");
+ 	exec sql at con2 execute st_id4 using descriptor inp_sqlda into descriptor outp_sqlda;
+ 
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql at con2 commit;
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate prepare st_id4;
+ 
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ 
+ 	strcpy(msg, "disconnect");
+ 	exec sql disconnect con2;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table t1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect");
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
#84Boszormenyi Zoltan
zb@cybertec.at
In reply to: Boszormenyi Zoltan (#73)
1 attachment(s)
ECPG DESCRIBE [OUTPUT] support

Hi,

new patch is attached. Modified according to
the new DB2 / Sybase compatible SQLDA structure.
ECPGdescribe() has an "int compat" parameter, because:
- the (struct prepared_statement *)->stmt ->compat is not set, and
- it's more sensible to use the compat mode of the
ECPGdescribe() caller, because different source files can be
compiled with different (native or compat) modes.
The Informix-specific syntax "DESCRIBE ... INTO sqlda" is also
accepted in native mode now.

Best regards,
Zolt�n B�sz�rm�nyi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

Attachments:

3-pg85-describe-17-ctxdiff.patchtext/x-patch; name=3-pg85-describe-17-ctxdiff.patchDownload
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/ecpglib/descriptor.c pgsql.3/src/interfaces/ecpg/ecpglib/descriptor.c
*** pgsql.2.1/src/interfaces/ecpg/ecpglib/descriptor.c	2009-08-07 13:06:28.000000000 +0200
--- pgsql.3/src/interfaces/ecpg/ecpglib/descriptor.c	2010-01-04 17:04:33.000000000 +0100
***************
*** 13,18 ****
--- 13,19 ----
  #include "ecpgerrno.h"
  #include "extern.h"
  #include "sqlca.h"
+ #include "sqlda.h"
  #include "sql3types.h"
  
  static void descriptor_free(struct descriptor * desc);
*************** get_char_item(int lineno, void *var, enu
*** 226,231 ****
--- 227,238 ----
  	return (true);
  }
  
+ #define RETURN_IF_NO_DATA	if (ntuples < 1) \
+ 				{ \
+ 					ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL); \
+ 					return (false); \
+ 				}
+ 
  bool
  ECPGget_desc(int lineno, const char *desc_name, int index,...)
  {
*************** ECPGget_desc(int lineno, const char *des
*** 244,254 ****
  		return (false);
  
  	ntuples = PQntuples(ECPGresult);
- 	if (ntuples < 1)
- 	{
- 		ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL);
- 		return (false);
- 	}
  
  	if (index < 1 || index > PQnfields(ECPGresult))
  	{
--- 251,256 ----
*************** ECPGget_desc(int lineno, const char *des
*** 283,288 ****
--- 285,291 ----
  		switch (type)
  		{
  			case (ECPGd_indicator):
+ 				RETURN_IF_NO_DATA;
  				data_var.ind_type = vartype;
  				data_var.ind_pointer = var;
  				data_var.ind_varcharsize = varcharsize;
*************** ECPGget_desc(int lineno, const char *des
*** 295,300 ****
--- 298,304 ----
  				break;
  
  			case ECPGd_data:
+ 				RETURN_IF_NO_DATA;
  				data_var.type = vartype;
  				data_var.pointer = var;
  				data_var.varcharsize = varcharsize;
*************** ECPGget_desc(int lineno, const char *des
*** 377,382 ****
--- 381,387 ----
  			case ECPGd_ret_length:
  			case ECPGd_ret_octet:
  
+ 				RETURN_IF_NO_DATA;
  				/*
  				 * this is like ECPGstore_result
  				 */
*************** ECPGget_desc(int lineno, const char *des
*** 480,485 ****
--- 485,491 ----
  	sqlca->sqlerrd[2] = ntuples;
  	return (true);
  }
+ #undef RETURN_IF_NO_DATA
  
  bool
  ECPGset_desc_header(int lineno, const char *desc_name, int count)
*************** ecpg_find_desc(int line, const char *nam
*** 723,730 ****
  }
  
  bool
! ECPGdescribe(int line, bool input, const char *statement,...)
  {
! 	ecpg_log("ECPGdescribe called on line %d for %s: %s\n", line, input ? "input" : "output", statement);
! 	return false;
  }
--- 729,868 ----
  }
  
  bool
! ECPGdescribe(int line, int compat, bool input, const char *connection_name, const char *stmt_name, ...)
  {
! 	bool		ret = false;
! 	struct connection *con;
! 	struct prepared_statement *prep;
! 	PGresult   *res;
! 	va_list		args;
! 
! 	/* DESCRIBE INPUT is not yet supported */
! 	if (input)
! 		return ret;
! 
! 	con = ecpg_get_connection(connection_name);
! 	if (!con)
! 		return false;
! 	prep = ecpg_find_prepared_statement(stmt_name, con, NULL);
! 	if (!prep)
! 		return ret;
! 
! 	va_start(args, stmt_name);
! 
! 	for (;;)
! 	{
! 		enum ECPGttype	type, dummy_type;
! 		void		*ptr, *dummy_ptr;
! 		long		dummy;
! 
! 		/* variable type */
! 		type = va_arg(args, enum ECPGttype);
! 
! 		if (type == ECPGt_EORT)
! 			break;
! 
! 		/* rest of variable parameters*/
! 		ptr = va_arg(args, void *);
! 		dummy = va_arg(args, long);
! 		dummy = va_arg(args, long);
! 		dummy = va_arg(args, long);
! 
! 		/* variable indicator */
! 		dummy_type = va_arg(args, enum ECPGttype);
! 		dummy_ptr = va_arg(args, void *);
! 		dummy = va_arg(args, long);
! 		dummy = va_arg(args, long);
! 		dummy = va_arg(args, long);
! 
! 		switch (type)
! 		{
! 			case ECPGt_descriptor:
! 			{
! 				char	*name = ptr;
! 				struct descriptor *desc = ecpg_find_desc(line, name);
! 
! 				if (desc == NULL)
! 					break;
! 
! 				res = PQdescribePrepared(con->connection, stmt_name);
! 				if (!ecpg_check_PQresult(res, line, con->connection, compat))
! 					break;
! 
! 				if (desc->result != NULL)
! 					PQclear(desc->result);
! 
! 				desc->result = res;
! 				ret = true;
! 				break;
! 			}
! 			case ECPGt_sqlda:
! 			{
! 				if (INFORMIX_MODE(compat))
! 				{
! 					struct sqlda_compat **_sqlda = ptr;
! 					struct sqlda_compat *sqlda;
! 
! 					res = PQdescribePrepared(con->connection, stmt_name);
! 					if (!ecpg_check_PQresult(res, line, con->connection, compat))
! 						break;
! 
! 					sqlda = ecpg_build_compat_sqlda(line, res, -1, compat);
! 					if (sqlda)
! 					{
! 						struct sqlda_compat *sqlda_old = *_sqlda;
! 						struct sqlda_compat *sqlda_old1;
! 
! 						while (sqlda_old)
! 						{
! 							sqlda_old1 = sqlda_old->desc_next;
! 							free(sqlda_old);
! 							sqlda_old = sqlda_old1;
! 						}
! 
! 						*_sqlda = sqlda;
! 						ret = true;
! 					}
! 
! 					PQclear(res);
! 				}
! 				else
! 				{
! 					struct sqlda_struct **_sqlda = ptr;
! 					struct sqlda_struct *sqlda;
! 
! 					res = PQdescribePrepared(con->connection, stmt_name);
! 					if (!ecpg_check_PQresult(res, line, con->connection, compat))
! 						break;
! 
! 					sqlda = ecpg_build_native_sqlda(line, res, -1, compat);
! 					if (sqlda)
! 					{
! 						struct sqlda_struct *sqlda_old = *_sqlda;
! 						struct sqlda_struct *sqlda_old1;
! 
! 						while (sqlda_old)
! 						{
! 							sqlda_old1 = sqlda_old->desc_next;
! 							free(sqlda_old);
! 							sqlda_old = sqlda_old1;
! 						}
! 
! 						*_sqlda = sqlda;
! 						ret = true;
! 					}
! 
! 					PQclear(res);
! 				}
! 				break;
! 			}
! 			default:
! 				/* nothing else may come */
! 				;
! 		}
! 	}
! 
! 	va_end(args);
! 
! 	return ret;
  }
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/ecpglib/extern.h pgsql.3/src/interfaces/ecpg/ecpglib/extern.h
*** pgsql.2.1/src/interfaces/ecpg/ecpglib/extern.h	2010-01-01 16:25:58.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/ecpglib/extern.h	2010-01-04 14:57:13.000000000 +0100
*************** struct statement
*** 60,65 ****
--- 60,74 ----
  	struct variable *outlist;
  };
  
+ /* structure to store prepared statements for a connection */
+ struct prepared_statement
+ {
+ 	char	   *name;
+ 	bool		prepared;
+ 	struct statement *stmt;
+ 	struct prepared_statement *next;
+ };
+ 
  /* structure to store connections */
  struct connection
  {
*************** struct descriptor *ecpggetdescp(int, cha
*** 139,144 ****
--- 148,156 ----
  
  struct descriptor *ecpg_find_desc(int line, const char *name);
  
+ struct prepared_statement *ecpg_find_prepared_statement(const char *,
+ 				  struct connection *, struct prepared_statement **);
+ 
  bool ecpg_store_result(const PGresult *results, int act_field,
  				  const struct statement * stmt, struct variable * var);
  bool		ecpg_store_input(const int, const bool, const struct variable *, char **, bool);
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/ecpglib/prepare.c pgsql.3/src/interfaces/ecpg/ecpglib/prepare.c
*** pgsql.2.1/src/interfaces/ecpg/ecpglib/prepare.c	2009-10-15 13:26:30.000000000 +0200
--- pgsql.3/src/interfaces/ecpg/ecpglib/prepare.c	2010-01-04 14:57:13.000000000 +0100
***************
*** 11,24 ****
  #include "extern.h"
  #include "sqlca.h"
  
- struct prepared_statement
- {
- 	char	   *name;
- 	bool		prepared;
- 	struct statement *stmt;
- 	struct prepared_statement *next;
- };
- 
  #define STMTID_SIZE 32
  
  typedef struct
--- 11,16 ----
*************** static const int stmtCacheNBuckets = 203
*** 35,42 ****
  static const int stmtCacheEntPerBucket = 8;		/* # entries/bucket		*/
  static stmtCacheEntry stmtCacheEntries[16384] = {{0, {0}, 0, 0, 0}};
  
- static struct prepared_statement *find_prepared_statement(const char *name,
- 				 struct connection * con, struct prepared_statement ** prev);
  static bool deallocate_one(int lineno, enum COMPAT_MODE c, struct connection * con,
  		 struct prepared_statement * prev, struct prepared_statement * this);
  
--- 27,32 ----
*************** ECPGprepare(int lineno, const char *conn
*** 126,132 ****
  		return false;
  
  	/* check if we already have prepared this statement */
! 	this = find_prepared_statement(name, con, &prev);
  	if (this && !deallocate_one(lineno, ECPG_COMPAT_PGSQL, con, prev, this))
  		return false;
  
--- 116,122 ----
  		return false;
  
  	/* check if we already have prepared this statement */
! 	this = ecpg_find_prepared_statement(name, con, &prev);
  	if (this && !deallocate_one(lineno, ECPG_COMPAT_PGSQL, con, prev, this))
  		return false;
  
*************** ECPGprepare(int lineno, const char *conn
*** 179,186 ****
  	return true;
  }
  
! static struct prepared_statement *
! find_prepared_statement(const char *name,
  				 struct connection * con, struct prepared_statement ** prev_)
  {
  	struct prepared_statement *this,
--- 169,176 ----
  	return true;
  }
  
! struct prepared_statement *
! ecpg_find_prepared_statement(const char *name,
  				 struct connection * con, struct prepared_statement ** prev_)
  {
  	struct prepared_statement *this,
*************** ECPGdeallocate(int lineno, int c, const 
*** 262,268 ****
  	if (!ecpg_init(con, connection_name, lineno))
  		return false;
  
! 	this = find_prepared_statement(name, con, &prev);
  	if (this)
  		return deallocate_one(lineno, c, con, prev, this);
  
--- 252,258 ----
  	if (!ecpg_init(con, connection_name, lineno))
  		return false;
  
! 	this = ecpg_find_prepared_statement(name, con, &prev);
  	if (this)
  		return deallocate_one(lineno, c, con, prev, this);
  
*************** ecpg_prepared(const char *name, struct c
*** 297,303 ****
  {
  	struct prepared_statement *this;
  
! 	this = find_prepared_statement(name, con, NULL);
  	return this ? this->stmt->command : NULL;
  }
  
--- 287,293 ----
  {
  	struct prepared_statement *this;
  
! 	this = ecpg_find_prepared_statement(name, con, NULL);
  	return this ? this->stmt->command : NULL;
  }
  
*************** ecpg_freeStmtCacheEntry(int lineno, int 
*** 394,400 ****
  	con = ecpg_get_connection(entry->connection);
  
  	/* free the 'prepared_statement' list entry		  */
! 	this = find_prepared_statement(entry->stmtID, con, &prev);
  	if (this && !deallocate_one(lineno, compat, con, prev, this))
  		return (-1);
  
--- 384,390 ----
  	con = ecpg_get_connection(entry->connection);
  
  	/* free the 'prepared_statement' list entry		  */
! 	this = ecpg_find_prepared_statement(entry->stmtID, con, &prev);
  	if (this && !deallocate_one(lineno, compat, con, prev, this))
  		return (-1);
  
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/ecpglib/sqlda.c~ pgsql.3/src/interfaces/ecpg/ecpglib/sqlda.c~
*** pgsql.2.1/src/interfaces/ecpg/ecpglib/sqlda.c~	2010-01-04 17:48:14.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/ecpglib/sqlda.c~	1970-01-01 01:00:00.000000000 +0100
***************
*** 1,616 ****
- /*
-  * SQLDA support routines
-  *
-  * The allocated memory area pointed by an sqlda pointer
-  * contains both the metadata and the data, so freeing up
-  * is a simple free(sqlda) as expected by the ESQL/C examples.
-  */
- 
- #define POSTGRES_ECPG_INTERNAL
- #include "postgres_fe.h"
- #include "pg_type.h"
- 
- #include <inttypes.h>
- #include <dlfcn.h>
- 
- #include "ecpg-pthread-win32.h"
- #include "decimal.h"
- #include "ecpgtype.h"
- #include "ecpglib.h"
- #include "ecpgerrno.h"
- #include "extern.h"
- #include "sqlca.h"
- #include "sqlda-native.h"
- #include "sqlda-compat.h"
- 
- /*
-  * Compute the next variable's offset with
-  * the current variable's size and alignment.
-  * 
-  *
-  * Returns:
-  * - the current variable's offset in *current
-  * - the next variable's offset in *next
-  */
- static void
- ecpg_sqlda_align_add_size(long offset, int alignment, int size, long *current, long *next)
- {
- 	if (offset % alignment)
- 		offset += alignment - (offset % alignment);
- 	if (current)
- 		*current = offset;
- 	offset += size;
- 	if (next)
- 		*next = offset;
- }
- 
- static long
- sqlda_compat_empty_size(const PGresult *res)
- {
- 	long	offset;
- 	int	i;
- 	int	sqld = PQnfields(res);
- 
- 	/* Initial size to store main structure and field structures */
- 	offset = sizeof(struct sqlda_compat) + sqld * sizeof(struct sqlvar_compat);
- 
- 	/* Add space for field names */
- 	for (i = 0; i < sqld; i++)
- 		offset += strlen(PQfname(res, i)) + 1;
- 
- 	/* Add padding to the first field value */
- 	ecpg_sqlda_align_add_size(offset, sizeof(int), 0, &offset, NULL);
- 
- 	return offset;
- }
- 
- static long
- sqlda_common_total_size(const PGresult *res, int row, enum COMPAT_MODE compat, long offset)
- {
- 	int	sqld = PQnfields(res);
- 	int	i;
- 	long	next_offset;
- 
- 	/* Add space for the field values */
- 	for (i = 0; i < sqld; i++)
- 	{
- 		enum ECPGttype type = sqlda_dynamic_type(PQftype(res, i), compat);
- 		switch (type)
- 		{
- 			case ECPGt_short:
- 			case ECPGt_unsigned_short:
- 				ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
- 				break;
- 			case ECPGt_int:
- 			case ECPGt_unsigned_int:
- 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
- 				break;
- 			case ECPGt_long:
- 			case ECPGt_unsigned_long:
- 				ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
- 				break;
- 			case ECPGt_long_long:
- 			case ECPGt_unsigned_long_long:
- 				ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
- 				break;
- 			case ECPGt_bool:
- 				ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
- 				break;
- 			case ECPGt_float:
- 				ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
- 				break;
- 			case ECPGt_double:
- 				ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
- 				break;
- 			case ECPGt_decimal:
- 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
- 				break;
- 			case ECPGt_numeric:
- 				/*
- 				 * Let's align both the numeric struct and the digits array to int
- 				 * Unfortunately we need to do double work here to compute the size
- 				 * of the space needed for the numeric structure.
- 				 */
- 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
- 				ecpg_log("%s type %s offset1 %d\n", __FUNCTION__, ecpg_type_name(type), offset);
- 				if (!PQgetisnull(res, row, i))
- 				{
- 					char	   *val = PQgetvalue(res, row, i);
- 					numeric	   *num;
- 
- 					num = PGTYPESnumeric_from_asc(val, NULL);
- 					if (!num)
- 						break;
- 					ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
- 					ecpg_log("%s type %s offset2 %d\n", __FUNCTION__, ecpg_type_name(type), offset);
- 					PGTYPESnumeric_free(num);
- 				}
- 				break;
- 			case ECPGt_date:
- 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(date), &offset, &next_offset);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
- 				break;
- 			case ECPGt_timestamp:
- 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(timestamp), &offset, &next_offset);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
- 				break;
- 			case ECPGt_interval:
- 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(interval), &offset, &next_offset);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
- 				break;
- 			case ECPGt_char:
- 			case ECPGt_unsigned_char:
- 			case ECPGt_string:
- 			default:
- 			{
- 				long	datalen = strlen(PQgetvalue(res, row, i)) + 1;
- 				ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(type), offset);
- 				break;
- 			}
- 		}
- 		offset = next_offset;
- 	}
- 	return offset;
- }
- 
- 
- static long
- sqlda_compat_total_size(const PGresult *res, int row, enum COMPAT_MODE compat)
- {
- 	long	offset;
- 
- 	offset = sqlda_compat_empty_size(res);
- 
- 	if (row < 0)
- 		return offset;
- 
- 	offset = sqlda_common_total_size(res, row, compat, offset);
- 	return offset;
- }
- 
- static long
- sqlda_native_empty_size(const PGresult *res)
- {
- 	long	offset;
- 	int	sqld = PQnfields(res);
- 
- 	/* Initial size to store main structure and field structures */
- 	offset = sizeof(struct sqlda_struct) + (sqld - 1) * sizeof(struct sqlvar_struct);
- 
- 	/* Add padding to the first field value */
- 	ecpg_sqlda_align_add_size(offset, sizeof(int), 0, &offset, NULL);
- 
- 	return offset;
- }
- 
- static long
- sqlda_native_total_size(const PGresult *res, int row, enum COMPAT_MODE compat)
- {
- 	long	offset;
- 
- 	offset = sqlda_native_empty_size(res);
- 
- 	if (row < 0)
- 		return offset;
- 
- 	offset = sqlda_common_total_size(res, row, compat, offset);
- 	return offset;
- }
- 
- /*
-  * Build "struct sqlda_compat" (metadata only) from PGresult
-  * leaving enough space for the field values in
-  * the given row number
-  */
- struct sqlda_compat *
- ecpg_build_compat_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compat)
- {
- 	struct sqlda_compat *sqlda;
- 	struct sqlvar_compat *sqlvar;
- 	char	   *fname;
- 	long		size;
- 	int		sqld;
- 	int		i;
- 
- 	size = sqlda_compat_total_size(res, row, compat);
- 	sqlda = (struct sqlda_compat *)ecpg_alloc(size, line);
- 	if (!sqlda)
- 		return NULL;
- 
- 	memset(sqlda, 0, size);
- 	sqlvar = (struct sqlvar_compat *)(sqlda + 1);
- 	sqld = PQnfields(res);
- 	fname = (char *)(sqlvar + sqld);
- 
- 	sqlda->sqld = sqld;
- 	sqlda->desc_occ = size; /* cheat here, keep the full allocated size */
- 	sqlda->sqlvar = sqlvar;
- 
- 	for (i = 0; i < sqlda->sqld; i++)
- 	{
- 		sqlda->sqlvar[i].sqltype = sqlda_dynamic_type(PQftype(res, i), compat);
- 		strcpy(fname, PQfname(res, i));
- 		sqlda->sqlvar[i].sqlname = fname;
- 		fname += strlen(sqlda->sqlvar[i].sqlname) + 1;
- 		sqlda->sqlvar[i].sqlformat = (char *)(long)PQfformat(res, i);
- 		sqlda->sqlvar[i].sqlxid = PQftype(res, i);
- 		sqlda->sqlvar[i].sqltypelen = PQfsize(res, i);
- 	}
- 
- 	return sqlda;
- }
- 
- /*
-  * Sets values from PGresult.
-  */
- static int2	value_is_null = -1;
- static int2	value_is_not_null = 0;
- 
- void
- ecpg_set_compat_sqlda(int lineno, struct sqlda_compat **_sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)
- {
- 	struct sqlda_compat *sqlda = (*_sqlda);
- 	int		i;
- 	long		offset, next_offset;
- 
- 	if (row < 0)
- 		return;
- 
- 	/* Offset for the first field value */
- 	offset = sqlda_compat_empty_size(res);
- 
- 	/*
- 	 * Set sqlvar[i]->sqldata pointers and convert values to correct format
- 	 */
- 	for (i = 0; i < sqlda->sqld; i++)
- 	{
- 		int	isnull;
- 		int	datalen;
- 		bool	set_data = true;
- 
- 		switch (sqlda->sqlvar[i].sqltype)
- 		{
- 			case ECPGt_short:
- 			case ECPGt_unsigned_short:
- 				ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(short);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 			case ECPGt_int:
- 			case ECPGt_unsigned_int:
- 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(int);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 			case ECPGt_long:
- 			case ECPGt_unsigned_long:
- 				ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(long);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 			case ECPGt_long_long:
- 			case ECPGt_unsigned_long_long:
- 				ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(long long);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 			case ECPGt_bool:
- 				ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(bool);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 			case ECPGt_float:
- 				ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(float);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 			case ECPGt_double:
- 				ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(double);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 			case ECPGt_decimal:
- 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(decimal);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 			case ECPGt_numeric:
- 			{
- 				numeric	   *num;
- 				char	   *val;
- 
- 				set_data = false;
- 
- 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(numeric);
- 				ecpg_log("%s type %s offset1 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 
- 				if (PQgetisnull(res, row, i))
- 				{
- 					ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
- 					break;
- 				}
- 
- 				val = PQgetvalue(res, row, i);
- 				num = PGTYPESnumeric_from_asc(val, NULL);
- 				if (!num)
- 				{
- 					ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
- 					break;
- 				}
- 
- 				memcpy(sqlda->sqlvar[i].sqldata, num, sizeof(numeric));
- 
- 				ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
- 				memcpy((char *)sqlda + offset, num->buf, num->ndigits + 1);
- 				ecpg_log("%s type %s offset2 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 
- 				((numeric *)sqlda->sqlvar[i].sqldata)->buf = (NumericDigit *)sqlda + offset;
- 				((numeric *)sqlda->sqlvar[i].sqldata)->digits = (NumericDigit *)sqlda + offset + (num->digits - num->buf);
- 
- 				PGTYPESnumeric_free(num);
- 
- 				break;
- 			}
- 			case ECPGt_date:
- 				ecpg_sqlda_align_add_size(offset, sizeof(date), sizeof(date), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(date);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 			case ECPGt_timestamp:
- 				ecpg_sqlda_align_add_size(offset, sizeof(timestamp), sizeof(timestamp), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(timestamp);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 			case ECPGt_interval:
- 				ecpg_sqlda_align_add_size(offset, sizeof(int64_t), sizeof(interval), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(interval);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 			case ECPGt_char:
- 			case ECPGt_unsigned_char:
- 			case ECPGt_string:
- 			default:
- 				datalen = strlen(PQgetvalue(res, row, i)) + 1;
- 				ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = datalen;
- 				if (datalen > 32768)
- 					sqlda->sqlvar[i].sqlilongdata = sqlda->sqlvar[i].sqldata;
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 		}
- 
- 		isnull = PQgetisnull(res, row, i);
- 		ecpg_log("%s row %d col %d %s\n", __FUNCTION__, row, i, isnull ? "IS NULL" : "IS NOT NULL");
- 		sqlda->sqlvar[i].sqlind = isnull ? &value_is_null : &value_is_not_null;
- 		sqlda->sqlvar[i].sqlitype = ECPGt_short;
- 		sqlda->sqlvar[i].sqlilen = sizeof(short);
- 		if (!isnull)
- 		{
- 			if (set_data)
- 				ecpg_get_data(res, row, i, lineno,
- 						sqlda->sqlvar[i].sqltype, ECPGt_NO_INDICATOR,
- 						sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
- 						ECPG_ARRAY_NONE, compat, false);
- 		}
- 		else
- 			ECPGset_noind_null(sqlda->sqlvar[i].sqltype, sqlda->sqlvar[i].sqldata);
- 
- 		offset = next_offset;
- 	}
- }
- 
- struct sqlda_struct *
- ecpg_build_native_sqlda(int line, PGresult *res, int row, enum COMPAT_MODE compat)
- {
- 	struct sqlda_struct *sqlda;
- 	long		size;
- 	int		sqld;
- 	int		i;
- 
- 	size = sqlda_native_total_size(res, row, compat);
- 	sqlda = (struct sqlda_struct *)ecpg_alloc(size, line);
- 	if (!sqlda)
- 		return NULL;
- 
- 	memset(sqlda, 0, size);
- 	sqld = PQnfields(res);
- 
- 	sprintf(sqlda->sqldaid, "SQLDA  ");
- 	sqlda->sqld = sqlda->sqln = sqld;
- 
- 	for (i = 0; i < sqlda->sqld; i++)
- 	{
- 		char	   *fname;
- 
- 		sqlda->sqlvar[i].sqltype = sqlda_dynamic_type(PQftype(res, i), compat);
- 		fname = PQfname(res, i);
- 		sqlda->sqlvar[i].sqlname.length = strlen(fname);
- 		strcpy(sqlda->sqlvar[i].sqlname.data, fname);
- 	}
- 
- 	return sqlda;
- }
- 
- void
- ecpg_set_native_sqlda(int lineno, struct sqlda_struct **_sqlda, const PGresult *res, int row, enum COMPAT_MODE compat)
- {
- 	struct sqlda_struct *sqlda = (*_sqlda);
- 	int		i;
- 	long		offset, next_offset;
- 
- 	if (row < 0)
- 		return;
- 
- 	/* Offset for the first field value */
- 	offset = sqlda_native_empty_size(res);
- 
- 	/*
- 	 * Set sqlvar[i]->sqldata pointers and convert values to correct format
- 	 */
- 	for (i = 0; i < sqlda->sqld; i++)
- 	{
- 		int	isnull;
- 		int	datalen;
- 		bool	set_data = true;
- 
- 		switch (sqlda->sqlvar[i].sqltype)
- 		{
- 			case ECPGt_short:
- 			case ECPGt_unsigned_short:
- 				ecpg_sqlda_align_add_size(offset, sizeof(short), sizeof(short), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(short);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 			case ECPGt_int:
- 			case ECPGt_unsigned_int:
- 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(int), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(int);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 			case ECPGt_long:
- 			case ECPGt_unsigned_long:
- 				ecpg_sqlda_align_add_size(offset, sizeof(long), sizeof(long), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(long);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 			case ECPGt_long_long:
- 			case ECPGt_unsigned_long_long:
- 				ecpg_sqlda_align_add_size(offset, sizeof(long long), sizeof(long long), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(long long);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 			case ECPGt_bool:
- 				ecpg_sqlda_align_add_size(offset, sizeof(bool), sizeof(bool), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(bool);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 			case ECPGt_float:
- 				ecpg_sqlda_align_add_size(offset, sizeof(float), sizeof(float), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(float);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 			case ECPGt_double:
- 				ecpg_sqlda_align_add_size(offset, sizeof(double), sizeof(double), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(double);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 			case ECPGt_decimal:
- 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(decimal), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(decimal);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 			case ECPGt_numeric:
- 			{
- 				numeric	   *num;
- 				char	   *val;
- 
- 				set_data = false;
- 
- 				ecpg_sqlda_align_add_size(offset, sizeof(int), sizeof(numeric), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(numeric);
- 				ecpg_log("%s type %s offset1 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 
- 				if (PQgetisnull(res, row, i))
- 				{
- 					ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
- 					break;
- 				}
- 
- 				val = PQgetvalue(res, row, i);
- 				num = PGTYPESnumeric_from_asc(val, NULL);
- 				if (!num)
- 				{
- 					ECPGset_noind_null(ECPGt_numeric, sqlda->sqlvar[i].sqldata);
- 					break;
- 				}
- 
- 				memcpy(sqlda->sqlvar[i].sqldata, num, sizeof(numeric));
- 
- 				ecpg_sqlda_align_add_size(next_offset, sizeof(int), num->ndigits + 1, &offset, &next_offset);
- 				memcpy((char *)sqlda + offset, num->buf, num->ndigits + 1);
- 				ecpg_log("%s type %s offset2 %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 
- 				((numeric *)sqlda->sqlvar[i].sqldata)->buf = (NumericDigit *)sqlda + offset;
- 				((numeric *)sqlda->sqlvar[i].sqldata)->digits = (NumericDigit *)sqlda + offset + (num->digits - num->buf);
- 
- 				PGTYPESnumeric_free(num);
- 
- 				break;
- 			}
- 			case ECPGt_date:
- 				ecpg_sqlda_align_add_size(offset, sizeof(date), sizeof(date), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(date);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 			case ECPGt_timestamp:
- 				ecpg_sqlda_align_add_size(offset, sizeof(timestamp), sizeof(timestamp), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(timestamp);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 			case ECPGt_interval:
- 				ecpg_sqlda_align_add_size(offset, sizeof(int64_t), sizeof(interval), &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = sizeof(interval);
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 			case ECPGt_char:
- 			case ECPGt_unsigned_char:
- 			case ECPGt_string:
- 			default:
- 				datalen = strlen(PQgetvalue(res, row, i)) + 1;
- 				ecpg_sqlda_align_add_size(offset, sizeof(int), datalen, &offset, &next_offset);
- 				sqlda->sqlvar[i].sqldata = (char *)sqlda + offset;
- 				sqlda->sqlvar[i].sqllen = datalen;
- 				ecpg_log("%s type %s offset %d\n", __FUNCTION__, ecpg_type_name(sqlda->sqlvar[i].sqltype), offset);
- 				break;
- 		}
- 
- 		isnull = PQgetisnull(res, row, i);
- 		ecpg_log("%s row %d col %d %s\n", __FUNCTION__, row, i, isnull ? "IS NULL" : "IS NOT NULL");
- 		sqlda->sqlvar[i].sqlind = isnull ? &value_is_null : &value_is_not_null;
- 		if (!isnull)
- 		{
- 			if (set_data)
- 				ecpg_get_data(res, row, i, lineno,
- 						sqlda->sqlvar[i].sqltype, ECPGt_NO_INDICATOR,
- 						sqlda->sqlvar[i].sqldata, NULL, 0, 0, 0,
- 						ECPG_ARRAY_NONE, compat, false);
- 		}
- 
- 		offset = next_offset;
- 	}
- }
--- 0 ----
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/include/ecpglib.h pgsql.3/src/interfaces/ecpg/include/ecpglib.h
*** pgsql.2.1/src/interfaces/ecpg/include/ecpglib.h	2009-09-21 15:19:11.000000000 +0200
--- pgsql.3/src/interfaces/ecpg/include/ecpglib.h	2010-01-04 17:02:52.000000000 +0100
*************** bool		ECPGset_desc(int, const char *, in
*** 83,89 ****
  
  void		ECPGset_noind_null(enum ECPGttype, void *);
  bool		ECPGis_noind_null(enum ECPGttype, void *);
! bool		ECPGdescribe(int, bool, const char *,...);
  
  /* dynamic result allocation */
  void		ECPGfree_auto_mem(void);
--- 83,89 ----
  
  void		ECPGset_noind_null(enum ECPGttype, void *);
  bool		ECPGis_noind_null(enum ECPGttype, void *);
! bool		ECPGdescribe(int, int, bool, const char *, const char *, ...);
  
  /* dynamic result allocation */
  void		ECPGfree_auto_mem(void);
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/preproc/ecpg.addons pgsql.3/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.2.1/src/interfaces/ecpg/preproc/ecpg.addons	2010-01-01 14:35:36.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/preproc/ecpg.addons	2010-01-04 17:10:40.000000000 +0100
*************** ECPG: stmtViewStmt rule
*** 84,90 ****
  	}
  	| ECPGDescribe
  	{
! 		fprintf(yyout, "{ ECPGdescribe(__LINE__, %s,", $1);
  		dump_variables(argsresult, 1);
  		fputs("ECPGt_EORT);", yyout);
  		fprintf(yyout, "}");
--- 84,90 ----
  	}
  	| ECPGDescribe
  	{
! 		fprintf(yyout, "{ ECPGdescribe(__LINE__, %d, %s,", compat, $1);
  		dump_variables(argsresult, 1);
  		fputs("ECPGt_EORT);", yyout);
  		fprintf(yyout, "}");
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/preproc/ecpg.trailer pgsql.3/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.2.1/src/interfaces/ecpg/preproc/ecpg.trailer	2010-01-01 16:28:15.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/preproc/ecpg.trailer	2010-01-04 15:10:00.000000000 +0100
*************** into_descriptor: INTO SQL_SQL SQL_DESCRI
*** 994,999 ****
--- 994,1006 ----
  		}
  		;
  
+ into_sqlda: INTO name
+ 		{
+ 			add_variable_to_head(&argsresult, sqlda_variable($2), &no_indicator);
+ 			$$ = EMPTY;
+ 		}
+ 		;
+ 
  using_list: UsingValue | UsingValue ',' using_list;
  
  UsingValue: UsingConst
*************** UsingConst: Iconst			{ $$ = $1; }
*** 1019,1046 ****
  		;
  
  /*
!  * We accept descibe but do nothing with it so far.
   */
! ECPGDescribe: SQL_DESCRIBE INPUT_P name using_descriptor
  	{
  		const char *con = connection ? connection : "NULL";
  		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
! 		$$ = (char *) mm_alloc(sizeof("1, ECPGprepared_statement(, \"\", __LINE__)") + strlen(con) + strlen($3));
! 		sprintf($$, "1, ECPGprepared_statement(%s, \"%s\", __LINE__)", con, $3);
  	}
! 	| SQL_DESCRIBE opt_output name using_descriptor
  	{
  		const char *con = connection ? connection : "NULL";
! 		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
! 		$$ = (char *) mm_alloc(sizeof("0, ECPGprepared_statement(, \"\", __LINE__)") + strlen(con) + strlen($3));
! 		sprintf($$, "0, ECPGprepared_statement(%s, \"%s\", __LINE__)", con, $3);
  	}
! 	| SQL_DESCRIBE opt_output name into_descriptor
  	{
  		const char *con = connection ? connection : "NULL";
  		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
! 		$$ = (char *) mm_alloc(sizeof("0, ECPGprepared_statement(, \"\", __LINE__)") + strlen(con) + strlen($3));
! 		sprintf($$, "0, ECPGprepared_statement(%s, \"%s\", __LINE__)", con, $3);
  	}
  	;
  
--- 1026,1070 ----
  		;
  
  /*
!  * We accept DESCRIBE [OUTPUT] but do nothing with DESCRIBE INPUT so far.
   */
! ECPGDescribe: SQL_DESCRIBE INPUT_P prepared_name using_descriptor
  	{
  		const char *con = connection ? connection : "NULL";
  		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
! 		$$ = (char *) mm_alloc(sizeof("1, , ") + strlen(con) + strlen($3));
! 		sprintf($$, "1, %s, %s", con, $3);
  	}
! 	| SQL_DESCRIBE opt_output prepared_name using_descriptor
  	{
  		const char *con = connection ? connection : "NULL";
! 		struct variable *var;
! 
! 		var = argsinsert->variable;
! 		remove_variable_from_list(&argsinsert, var);
! 		add_variable_to_head(&argsresult, var, &no_indicator);
! 
! 		$$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
! 		sprintf($$, "0, %s, %s", con, $3);
  	}
! 	| SQL_DESCRIBE opt_output prepared_name into_descriptor
! 	{
! 		const char *con = connection ? connection : "NULL";
! 		$$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
! 		sprintf($$, "0, %s, %s", con, $3);
! 	}
! 	| SQL_DESCRIBE INPUT_P prepared_name into_sqlda
  	{
  		const char *con = connection ? connection : "NULL";
  		mmerror(PARSE_ERROR, ET_WARNING, "using unsupported DESCRIBE statement");
! 		$$ = (char *) mm_alloc(sizeof("1, , ") + strlen(con) + strlen($3));
! 		sprintf($$, "1, %s, %s", con, $3);
! 	}
! 	| SQL_DESCRIBE opt_output prepared_name into_sqlda
! 	{
! 		const char *con = connection ? connection : "NULL";
! 		$$ = (char *) mm_alloc(sizeof("0, , ") + strlen(con) + strlen($3));
! 		sprintf($$, "0, %s, %s", con, $3);
  	}
  	;
  
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/preproc/ecpg.type pgsql.3/src/interfaces/ecpg/preproc/ecpg.type
*** pgsql.2.1/src/interfaces/ecpg/preproc/ecpg.type	2010-01-01 14:35:36.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/preproc/ecpg.type	2010-01-04 14:57:13.000000000 +0100
***************
*** 72,77 ****
--- 72,78 ----
  %type <str> execute_rest
  %type <str> indicator
  %type <str> into_descriptor
+ %type <str> into_sqlda
  %type <str> Iresult
  %type <str> on_off
  %type <str> opt_bit_field
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/test/compat_informix/describe.pgc pgsql.3/src/interfaces/ecpg/test/compat_informix/describe.pgc
*** pgsql.2.1/src/interfaces/ecpg/test/compat_informix/describe.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/compat_informix/describe.pgc	2010-01-04 15:34:27.000000000 +0100
***************
*** 0 ****
--- 1,199 ----
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ exec sql include ../regression;
+ exec sql include sqlda.h;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ sqlda_t	*sqlda1, *sqlda2, *sqlda3;
+ 
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ 	char	*stmt1 = "SELECT id, t FROM descr_t1";
+ 	char	*stmt2 = "SELECT id, t FROM descr_t1 WHERE id = -1";
+ 	int	i, count1, count2;
+ 	char	field_name1[30] = "not set";
+ 	char	field_name2[30] = "not set";
+ exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table descr_t1(id serial primary key, t text);
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into descr_t1(id, t) values (default, 'a');
+ 	exec sql insert into descr_t1(id, t) values (default, 'b');
+ 	exec sql insert into descr_t1(id, t) values (default, 'c');
+ 	exec sql insert into descr_t1(id, t) values (default, 'd');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/*
+ 	 * Test DESCRIBE with a query producing tuples.
+ 	 * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
+ 	 * Informix-compat mode.
+ 	 */
+ 
+ 	strcpy(msg, "allocate");
+ 	exec sql allocate descriptor desc1;
+ 	exec sql allocate descriptor desc2;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id1 FROM :stmt1;
+ 
+ 	sqlda1 = sqlda2 = sqlda3 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	exec sql describe st_id1 into sql descriptor desc1;
+ 	exec sql describe st_id1 using sql descriptor desc2;
+ 
+ 	exec sql describe st_id1 into descriptor sqlda1;
+ 	exec sql describe st_id1 using descriptor sqlda2;
+ 	exec sql describe st_id1 into sqlda3;
+ 
+ 	if (sqlda1 == NULL)
+ 	{
+ 		printf("sqlda1 NULL\n");
+ 		exit(1);
+ 	}
+ 
+ 	if (sqlda2 == NULL)
+ 	{
+ 		printf("sqlda2 NULL\n");
+ 		exit(1);
+ 	}
+ 
+ 	if (sqlda3 == NULL)
+ 	{
+ 		printf("sqlda3 NULL\n");
+ 		exit(1);
+ 	}
+ 
+ 	strcpy(msg, "get descriptor");
+ 	exec sql get descriptor desc1 :count1 = count;
+ 	exec sql get descriptor desc1 :count2 = count;
+ 
+ 	if (count1 != count2)
+ 	{
+ 		printf("count1 (%d) != count2 (%d)\n", count1, count2);
+ 		exit(1);
+ 	}
+ 
+ 	if (count1 != sqlda1->sqld)
+ 	{
+ 		printf("count1 (%d) != sqlda1->sqld (%d)\n", count1, sqlda1->sqld);
+ 		exit(1);
+ 	}
+ 
+ 	if (count1 != sqlda2->sqld)
+ 	{
+ 		printf("count1 (%d) != sqlda2->sqld (%d)\n", count1, sqlda2->sqld);
+ 		exit(1);
+ 	}
+ 
+ 	if (count1 != sqlda3->sqld)
+ 	{
+ 		printf("count1 (%d) != sqlda3->sqld (%d)\n", count1, sqlda3->sqld);
+ 		exit(1);
+ 	}
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		exec sql get descriptor desc1 value :i :field_name1 = name;
+ 		exec sql get descriptor desc2 value :i :field_name2 = name;
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname,
+ 			sqlda3->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate descriptor desc1;
+ 	exec sql deallocate descriptor desc2;
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 	free(sqlda3);
+ 
+ 	exec sql deallocate prepare st_id1;
+ 
+ 	/* Test DESCRIBE with a query not producing tuples */
+ 
+ 	strcpy(msg, "allocate");
+ 	exec sql allocate descriptor desc1;
+ 	exec sql allocate descriptor desc2;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id2 FROM :stmt2;
+ 
+ 	sqlda1 = sqlda2 = sqlda3 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	exec sql describe st_id2 into sql descriptor desc1;
+ 	exec sql describe st_id2 using sql descriptor desc2;
+ 
+ 	exec sql describe st_id2 into descriptor sqlda1;
+ 	exec sql describe st_id2 using descriptor sqlda2;
+ 	exec sql describe st_id2 into sqlda3;
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	exec sql get descriptor desc1 :count1 = count;
+ 	exec sql get descriptor desc1 :count2 = count;
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld &&
+ 		count1 == sqlda3->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		exec sql get descriptor desc1 value :i :field_name1 = name;
+ 		exec sql get descriptor desc2 value :i :field_name2 = name;
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname,
+ 			sqlda3->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate descriptor desc1;
+ 	exec sql deallocate descriptor desc2;
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 	free(sqlda3);
+ 
+ 	exec sql deallocate prepare st_id2;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table descr_t1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/test/compat_informix/Makefile pgsql.3/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.2.1/src/interfaces/ecpg/test/compat_informix/Makefile	2010-01-01 14:35:36.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/compat_informix/Makefile	2010-01-04 14:57:13.000000000 +0100
*************** TESTS = test_informix test_informix.c \
*** 17,22 ****
--- 17,23 ----
          rfmtlong rfmtlong.c \
          rnull rnull.c \
          sqlda sqlda.c \
+         describe describe.c \
          charfuncs charfuncs.c
  
  all: $(TESTS)
Binary files pgsql.2.1/src/interfaces/ecpg/test/core.25004 and pgsql.3/src/interfaces/ecpg/test/core.25004 differ
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/test/ecpg_schedule pgsql.3/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.2.1/src/interfaces/ecpg/test/ecpg_schedule	2010-01-01 14:35:36.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/ecpg_schedule	2010-01-04 14:57:13.000000000 +0100
*************** test: compat_informix/rfmtdate
*** 4,9 ****
--- 4,10 ----
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
  test: compat_informix/sqlda
+ test: compat_informix/describe
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: sql/copystdout
*** 31,36 ****
--- 32,38 ----
  test: sql/define
  test: sql/desc
  test: sql/sqlda
+ test: sql/describe
  test: sql/dynalloc
  test: sql/dynalloc2
  test: sql/dyntest
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/test/ecpg_schedule_tcp pgsql.3/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.2.1/src/interfaces/ecpg/test/ecpg_schedule_tcp	2010-01-01 14:35:36.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/ecpg_schedule_tcp	2010-01-04 14:57:13.000000000 +0100
*************** test: compat_informix/rfmtdate
*** 4,9 ****
--- 4,10 ----
  test: compat_informix/rfmtlong
  test: compat_informix/rnull
  test: compat_informix/sqlda
+ test: compat_informix/describe
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: sql/copystdout
*** 31,36 ****
--- 32,38 ----
  test: sql/define
  test: sql/desc
  test: sql/sqlda
+ test: sql/describe
  test: sql/dynalloc
  test: sql/dynalloc2
  test: sql/dyntest
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-describe.c pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.c
*** pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-describe.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.c	2010-01-04 17:12:47.000000000 +0100
***************
*** 0 ****
--- 1,472 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPG_INFORMIX_COMPAT 1
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "describe.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 4 "describe.pgc"
+ 
+ 
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+ 
+ #ifndef ECPG_SQLDA_H
+ #define ECPG_SQLDA_H
+ 
+ #ifdef ECPG_INFORMIX_COMPAT
+ 
+ #include "sqlda-compat.h"
+ typedef struct sqlvar_compat	sqlvar_t;
+ typedef struct sqlda_compat	sqlda_t;
+ 
+ #else
+ 
+ #include "sqlda-native.h"
+ typedef struct sqlvar_struct	sqlvar_t;
+ typedef struct sqlda_struct	sqlda_t;
+ 
+ #endif
+ 
+ #endif /* ECPG_SQLDA_H */
+ 
+ #line 5 "describe.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 7 "describe.pgc"
+ 
+ 
+ sqlda_t	*sqlda1, *sqlda2, *sqlda3;
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		  
+ 		  
+ 		  
+ 
+ #line 15 "describe.pgc"
+  char * stmt1 = "SELECT id, t FROM descr_t1" ;
+  
+ #line 16 "describe.pgc"
+  char * stmt2 = "SELECT id, t FROM descr_t1 WHERE id = -1" ;
+  
+ #line 17 "describe.pgc"
+  int i , count1 , count2 ;
+  
+ #line 18 "describe.pgc"
+  char field_name1 [ 30 ] = "not set" ;
+  
+ #line 19 "describe.pgc"
+  char field_name2 [ 30 ] = "not set" ;
+ /* exec sql end declare section */
+ #line 20 "describe.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0); 
+ #line 27 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 27 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 30 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 30 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table descr_t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
+ #line 33 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 33 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into descr_t1 ( id , t ) values ( default , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 36 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into descr_t1 ( id , t ) values ( default , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 37 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into descr_t1 ( id , t ) values ( default , 'c' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 38 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into descr_t1 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 39 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 39 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 42 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 42 "describe.pgc"
+ 
+ 
+ 	/*
+ 	 * Test DESCRIBE with a query producing tuples.
+ 	 * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
+ 	 * Informix-compat mode.
+ 	 */
+ 
+ 	strcpy(msg, "allocate");
+ 	ECPGallocate_desc(__LINE__, "desc1");
+ #line 51 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 51 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc2");
+ #line 52 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 52 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 55 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 55 "describe.pgc"
+ 
+ 
+ 	sqlda1 = sqlda2 = sqlda3 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	{ ECPGdescribe(__LINE__, 1, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 60 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 1, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 61 "describe.pgc"
+ 
+ 
+ 	{ ECPGdescribe(__LINE__, 1, 0, NULL, "st_id1",
+ 	ECPGt_sqlda, &sqlda1, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 63 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 1, 0, NULL, "st_id1",
+ 	ECPGt_sqlda, &sqlda2, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 64 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 1, 0, NULL, "st_id1",
+ 	ECPGt_sqlda, &sqlda3, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 65 "describe.pgc"
+ 
+ 
+ 	if (sqlda1 == NULL)
+ 	{
+ 		printf("sqlda1 NULL\n");
+ 		exit(1);
+ 	}
+ 
+ 	if (sqlda2 == NULL)
+ 	{
+ 		printf("sqlda2 NULL\n");
+ 		exit(1);
+ 	}
+ 
+ 	if (sqlda3 == NULL)
+ 	{
+ 		printf("sqlda3 NULL\n");
+ 		exit(1);
+ 	}
+ 
+ 	strcpy(msg, "get descriptor");
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));
+ 
+ #line 86 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 86 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count2));
+ 
+ #line 87 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 87 "describe.pgc"
+ 
+ 
+ 	if (count1 != count2)
+ 	{
+ 		printf("count1 (%d) != count2 (%d)\n", count1, count2);
+ 		exit(1);
+ 	}
+ 
+ 	if (count1 != sqlda1->sqld)
+ 	{
+ 		printf("count1 (%d) != sqlda1->sqld (%d)\n", count1, sqlda1->sqld);
+ 		exit(1);
+ 	}
+ 
+ 	if (count1 != sqlda2->sqld)
+ 	{
+ 		printf("count1 (%d) != sqlda2->sqld (%d)\n", count1, sqlda2->sqld);
+ 		exit(1);
+ 	}
+ 
+ 	if (count1 != sqlda3->sqld)
+ 	{
+ 		printf("count1 (%d) != sqlda3->sqld (%d)\n", count1, sqlda3->sqld);
+ 		exit(1);
+ 	}
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+ 	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 115 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 115 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+ 	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 116 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 116 "describe.pgc"
+ 
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname,
+ 			sqlda3->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 126 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 126 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 127 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 127 "describe.pgc"
+ 
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 	free(sqlda3);
+ 
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id1");
+ #line 132 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 132 "describe.pgc"
+ 
+ 
+ 	/* Test DESCRIBE with a query not producing tuples */
+ 
+ 	strcpy(msg, "allocate");
+ 	ECPGallocate_desc(__LINE__, "desc1");
+ #line 137 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 137 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc2");
+ #line 138 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 138 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2);
+ #line 141 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 141 "describe.pgc"
+ 
+ 
+ 	sqlda1 = sqlda2 = sqlda3 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	{ ECPGdescribe(__LINE__, 1, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 146 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 1, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 147 "describe.pgc"
+ 
+ 
+ 	{ ECPGdescribe(__LINE__, 1, 0, NULL, "st_id2",
+ 	ECPGt_sqlda, &sqlda1, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 149 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 1, 0, NULL, "st_id2",
+ 	ECPGt_sqlda, &sqlda2, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 150 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 1, 0, NULL, "st_id2",
+ 	ECPGt_sqlda, &sqlda3, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 151 "describe.pgc"
+ 
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));
+ 
+ #line 157 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 157 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count2));
+ 
+ #line 158 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 158 "describe.pgc"
+ 
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld &&
+ 		count1 == sqlda3->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+ 	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 168 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 168 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+ 	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 169 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 169 "describe.pgc"
+ 
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname,
+ 			sqlda2->sqlvar[i-1].sqlname,
+ 			sqlda3->sqlvar[i-1].sqlname);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 179 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 179 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 180 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 180 "describe.pgc"
+ 
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 	free(sqlda3);
+ 
+ 	{ ECPGdeallocate(__LINE__, 1, NULL, "st_id2");
+ #line 185 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 185 "describe.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table descr_t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 190 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 190 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 193 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 193 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 196 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 196 "describe.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr
*** pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.stderr	2010-01-04 17:12:46.000000000 +0100
***************
*** 0 ****
--- 1,112 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: query: create table descr_t1 ( id serial primary key , t text ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into descr_t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into descr_t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into descr_t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: query: insert into descr_t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 42: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 55: name st_id1; query: "SELECT id, t FROM descr_t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 132: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 141: name st_id2; query: "SELECT id, t FROM descr_t1 WHERE id = -1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_compat_sqlda sqld = 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 185: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 190: query: drop table descr_t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 190: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 190: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 193: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout
*** pgsql.2.1/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-describe.stdout	2010-01-04 14:57:13.000000000 +0100
***************
*** 0 ****
--- 1,24 ----
+ 1
+ 	field_name1 'id'
+ 	field_name2 'id'
+ 	sqlda1 'id'
+ 	sqlda2 'id'
+ 	sqlda3 'id'
+ 2
+ 	field_name1 't'
+ 	field_name2 't'
+ 	sqlda1 't'
+ 	sqlda2 't'
+ 	sqlda3 't'
+ 1
+ 	field_name1 'id'
+ 	field_name2 'id'
+ 	sqlda1 'id'
+ 	sqlda2 'id'
+ 	sqlda3 'id'
+ 2
+ 	field_name1 't'
+ 	field_name2 't'
+ 	sqlda1 't'
+ 	sqlda2 't'
+ 	sqlda3 't'
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/test/expected/preproc-describe.c pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.c
*** pgsql.2.1/src/interfaces/ecpg/test/expected/preproc-describe.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.c	2010-01-04 14:57:13.000000000 +0100
***************
*** 0 ****
--- 1,481 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "describe.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 4 "describe.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 6 "describe.pgc"
+ 
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		    
+ 		  
+ 		  
+ 		  
+ 		  
+ 
+ #line 12 "describe.pgc"
+  char * stmt1 = "SELECT id, t FROM t1" ;
+  
+ #line 13 "describe.pgc"
+  char * stmt2 = "SELECT id, t FROM t1 WHERE id = -1" ;
+  
+ #line 14 "describe.pgc"
+  int i , count1 , count2 , count3 , count4 ;
+  
+ #line 15 "describe.pgc"
+  char field_name1 [ 30 ] = "not set" ;
+  
+ #line 16 "describe.pgc"
+  char field_name2 [ 30 ] = "not set" ;
+  
+ #line 17 "describe.pgc"
+  char field_name3 [ 30 ] = "not set" ;
+  
+ #line 18 "describe.pgc"
+  char field_name4 [ 30 ] = "not set" ;
+ /* exec sql end declare section */
+ #line 19 "describe.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
+ #line 26 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 26 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 29 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 29 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
+ #line 32 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 32 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 35 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 35 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 36 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'c' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 37 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 38 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 41 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "describe.pgc"
+ 
+ 
+ 	/*
+ 	 * Test DESCRIBE with a query producing tuples.
+ 	 * DESCRIPTOR and SQL DESCRIPTOR are the same in native mode.
+ 	 */
+ 
+ 	strcpy(msg, "allocate");
+ 	ECPGallocate_desc(__LINE__, "desc1");
+ #line 49 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 49 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc2");
+ #line 50 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 50 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc3");
+ #line 51 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 51 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc4");
+ #line 52 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 52 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 55 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 55 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "describe");
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 58 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 59 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc3", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 60 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc4", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 61 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "get descriptor");
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));
+ 
+ #line 64 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 64 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc2", &(count2));
+ 
+ #line 65 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 65 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc3", &(count3));
+ 
+ #line 66 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 66 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc4", &(count4));
+ 
+ #line 67 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 67 "describe.pgc"
+ 
+ 
+ 	if (!(count1 == count2 && count1 == count3 && count1 == count4))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+ 	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 74 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 74 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+ 	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 75 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 75 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc3", i,ECPGd_name,
+ 	ECPGt_char,(field_name3),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 76 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 76 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc4", i,ECPGd_name,
+ 	ECPGt_char,(field_name4),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 77 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 77 "describe.pgc"
+ 
+ 		printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
+ 			field_name1, field_name2, field_name3, field_name4);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 83 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 83 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 84 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 84 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc3");
+ #line 85 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 85 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc4");
+ #line 86 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 86 "describe.pgc"
+ 
+ 
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
+ #line 88 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 88 "describe.pgc"
+ 
+ 
+ 	/* Test DESCRIBE with a query not producing tuples */
+ 
+ 	strcpy(msg, "allocate");
+ 	ECPGallocate_desc(__LINE__, "desc1");
+ #line 93 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 93 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc2");
+ #line 94 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 94 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc3");
+ #line 95 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 95 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc4");
+ #line 96 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 96 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2);
+ #line 99 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 99 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "describe");
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 102 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 103 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc3", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 104 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc4", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 105 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "get descriptor");
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));
+ 
+ #line 108 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 108 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc2", &(count2));
+ 
+ #line 109 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 109 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc3", &(count3));
+ 
+ #line 110 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 110 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc4", &(count4));
+ 
+ #line 111 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 111 "describe.pgc"
+ 
+ 
+ 	if (!(count1 == count2 && count1 == count3 && count1 == count4))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+ 	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 118 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 118 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+ 	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 119 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 119 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc3", i,ECPGd_name,
+ 	ECPGt_char,(field_name3),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 120 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 120 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc4", i,ECPGd_name,
+ 	ECPGt_char,(field_name4),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 121 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 121 "describe.pgc"
+ 
+ 		printf("field_name 1 '%s' 2 '%s' 3 '%s' 4 '%s'\n",
+ 			field_name1, field_name2, field_name3, field_name4);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 127 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 127 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 128 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 128 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc3");
+ #line 129 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 129 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc4");
+ #line 130 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 130 "describe.pgc"
+ 
+ 
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
+ #line 132 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 132 "describe.pgc"
+ 
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table t1", ECPGt_EOIT, ECPGt_EORT);
+ #line 138 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 138 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 141 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 141 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 144 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 144 "describe.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/test/expected/preproc-describe.stderr pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.stderr
*** pgsql.2.1/src/interfaces/ecpg/test/expected/preproc-describe.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.stderr	2010-01-04 14:57:13.000000000 +0100
***************
*** 0 ****
--- 1,140 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: query: create table t1 ( id serial primary key , t text ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: query: insert into t1 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into t1 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into t1 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into t1 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 41: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 55: name st_id1; query: "SELECT id, t FROM t1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 88: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 99: name st_id2; query: "SELECT id, t FROM t1 WHERE id = -1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 132: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 138: query: drop table t1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 138: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 138: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 141: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/test/expected/preproc-describe.stdout pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.stdout
*** pgsql.2.1/src/interfaces/ecpg/test/expected/preproc-describe.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/preproc-describe.stdout	2010-01-04 14:57:13.000000000 +0100
***************
*** 0 ****
--- 1,4 ----
+ field_name 1 'id' 2 'id' 3 'id' 4 'id'
+ field_name 1 't' 2 't' 3 't' 4 't'
+ field_name 1 'id' 2 'id' 3 'id' 4 'id'
+ field_name 1 't' 2 't' 3 't' 4 't'
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/test/expected/sql-describe.c pgsql.3/src/interfaces/ecpg/test/expected/sql-describe.c
*** pgsql.2.1/src/interfaces/ecpg/test/expected/sql-describe.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/sql-describe.c	2010-01-04 17:12:28.000000000 +0100
***************
*** 0 ****
--- 1,469 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "describe.pgc"
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 4 "describe.pgc"
+ 
+ 
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+ 
+ #ifndef ECPG_SQLDA_H
+ #define ECPG_SQLDA_H
+ 
+ #ifdef ECPG_INFORMIX_COMPAT
+ 
+ #include "sqlda-compat.h"
+ typedef struct sqlvar_compat	sqlvar_t;
+ typedef struct sqlda_compat	sqlda_t;
+ 
+ #else
+ 
+ #include "sqlda-native.h"
+ typedef struct sqlvar_struct	sqlvar_t;
+ typedef struct sqlda_struct	sqlda_t;
+ 
+ #endif
+ 
+ #endif /* ECPG_SQLDA_H */
+ 
+ #line 5 "describe.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 7 "describe.pgc"
+ 
+ 
+ sqlda_t	*sqlda1, *sqlda2, *sqlda3;
+ 
+ int
+ main (void)
+ {
+ /* exec sql begin declare section */
+ 		  
+ 		  
+ 		  
+ 		  
+ 		  
+ 
+ #line 15 "describe.pgc"
+  char * stmt1 = "SELECT id, t FROM descr_t2" ;
+  
+ #line 16 "describe.pgc"
+  char * stmt2 = "SELECT id, t FROM descr_t2 WHERE id = -1" ;
+  
+ #line 17 "describe.pgc"
+  int i , count1 , count2 ;
+  
+ #line 18 "describe.pgc"
+  char field_name1 [ 30 ] = "not set" ;
+  
+ #line 19 "describe.pgc"
+  char field_name2 [ 30 ] = "not set" ;
+ /* exec sql end declare section */
+ #line 20 "describe.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
+ #line 27 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 27 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 30 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 30 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table descr_t2 ( id serial primary key , t text )", ECPGt_EOIT, ECPGt_EORT);
+ #line 33 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 33 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into descr_t2 ( id , t ) values ( default , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 36 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into descr_t2 ( id , t ) values ( default , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 37 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into descr_t2 ( id , t ) values ( default , 'c' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 38 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "describe.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into descr_t2 ( id , t ) values ( default , 'd' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 39 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 39 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 42 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 42 "describe.pgc"
+ 
+ 
+ 	/*
+ 	 * Test DESCRIBE with a query producing tuples.
+ 	 * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
+ 	 * Informix-compat mode.
+ 	 */
+ 
+ 	strcpy(msg, "allocate");
+ 	ECPGallocate_desc(__LINE__, "desc1");
+ #line 51 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 51 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc2");
+ #line 52 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 52 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);
+ #line 55 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 55 "describe.pgc"
+ 
+ 
+ 	sqlda1 = sqlda2 = sqlda3 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	{ ECPGdescribe(__LINE__, 0, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 60 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, 0, NULL, "st_id1",
+ 	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 61 "describe.pgc"
+ 
+ 
+ 	{ ECPGdescribe(__LINE__, 0, 0, NULL, "st_id1",
+ 	ECPGt_sqlda, &sqlda1, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 63 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, 0, NULL, "st_id1",
+ 	ECPGt_sqlda, &sqlda2, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 64 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, 0, NULL, "st_id1",
+ 	ECPGt_sqlda, &sqlda3, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 65 "describe.pgc"
+ 
+ 
+ 	if (sqlda1 == NULL)
+ 	{
+ 		printf("sqlda1 NULL\n");
+ 		exit(1);
+ 	}
+ 
+ 	if (sqlda2 == NULL)
+ 	{
+ 		printf("sqlda2 NULL\n");
+ 		exit(1);
+ 	}
+ 
+ 	if (sqlda3 == NULL)
+ 	{
+ 		printf("sqlda3 NULL\n");
+ 		exit(1);
+ 	}
+ 
+ 	strcpy(msg, "get descriptor");
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));
+ 
+ #line 86 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 86 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count2));
+ 
+ #line 87 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 87 "describe.pgc"
+ 
+ 
+ 	if (count1 != count2)
+ 	{
+ 		printf("count1 (%d) != count2 (%d)\n", count1, count2);
+ 		exit(1);
+ 	}
+ 
+ 	if (count1 != sqlda1->sqld)
+ 	{
+ 		printf("count1 (%d) != sqlda1->sqld (%d)\n", count1, sqlda1->sqld);
+ 		exit(1);
+ 	}
+ 
+ 	if (count1 != sqlda2->sqld)
+ 	{
+ 		printf("count1 (%d) != sqlda2->sqld (%d)\n", count1, sqlda2->sqld);
+ 		exit(1);
+ 	}
+ 
+ 	if (count1 != sqlda3->sqld)
+ 	{
+ 		printf("count1 (%d) != sqlda3->sqld (%d)\n", count1, sqlda3->sqld);
+ 		exit(1);
+ 	}
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+ 	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 115 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 115 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+ 	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 116 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 116 "describe.pgc"
+ 
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname.data,
+ 			sqlda2->sqlvar[i-1].sqlname.data,
+ 			sqlda3->sqlvar[i-1].sqlname.data);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 126 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 126 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 127 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 127 "describe.pgc"
+ 
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 	free(sqlda3);
+ 
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id1");
+ #line 132 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 132 "describe.pgc"
+ 
+ 
+ 	/* Test DESCRIBE with a query not producing tuples */
+ 
+ 	strcpy(msg, "allocate");
+ 	ECPGallocate_desc(__LINE__, "desc1");
+ #line 137 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 137 "describe.pgc"
+ 
+ 	ECPGallocate_desc(__LINE__, "desc2");
+ #line 138 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 138 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "prepare");
+ 	{ ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt2);
+ #line 141 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 141 "describe.pgc"
+ 
+ 
+ 	sqlda1 = sqlda2 = sqlda3 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	{ ECPGdescribe(__LINE__, 0, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc1", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 146 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, 0, NULL, "st_id2",
+ 	ECPGt_descriptor, "desc2", 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 147 "describe.pgc"
+ 
+ 
+ 	{ ECPGdescribe(__LINE__, 0, 0, NULL, "st_id2",
+ 	ECPGt_sqlda, &sqlda1, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 149 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, 0, NULL, "st_id2",
+ 	ECPGt_sqlda, &sqlda2, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 150 "describe.pgc"
+ 
+ 	{ ECPGdescribe(__LINE__, 0, 0, NULL, "st_id2",
+ 	ECPGt_sqlda, &sqlda3, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);}
+ #line 151 "describe.pgc"
+ 
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count1));
+ 
+ #line 157 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 157 "describe.pgc"
+ 
+ 	{ ECPGget_desc_header(__LINE__, "desc1", &(count2));
+ 
+ #line 158 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 158 "describe.pgc"
+ 
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld &&
+ 		count1 == sqlda3->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		{ ECPGget_desc(__LINE__, "desc1", i,ECPGd_name,
+ 	ECPGt_char,(field_name1),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 168 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 168 "describe.pgc"
+ 
+ 		{ ECPGget_desc(__LINE__, "desc2", i,ECPGd_name,
+ 	ECPGt_char,(field_name2),(long)30,(long)1,(30)*sizeof(char), ECPGd_EODT);
+ 
+ #line 169 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 169 "describe.pgc"
+ 
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname.data,
+ 			sqlda2->sqlvar[i-1].sqlname.data,
+ 			sqlda3->sqlvar[i-1].sqlname.data);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	ECPGdeallocate_desc(__LINE__, "desc1");
+ #line 179 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 179 "describe.pgc"
+ 
+ 	ECPGdeallocate_desc(__LINE__, "desc2");
+ #line 180 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);
+ #line 180 "describe.pgc"
+ 
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 	free(sqlda3);
+ 
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "st_id2");
+ #line 185 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 185 "describe.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table descr_t2", ECPGt_EOIT, ECPGt_EORT);
+ #line 190 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 190 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 193 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 193 "describe.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 196 "describe.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 196 "describe.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/test/expected/sql-describe.stderr pgsql.3/src/interfaces/ecpg/test/expected/sql-describe.stderr
*** pgsql.2.1/src/interfaces/ecpg/test/expected/sql-describe.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/sql-describe.stderr	2010-01-04 15:50:53.000000000 +0100
***************
*** 0 ****
--- 1,112 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: query: create table descr_t2 ( id serial primary key , t text ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 33: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into descr_t2 ( id , t ) values ( default , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into descr_t2 ( id , t ) values ( default , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into descr_t2 ( id , t ) values ( default , 'c' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: query: insert into descr_t2 ( id , t ) values ( default , 'd' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 42: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 55: name st_id1; query: "SELECT id, t FROM descr_t2"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 132: name st_id1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 141: name st_id2; query: "SELECT id, t FROM descr_t2 WHERE id = -1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc_header: found 2 attributes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = id
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: reading items for tuple 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGget_desc: NAME = t
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 185: name st_id2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 190: query: drop table descr_t2; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 190: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 190: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 193: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/test/expected/sql-describe.stdout pgsql.3/src/interfaces/ecpg/test/expected/sql-describe.stdout
*** pgsql.2.1/src/interfaces/ecpg/test/expected/sql-describe.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/expected/sql-describe.stdout	2010-01-04 15:42:39.000000000 +0100
***************
*** 0 ****
--- 1,24 ----
+ 1
+ 	field_name1 'id'
+ 	field_name2 'id'
+ 	sqlda1 'id'
+ 	sqlda2 'id'
+ 	sqlda3 'id'
+ 2
+ 	field_name1 't'
+ 	field_name2 't'
+ 	sqlda1 't'
+ 	sqlda2 't'
+ 	sqlda3 't'
+ 1
+ 	field_name1 'id'
+ 	field_name2 'id'
+ 	sqlda1 'id'
+ 	sqlda2 'id'
+ 	sqlda3 'id'
+ 2
+ 	field_name1 't'
+ 	field_name2 't'
+ 	sqlda1 't'
+ 	sqlda2 't'
+ 	sqlda3 't'
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/test/sql/describe.pgc pgsql.3/src/interfaces/ecpg/test/sql/describe.pgc
*** pgsql.2.1/src/interfaces/ecpg/test/sql/describe.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/sql/describe.pgc	2010-01-04 15:40:35.000000000 +0100
***************
*** 0 ****
--- 1,199 ----
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ exec sql include ../regression;
+ exec sql include sqlda.h;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ sqlda_t	*sqlda1, *sqlda2, *sqlda3;
+ 
+ int
+ main (void)
+ {
+ exec sql begin declare section;
+ 	char	*stmt1 = "SELECT id, t FROM descr_t2";
+ 	char	*stmt2 = "SELECT id, t FROM descr_t2 WHERE id = -1";
+ 	int	i, count1, count2;
+ 	char	field_name1[30] = "not set";
+ 	char	field_name2[30] = "not set";
+ exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table descr_t2(id serial primary key, t text);
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into descr_t2(id, t) values (default, 'a');
+ 	exec sql insert into descr_t2(id, t) values (default, 'b');
+ 	exec sql insert into descr_t2(id, t) values (default, 'c');
+ 	exec sql insert into descr_t2(id, t) values (default, 'd');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/*
+ 	 * Test DESCRIBE with a query producing tuples.
+ 	 * DESCRIPTOR and SQL DESCRIPTOR are NOT the same in
+ 	 * Informix-compat mode.
+ 	 */
+ 
+ 	strcpy(msg, "allocate");
+ 	exec sql allocate descriptor desc1;
+ 	exec sql allocate descriptor desc2;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id1 FROM :stmt1;
+ 
+ 	sqlda1 = sqlda2 = sqlda3 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	exec sql describe st_id1 into sql descriptor desc1;
+ 	exec sql describe st_id1 using sql descriptor desc2;
+ 
+ 	exec sql describe st_id1 into descriptor sqlda1;
+ 	exec sql describe st_id1 using descriptor sqlda2;
+ 	exec sql describe st_id1 into sqlda3;
+ 
+ 	if (sqlda1 == NULL)
+ 	{
+ 		printf("sqlda1 NULL\n");
+ 		exit(1);
+ 	}
+ 
+ 	if (sqlda2 == NULL)
+ 	{
+ 		printf("sqlda2 NULL\n");
+ 		exit(1);
+ 	}
+ 
+ 	if (sqlda3 == NULL)
+ 	{
+ 		printf("sqlda3 NULL\n");
+ 		exit(1);
+ 	}
+ 
+ 	strcpy(msg, "get descriptor");
+ 	exec sql get descriptor desc1 :count1 = count;
+ 	exec sql get descriptor desc1 :count2 = count;
+ 
+ 	if (count1 != count2)
+ 	{
+ 		printf("count1 (%d) != count2 (%d)\n", count1, count2);
+ 		exit(1);
+ 	}
+ 
+ 	if (count1 != sqlda1->sqld)
+ 	{
+ 		printf("count1 (%d) != sqlda1->sqld (%d)\n", count1, sqlda1->sqld);
+ 		exit(1);
+ 	}
+ 
+ 	if (count1 != sqlda2->sqld)
+ 	{
+ 		printf("count1 (%d) != sqlda2->sqld (%d)\n", count1, sqlda2->sqld);
+ 		exit(1);
+ 	}
+ 
+ 	if (count1 != sqlda3->sqld)
+ 	{
+ 		printf("count1 (%d) != sqlda3->sqld (%d)\n", count1, sqlda3->sqld);
+ 		exit(1);
+ 	}
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		exec sql get descriptor desc1 value :i :field_name1 = name;
+ 		exec sql get descriptor desc2 value :i :field_name2 = name;
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname.data,
+ 			sqlda2->sqlvar[i-1].sqlname.data,
+ 			sqlda3->sqlvar[i-1].sqlname.data);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate descriptor desc1;
+ 	exec sql deallocate descriptor desc2;
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 	free(sqlda3);
+ 
+ 	exec sql deallocate prepare st_id1;
+ 
+ 	/* Test DESCRIBE with a query not producing tuples */
+ 
+ 	strcpy(msg, "allocate");
+ 	exec sql allocate descriptor desc1;
+ 	exec sql allocate descriptor desc2;
+ 
+ 	strcpy(msg, "prepare");
+ 	exec sql prepare st_id2 FROM :stmt2;
+ 
+ 	sqlda1 = sqlda2 = sqlda3 = NULL;
+ 
+ 	strcpy(msg, "describe");
+ 	exec sql describe st_id2 into sql descriptor desc1;
+ 	exec sql describe st_id2 using sql descriptor desc2;
+ 
+ 	exec sql describe st_id2 into descriptor sqlda1;
+ 	exec sql describe st_id2 using descriptor sqlda2;
+ 	exec sql describe st_id2 into sqlda3;
+ 
+ 	if (sqlda1 == NULL || sqlda1 == NULL || sqlda2 == NULL)
+ 		exit(1);
+ 
+ 	strcpy(msg, "get descriptor");
+ 	exec sql get descriptor desc1 :count1 = count;
+ 	exec sql get descriptor desc1 :count2 = count;
+ 
+ 	if (!(	count1 == count2 &&
+ 		count1 == sqlda1->sqld &&
+ 		count1 == sqlda2->sqld &&
+ 		count1 == sqlda3->sqld))
+ 		exit(1);
+ 
+ 	for (i = 1; i <= count1; i++)
+ 	{
+ 		exec sql get descriptor desc1 value :i :field_name1 = name;
+ 		exec sql get descriptor desc2 value :i :field_name2 = name;
+ 		printf("%d\n\tfield_name1 '%s'\n\tfield_name2 '%s'\n\t"
+ 			"sqlda1 '%s'\n\tsqlda2 '%s'\n\tsqlda3 '%s'\n",
+ 			i, field_name1, field_name2,
+ 			sqlda1->sqlvar[i-1].sqlname.data,
+ 			sqlda2->sqlvar[i-1].sqlname.data,
+ 			sqlda3->sqlvar[i-1].sqlname.data);
+ 	}
+ 
+ 	strcpy(msg, "deallocate");
+ 	exec sql deallocate descriptor desc1;
+ 	exec sql deallocate descriptor desc2;
+ 	free(sqlda1);
+ 	free(sqlda2);
+ 	free(sqlda3);
+ 
+ 	exec sql deallocate prepare st_id2;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table descr_t2;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.2.1/src/interfaces/ecpg/test/sql/Makefile pgsql.3/src/interfaces/ecpg/test/sql/Makefile
*** pgsql.2.1/src/interfaces/ecpg/test/sql/Makefile	2010-01-01 14:35:36.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/test/sql/Makefile	2010-01-04 14:57:13.000000000 +0100
*************** TESTS = array array.c \
*** 9,14 ****
--- 9,16 ----
          copystdout copystdout.c \
  	define define.c \
          desc desc.c \
+         sqlda sqlda.c \
+         describe describe.c \
          dyntest dyntest.c \
          dynalloc dynalloc.c \
          dynalloc2 dynalloc2.c \
*************** TESTS = array array.c \
*** 20,26 ****
          parser parser.c \
          quote quote.c \
          show show.c \
-         sqlda sqlda.c \
          insupd insupd.c 
  
  all: $(TESTS)
--- 22,27 ----
#85Boszormenyi Zoltan
zb@cybertec.at
In reply to: Boszormenyi Zoltan (#75)
1 attachment(s)
ECPG out-of-scope cursor support in native mode

Hi,

new patch attached, rebased to the latest
SQLDA and DESCRIBE patches.
This is the variant with support in native mode.

Best regards,
Zolt�n B�sz�rm�nyi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

Attachments:

4.1-pg85-outofscopedeclare-9-ctxdiff.patchtext/x-patch; name=4.1-pg85-outofscopedeclare-9-ctxdiff.patchDownload
diff -dcrpN pgsql.3/src/interfaces/ecpg/compatlib/informix.c pgsql.4.1/src/interfaces/ecpg/compatlib/informix.c
*** pgsql.3/src/interfaces/ecpg/compatlib/informix.c	2009-10-01 20:37:18.000000000 +0200
--- pgsql.4.1/src/interfaces/ecpg/compatlib/informix.c	2010-01-04 17:24:50.000000000 +0100
*************** rtypwidth(int sqltype, int sqllen)
*** 1004,1060 ****
  	return 0;
  }
  
- static struct var_list
- {
- 	int			number;
- 	void	   *pointer;
- 	struct var_list *next;
- }	*ivlist = NULL;
- 
  void
  ECPG_informix_set_var(int number, void *pointer, int lineno)
  {
! 	struct var_list *ptr;
! 
! 	for (ptr = ivlist; ptr != NULL; ptr = ptr->next)
! 	{
! 		if (ptr->number == number)
! 		{
! 			/* already known => just change pointer value */
! 			ptr->pointer = pointer;
! 			return;
! 		}
! 	}
! 
! 	/* a new one has to be added */
! 	ptr = (struct var_list *) calloc(1L, sizeof(struct var_list));
! 	if (!ptr)
! 	{
! 		struct sqlca_t *sqlca = ECPGget_sqlca();
! 
! 		sqlca->sqlcode = ECPG_OUT_OF_MEMORY;
! 		strncpy(sqlca->sqlstate, "YE001", sizeof("YE001"));
! 		snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), "out of memory on line %d", lineno);
! 		sqlca->sqlerrm.sqlerrml = strlen(sqlca->sqlerrm.sqlerrmc);
! 		/* free all memory we have allocated for the user */
! 		ECPGfree_auto_mem();
! 	}
! 	else
! 	{
! 		ptr->number = number;
! 		ptr->pointer = pointer;
! 		ptr->next = ivlist;
! 		ivlist = ptr;
! 	}
  }
  
  void *
  ECPG_informix_get_var(int number)
  {
! 	struct var_list *ptr;
! 
! 	for (ptr = ivlist; ptr != NULL && ptr->number != number; ptr = ptr->next);
! 	return (ptr) ? ptr->pointer : NULL;
  }
  
  void
--- 1004,1019 ----
  	return 0;
  }
  
  void
  ECPG_informix_set_var(int number, void *pointer, int lineno)
  {
! 	ECPGset_var(number, pointer, lineno);
  }
  
  void *
  ECPG_informix_get_var(int number)
  {
! 	return ECPGget_var(number);
  }
  
  void
diff -dcrpN pgsql.3/src/interfaces/ecpg/ecpglib/exports.txt pgsql.4.1/src/interfaces/ecpg/ecpglib/exports.txt
*** pgsql.3/src/interfaces/ecpg/ecpglib/exports.txt	2009-09-21 15:19:11.000000000 +0200
--- pgsql.4.1/src/interfaces/ecpg/ecpglib/exports.txt	2010-01-04 17:24:50.000000000 +0100
*************** ECPGstatus                       23
*** 26,29 ****
  ECPGtrans                        24
  sqlprint                         25
  ECPGget_PGconn			 26
! ECPGtransactionStatus      27
--- 26,31 ----
  ECPGtrans                        24
  sqlprint                         25
  ECPGget_PGconn			 26
! ECPGtransactionStatus		 27
! ECPGset_var			 28
! ECPGget_var			 29
diff -dcrpN pgsql.3/src/interfaces/ecpg/ecpglib/misc.c pgsql.4.1/src/interfaces/ecpg/ecpglib/misc.c
*** pgsql.3/src/interfaces/ecpg/ecpglib/misc.c	2009-11-25 11:56:39.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/ecpglib/misc.c	2010-01-04 17:24:50.000000000 +0100
*************** ecpg_gettext(const char *msgid)
*** 505,507 ****
--- 505,559 ----
  }
  
  #endif   /* ENABLE_NLS */
+ 
+ static struct var_list
+ {
+ 	int		number;
+ 	void	   *pointer;
+ 	struct var_list *next;
+ } *ivlist = NULL;
+ 
+ void
+ ECPGset_var(int number, void *pointer, int lineno)
+ {
+ 	struct var_list *ptr;
+ 
+ 	for (ptr = ivlist; ptr != NULL; ptr = ptr->next)
+ 	{
+ 		if (ptr->number == number)
+ 		{
+ 			/* already known => just change pointer value */
+ 			ptr->pointer = pointer;
+ 			return;
+ 		}
+ 	}
+ 
+ 	/* a new one has to be added */
+ 	ptr = (struct var_list *) calloc(1L, sizeof(struct var_list));
+ 	if (!ptr)
+ 	{
+ 		struct sqlca_t *sqlca = ECPGget_sqlca();
+ 		sqlca->sqlcode = ECPG_OUT_OF_MEMORY;
+ 		strncpy(sqlca->sqlstate, "YE001", sizeof("YE001"));
+ 		snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), "out of memory on line %d", lineno);
+ 		sqlca->sqlerrm.sqlerrml = strlen(sqlca->sqlerrm.sqlerrmc);
+ 		/* free all memory we have allocated for the user */
+ 		ECPGfree_auto_mem();
+ 	}
+ 	else
+ 	{
+ 		ptr->number = number;
+ 		ptr->pointer = pointer;
+ 		ptr->next = ivlist;
+ 		ivlist = ptr;
+ 	}
+ }
+ 
+ void *
+ ECPGget_var(int number)
+ {
+ 	struct var_list *ptr;
+ 
+ 	for (ptr = ivlist; ptr != NULL && ptr->number != number; ptr = ptr->next);
+ 		return (ptr) ? ptr->pointer : NULL;
+ }
diff -dcrpN pgsql.3/src/interfaces/ecpg/include/ecpglib.h pgsql.4.1/src/interfaces/ecpg/include/ecpglib.h
*** pgsql.3/src/interfaces/ecpg/include/ecpglib.h	2010-01-04 17:02:52.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/include/ecpglib.h	2010-01-04 17:24:50.000000000 +0100
*************** void		ECPGset_noind_null(enum ECPGttype,
*** 85,90 ****
--- 85,93 ----
  bool		ECPGis_noind_null(enum ECPGttype, void *);
  bool		ECPGdescribe(int, int, bool, const char *, const char *, ...);
  
+ void		ECPGset_var(int, void *, int);
+ void	   *ECPGget_var(int number);
+ 
  /* dynamic result allocation */
  void		ECPGfree_auto_mem(void);
  
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/descriptor.c pgsql.4.1/src/interfaces/ecpg/preproc/descriptor.c
*** pgsql.3/src/interfaces/ecpg/preproc/descriptor.c	2010-01-01 14:35:36.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/descriptor.c	2010-01-04 17:24:50.000000000 +0100
*************** struct variable *
*** 317,323 ****
  descriptor_variable(const char *name, int input)
  {
  	static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN];
! 	static const struct ECPGtype descriptor_type = {ECPGt_descriptor, NULL, NULL, {NULL}, 0};
  	static const struct variable varspace[2] = {
  		{descriptor_names[0], (struct ECPGtype *) & descriptor_type, 0, NULL},
  		{descriptor_names[1], (struct ECPGtype *) & descriptor_type, 0, NULL}
--- 317,323 ----
  descriptor_variable(const char *name, int input)
  {
  	static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN];
! 	static const struct ECPGtype descriptor_type = {ECPGt_descriptor, NULL, NULL, NULL, {NULL}, 0};
  	static const struct variable varspace[2] = {
  		{descriptor_names[0], (struct ECPGtype *) & descriptor_type, 0, NULL},
  		{descriptor_names[1], (struct ECPGtype *) & descriptor_type, 0, NULL}
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/ecpg.addons pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.3/src/interfaces/ecpg/preproc/ecpg.addons	2010-01-04 17:10:40.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.addons	2010-01-04 17:24:50.000000000 +0100
*************** ECPG: DeclareCursorStmtDECLAREcursor_nam
*** 310,320 ****
--- 310,323 ----
  
  		this->next = cur;
  		this->name = $2;
+ 		this->function = (current_function ? mm_strdup(current_function) : NULL);
  		this->connection = connection;
  		this->opened = false;
  		this->command =  cat_str(7, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for"), $7);
  		this->argsinsert = argsinsert;
+ 		this->argsinsert_oos = NULL;
  		this->argsresult = argsresult;
+ 		this->argsresult_oos = NULL;
  		argsinsert = argsresult = NULL;
  		cur = this;
  
*************** ECPG: DeclareCursorStmtDECLAREcursor_nam
*** 327,343 ****
  		}
  		comment = cat_str(3, make_str("/*"), c1, make_str("*/"));
  
! 		if (INFORMIX_MODE)
! 		{
! 			if (braces_open > 0) /* we're in a function */
! 			{
! 				$$ = cat_str(4, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), make_str("ECPG_informix_reset_sqlca();"), comment);
! 			}
! 			else
! 				$$ = cat_str(3, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), comment);
! 		}
  		else
! 			$$ = comment;
  	}
  ECPG: ClosePortalStmtCLOSEcursor_name block
  	{
--- 330,346 ----
  		}
  		comment = cat_str(3, make_str("/*"), c1, make_str("*/"));
  
! 		if ((braces_open > 0) && INFORMIX_MODE) /* we're in a function */
! 			$$ = cat_str(4,
! 				adjust_outofscope_cursor_vars(this, true),
! 				adjust_outofscope_cursor_vars(this, false),
! 				make_str("ECPG_informix_reset_sqlca();"),
! 				comment);
  		else
! 			$$ = cat_str(3,
! 				adjust_outofscope_cursor_vars(this, true),
! 				adjust_outofscope_cursor_vars(this, false),
! 				comment);
  	}
  ECPG: ClosePortalStmtCLOSEcursor_name block
  	{
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/ecpg.c pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.c
*** pgsql.3/src/interfaces/ecpg/preproc/ecpg.c	2010-01-01 14:43:43.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.c	2010-01-04 17:24:50.000000000 +0100
*************** main(int argc, char *const argv[])
*** 419,426 ****
  				/* and structure member lists */
  				memset(struct_member_list, 0, sizeof(struct_member_list));
  
! 				/* and our variable counter for Informix compatibility */
! 				ecpg_informix_var = 0;
  
  				/* finally the actual connection */
  				connection = NULL;
--- 419,426 ----
  				/* and structure member lists */
  				memset(struct_member_list, 0, sizeof(struct_member_list));
  
! 				/* and our variable counter for out of scope cursors' variables */
! 				ecpg_internal_var = 0;
  
  				/* finally the actual connection */
  				connection = NULL;
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/ecpg.header pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.header
*** pgsql.3/src/interfaces/ecpg/preproc/ecpg.header	2009-11-06 11:06:24.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.header	2010-01-04 17:24:50.000000000 +0100
***************
*** 33,39 ****
   */
  int struct_level = 0;
  int braces_open; /* brace level counter */
! int ecpg_informix_var = 0;
  char	*connection = NULL;
  char	*input_filename = NULL;
  
--- 33,40 ----
   */
  int struct_level = 0;
  int braces_open; /* brace level counter */
! char *current_function;
! int ecpg_internal_var = 0;
  char	*connection = NULL;
  char	*input_filename = NULL;
  
*************** static char *ECPGstruct_sizeof = NULL;
*** 53,62 ****
  /* for forward declarations we have to store some data as well */
  static char *forward_name = NULL;
  
! struct ECPGtype ecpg_no_indicator = {ECPGt_NO_INDICATOR, NULL, NULL, {NULL}, 0};
  struct variable no_indicator = {"no_indicator", &ecpg_no_indicator, 0, NULL};
  
! struct ECPGtype ecpg_query = {ECPGt_char_variable, NULL, NULL, {NULL}, 0};
  
  /*
   * Handle parsing errors and warnings
--- 54,63 ----
  /* for forward declarations we have to store some data as well */
  static char *forward_name = NULL;
  
! struct ECPGtype ecpg_no_indicator = {ECPGt_NO_INDICATOR, NULL, NULL, NULL, {NULL}, 0};
  struct variable no_indicator = {"no_indicator", &ecpg_no_indicator, 0, NULL};
  
! struct ECPGtype ecpg_query = {ECPGt_char_variable, NULL, NULL, NULL, {NULL}, 0};
  
  /*
   * Handle parsing errors and warnings
*************** create_questionmarks(char *name, bool ar
*** 226,301 ****
  }
  
  static char *
! adjust_informix(struct arguments *list)
  {
  	/* Informix accepts DECLARE with variables that are out of scope when OPEN is called.
!  	 * for instance you can declare variables in a function, and then subsequently use them
! 	 * {
! 	 *      declare_vars();
! 	 *      exec sql ... which uses vars declared in the above function
  	 *
! 	 * This breaks standard and leads to some very dangerous programming.
! 	 * Since they do, we have to work around and accept their syntax as well.
! 	 * But we will do so ONLY in Informix mode.
! 	 * We have to change the variables to our own struct and just store the pointer instead of the variable
  	 */
  
! 	 struct arguments *ptr;
! 	 char *result = make_str("");
  
! 	 for (ptr = list; ptr != NULL; ptr = ptr->next)
! 	 {
! 	 	char temp[20]; /* this should be sufficient unless you have 8 byte integers */
  		char *original_var;
  
! 	 	/* change variable name to "ECPG_informix_get_var(<counter>)" */
  		original_var = ptr->variable->name;
! 		sprintf(temp, "%d))", ecpg_informix_var);
  
! 		if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char && ptr->variable->type->type != ECPGt_unsigned_char && ptr->variable->type->type != ECPGt_string) && atoi(ptr->variable->type->size) > 1)
  		{
! 			ptr->variable = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, make_str("1"), ptr->variable->type->u.element->lineno), ptr->variable->type->size), 0);
! 			sprintf(temp, "%d, (", ecpg_informix_var++);
  		}
  		else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char || ptr->variable->type->type == ECPGt_unsigned_char || ptr->variable->type->type == ECPGt_string) && atoi(ptr->variable->type->size) > 1)
  		{
! 			ptr->variable = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->lineno), 0);
! 			sprintf(temp, "%d, (", ecpg_informix_var++);
  		}
  		else
  		{
! 			ptr->variable = new_variable(cat_str(4, make_str("*("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->lineno), 0);
! 			sprintf(temp, "%d, &(", ecpg_informix_var++);
  		}
  
! 		/* create call to "ECPG_informix_set_var(<counter>, <pointer>. <linen number>)" */
! 		result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var), make_str("), __LINE__);\n"));
  
! 		/* now the indicator if there is one */
! 		if (ptr->indicator->type->type != ECPGt_NO_INDICATOR)
  		{
! 			/* change variable name to "ECPG_informix_get_var(<counter>)" */
  			original_var = ptr->indicator->name;
! 			sprintf(temp, "%d))", ecpg_informix_var);
  
! 			/* create call to "ECPG_informix_set_var(<counter>, <pointer>. <linen number>)" */
! 			if (atoi(ptr->indicator->type->size) > 1)
  			{
! 				ptr->indicator = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->lineno), 0);
! 				sprintf(temp, "%d, (", ecpg_informix_var++);
  			}
  			else
  			{
! 				ptr->indicator = new_variable(cat_str(4, make_str("*("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->lineno), 0);
! 				sprintf(temp, "%d, &(", ecpg_informix_var++);
  			}
! 			result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var), make_str("), __LINE__);\n"));
  		}
- 	 }
  
! 	 return result;
  }
  
  static struct cursor *
  add_additional_variables(char *name, bool insert)
  {
--- 227,379 ----
  }
  
  static char *
! adjust_outofscope_cursor_vars(struct cursor *cur, bool insert)
  {
  	/* Informix accepts DECLARE with variables that are out of scope when OPEN is called.
! 	 * For instance you can DECLARE a cursor in one function, and OPEN/FETCH/CLOSE
! 	 * it in other functions. This is very useful for e.g. event-driver programming,
! 	 * but may also lead to dangerous programming. The limitation when this is allowed
! 	 * and doesn's cause problems have to be documented, like the allocated variables
! 	 * must not be realloc()'ed.
  	 *
! 	 * We have to change the variables to our own struct and just store the pointer
! 	 * instead of the variable. Do it only for local variables, not for globals.
  	 */
  
! 	struct arguments *list;
! 	struct arguments *ptr;
! 	struct arguments *newlist = NULL;
! 	struct variable *newvar, *newind;
! 	char *result = make_str("");
  
! 	list = (insert ? cur->argsinsert : cur->argsresult);
! 
! 	for (ptr = list; ptr != NULL; ptr = ptr->next)
! 	{
! 		char temp[20]; /* this should be sufficient unless you have 8 byte integers */
  		char *original_var;
+ 		bool skip_set_var = false;
  
! 		/* change variable name to "ECPGget_var(<counter>)" */
  		original_var = ptr->variable->name;
! 		sprintf(temp, "%d))", ecpg_internal_var);
  
! 		/* Don't emit ECPGset_var() calls for global variables */
! 		if (ptr->variable->brace_level == 0)
  		{
! 			newvar = ptr->variable;
! 			skip_set_var = true;
! 		}
! 		else if ((ptr->variable->type->type == ECPGt_char_variable) && (!strncmp(ptr->variable->name, "ECPGprepared_statement", strlen("ECPGprepared_statement"))))
! 		{
! 			newvar = ptr->variable;
! 			skip_set_var = true;
! 		}
! 		else if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char && ptr->variable->type->type != ECPGt_unsigned_char && ptr->variable->type->type != ECPGt_string) && atoi(ptr->variable->type->size) > 1)
! 		{
! 			newvar = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, make_str("1"), ptr->variable->type->u.element->lineno), ptr->variable->type->size), 0);
! 			sprintf(temp, "%d, (", ecpg_internal_var++);
  		}
  		else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char || ptr->variable->type->type == ECPGt_unsigned_char || ptr->variable->type->type == ECPGt_string) && atoi(ptr->variable->type->size) > 1)
  		{
! 			newvar = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->lineno), 0);
! 			if (ptr->variable->type->type == ECPGt_varchar)
! 				sprintf(temp, "%d, &(", ecpg_internal_var++);
! 			else
! 				sprintf(temp, "%d, (", ecpg_internal_var++);
! 		}
! 		else if (ptr->variable->type->type == ECPGt_struct || ptr->variable->type->type == ECPGt_union)
! 		{
! 			sprintf(temp, "%d)))", ecpg_internal_var);
! 			newvar = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->variable->type->type_name), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->variable->type->u.members, ptr->variable->type->type, ptr->variable->type->type_name, ptr->variable->type->struct_sizeof), 0);
! 			sprintf(temp, "%d, &(", ecpg_internal_var++);
! 		}
! 		else if (ptr->variable->type->type == ECPGt_array)
! 		{
! 			if (ptr->variable->type->u.element->type == ECPGt_struct || ptr->variable->type->u.element->type == ECPGt_union)
! 			{
! 				sprintf(temp, "%d)))", ecpg_internal_var);
! 				newvar = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->variable->type->u.element->type_name), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->variable->type->u.element->u.members, ptr->variable->type->u.element->type, ptr->variable->type->u.element->type_name, ptr->variable->type->u.element->struct_sizeof), 0);
! 				sprintf(temp, "%d, (", ecpg_internal_var++);
! 			}
! 			else
! 			{
! 				newvar = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, ptr->variable->type->u.element->size, ptr->variable->type->u.element->lineno), ptr->variable->type->size), 0);
! 				sprintf(temp, "%d, &(", ecpg_internal_var++);
! 			}
  		}
  		else
  		{
! 			newvar = new_variable(cat_str(4, make_str("*("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->lineno), 0);
! 			sprintf(temp, "%d, &(", ecpg_internal_var++);
  		}
  
! 		/* create call to "ECPGset_var(<counter>, <pointer>. <linen number>)" */
! 		if (!skip_set_var)
! 			result = cat_str(5, result, make_str("ECPGset_var("), mm_strdup(temp), mm_strdup(original_var), make_str("), __LINE__);\n"));
  
! 		/* now the indicator if there is one and it's not a global variable */
! 		if ((ptr->indicator->type->type == ECPGt_NO_INDICATOR) || (ptr->indicator->brace_level == 0))
  		{
! 			newind = ptr->indicator;
! 		}
! 		else
! 		{
! 			/* change variable name to "ECPGget_var(<counter>)" */
  			original_var = ptr->indicator->name;
! 			sprintf(temp, "%d))", ecpg_internal_var);
  
! 			if (ptr->indicator->type->type == ECPGt_struct || ptr->indicator->type->type == ECPGt_union)
  			{
! 				sprintf(temp, "%d)))", ecpg_internal_var);
! 				newind = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->indicator->type->type_name), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->indicator->type->u.members, ptr->indicator->type->type, ptr->indicator->type->type_name, ptr->indicator->type->struct_sizeof), 0);
! 				sprintf(temp, "%d, &(", ecpg_internal_var++);
! 			}
! 			else if (ptr->indicator->type->type == ECPGt_array)
! 			{
! 				if (ptr->indicator->type->u.element->type == ECPGt_struct || ptr->indicator->type->u.element->type == ECPGt_union)
! 				{
! 					sprintf(temp, "%d)))", ecpg_internal_var);
! 					newind = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->indicator->type->u.element->type_name), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->indicator->type->u.element->u.members, ptr->indicator->type->u.element->type, ptr->indicator->type->u.element->type_name, ptr->indicator->type->u.element->struct_sizeof), 0);
! 					sprintf(temp, "%d, (", ecpg_internal_var++);
! 				}
! 				else
! 				{
! 					newind = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->indicator->type->u.element->type)), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->indicator->type->u.element->type, ptr->indicator->type->u.element->size, ptr->indicator->type->u.element->lineno), ptr->indicator->type->size), 0);
! 					sprintf(temp, "%d, &(", ecpg_internal_var++);
! 				}
! 			}
! 			else if (atoi(ptr->indicator->type->size) > 1)
! 			{
! 				newind = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->lineno), 0);
! 				sprintf(temp, "%d, (", ecpg_internal_var++);
  			}
  			else
  			{
! 				newind = new_variable(cat_str(4, make_str("*("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->lineno), 0);
! 				sprintf(temp, "%d, &(", ecpg_internal_var++);
  			}
! 
! 			/* create call to "ECPGset_var(<counter>, <pointer>. <linen number>)" */
! 			result = cat_str(5, result, make_str("ECPGset_var("), mm_strdup(temp), mm_strdup(original_var), make_str("), __LINE__);\n"));
  		}
  
! 		add_variable_to_tail(&newlist, newvar, newind);
! 	}
! 
! 	if (insert)
! 		cur->argsinsert_oos = newlist;
! 	else
! 		cur->argsresult_oos = newlist;
! 
! 	return result;
  }
  
+ /* This tests whether the cursor was declared and opened in the same function. */
+ #define SAMEFUNC(cur)	\
+ 	((cur->function == NULL) ||		\
+ 	 (cur->function != NULL && !strcmp(cur->function, current_function)))
+ 
  static struct cursor *
  add_additional_variables(char *name, bool insert)
  {
*************** add_additional_variables(char *name, boo
*** 318,329 ****
  	{
  		/* add all those input variables that were given earlier
  		 * note that we have to append here but have to keep the existing order */
! 		for (p = ptr->argsinsert; p; p = p->next)
  			add_variable_to_tail(&argsinsert, p->variable, p->indicator);
  	}
  
  	/* add all those output variables that were given earlier */
! 	for (p = ptr->argsresult; p; p = p->next)
  		add_variable_to_tail(&argsresult, p->variable, p->indicator);
  
  	return ptr;
--- 396,407 ----
  	{
  		/* add all those input variables that were given earlier
  		 * note that we have to append here but have to keep the existing order */
! 		for (p = (SAMEFUNC(ptr) ? ptr->argsinsert : ptr->argsinsert_oos); p; p = p->next)
  			add_variable_to_tail(&argsinsert, p->variable, p->indicator);
  	}
  
  	/* add all those output variables that were given earlier */
! 	for (p = (SAMEFUNC(ptr) ? ptr->argsresult : ptr->argsresult_oos); p; p = p->next)
  		add_variable_to_tail(&argsresult, p->variable, p->indicator);
  
  	return ptr;
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/ecpg.trailer pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.3/src/interfaces/ecpg/preproc/ecpg.trailer	2010-01-04 15:10:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.trailer	2010-01-04 17:24:50.000000000 +0100
*************** statement: ecpgstart at stmt ';'        
*** 16,22 ****
                  | c_thing               { fprintf(yyout, "%s", $1); free($1); }
                  | CPP_LINE              { fprintf(yyout, "%s", $1); free($1); }
                  | '{'                   { braces_open++; fputs("{", yyout); }
!                 | '}'                   { remove_typedefs(braces_open); remove_variables(braces_open--); fputs("}", yyout); }
                  ;
  
  CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
--- 16,32 ----
                  | c_thing               { fprintf(yyout, "%s", $1); free($1); }
                  | CPP_LINE              { fprintf(yyout, "%s", $1); free($1); }
                  | '{'                   { braces_open++; fputs("{", yyout); }
!                 | '}'
! 		{
! 			remove_typedefs(braces_open);
! 			remove_variables(braces_open--);
! 			if (braces_open == 0)
! 			{
! 				free(current_function);
! 				current_function = NULL;
! 			}
! 			fputs("}", yyout);
! 		}
                  ;
  
  CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 281,286 ****
--- 291,297 ----
  			char *cursor_marker = $2[0] == ':' ? make_str("$0") : mm_strdup($2);
  			struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable));
  			const char *con = connection ? connection : "NULL";
+ 			char *comment;
  
  			for (ptr = cur; ptr != NULL; ptr = ptr->next)
  			{
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 294,302 ****
--- 305,315 ----
  			/* initial definition */
  			this->next = cur;
  			this->name = $2;
+ 			this->function = (current_function ? mm_strdup(current_function) : NULL);
  			this->connection = connection;
  			this->command =  cat_str(6, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for $1"));
  			this->argsresult = NULL;
+ 			this->argsresult_oos = NULL;
  
  			thisquery->type = &ecpg_query;
  			thisquery->brace_level = 0;
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 305,310 ****
--- 318,324 ----
  			sprintf(thisquery->name, "ECPGprepared_statement(%s, %s, __LINE__)", con, $7);
  
  			this->argsinsert = NULL;
+ 			this->argsinsert_oos = NULL;
  			if ($2[0] == ':')
  			{
  				struct variable *var = find_variable($2 + 1);
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 315,324 ****
  
  			cur = this;
  
! 			if (INFORMIX_MODE && braces_open > 0) /* we're in a function */
! 				$$ = cat_str(4, make_str("ECPG_informix_reset_sqlca();"), make_str("/*"), mm_strdup(this->command), make_str("*/"));
  			else
! 				$$ = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/"));
  		}
  		;
  
--- 329,347 ----
  
  			cur = this;
  
! 			comment = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/"));
! 
! 			if ((braces_open > 0) && INFORMIX_MODE) /* we're in a function */
! 				$$ = cat_str(4,
! 					adjust_outofscope_cursor_vars(this, true),
! 					adjust_outofscope_cursor_vars(this, false),
! 					make_str("ECPG_informix_reset_sqlca();"),
! 					comment);
  			else
! 				$$ = cat_str(3,
! 					adjust_outofscope_cursor_vars(this, true),
! 					adjust_outofscope_cursor_vars(this, false),
! 					comment);
  		}
  		;
  
*************** var_declaration: storage_declaration
*** 402,407 ****
--- 425,431 ----
  		var_type
  		{
  			actual_type[struct_level].type_enum = $2.type_enum;
+ 			actual_type[struct_level].type_str = $2.type_str;
  			actual_type[struct_level].type_dimension = $2.type_dimension;
  			actual_type[struct_level].type_index = $2.type_index;
  			actual_type[struct_level].type_sizeof = $2.type_sizeof;
*************** var_declaration: storage_declaration
*** 415,420 ****
--- 439,445 ----
  		| var_type
  		{
  			actual_type[struct_level].type_enum = $1.type_enum;
+ 			actual_type[struct_level].type_str = $1.type_str;
  			actual_type[struct_level].type_dimension = $1.type_dimension;
  			actual_type[struct_level].type_index = $1.type_index;
  			actual_type[struct_level].type_sizeof = $1.type_sizeof;
*************** variable: opt_pointer ECPGColLabel opt_a
*** 826,834 ****
  				case ECPGt_struct:
  				case ECPGt_union:
  					if (atoi(dimension) < 0)
! 						type = ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_sizeof);
  					else
! 						type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_sizeof), dimension);
  
  					$$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
  					break;
--- 851,859 ----
  				case ECPGt_struct:
  				case ECPGt_union:
  					if (atoi(dimension) < 0)
! 						type = ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_str, actual_type[struct_level].type_sizeof);
  					else
! 						type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_str, actual_type[struct_level].type_sizeof), dimension);
  
  					$$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
  					break;
*************** ECPGVar: SQL_VAR
*** 1303,1311 ****
  					case ECPGt_struct:
  					case ECPGt_union:
  						if (atoi(dimension) < 0)
! 							type = ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_sizeof);
  						else
! 							type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum,$5.type_sizeof), dimension);
  						break;
  
  					case ECPGt_varchar:
--- 1328,1336 ----
  					case ECPGt_struct:
  					case ECPGt_union:
  						if (atoi(dimension) < 0)
! 							type = ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_str, $5.type_sizeof);
  						else
! 							type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_str, $5.type_sizeof), dimension);
  						break;
  
  					case ECPGt_varchar:
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/extern.h pgsql.4.1/src/interfaces/ecpg/preproc/extern.h
*** pgsql.3/src/interfaces/ecpg/preproc/extern.h	2010-01-01 14:35:36.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/extern.h	2010-01-04 17:24:50.000000000 +0100
*************** extern int	braces_open,
*** 26,34 ****
  			questionmarks,
  			ret_value,
  			struct_level,
! 			ecpg_informix_var,
  			regression_mode,
  			auto_prepare;
  extern char *descriptor_index;
  extern char *descriptor_name;
  extern char *connection;
--- 26,35 ----
  			questionmarks,
  			ret_value,
  			struct_level,
! 			ecpg_internal_var,
  			regression_mode,
  			auto_prepare;
+ extern char *current_function;
  extern char *descriptor_index;
  extern char *descriptor_name;
  extern char *connection;
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/pgc.l pgsql.4.1/src/interfaces/ecpg/preproc/pgc.l
*** pgsql.3/src/interfaces/ecpg/preproc/pgc.l	2009-09-18 08:26:55.000000000 +0200
--- pgsql.4.1/src/interfaces/ecpg/preproc/pgc.l	2010-01-04 17:24:50.000000000 +0100
*************** static char    *literalbuf = NULL;		/* e
*** 41,46 ****
--- 41,49 ----
  static int		literallen;				/* actual current length */
  static int		literalalloc;			/* current allocated buffer size */
  
+ /* Used for detecting global state together with braces_open */
+ static int		parenths_open;
+ 
  #define startlit()	(literalbuf[0] = '\0', literallen = 0)
  static void addlit(char *ytext, int yleng);
  static void addlitchar (unsigned char);
*************** cppline			{space}*#(.*\\{space})*.*{newl
*** 788,794 ****
  					}
  <C>{identifier} 	{
  						const ScanKeyword		*keyword;
! 							
  						/* Informix uses SQL defines only in SQL space */
  						/* however, some defines have to be taken care of for compatibility */
  						if ((!INFORMIX_MODE || !isinformixdefine()) && !isdefine())
--- 791,807 ----
  					}
  <C>{identifier} 	{
  						const ScanKeyword		*keyword;
! 
! 						/*
! 						 * Try to detect a function name:
! 						 * look for identifiers at the global scope
! 						 * keep the last identifier before the first '(' and '{' */
! 						if (braces_open == 0 && parenths_open == 0)
! 						{
! 							if (current_function)
! 								free(current_function);
! 							current_function = mm_strdup(yytext);
! 						}
  						/* Informix uses SQL defines only in SQL space */
  						/* however, some defines have to be taken care of for compatibility */
  						if ((!INFORMIX_MODE || !isinformixdefine()) && !isdefine())
*************** cppline			{space}*#(.*\\{space})*.*{newl
*** 811,818 ****
  <C>"/"				{ return('/'); }
  <C>"+"				{ return('+'); }
  <C>"-"				{ return('-'); }
! <C>"("				{ return('('); }
! <C>")"				{ return(')'); }
  <C,xskip>{space}		{ ECHO; }
  <C>\{				{ return('{'); }
  <C>\}				{ return('}'); }
--- 824,831 ----
  <C>"/"				{ return('/'); }
  <C>"+"				{ return('+'); }
  <C>"-"				{ return('-'); }
! <C>"("				{ parenths_open++; return('('); }
! <C>")"				{ parenths_open--; return(')'); }
  <C,xskip>{space}		{ ECHO; }
  <C>\{				{ return('{'); }
  <C>\}				{ return('}'); }
*************** void
*** 1178,1183 ****
--- 1191,1198 ----
  lex_init(void)
  {
  	braces_open = 0;
+ 	parenths_open = 0;
+ 	current_function = NULL;
  
  	preproc_tos = 0;
  	yylineno = 1;
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/type.c pgsql.4.1/src/interfaces/ecpg/preproc/type.c
*** pgsql.3/src/interfaces/ecpg/preproc/type.c	2010-01-01 14:35:36.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/type.c	2010-01-04 17:24:50.000000000 +0100
*************** ECPGstruct_member_dup(struct ECPGstruct_
*** 46,52 ****
  		{
  			case ECPGt_struct:
  			case ECPGt_union:
! 				type = ECPGmake_struct_type(rm->type->u.members, rm->type->type, rm->type->struct_sizeof);
  				break;
  			case ECPGt_array:
  
--- 46,52 ----
  		{
  			case ECPGt_struct:
  			case ECPGt_union:
! 				type = ECPGmake_struct_type(rm->type->u.members, rm->type->type, rm->type->type_name, rm->type->struct_sizeof);
  				break;
  			case ECPGt_array:
  
*************** ECPGstruct_member_dup(struct ECPGstruct_
*** 55,61 ****
  				 * create the struct too
  				 */
  				if (rm->type->u.element->type == ECPGt_struct)
! 					type = ECPGmake_struct_type(rm->type->u.element->u.members, rm->type->u.element->type, rm->type->u.element->struct_sizeof);
  				else
  					type = ECPGmake_array_type(ECPGmake_simple_type(rm->type->u.element->type, rm->type->u.element->size, rm->type->u.element->lineno), rm->type->size);
  				break;
--- 55,61 ----
  				 * create the struct too
  				 */
  				if (rm->type->u.element->type == ECPGt_struct)
! 					type = ECPGmake_struct_type(rm->type->u.element->u.members, rm->type->u.element->type, rm->type->u.element->type_name, rm->type->u.element->struct_sizeof);
  				else
  					type = ECPGmake_array_type(ECPGmake_simple_type(rm->type->u.element->type, rm->type->u.element->size, rm->type->u.element->lineno), rm->type->size);
  				break;
*************** ECPGmake_simple_type(enum ECPGttype type
*** 98,103 ****
--- 98,104 ----
  	struct ECPGtype *ne = (struct ECPGtype *) mm_alloc(sizeof(struct ECPGtype));
  
  	ne->type = type;
+ 	ne->type_name = NULL;
  	ne->size = size;
  	ne->u.element = NULL;
  	ne->struct_sizeof = NULL;
*************** ECPGmake_array_type(struct ECPGtype * ty
*** 117,126 ****
  }
  
  struct ECPGtype *
! ECPGmake_struct_type(struct ECPGstruct_member * rm, enum ECPGttype type, char *struct_sizeof)
  {
  	struct ECPGtype *ne = ECPGmake_simple_type(type, make_str("1"), 0);
  
  	ne->u.members = ECPGstruct_member_dup(rm);
  	ne->struct_sizeof = struct_sizeof;
  
--- 118,128 ----
  }
  
  struct ECPGtype *
! ECPGmake_struct_type(struct ECPGstruct_member * rm, enum ECPGttype type, char *type_name, char *struct_sizeof)
  {
  	struct ECPGtype *ne = ECPGmake_simple_type(type, make_str("1"), 0);
  
+ 	ne->type_name = mm_strdup(type_name);
  	ne->u.members = ECPGstruct_member_dup(rm);
  	ne->struct_sizeof = struct_sizeof;
  
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/type.h pgsql.4.1/src/interfaces/ecpg/preproc/type.h
*** pgsql.3/src/interfaces/ecpg/preproc/type.h	2009-06-13 18:25:05.000000000 +0200
--- pgsql.4.1/src/interfaces/ecpg/preproc/type.h	2010-01-04 17:24:50.000000000 +0100
*************** struct ECPGstruct_member
*** 17,22 ****
--- 17,23 ----
  struct ECPGtype
  {
  	enum ECPGttype type;
+ 	char	   *type_name;			/* For struct and union types it is the struct name */
  	char	   *size;			/* For array it is the number of elements. For
  								 * varchar it is the maxsize of the area. */
  	char	   *struct_sizeof;	/* For a struct this is the sizeof() type as
*************** void		ECPGmake_struct_member(char *, str
*** 36,42 ****
  struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, char *, int);
  struct ECPGtype *ECPGmake_varchar_type(enum ECPGttype, long);
  struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, char *);
! struct ECPGtype *ECPGmake_struct_type(struct ECPGstruct_member *, enum ECPGttype, char *);
  struct ECPGstruct_member *ECPGstruct_member_dup(struct ECPGstruct_member *);
  
  /* Frees a type. */
--- 37,43 ----
  struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, char *, int);
  struct ECPGtype *ECPGmake_varchar_type(enum ECPGttype, long);
  struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, char *);
! struct ECPGtype *ECPGmake_struct_type(struct ECPGstruct_member *, enum ECPGttype, char *, char *);
  struct ECPGstruct_member *ECPGstruct_member_dup(struct ECPGstruct_member *);
  
  /* Frees a type. */
*************** struct _include_path
*** 123,133 ****
--- 124,137 ----
  struct cursor
  {
  	char	   *name;
+ 	char	   *function;
  	char	   *command;
  	char	   *connection;
  	bool		opened;
  	struct arguments *argsinsert;
+ 	struct arguments *argsinsert_oos;
  	struct arguments *argsresult;
+ 	struct arguments *argsresult_oos;
  	struct cursor *next;
  };
  
diff -dcrpN pgsql.3/src/interfaces/ecpg/preproc/variable.c pgsql.4.1/src/interfaces/ecpg/preproc/variable.c
*** pgsql.3/src/interfaces/ecpg/preproc/variable.c	2009-11-26 18:57:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/variable.c	2010-01-04 17:24:50.000000000 +0100
*************** find_struct_member(char *name, char *str
*** 47,53 ****
  						return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->type, members->type->u.element->size, members->type->u.element->lineno), members->type->size), brace_level));
  					case ECPGt_struct:
  					case ECPGt_union:
! 						return (new_variable(name, ECPGmake_struct_type(members->type->u.members, members->type->type, members->type->struct_sizeof), brace_level));
  					default:
  						return (new_variable(name, ECPGmake_simple_type(members->type->type, members->type->size, members->type->lineno), brace_level));
  				}
--- 47,53 ----
  						return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->type, members->type->u.element->size, members->type->u.element->lineno), members->type->size), brace_level));
  					case ECPGt_struct:
  					case ECPGt_union:
! 						return (new_variable(name, ECPGmake_struct_type(members->type->u.members, members->type->type, members->type->type_name, members->type->struct_sizeof), brace_level));
  					default:
  						return (new_variable(name, ECPGmake_simple_type(members->type->type, members->type->size, members->type->lineno), brace_level));
  				}
*************** find_struct_member(char *name, char *str
*** 94,100 ****
  								return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->u.element->type, members->type->u.element->u.element->size, members->type->u.element->u.element->lineno), members->type->u.element->size), brace_level));
  							case ECPGt_struct:
  							case ECPGt_union:
! 								return (new_variable(name, ECPGmake_struct_type(members->type->u.element->u.members, members->type->u.element->type, members->type->u.element->struct_sizeof), brace_level));
  							default:
  								return (new_variable(name, ECPGmake_simple_type(members->type->u.element->type, members->type->u.element->size, members->type->u.element->lineno), brace_level));
  						}
--- 94,100 ----
  								return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->u.element->type, members->type->u.element->u.element->size, members->type->u.element->u.element->lineno), members->type->u.element->size), brace_level));
  							case ECPGt_struct:
  							case ECPGt_union:
! 								return (new_variable(name, ECPGmake_struct_type(members->type->u.element->u.members, members->type->u.element->type, members->type->u.element->type_name, members->type->u.element->struct_sizeof), brace_level));
  							default:
  								return (new_variable(name, ECPGmake_simple_type(members->type->u.element->type, members->type->u.element->size, members->type->u.element->lineno), brace_level));
  						}
*************** find_variable(char *name)
*** 235,241 ****
  						return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(p->type->u.element->u.element->type, p->type->u.element->u.element->size, p->type->u.element->u.element->lineno), p->type->u.element->size), p->brace_level));
  					case ECPGt_struct:
  					case ECPGt_union:
! 						return (new_variable(name, ECPGmake_struct_type(p->type->u.element->u.members, p->type->u.element->type, p->type->u.element->struct_sizeof), p->brace_level));
  					default:
  						return (new_variable(name, ECPGmake_simple_type(p->type->u.element->type, p->type->u.element->size, p->type->u.element->lineno), p->brace_level));
  				}
--- 235,241 ----
  						return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(p->type->u.element->u.element->type, p->type->u.element->u.element->size, p->type->u.element->u.element->lineno), p->type->u.element->size), p->brace_level));
  					case ECPGt_struct:
  					case ECPGt_union:
! 						return (new_variable(name, ECPGmake_struct_type(p->type->u.element->u.members, p->type->u.element->type, p->type->u.element->type_name, p->type->u.element->struct_sizeof), p->brace_level));
  					default:
  						return (new_variable(name, ECPGmake_simple_type(p->type->u.element->type, p->type->u.element->size, p->type->u.element->lineno), p->brace_level));
  				}
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/ecpg_schedule pgsql.4.1/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.3/src/interfaces/ecpg/test/ecpg_schedule	2010-01-04 14:57:13.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/ecpg_schedule	2010-01-04 17:24:50.000000000 +0100
*************** test: preproc/init
*** 24,29 ****
--- 24,31 ----
  test: preproc/strings
  test: preproc/type
  test: preproc/variable
+ test: preproc/struct
+ test: preproc/outofscope
  test: preproc/whenever
  test: sql/array
  test: sql/binary
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/ecpg_schedule_tcp pgsql.4.1/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.3/src/interfaces/ecpg/test/ecpg_schedule_tcp	2010-01-04 14:57:13.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/ecpg_schedule_tcp	2010-01-04 17:24:50.000000000 +0100
*************** test: preproc/init
*** 24,29 ****
--- 24,31 ----
  test: preproc/strings
  test: preproc/type
  test: preproc/variable
+ test: preproc/struct
+ test: preproc/outofscope
  test: preproc/whenever
  test: sql/array
  test: sql/binary
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c pgsql.4.1/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c
*** pgsql.3/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c	2010-01-04 13:51:27.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c	2010-01-04 17:24:50.000000000 +0100
*************** if (sqlca.sqlcode < 0) dosqlprint ( );}
*** 148,154 ****
  
  
  	sqlca.sqlcode = 100;
! 	ECPG_informix_set_var( 0, &( i ), __LINE__);\
   ECPG_informix_reset_sqlca(); /* declare c cursor for select * from test where i <= $1  */
  #line 49 "test_informix.pgc"
  
--- 148,154 ----
  
  
  	sqlca.sqlcode = 100;
! 	ECPGset_var( 0, &( i ), __LINE__);\
   ECPG_informix_reset_sqlca(); /* declare c cursor for select * from test where i <= $1  */
  #line 49 "test_informix.pgc"
  
*************** if (sqlca.sqlcode < 0) dosqlprint ( );}
*** 246,252 ****
  static void openit(void)
  {
  	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare c cursor for select * from test where i <= $1 ", 
! 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 0))),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 95 "test_informix.pgc"
  
--- 246,252 ----
  static void openit(void)
  {
  	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare c cursor for select * from test where i <= $1 ", 
! 	ECPGt_int,&(*( int  *)(ECPGget_var( 0))),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 95 "test_informix.pgc"
  
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/preproc-cursor.c pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-cursor.c
*** pgsql.3/src/interfaces/ecpg/test/expected/preproc-cursor.c	2009-11-26 16:55:57.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-cursor.c	2010-01-04 17:24:50.000000000 +0100
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 153,159 ****
  	/* Dynamic cursorname test with INTO list in FETCH stmts */
  
  	strcpy(msg, "declare");
! 	/* declare $0 cursor for select id , t from t1 */
  #line 59 "cursor.pgc"
  
  
--- 153,160 ----
  	/* Dynamic cursorname test with INTO list in FETCH stmts */
  
  	strcpy(msg, "declare");
! 	ECPGset_var( 0, &( curname1 ), __LINE__);\
!  /* declare $0 cursor for select id , t from t1 */
  #line 59 "cursor.pgc"
  
  
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 286,292 ****
  	/* Dynamic cursorname test with INTO list in DECLARE stmt */
  
  	strcpy(msg, "declare");
! 	/* declare $0 cursor for select id , t from t1 */
  #line 100 "cursor.pgc"
  
  
--- 287,296 ----
  	/* Dynamic cursorname test with INTO list in DECLARE stmt */
  
  	strcpy(msg, "declare");
! 	ECPGset_var( 3, &( curname2 ), __LINE__);\
!  ECPGset_var( 1, ( t ), __LINE__);\
!  ECPGset_var( 2, &( id ), __LINE__);\
!  /* declare $0 cursor for select id , t from t1 */
  #line 100 "cursor.pgc"
  
  
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 435,441 ****
  
  
  	strcpy(msg, "declare");
! 	/* declare $0 cursor for $1 */
  #line 143 "cursor.pgc"
  
  
--- 439,446 ----
  
  
  	strcpy(msg, "declare");
! 	ECPGset_var( 4, &( curname3 ), __LINE__);\
!  /* declare $0 cursor for $1 */
  #line 143 "cursor.pgc"
  
  
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 590,596 ****
  
  
  	strcpy(msg, "declare");
! 	/* declare $0 cursor for $1 */
  #line 193 "cursor.pgc"
  
  
--- 595,602 ----
  
  
  	strcpy(msg, "declare");
! 	ECPGset_var( 5, &( curname4 ), __LINE__);\
!  /* declare $0 cursor for $1 */
  #line 193 "cursor.pgc"
  
  
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/preproc-outofscope.c pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-outofscope.c
*** pgsql.3/src/interfaces/ecpg/test/expected/preproc-outofscope.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-outofscope.c	2010-01-04 17:36:49.000000000 +0100
***************
*** 0 ****
--- 1,591 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "outofscope.pgc"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ #include <limits.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 7 "outofscope.pgc"
+ 
+ 
+ 
+ #line 1 "sqlda.h"
+ /*
+  * $PostgreSQL: pgsql/src/interfaces/ecpg/include/sqlda.h,v 1.4 2009/06/11 14:49:13 momjian Exp $
+  */
+ 
+ #ifndef ECPG_SQLDA_H
+ #define ECPG_SQLDA_H
+ 
+ #ifdef ECPG_INFORMIX_COMPAT
+ 
+ #include "sqlda-compat.h"
+ typedef struct sqlvar_compat	sqlvar_t;
+ typedef struct sqlda_compat	sqlda_t;
+ 
+ #else
+ 
+ #include "sqlda-native.h"
+ typedef struct sqlvar_struct	sqlvar_t;
+ typedef struct sqlda_struct	sqlda_t;
+ 
+ #endif
+ 
+ #endif /* ECPG_SQLDA_H */
+ 
+ #line 9 "outofscope.pgc"
+ 
+ 
+ #line 1 "pgtypes_numeric.h"
+ /* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_numeric.h,v 1.16 2006/08/09 07:30:56 meskes Exp $ */
+ 
+ #ifndef PGTYPES_NUMERIC
+ #define PGTYPES_NUMERIC
+ 
+ #define NUMERIC_POS						0x0000
+ #define NUMERIC_NEG						0x4000
+ #define NUMERIC_NAN						0xC000
+ #define NUMERIC_MAX_PRECISION			1000
+ #define NUMERIC_MAX_DISPLAY_SCALE		NUMERIC_MAX_PRECISION
+ #define NUMERIC_MIN_DISPLAY_SCALE		0
+ #define NUMERIC_MIN_SIG_DIGITS			16
+ 
+ #define DECSIZE 30
+ 
+ typedef unsigned char NumericDigit;
+ typedef struct
+ {
+ 	int			ndigits;		/* number of digits in digits[] - can be 0! */
+ 	int			weight;			/* weight of first digit */
+ 	int			rscale;			/* result scale */
+ 	int			dscale;			/* display scale */
+ 	int			sign;			/* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
+ 	NumericDigit *buf;			/* start of alloc'd space for digits[] */
+ 	NumericDigit *digits;		/* decimal digits */
+ } numeric;
+ 
+ typedef struct
+ {
+ 	int			ndigits;		/* number of digits in digits[] - can be 0! */
+ 	int			weight;			/* weight of first digit */
+ 	int			rscale;			/* result scale */
+ 	int			dscale;			/* display scale */
+ 	int			sign;			/* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
+ 	NumericDigit digits[DECSIZE];		/* decimal digits */
+ } decimal;
+ 
+ #ifdef __cplusplus
+ extern		"C"
+ {
+ #endif
+ 
+ numeric    *PGTYPESnumeric_new(void);
+ decimal    *PGTYPESdecimal_new(void);
+ void		PGTYPESnumeric_free(numeric *);
+ void		PGTYPESdecimal_free(decimal *);
+ numeric    *PGTYPESnumeric_from_asc(char *, char **);
+ char	   *PGTYPESnumeric_to_asc(numeric *, int);
+ int			PGTYPESnumeric_add(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_sub(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_mul(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_div(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_cmp(numeric *, numeric *);
+ int			PGTYPESnumeric_from_int(signed int, numeric *);
+ int			PGTYPESnumeric_from_long(signed long int, numeric *);
+ int			PGTYPESnumeric_copy(numeric *, numeric *);
+ int			PGTYPESnumeric_from_double(double, numeric *);
+ int			PGTYPESnumeric_to_double(numeric *, double *);
+ int			PGTYPESnumeric_to_int(numeric *, int *);
+ int			PGTYPESnumeric_to_long(numeric *, long *);
+ int			PGTYPESnumeric_to_decimal(numeric *, decimal *);
+ int			PGTYPESnumeric_from_decimal(decimal *, numeric *);
+ 
+ #ifdef __cplusplus
+ }
+ #endif
+ 
+ #endif   /* PGTYPES_NUMERIC */
+ 
+ #line 10 "outofscope.pgc"
+ 
+ 
+ /* exec sql begin declare section */
+ 
+ #line 1 "struct.h"
+ 
+   
+ 		
+ 		
+ 		 /* dec_t */
+ 		
+ 		
+ 
+    typedef struct mytype  MYTYPE ;
+ 
+ #line 9 "struct.h"
+ 
+ 
+   
+ 		
+ 		
+ 		
+ 		
+ 		
+ 
+    typedef struct mynulltype  MYNULLTYPE ;
+ 
+ #line 18 "struct.h"
+ 
+ 
+ #line 13 "outofscope.pgc"
+ 
+ struct mytype { 
+ #line 3 "struct.h"
+  int id ;
+  
+ #line 4 "struct.h"
+  char t [ 64 ] ;
+  
+ #line 5 "struct.h"
+  double d1 ;
+  
+ #line 6 "struct.h"
+  double d2 ;
+  
+ #line 7 "struct.h"
+  char c [ 30 ] ;
+  } ; struct mynulltype { 
+ #line 12 "struct.h"
+  int id ;
+  
+ #line 13 "struct.h"
+  int t ;
+  
+ #line 14 "struct.h"
+  int d1 ;
+  
+ #line 15 "struct.h"
+  int d2 ;
+  
+ #line 16 "struct.h"
+  int c ;
+  } ;/* exec sql end declare section */
+ #line 14 "outofscope.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 16 "outofscope.pgc"
+ 
+ 
+ /* Functions for test 1 */
+ 
+ static void
+ get_var1(MYTYPE **myvar0, MYNULLTYPE **mynullvar0)
+ {
+ 	/* exec sql begin declare section */
+ 			  
+ 		  
+ 	
+ #line 24 "outofscope.pgc"
+  MYTYPE * myvar = malloc ( sizeof ( MYTYPE ) ) ;
+  
+ #line 25 "outofscope.pgc"
+  MYNULLTYPE * mynullvar = malloc ( sizeof ( MYNULLTYPE ) ) ;
+ /* exec sql end declare section */
+ #line 26 "outofscope.pgc"
+ 
+ 
+ 	/* Test DECLARE ... SELECT ... INTO with pointers */
+ 
+ 	ECPGset_var( 0, ( myvar ), __LINE__);\
+  ECPGset_var( 1, ( mynullvar ), __LINE__);\
+  /* declare mycur cursor for select * from a1 */
+ #line 30 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ 
+ 	*myvar0 = myvar;
+ 	*mynullvar0 = mynullvar;
+ }
+ 
+ static void
+ open_cur1(void)
+ {
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT, 
+ 	ECPGt_int,&((*( MYTYPE  *)(ECPGget_var( 0))).id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&((*( MYTYPE  *)(ECPGget_var( 0))).t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).t),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&((*( MYTYPE  *)(ECPGget_var( 0))).d1),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).d1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&((*( MYTYPE  *)(ECPGget_var( 0))).d2),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).d2),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&((*( MYTYPE  *)(ECPGget_var( 0))).c),(long)30,(long)1,(30)*sizeof(char), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 42 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 42 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ get_record1(void)
+ {
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch mycur", ECPGt_EOIT, 
+ 	ECPGt_int,&((*( MYTYPE  *)(ECPGget_var( 0))).id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&((*( MYTYPE  *)(ECPGget_var( 0))).t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).t),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&((*( MYTYPE  *)(ECPGget_var( 0))).d1),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).d1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&((*( MYTYPE  *)(ECPGget_var( 0))).d2),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).d2),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&((*( MYTYPE  *)(ECPGget_var( 0))).c),(long)30,(long)1,(30)*sizeof(char), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 51 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 51 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0 && sqlca.sqlcode != ECPG_NOT_FOUND)
+ 		exit(1);
+ }
+ 
+ static void
+ close_cur1(void)
+ {
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur", ECPGt_EOIT, ECPGt_EORT);
+ #line 60 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 60 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ /* Functions for test 2 */
+ 
+ sqlda_t	*inp_sqlda, *outp_sqlda;
+ 
+ /* exec sql begin declare section */
+ 	  
+ 	  
+ 	
+ 
+ #line 71 "outofscope.pgc"
+  char * stmt2 = "SELECT * FROM a1 WHERE id = ?" ;
+  
+ #line 72 "outofscope.pgc"
+  char * curname2 = "mycur" ;
+  
+ #line 73 "outofscope.pgc"
+  int id ;
+ /* exec sql end declare section */
+ #line 74 "outofscope.pgc"
+ 
+ 
+ static void
+ prepare2(void)
+ {
+ 	{ ECPGprepare(__LINE__, NULL, 0, "prepared_stmt", stmt2);
+ #line 79 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 79 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ 
+ 	inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(sqlda_t));
+ 	inp_sqlda->sqln = 1;
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 	id = 4;
+ }
+ 
+ static void
+ declare2(void)
+ {
+ 	/* declare $0 cursor for $1 */
+ #line 96 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ dealloc_prep2(void)
+ {
+ 	{ ECPGdeallocate(__LINE__, 0, NULL, "prepared_stmt");
+ #line 105 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 105 "outofscope.pgc"
+ 
+ 
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ }
+ 
+ static void
+ open_cur2(void)
+ {
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare $0 cursor for $1", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "prepared_stmt", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, 
+ 	ECPGt_sqlda, &inp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 114 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 114 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ close_cur2(void)
+ {
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 123 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 123 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ get_record2(void)
+ {
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch $0", 
+ 	ECPGt_char,&(curname2),(long)0,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, 
+ 	ECPGt_sqlda, &outp_sqlda, 0L, 0L, 0L, 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 132 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 132 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0 && sqlca.sqlcode != ECPG_NOT_FOUND)
+ 		exit(1);
+ }
+ 
+ static void
+ dump_sqlda(sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (outp_sqlda->sqlvar[i].sqlind && *(outp_sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", outp_sqlda->sqlvar[i].sqlname.data);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case ECPGt_char:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname.data, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_int:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname.data, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ #if (LONG_BIT == 64) /* Defined via <limits.h> */
+ 		case ECPGt_long:
+ #else
+ # if (LONG_BIT = 32)
+ 		case ECPGt_long_long:
+ # else
+ #  error Neither "long" nor "long long" are 64-bit
+ # endif
+ #endif
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname.data, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_double: 
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname.data, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_numeric:
+ 			{
+ 				char	*val;
+ 				val = PGTYPESnumeric_to_asc((numeric*)sqlda->sqlvar[i].sqldata, -1);
+ 				printf("name sqlda descriptor: '%s' value NUMERIC '%s'\n", sqlda->sqlvar[i].sqlname.data, val);
+ 				free(val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ 	MYTYPE		*myvar;
+ 	MYNULLTYPE	*mynullvar;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
+ #line 193 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 193 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 196 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 196 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
+ #line 199 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 199 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 202 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 202 "outofscope.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null )", ECPGt_EOIT, ECPGt_EORT);
+ #line 203 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 203 "outofscope.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , '\"a\"' , - 1.0 , 'nan' :: float8 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 204 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 204 "outofscope.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 205 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 205 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 208 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 208 "outofscope.pgc"
+ 
+ 
+ 	/* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE */
+ 
+ 	get_var1(&myvar, &mynullvar);
+ 	open_cur1();
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 215 "outofscope.pgc"
+ 
+ 
+ 	while (1)
+ 	{
+ 		memset(myvar, 0, sizeof(MYTYPE));
+ 		get_record1();
+ 		if (sqlca.sqlcode == ECPG_NOT_FOUND)
+ 			break;
+ 		printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+ 			myvar->id, mynullvar->id ? " (NULL)" : "",
+ 			myvar->t, mynullvar->t ? " (NULL)" : "",
+ 			myvar->d1, mynullvar->d1 ? " (NULL)" : "",
+ 			myvar->d2, mynullvar->d2 ? " (NULL)" : "",
+ 			myvar->c, mynullvar->c ? " (NULL)" : "");
+ 	}
+ 
+ 	close_cur1();
+ 
+ 	/* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE interaction
+ 	 * with a dynamic cursor and prepared statment using an sqlda
+ 	 */
+ 
+ 	prepare2();
+ 	declare2();
+ 	open_cur2();
+ 
+ 	get_record2();
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	close_cur2();
+ 	dealloc_prep2();
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table a1", ECPGt_EOIT, ECPGt_EORT);
+ #line 250 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 250 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 253 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 253 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 256 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 256 "outofscope.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr
*** pgsql.3/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr	2010-01-04 17:36:49.000000000 +0100
***************
*** 0 ****
--- 1,208 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 196: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: query: create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 199: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 202: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 202: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 202: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 203: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 203: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 203: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 204: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , '"a"' , - 1.0 , 'nan' :: float8 , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 204: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 204: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 205: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 205: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 205: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 208: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 42: query: declare mycur cursor for select * from a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 42: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 42: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: "a" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: -1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: 2.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 51: RESULT: b          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 51: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 51: no data found on line 51
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 60: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 60: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 60: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 79: name prepared_stmt; query: "SELECT * FROM a1 WHERE id = $1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 114: query: declare mycur cursor for SELECT * FROM a1 WHERE id = $1; with 1 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 114: using PQexecParams
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 114: parameter 1 = 4
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 114: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 132: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 132: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 132: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: sqlda_common_total_size type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_build_native_sqlda sqld = 5
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 132: new sqlda was built
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type int offset 512
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 0 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 132: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 516
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 1 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 132: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset1 520
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type numeric offset2 560
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 2 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type double offset 568
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 3 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 132: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda type char offset 576
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_set_native_sqlda row 0 col 4 IS NOT NULL
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 132: RESULT: b          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 132: putting result (1 tuple 5 fields) into sqlda descriptor
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 123: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 123: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 123: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 105: name prepared_stmt
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 250: query: drop table a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 250: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 250: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 253: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/preproc-outofscope.stdout pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-outofscope.stdout
*** pgsql.3/src/interfaces/ecpg/test/expected/preproc-outofscope.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-outofscope.stdout	2010-01-04 17:24:50.000000000 +0100
***************
*** 0 ****
--- 1,9 ----
+ id=1 t='a' d1=1.000000 d2=2.000000 c = 'a         '
+ id=2 t='' (NULL) d1=0.000000 (NULL) d2=0.000000 (NULL) c = '' (NULL)
+ id=3 t='"a"' d1=-1.000000 d2=nan c = 'a         '
+ id=4 t='b' d1=2.000000 d2=3.000000 c = 'b         '
+ name sqlda descriptor: 'id' value 4
+ name sqlda descriptor: 't' value 'b'
+ name sqlda descriptor: 'd1' value NUMERIC '2.0'
+ name sqlda descriptor: 'd2' value 3.000000
+ name sqlda descriptor: 'c' value 'b         '
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/preproc-struct.c pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-struct.c
*** pgsql.3/src/interfaces/ecpg/test/expected/preproc-struct.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-struct.c	2010-01-04 17:24:50.000000000 +0100
***************
*** 0 ****
--- 1,263 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "struct.pgc"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 5 "struct.pgc"
+ 
+ 
+ /* exec sql begin declare section */
+ 
+ #line 1 "struct.h"
+ 
+   
+ 		
+ 		
+ 		 /* dec_t */
+ 		
+ 		
+ 
+    typedef struct mytype  MYTYPE ;
+ 
+ #line 9 "struct.h"
+ 
+ 
+   
+ 		
+ 		
+ 		
+ 		
+ 		
+ 
+    typedef struct mynulltype  MYNULLTYPE ;
+ 
+ #line 18 "struct.h"
+ 
+ 
+ #line 8 "struct.pgc"
+ 
+ struct mytype { 
+ #line 3 "struct.h"
+  int id ;
+  
+ #line 4 "struct.h"
+  char t [ 64 ] ;
+  
+ #line 5 "struct.h"
+  double d1 ;
+  
+ #line 6 "struct.h"
+  double d2 ;
+  
+ #line 7 "struct.h"
+  char c [ 30 ] ;
+  } ; struct mynulltype { 
+ #line 12 "struct.h"
+  int id ;
+  
+ #line 13 "struct.h"
+  int t ;
+  
+ #line 14 "struct.h"
+  int d1 ;
+  
+ #line 15 "struct.h"
+  int d2 ;
+  
+ #line 16 "struct.h"
+  int c ;
+  } ;/* exec sql end declare section */
+ #line 9 "struct.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 11 "struct.pgc"
+ 
+ 
+ int
+ main (void)
+ {
+ 	/* exec sql begin declare section */
+ 			
+ 		
+ 	
+ #line 17 "struct.pgc"
+  MYTYPE myvar ;
+  
+ #line 18 "struct.pgc"
+  MYNULLTYPE mynullvar ;
+ /* exec sql end declare section */
+ #line 19 "struct.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
+ #line 26 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 26 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 29 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 29 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
+ #line 32 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 32 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 35 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 35 "struct.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null )", ECPGt_EOIT, ECPGt_EORT);
+ #line 36 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "struct.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , '\"a\"' , - 1.0 , 'nan' :: float8 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 37 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "struct.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 38 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 41 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "struct.pgc"
+ 
+ 
+ 	/* Test DECLARE ... SELECT ... INTO with struct type */
+ 
+ 	ECPGset_var( 0, &( myvar ), __LINE__);\
+  ECPGset_var( 1, &( mynullvar ), __LINE__);\
+  /* declare mycur cursor for select * from a1 */
+ #line 45 "struct.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT, 
+ 	ECPGt_int,&(myvar.id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&(mynullvar.id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&(myvar.t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_int,&(mynullvar.t),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&(myvar.d1),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&(mynullvar.d1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&(myvar.d2),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&(mynullvar.d2),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&(myvar.c),(long)30,(long)1,(30)*sizeof(char), 
+ 	ECPGt_int,&(mynullvar.c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 46 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 46 "struct.pgc"
+ 
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 48 "struct.pgc"
+ 
+ 
+ 	while (1)
+ 	{
+ 		memset(&myvar, 0, sizeof(myvar));
+ 		{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch mycur", ECPGt_EOIT, 
+ 	ECPGt_int,&(myvar.id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&(mynullvar.id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&(myvar.t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_int,&(mynullvar.t),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&(myvar.d1),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&(mynullvar.d1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&(myvar.d2),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&(mynullvar.d2),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&(myvar.c),(long)30,(long)1,(30)*sizeof(char), 
+ 	ECPGt_int,&(mynullvar.c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 53 "struct.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 53 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 53 "struct.pgc"
+ 
+ 		printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+ 			myvar.id, mynullvar.id ? " (NULL)" : "",
+ 			myvar.t, mynullvar.t ? " (NULL)" : "",
+ 			myvar.d1, mynullvar.d1 ? " (NULL)" : "",
+ 			myvar.d2, mynullvar.d2 ? " (NULL)" : "",
+ 			myvar.c, mynullvar.c ? " (NULL)" : "");
+ 	}
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur", ECPGt_EOIT, ECPGt_EORT);
+ #line 62 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 62 "struct.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table a1", ECPGt_EOIT, ECPGt_EORT);
+ #line 67 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 67 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 70 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 70 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 73 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 73 "struct.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/preproc-struct.stderr pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-struct.stderr
*** pgsql.3/src/interfaces/ecpg/test/expected/preproc-struct.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-struct.stderr	2010-01-04 17:24:50.000000000 +0100
***************
*** 0 ****
--- 1,136 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: query: create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , '"a"' , - 1.0 , 'nan' :: float8 , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 41: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 46: query: declare mycur cursor for select * from a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 46: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 46: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: "a" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: -1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 2.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: b          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 53: no data found on line 53
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 62: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 67: query: drop table a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 67: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 67: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 70: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/preproc-struct.stdout pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-struct.stdout
*** pgsql.3/src/interfaces/ecpg/test/expected/preproc-struct.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-struct.stdout	2010-01-04 17:24:50.000000000 +0100
***************
*** 0 ****
--- 1,4 ----
+ id=1 t='a' d1=1.000000 d2=2.000000 c = 'a         '
+ id=2 t='' (NULL) d1=0.000000 (NULL) d2=0.000000 (NULL) c = '' (NULL)
+ id=3 t='"a"' d1=-1.000000 d2=nan c = 'a         '
+ id=4 t='b' d1=2.000000 d2=3.000000 c = 'b         '
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/expected/sql-binary.c pgsql.4.1/src/interfaces/ecpg/test/expected/sql-binary.c
*** pgsql.3/src/interfaces/ecpg/test/expected/sql-binary.c	2009-08-07 13:06:28.000000000 +0200
--- pgsql.4.1/src/interfaces/ecpg/test/expected/sql-binary.c	2010-01-04 17:24:50.000000000 +0100
*************** main (void)
*** 107,113 ****
        exit (sqlca.sqlcode);
      }
  
!   /* declare C cursor for select name , accs , byte from empl where idnum = $1  */
  #line 58 "binary.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select name , accs , byte from empl where idnum = $1 ", 
--- 107,114 ----
        exit (sqlca.sqlcode);
      }
  
!   ECPGset_var( 0, &( empl.idnum ), __LINE__);\
!  /* declare C cursor for select name , accs , byte from empl where idnum = $1  */
  #line 58 "binary.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select name , accs , byte from empl where idnum = $1 ", 
*************** main (void)
*** 133,139 ****
    printf ("name=%s, accs=%d byte=%s\n", empl.name, empl.accs, empl.byte);
  
    memset(empl.name, 0, 21L);
!   /* declare B binary cursor for select name , accs , byte from empl where idnum = $1  */
  #line 70 "binary.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare B binary cursor for select name , accs , byte from empl where idnum = $1 ", 
--- 134,141 ----
    printf ("name=%s, accs=%d byte=%s\n", empl.name, empl.accs, empl.byte);
  
    memset(empl.name, 0, 21L);
!   ECPGset_var( 1, &( empl.idnum ), __LINE__);\
!  /* declare B binary cursor for select name , accs , byte from empl where idnum = $1  */
  #line 70 "binary.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare B binary cursor for select name , accs , byte from empl where idnum = $1 ", 
*************** main (void)
*** 166,172 ****
  	printf("(%o)", (unsigned char)empl.byte[i]);
    printf("\n");
  
!   /* declare A binary cursor for select byte from empl where idnum = $1  */
  #line 87 "binary.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare A binary cursor for select byte from empl where idnum = $1 ", 
--- 168,175 ----
  	printf("(%o)", (unsigned char)empl.byte[i]);
    printf("\n");
  
!   ECPGset_var( 2, &( empl.idnum ), __LINE__);\
!  /* declare A binary cursor for select byte from empl where idnum = $1  */
  #line 87 "binary.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare A binary cursor for select byte from empl where idnum = $1 ", 
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/preproc/Makefile pgsql.4.1/src/interfaces/ecpg/test/preproc/Makefile
*** pgsql.3/src/interfaces/ecpg/test/preproc/Makefile	2009-11-26 18:57:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/preproc/Makefile	2010-01-04 17:24:50.000000000 +0100
*************** TESTS = array_of_struct array_of_struct.
*** 11,16 ****
--- 11,18 ----
  	define define.c \
  	init init.c \
  	strings strings.c \
+ 	struct struct.c \
+ 	outofscope outofscope.c \
  	type type.c \
  	variable variable.c \
  	whenever whenever.c
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/preproc/outofscope.pgc pgsql.4.1/src/interfaces/ecpg/test/preproc/outofscope.pgc
*** pgsql.3/src/interfaces/ecpg/test/preproc/outofscope.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/preproc/outofscope.pgc	2010-01-04 17:34:20.000000000 +0100
***************
*** 0 ****
--- 1,259 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <inttypes.h>
+ #include <limits.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql include sqlda.h;
+ exec sql include pgtypes_numeric.h;
+ 
+ exec sql begin declare section;
+ exec sql include struct.h;
+ exec sql end declare section;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ /* Functions for test 1 */
+ 
+ static void
+ get_var1(MYTYPE **myvar0, MYNULLTYPE **mynullvar0)
+ {
+ 	exec sql begin declare section;
+ 	MYTYPE		*myvar = malloc(sizeof(MYTYPE));
+ 	MYNULLTYPE	*mynullvar = malloc(sizeof(MYNULLTYPE));
+ 	exec sql end declare section;
+ 
+ 	/* Test DECLARE ... SELECT ... INTO with pointers */
+ 
+ 	exec sql declare mycur cursor for select * INTO :myvar :mynullvar from a1;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ 
+ 	*myvar0 = myvar;
+ 	*mynullvar0 = mynullvar;
+ }
+ 
+ static void
+ open_cur1(void)
+ {
+ 	exec sql open mycur;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ get_record1(void)
+ {
+ 	exec sql fetch mycur;
+ 
+ 	if (sqlca.sqlcode != 0 && sqlca.sqlcode != ECPG_NOT_FOUND)
+ 		exit(1);
+ }
+ 
+ static void
+ close_cur1(void)
+ {
+ 	exec sql close mycur;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ /* Functions for test 2 */
+ 
+ sqlda_t	*inp_sqlda, *outp_sqlda;
+ 
+ exec sql begin declare section;
+ char	*stmt2 = "SELECT * FROM a1 WHERE id = ?";
+ char	*curname2 = "mycur";
+ int	id;
+ exec sql end declare section;
+ 
+ static void
+ prepare2(void)
+ {
+ 	exec sql prepare prepared_stmt from :stmt2;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ 
+ 	inp_sqlda = (sqlda_t *)malloc(sizeof(sqlda_t));
+ 	memset(inp_sqlda, 0, sizeof(sqlda_t));
+ 	inp_sqlda->sqln = 1;
+ 
+ 	inp_sqlda->sqlvar[0].sqltype = ECPGt_int;
+ 	inp_sqlda->sqlvar[0].sqldata = (char *)&id;
+ 	id = 4;
+ }
+ 
+ static void
+ declare2(void)
+ {
+ 	exec sql declare :curname2 cursor for prepared_stmt;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ dealloc_prep2(void)
+ {
+ 	exec sql deallocate prepare prepared_stmt;
+ 
+ 	free(inp_sqlda);
+ 	free(outp_sqlda);
+ }
+ 
+ static void
+ open_cur2(void)
+ {
+ 	exec sql open :curname2 using descriptor inp_sqlda;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ close_cur2(void)
+ {
+ 	exec sql close :curname2;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ get_record2(void)
+ {
+ 	exec sql fetch :curname2 into descriptor outp_sqlda;
+ 
+ 	if (sqlca.sqlcode != 0 && sqlca.sqlcode != ECPG_NOT_FOUND)
+ 		exit(1);
+ }
+ 
+ static void
+ dump_sqlda(sqlda_t *sqlda)
+ {
+ 	int	i;
+ 
+ 	for (i = 0; i < sqlda->sqld; i++)
+ 	{
+ 		if (outp_sqlda->sqlvar[i].sqlind && *(outp_sqlda->sqlvar[i].sqlind) == -1)
+ 			printf("name sqlda descriptor: '%s' value NULL'\n", outp_sqlda->sqlvar[i].sqlname.data);
+ 		else
+ 		switch (sqlda->sqlvar[i].sqltype)
+ 		{
+ 		case ECPGt_char:
+ 			printf("name sqlda descriptor: '%s' value '%s'\n", sqlda->sqlvar[i].sqlname.data, sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_int:
+ 			printf("name sqlda descriptor: '%s' value %d\n", sqlda->sqlvar[i].sqlname.data, *(int *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ #if (LONG_BIT == 64) /* Defined via <limits.h> */
+ 		case ECPGt_long:
+ #else
+ # if (LONG_BIT = 32)
+ 		case ECPGt_long_long:
+ # else
+ #  error Neither "long" nor "long long" are 64-bit
+ # endif
+ #endif
+ 			printf("name sqlda descriptor: '%s' value %" PRId64 "\n", sqlda->sqlvar[i].sqlname.data, *(int64_t *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_double: 
+ 			printf("name sqlda descriptor: '%s' value %lf\n", sqlda->sqlvar[i].sqlname.data, *(double *)sqlda->sqlvar[i].sqldata);
+ 			break;
+ 		case ECPGt_numeric:
+ 			{
+ 				char	*val;
+ 				val = PGTYPESnumeric_to_asc((numeric*)sqlda->sqlvar[i].sqldata, -1);
+ 				printf("name sqlda descriptor: '%s' value NUMERIC '%s'\n", sqlda->sqlvar[i].sqlname.data, val);
+ 				free(val);
+ 				break;
+ 			}
+ 		}
+ 	}
+ }
+ 
+ int
+ main (void)
+ {
+ 	MYTYPE		*myvar;
+ 	MYNULLTYPE	*mynullvar;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table a1(id serial primary key, t text, d1 numeric, d2 float8, c character(10));
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, 'a', 1.0, 2, 'a');
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, null, null, null, null);
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, '"a"', -1.0, 'nan'::float8, 'a');
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, 'b', 2.0, 3, 'b');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE */
+ 
+ 	get_var1(&myvar, &mynullvar);
+ 	open_cur1();
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	while (1)
+ 	{
+ 		memset(myvar, 0, sizeof(MYTYPE));
+ 		get_record1();
+ 		if (sqlca.sqlcode == ECPG_NOT_FOUND)
+ 			break;
+ 		printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+ 			myvar->id, mynullvar->id ? " (NULL)" : "",
+ 			myvar->t, mynullvar->t ? " (NULL)" : "",
+ 			myvar->d1, mynullvar->d1 ? " (NULL)" : "",
+ 			myvar->d2, mynullvar->d2 ? " (NULL)" : "",
+ 			myvar->c, mynullvar->c ? " (NULL)" : "");
+ 	}
+ 
+ 	close_cur1();
+ 
+ 	/* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE interaction
+ 	 * with a dynamic cursor and prepared statment using an sqlda
+ 	 */
+ 
+ 	prepare2();
+ 	declare2();
+ 	open_cur2();
+ 
+ 	get_record2();
+ 	dump_sqlda(outp_sqlda);
+ 
+ 	close_cur2();
+ 	dealloc_prep2();
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table a1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/preproc/struct.h pgsql.4.1/src/interfaces/ecpg/test/preproc/struct.h
*** pgsql.3/src/interfaces/ecpg/test/preproc/struct.h	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/preproc/struct.h	2010-01-04 17:24:50.000000000 +0100
***************
*** 0 ****
--- 1,18 ----
+ 
+ struct mytype {
+ 	int	id;
+ 	char	t[64];
+ 	double	d1; /* dec_t */
+ 	double	d2;
+ 	char	c[30];
+ };
+ typedef struct mytype MYTYPE;
+ 
+ struct mynulltype {
+ 	int	id;
+ 	int	t;
+ 	int	d1;
+ 	int	d2;
+ 	int	c;
+ };
+ typedef struct mynulltype MYNULLTYPE;
diff -dcrpN pgsql.3/src/interfaces/ecpg/test/preproc/struct.pgc pgsql.4.1/src/interfaces/ecpg/test/preproc/struct.pgc
*** pgsql.3/src/interfaces/ecpg/test/preproc/struct.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/preproc/struct.pgc	2010-01-04 17:24:50.000000000 +0100
***************
*** 0 ****
--- 1,76 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql begin declare section;
+ exec sql include struct.h;
+ exec sql end declare section;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ int
+ main (void)
+ {
+ 	exec sql begin declare section;
+ 	MYTYPE		myvar;
+ 	MYNULLTYPE	mynullvar;
+ 	exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table a1(id serial primary key, t text, d1 numeric, d2 float8, c character(10));
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, 'a', 1.0, 2, 'a');
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, null, null, null, null);
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, '"a"', -1.0, 'nan'::float8, 'a');
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, 'b', 2.0, 3, 'b');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* Test DECLARE ... SELECT ... INTO with struct type */
+ 
+ 	exec sql declare mycur cursor for select * into :myvar :mynullvar from a1;
+ 	exec sql open mycur;
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	while (1)
+ 	{
+ 		memset(&myvar, 0, sizeof(myvar));
+ 		exec sql fetch mycur;
+ 		printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+ 			myvar.id, mynullvar.id ? " (NULL)" : "",
+ 			myvar.t, mynullvar.t ? " (NULL)" : "",
+ 			myvar.d1, mynullvar.d1 ? " (NULL)" : "",
+ 			myvar.d2, mynullvar.d2 ? " (NULL)" : "",
+ 			myvar.c, mynullvar.c ? " (NULL)" : "");
+ 	}
+ 
+ 	exec sql close mycur;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table a1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
#86Alvaro Herrera
alvherre@commandprompt.com
In reply to: Boszormenyi Zoltan (#83)
Re: ECPG SQLDA support

Boszormenyi Zoltan wrote:

I happened to notice this by chance:

+ #if (LONG_BIT == 64)
+ #define	SQLINT8		ECPGt_long
+ #define	SQLSERIAL8	ECPGt_long
+ #else
+ #define	SQLINT8		ECPGt_long_long
+ #define	SQLSERIAL8	ECPGt_long_long
+ #endif

I'm not sure how portable is the LONG_BIT business. We don't seem to
use it anywhere else (hmm, but then we do use CHAR_BIT elsewhere)

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

#87Boszormenyi Zoltan
zb@cybertec.at
In reply to: Alvaro Herrera (#86)
Re: ECPG SQLDA support

Alvaro Herrera �rta:

Boszormenyi Zoltan wrote:

I happened to notice this by chance:

+ #if (LONG_BIT == 64)
+ #define	SQLINT8		ECPGt_long
+ #define	SQLSERIAL8	ECPGt_long
+ #else
+ #define	SQLINT8		ECPGt_long_long
+ #define	SQLSERIAL8	ECPGt_long_long
+ #endif

I'm not sure how portable is the LONG_BIT business. We don't seem to
use it anywhere else (hmm, but then we do use CHAR_BIT elsewhere)

I specifically looked for a portable solution, as
#if sizeof(...) == N
is not evaluated at compile time.

Best regards,
Zolt�n B�sz�rm�nyi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

#88Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alvaro Herrera (#86)
Re: ECPG SQLDA support

Alvaro Herrera <alvherre@commandprompt.com> writes:

I'm not sure how portable is the LONG_BIT business.

I think checking SIZEOF_LONG would be preferred, since that's what
we use elsewhere. Although actually I wonder why this code exists
at all --- wouldn't it be easier to make these depend on "int64"?

regards, tom lane

#89Boszormenyi Zoltan
zb@cybertec.at
In reply to: Tom Lane (#88)
Re: ECPG SQLDA support

Tom Lane �rta:

Alvaro Herrera <alvherre@commandprompt.com> writes:

I'm not sure how portable is the LONG_BIT business.

I think checking SIZEOF_LONG would be preferred, since that's what
we use elsewhere. Although actually I wonder why this code exists
at all --- wouldn't it be easier to make these depend on "int64"?

regards, tom lane

Don't ask me why ECPGt_long_long and ECPGt_unsigned_long_long
exist. But they do, and the libecpg code has some
#ifdef HAVE_LONG_LONG_INT_64
surrounding code handling them. Maybe it would've been better to be
consistent with that coding.

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

#90Robert Haas
robertmhaas@gmail.com
In reply to: Boszormenyi Zoltan (#84)
Re: ECPG DESCRIBE [OUTPUT] support

On Mon, Jan 4, 2010 at 1:51 PM, Boszormenyi Zoltan <zb@cybertec.at> wrote:

new patch is attached. Modified according to
the new DB2 / Sybase compatible SQLDA structure.
ECPGdescribe() has an "int compat" parameter, because:
- the (struct prepared_statement *)->stmt ->compat is not set, and
- it's more sensible to use the compat mode of the
 ECPGdescribe() caller, because different source files can be
 compiled with different (native or compat) modes.
The Informix-specific syntax "DESCRIBE ... INTO sqlda" is also
accepted in native mode now.

For tracking purposes, can you add a "Patch"-type comment for each of
these to the relevant entry on commitfest.postgresql.org?

Thanks,

...Robert

#91Michael Meskes
meskes@postgresql.org
In reply to: Boszormenyi Zoltan (#83)
Re: ECPG SQLDA support

On Mon, Jan 04, 2010 at 07:39:14PM +0100, Boszormenyi Zoltan wrote:

new patch attached.
...

Great job Zoltan, committed.

The sqlda.h header switches between the two different
structures depending on a new #define introduced in
and added to the generated C source by the preprocessor

I changed this to use the already existing _ECPG_INFORMIX_H define.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ: 179140304, AIM/Yahoo/Skype: michaelmeskes, Jabber: meskes@jabber.org
VfL Borussia! Forca Barca! Go SF 49ers! Use: Debian GNU/Linux, PostgreSQL

#92Michael Meskes
meskes@postgresql.org
In reply to: Tom Lane (#88)
Re: ECPG SQLDA support

On Mon, Jan 04, 2010 at 02:32:56PM -0500, Tom Lane wrote:

I think checking SIZEOF_LONG would be preferred, since that's what
we use elsewhere. Although actually I wonder why this code exists
at all --- wouldn't it be easier to make these depend on "int64"?

It does use int64. However, ecpg uses HAVE_LONG_LONG_INT64 to decide whether
it's datatype ECPGt_long_long exists. I changed the patch to use the same
define as usual.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ: 179140304, AIM/Yahoo/Skype: michaelmeskes, Jabber: meskes@jabber.org
VfL Borussia! Forca Barca! Go SF 49ers! Use: Debian GNU/Linux, PostgreSQL

#93Boszormenyi Zoltan
zb@cybertec.at
In reply to: Boszormenyi Zoltan (#84)
1 attachment(s)
Re: ECPG DESCRIBE [OUTPUT] support

Hi,

I just saw that you committed the DESCRIBE patch.

Please, also add this small change that adds ecpg_raise()
calls to ECPGdescribe() to return the proper sqlca error
in error paths for:
- unsupported call for DESCRIBE INPUT
- no such connection name
- no such prepared statement

Thanks and best regards,
Zolt�n B�sz�rm�nyi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

Attachments:

3.1-describe-add-errors-2.patchtext/x-patch; name=3.1-describe-add-errors-2.patchDownload
*** /home/zozo/cvs/pgsql/pgsql/src/interfaces/ecpg/ecpglib/descriptor.c	2010-01-15 12:55:24.000000000 +0100
--- pgsql.3/src/interfaces/ecpg/ecpglib/descriptor.c	2010-01-15 13:14:35.000000000 +0100
***************
*** 739,752 ****
  
  	/* DESCRIBE INPUT is not yet supported */
  	if (input)
  		return ret;
  
  	con = ecpg_get_connection(connection_name);
  	if (!con)
! 		return false;
  	prep = ecpg_find_prepared_statement(stmt_name, con, NULL);
  	if (!prep)
  		return ret;
  
  	va_start(args, stmt_name);
  
--- 739,762 ----
  
  	/* DESCRIBE INPUT is not yet supported */
  	if (input)
+ 	{
+ 		ecpg_raise(line, ECPG_UNSUPPORTED, ECPG_SQLSTATE_ECPG_INTERNAL_ERROR, "DESCRIBE INPUT");
  		return ret;
+ 	}
  
  	con = ecpg_get_connection(connection_name);
  	if (!con)
! 	{
! 		ecpg_raise(line, ECPG_NO_CONN, ECPG_SQLSTATE_CONNECTION_DOES_NOT_EXIST,
! 				connection_name ? connection_name : ecpg_gettext("NULL"));
! 		return ret;
! 	}
  	prep = ecpg_find_prepared_statement(stmt_name, con, NULL);
  	if (!prep)
+ 	{
+ 		ecpg_raise(line, ECPG_INVALID_STMT, ECPG_SQLSTATE_INVALID_SQL_STATEMENT_NAME, stmt_name);
  		return ret;
+ 	}
  
  	va_start(args, stmt_name);
  
#94Michael Meskes
meskes@postgresql.org
In reply to: Boszormenyi Zoltan (#93)
Re: ECPG DESCRIBE [OUTPUT] support

On Fri, Jan 15, 2010 at 01:16:18PM +0100, Boszormenyi Zoltan wrote:

Please, also add this small change that adds ecpg_raise()
calls to ECPGdescribe() to return the proper sqlca error
in error paths for:
...

Done.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ: 179140304, AIM/Yahoo/Skype: michaelmeskes, Jabber: meskes@jabber.org
VfL Borussia! Forca Barca! Go SF 49ers! Use: Debian GNU/Linux, PostgreSQL

#95Boszormenyi Zoltan
zb@cybertec.at
In reply to: Michael Meskes (#94)
1 attachment(s)
ECPG documentation patch

Hi,

here's the documentation patch for the new ECPG features.

- I changed the order of sections "Using Descriptor Areas" and
"Informix compatibility mode"
- split the "Using Descriptor Areas", so it now have two subsections:
"Named SQL Descriptor Areas" and "SQLDA Descriptor Areas".
The second one talks about the native mode SQLDA only.
- Documented DESCRIBE and the USING/INTO quirks.
- Documented the "string" pseudo-type in compat mode
- Modified the section name "Additional embedded SQL statements",
it now reads "Additional/missing embedded SQL statements" and
documented the lack of "FREE cursor_name" statement and
the behaviour of "FREE statement_name" statement.
- Documented the Informix-compatible SQLDA under the
"Informix compatibility mode" section.

Best regards,
Zolt�n B�sz�rm�nyi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

Attachments:

ecpg-doc-3-ctxdiff.patchtext/x-patch; name=ecpg-doc-3-ctxdiff.patchDownload
*** pgsql.orig/doc/src/sgml/ecpg.sgml	2009-12-08 09:23:19.000000000 +0100
--- pgsql.doc/doc/src/sgml/ecpg.sgml	2010-01-15 19:07:01.000000000 +0100
***************
*** 2376,2381 ****
--- 2376,2853 ----
    </sect2>
   </sect1>
  
+  <sect1 id="ecpg-descriptors">
+   <title>Using Descriptor Areas</title>
+ 
+   <para>
+    An SQL descriptor area is a more sophisticated method for processing
+    the result of a <command>SELECT</command>, <command>FETCH</command> or
+    a <command>DESCRIBE</command> statement. An SQL descriptor area groups
+    the data of one row of data together with metadata items into one
+    data structure.  The metadata is particularly useful when executing
+    dynamic SQL statements, where the nature of the result columns might
+    not be known ahead of time. PostgreSQL provides two ways to use
+    Descriptor Areas: the named SQL Descriptor Areas and the C-structure
+    SQLDAs.
+   </para>
+ 
+   <sect2 id="ecpg-named-descriptors">
+    <title>Named SQL Descriptor Areas</title>
+ 
+    <para>
+     A named SQL descriptor area consists of a header, which contains
+     information concerning the entire descriptor, and one or more item
+     descriptor areas, which basically each describe one column in the
+     result row.
+    </para>
+ 
+    <para>
+     Before you can use an SQL descriptor area, you need to allocate one:
+ <programlisting>
+ EXEC SQL ALLOCATE DESCRIPTOR <replaceable>identifier</replaceable>;
+ </programlisting>
+     The identifier serves as the <quote>variable name</quote> of the
+     descriptor area.  <remark>The scope of the allocated descriptor is WHAT?.</remark>
+     When you don't need the descriptor anymore, you should deallocate
+     it:
+ <programlisting>
+ EXEC SQL DEALLOCATE DESCRIPTOR <replaceable>identifier</replaceable>;
+ </programlisting>
+    </para>
+ 
+    <para>
+     To use a descriptor area, specify it as the storage target in an
+     <literal>INTO</literal> clause, instead of listing host variables:
+ <programlisting>
+ EXEC SQL FETCH NEXT FROM mycursor INTO SQL DESCRIPTOR mydesc;
+ </programlisting>
+     If the resultset is empty, the Descriptor Area will still contain
+     the metadata from the query, i.e. the field names.
+    </para>
+ 
+    <para>
+     For not yet executed prepared queries, the <command>DESCRIBE</command>
+     statement can be used to get the metadata of the resultset:
+ <programlisting> 
+ EXEC SQL BEGIN DECLARE SECTION;
+ char *sql_stmt = "SELECT * FROM table1";
+ EXEC SQL END DECLARE SECTION;
+ 
+ EXEC SQL PREPARE stmt1 FROM :sql_stmt;
+ EXEC SQL DESCRIBE stmt1 INTO SQL DESCRIPTOR mydesc;
+ </programlisting>
+    </para>
+ 
+    <para>
+     Before PostgreSQL 8.5, the <literal>SQL</literal> keyword was optional,
+     so using <literal>DESCRIPTOR</literal> and <literal>SQL DESCRIPTOR</literal>
+     produced named SQL Descriptor Areas. Now it is mandatory, omitting
+     the <literal>SQL</literal> keyword produces SQLDA Descriptor Areas,
+     see <xref linkend="ecpg-sqlda-descriptors">. 
+    </para>
+ 
+    <para>
+     In <command>DESCRIBE</command> and <command>FETCH</command> statements,
+     the <literal>INTO</literal> and <literal>USING</literal> keywords can be
+     used to similarly: they produce the resultset and the metadata in a
+     Descriptor Area.
+    </para>
+ 
+    <para>
+     Now how do you get the data out of the descriptor area?  You can
+     think of the descriptor area as a structure with named fields.  To
+     retrieve the value of a field from the header and store it into a
+     host variable, use the following command:
+ <programlisting>
+ EXEC SQL GET DESCRIPTOR <replaceable>name</replaceable> :<replaceable>hostvar</replaceable> = <replaceable>field</replaceable>;
+ </programlisting>
+     Currently, there is only one header field defined:
+     <replaceable>COUNT</replaceable>, which tells how many item
+     descriptor areas exist (that is, how many columns are contained in
+     the result).  The host variable needs to be of an integer type.  To
+     get a field from the item descriptor area, use the following
+     command:
+ <programlisting>
+ EXEC SQL GET DESCRIPTOR <replaceable>name</replaceable> VALUE <replaceable>num</replaceable> :<replaceable>hostvar</replaceable> = <replaceable>field</replaceable>;
+ </programlisting>
+     <replaceable>num</replaceable> can be a literal integer or a host
+     variable containing an integer. Possible fields are:
+ 
+     <variablelist>
+      <varlistentry>
+       <term><literal>CARDINALITY</literal> (integer)</term>
+       <listitem>
+        <para>
+         number of rows in the result set
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
+       <term><literal>DATA</literal></term>
+       <listitem>
+        <para>
+         actual data item (therefore, the data type of this field
+         depends on the query)
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
+       <term><literal>DATETIME_INTERVAL_CODE</literal> (integer)</term>
+       <listitem>
+        <para>
+         ?
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
+       <term><literal>DATETIME_INTERVAL_PRECISION</literal> (integer)</term>
+       <listitem>
+        <para>
+         not implemented
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
+       <term><literal>INDICATOR</literal> (integer)</term>
+       <listitem>
+        <para>
+         the indicator (indicating a null value or a value truncation)
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
+       <term><literal>KEY_MEMBER</literal> (integer)</term>
+       <listitem>
+        <para>
+         not implemented
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
+       <term><literal>LENGTH</literal> (integer)</term>
+       <listitem>
+        <para>
+         length of the datum in characters
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
+       <term><literal>NAME</literal> (string)</term>
+       <listitem>
+        <para>
+         name of the column
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
+       <term><literal>NULLABLE</literal> (integer)</term>
+       <listitem>
+        <para>
+         not implemented
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
+       <term><literal>OCTET_LENGTH</literal> (integer)</term>
+       <listitem>
+        <para>
+         length of the character representation of the datum in bytes
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
+       <term><literal>PRECISION</literal> (integer)</term>
+       <listitem>
+        <para>
+         precision (for type <type>numeric</type>)
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
+       <term><literal>RETURNED_LENGTH</literal> (integer)</term>
+       <listitem>
+        <para>
+         length of the datum in characters
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
+       <term><literal>RETURNED_OCTET_LENGTH</literal> (integer)</term>
+       <listitem>
+        <para>
+         length of the character representation of the datum in bytes
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
+       <term><literal>SCALE</literal> (integer)</term>
+       <listitem>
+        <para>
+         scale (for type <type>numeric</type>)
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
+       <term><literal>TYPE</literal> (integer)</term>
+       <listitem>
+        <para>
+         numeric code of the data type of the column
+        </para>
+       </listitem>
+      </varlistentry>
+     </variablelist>
+    </para>
+ 
+    <para>
+     In <command>EXECUTE</command>, <command>DECLARE</command> and <command>OPEN</command>
+     statements, the effect of the <literal>INTO</literal> and <literal>USING</literal>
+     keywords are different. A Descriptor Area can also be manually built to
+     provide the input parameters for a query or a cursor and
+     <literal>USING SQL DESCRIPTOR <replaceable>name</replaceable></literal>
+     is the way to pass the input parameters into a parametrized query. The statement
+     to build a named SQL Descriptor Area is below:
+ <programlisting>
+ EXEC SQL SET DESCRIPTOR <replaceable>name</replaceable> VALUE <replaceable>num</replaceable> <replaceable>field</replaceable> = :<replaceable>hostvar</replaceable>;
+ </programlisting>
+    </para>
+ 
+    <para>
+     PostgreSQL supports retrieving more that one record in one <command>FETCH</command>
+     statement and storing the data in host variables in this case assumes that the
+     variable is an array. E.g.:
+ <programlisting>
+ EXEC SQL BEGIN DECLARE SECTION;
+ int id[5];
+ EXEC SQL END DECLARE SECTION;
+ 
+ EXEC SQL FETCH 5 FROM mycursor INTO SQL DESCRIPTOR mydesc;
+ 
+ EXEC SQL GET DESCRIPTOR mydesc VALUE 1 :id = DATA;
+ </programlisting>
+ 
+    </para>
+ 
+   </sect2>
+ 
+   <sect2 id="ecpg-sqlda-descriptors">
+    <title>SQLDA Descriptor Areas</title>
+ 
+    <para>
+     An SQLDA Descriptor Area is a C language structure which can be also used
+     to get the resultset and the metadata of a query. One structure stores one
+     record from the resultset.
+ <programlisting>
+ EXEC SQL include sqlda.h;
+ sqlda_t	*mysqlda;
+ 
+ EXEC SQL FETCH 3 FROM mycursor INTO DESCRIPTOR mysqlda;
+ </programlisting>
+     Note that the <literal>SQL</literal> keyword is omitted. The paragraphs about
+     the use cases of the <literal>INTO</literal> and <literal>USING</literal>
+     keywords in <xref linkend="ecpg-named-descriptors"> also apply here with an addition.
+     In a <command>DESCRIBE</command> statement the <literal>DESCRIPTOR</literal>
+     keyword can be completely omitted if the <literal>INTO</literal> keyword is used:
+ <programlisting>
+ EXEC SQL DESCRIBE prepared_statement INTO mysqlda;
+ </programlisting>
+    </para>
+ 
+    <para>
+     The structure of SQLDA is:
+ <programlisting>
+ #define NAMEDATALEN 64
+ 
+ struct sqlname
+ {
+         short           length;
+         char            data[NAMEDATALEN];
+ };
+ 
+ struct sqlvar_struct
+ {
+         short           sqltype;
+         short           sqllen;
+         char       *sqldata;
+         short      *sqlind;
+         struct sqlname sqlname;
+ };
+ 
+ struct sqlda_struct
+ {
+         char            sqldaid[8];
+         long            sqldabc;
+         short           sqln;
+         short           sqld;
+         struct sqlda_struct *desc_next;
+         struct sqlvar_struct    sqlvar[1];
+ };
+ 
+ typedef struct sqlvar_struct    sqlvar_t;
+ typedef struct sqlda_struct     sqlda_t;
+ </programlisting>
+    </para>
+ 
+    <para>
+     The allocated data for an SQLDA structure is variable as it depends on the
+     number of fields in a resultset and also depends on the length of the string
+     data values in a record. The individual fields of the <literal>SQLDA</literal>
+     structure are:
+ 
+     <variablelist>
+      <varlistentry>
+       <term><literal>sqldaid</></term>
+       <listitem>
+        <para>
+         It contains the "<literal>SQLDA  </literal>" literal string.
+        </para>
+       </listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><literal>sqldabc</></term>
+       <listitem>
+        <para>
+         It contains the size of the allocated space in bytes.
+        </para>
+       </listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><literal>sqln</></term>
+       <listitem>
+        <para>
+         It contains the number of input parameters for a parametrized query
+         case it's passed into <command>OPEN</command>, <command>DECLARE</command> or
+         <command>EXECUTE</command> statements using the <literal>USING</literal>
+         keyword. In case it's used as output of <command>SELECT</command>,
+         <command>EXECUTE</command> or <command>FETCH</command> statements,
+         its value is the same as <literal>sqld</literal>
+         statement
+        </para>
+       </listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><literal>sqld</></term>
+       <listitem>
+        <para>
+         It contains the number of fields in a resultset.
+        </para>
+       </listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><literal>desc_next</></term>
+       <listitem>
+        <para>
+         If the query returns more than one records, multiple linked SQLDA structures
+         are returned, the first record is stored in the SQLDA returned in the
+        </para>
+       </listitem>
+      </varlistentry>
+      <varlistentry>
+       <term><literal>sqlvar</></term>
+       <listitem>
+        <para>
+         This is the array of the fields in the resultset. The fields are:
+ 
+         <variablelist>
+ 
+          <varlistentry>
+          <term><literal>sqltype</></term>
+           <listitem>
+            <para>
+             It contains the type identifier of the field. For values,
+             see <literal>enum ECPGttype</literal> in <literal>ecpgtype.h</literal>.
+            </para>
+           </listitem>
+          </varlistentry>
+ 
+          <varlistentry>
+          <term><literal>sqllen</></term>
+           <listitem>
+            <para>
+             It contains the binary length of the field. E.g. 4 bytes for ECPGt_int.
+            </para>
+           </listitem>
+          </varlistentry>
+ 
+          <varlistentry>
+          <term><literal>sqldata</></term>
+           <listitem>
+            <para>
+             <literal>(char *)sqldata</literal> points to the data.
+            </para>
+           </listitem>
+          </varlistentry>
+ 
+          <varlistentry>
+          <term><literal>sqlind</></term>
+           <listitem>
+            <para>
+             <literal>(char *)sqlind</literal> points to the NULL indicator for data.
+             0 means NOT NULL, -1 means NULL.
+            </para>
+           </listitem>
+          </varlistentry>
+ 
+          <varlistentry>
+          <term><literal>sqlname</></term>
+           <listitem>
+            <para>
+             <literal>struct sqlname sqlname</literal> contains the name of the field
+             in a structure:
+ <programlisting>
+ struct sqlname
+ {
+         short           length;
+         char            data[NAMEDATALEN];
+ };
+ </programlisting>
+ 
+             <variablelist>
+              <varlistentry>
+               <term><literal>length</></term>
+                <listitem>
+                 <para>
+                  <literal>sqlname.length</literal> contains the length of the field name.
+                 </para>
+                </listitem>
+               </varlistentry>
+              <varlistentry>
+               <term><literal>data</></term>
+                <listitem>
+                 <para>
+                  <literal>sqlname.data</literal> contains the actual field name.
+                 </para>
+                </listitem>
+               </varlistentry>
+             </variablelist>
+            </para>
+           </listitem>
+          </varlistentry>
+ 
+         </variablelist>
+        </para>
+       </listitem>
+      </varlistentry>
+     </variablelist>
+    </para>
+ 
+   </sect2>
+ 
+  </sect1>
+ 
   <sect1 id="ecpg-informix-compat">
    <title><productname>Informix</productname> compatibility mode</title>
    <para>
***************
*** 2385,2442 ****
     the dollar sign instead of the <literal>EXEC SQL</> primitive to introduce
     embedded SQL commands.:
  <programlisting>
!    $int j = 3;
!    $CONNECT TO :dbname;
!    $CREATE TABLE test(i INT PRIMARY KEY, j INT);
!    $INSERT INTO test(i, j) VALUES (7, :j);
!    $COMMIT;
  </programlisting>
!   </para>
!   <para>
!    There are two compatiblity modes: INFORMIX, INFORMIX_SE
!   </para>
!   <para>
!    When linking programs that use this compatibility mode, remember to link
!    against <literal>libcompat</> that is shipped with ecpg.
!   </para>
!   <para>
!    Besides the previously explained syntactic sugar, the <productname>Informix</productname> compatibility
!    mode ports some functions for input, output and transformation of data as
!    well as embedded SQL statements known from E/SQL to ecpg.
!   </para>
!   <para>
!    <productname>Informix</productname> compatibility mode is closely connected to the pgtypeslib library
!    of ecpg. pgtypeslib maps SQL data types to data types within the C host
!    program and most of the additional functions of the <productname>Informix</productname> compatibility
!    mode allow you to operate on those C host program types. Note however that
!    the extent of the compatibility is limited. It does not try to copy <productname>Informix</productname>
!    behaviour; it allows you to do more or less the same operations and gives
!    you functions that have the same name and the same basic behavior but it is
!    no drop-in replacement if you are using <productname>Informix</productname> at the moment. Moreover,
!    some of the data types are different. For example,
!    <productname>PostgreSQL's</productname> datetime and interval types do not
!    know about ranges like for example <literal>YEAR TO MINUTE</> so you won't
!    find support in ecpg for that either.
!   </para>
  
-   <sect2>
-    <title>Additional embedded SQL statements</title>
-    <para>
-     <variablelist>
       <varlistentry>
!       <term><literal>CLOSE DATABASE</></term>
        <listitem>
         <para>
!         This statement closes the current connection. In fact, this is a
!         synonym for ecpg's <literal>DISCONNECT CURRENT</>.:
  <programlisting>
!     $CLOSE DATABASE;                /* close the current connection */
!     EXEC SQL CLOSE DATABASE;
  </programlisting>
         </para>
        </listitem>
       </varlistentry>
      </variablelist>
     </para>
    </sect2>
  
--- 2857,3229 ----
     the dollar sign instead of the <literal>EXEC SQL</> primitive to introduce
     embedded SQL commands.:
  <programlisting>
!    $int j = 3;
!    $CONNECT TO :dbname;
!    $CREATE TABLE test(i INT PRIMARY KEY, j INT);
!    $INSERT INTO test(i, j) VALUES (7, :j);
!    $COMMIT;
! </programlisting>
!   </para>
!   <para>
!    There are two compatiblity modes: INFORMIX, INFORMIX_SE
!   </para>
!   <para>
!    When linking programs that use this compatibility mode, remember to link
!    against <literal>libcompat</> that is shipped with ecpg.
!   </para>
!   <para>
!    Besides the previously explained syntactic sugar, the <productname>Informix</productname> compatibility
!    mode ports some functions for input, output and transformation of data as
!    well as embedded SQL statements known from E/SQL to ecpg.
!   </para>
!   <para>
!    <productname>Informix</productname> compatibility mode is closely connected to the pgtypeslib library
!    of ecpg. pgtypeslib maps SQL data types to data types within the C host
!    program and most of the additional functions of the <productname>Informix</productname> compatibility
!    mode allow you to operate on those C host program types. Note however that
!    the extent of the compatibility is limited. It does not try to copy <productname>Informix</productname>
!    behaviour; it allows you to do more or less the same operations and gives
!    you functions that have the same name and the same basic behavior but it is
!    no drop-in replacement if you are using <productname>Informix</productname> at the moment. Moreover,
!    some of the data types are different. For example,
!    <productname>PostgreSQL's</productname> datetime and interval types do not
!    know about ranges like for example <literal>YEAR TO MINUTE</> so you won't
!    find support in ecpg for that either.
!   </para>
! 
!   <sect2>
!    <title>Additional types</title>
!    <para>
!     The Informix-special "string" pseudo-type for storing right-trimmed character string data is now
!     supported in Informix-mode without using <literal>typedef</literal>. In fact, in Informix-mode,
!     ECPG refuses to process source files that contain <literal>typedef sometype string;</literal>
! <programlisting>
!     EXEC SQL BEGIN DECLARE SECTION;
!     string userid; /* this variable will contain trimmed data */
!     EXEC SQL END DECLARE SECTION;
! 
!     EXEC SQL FETCH MYCUR INTO :userid;
! </programlisting>
!    </para>
!   </sect2>
! 
!   <sect2>
!    <title>Additional/missing embedded SQL statements</title>
!    <para>
!     <variablelist>
!      <varlistentry>
!       <term><literal>CLOSE DATABASE</></term>
!       <listitem>
!        <para>
!         This statement closes the current connection. In fact, this is a
!         synonym for ecpg's <literal>DISCONNECT CURRENT</>.:
! <programlisting>
!     $CLOSE DATABASE;                /* close the current connection */
!     EXEC SQL CLOSE DATABASE;
! </programlisting>
!        </para>
!       </listitem>
!      </varlistentry>
!      <varlistentry>
!       <term><literal>FREE cursor_name</></term>
!       <listitem>
!        <para>
!         Due to the differences how ECPG works compared to Informix's ESQL/C (i.e. which steps
!         are purely grammar transformations and which steps rely on the underlying runtime library)
!         there is no <literal>FREE cursor_name</> statement in ECPG. This is because in ECPG,
!         <literal>DECLARE CURSOR</literal> doesn't translate to a function call into
!         the runtime library that uses to the cursor name. This means that there's no runtime
! 	bookkeeping of SQL cursors in the ECPG runtime library, only in the PostgreSQL server.
!        </para>
!       </listitem>
!      </varlistentry>
!      <varlistentry>
!       <term><literal>FREE statement_name</></term>
!       <listitem>
!        <para>
!         <literal>FREE statement_name</> is a synonym for <literal>DEALLOCATE PREPARE statement_name</>.
!        </para>      
!       </listitem>   
!      </varlistentry>
!     </variablelist>
!    </para>
!   </sect2>
! 
!   <sect2>
!    <title>Informix-compatible SQLDA Descriptor Areas</title>
!    <para>
!     Informix-compatible mode supports a different structure than the one described in
!     <xref linkend="ecpg-sqlda-descriptors">. See below:
! <programlisting>
! struct sqlvar_compat
! {
!         short   sqltype;
!         int     sqllen;
!         char       *sqldata;
!         short      *sqlind;
!         char       *sqlname;
!         char       *sqlformat;
!         short   sqlitype;
!         short   sqlilen;
!         char       *sqlidata;
!         int     sqlxid;
!         char       *sqltypename;
!         short   sqltypelen;
!         short   sqlownerlen;
!         short   sqlsourcetype;
!         char       *sqlownername;
!         int     sqlsourceid;
! 
!         char       *sqlilongdata;
!         int     sqlflags;
!         void       *sqlreserved;
! };
! 
! struct sqlda_compat
! {
!         short           sqld;
!         struct sqlvar_compat *sqlvar;
!         char            desc_name[19];
!         short           desc_occ;
!         struct sqlda_compat *desc_next;
!         void               *reserved;
! };
! 
! typedef struct sqlvar_compat    sqlvar_t;
! typedef struct sqlda_compat     sqlda_t;
! </programlisting>
!    </para>
! 
!    <para>
!     The global properties are:
!     <variablelist>  
! 
!      <varlistentry>
!      <term><literal>sqld</></term>
!       <listitem>
!        <para>
!         The number of fields in the <literal>SQLDA</> descriptor.
!        </para>
!       </listitem>
!      </varlistentry>
! 
!      <varlistentry>
!      <term><literal>sqlvar</></term>   
!       <listitem>
!        <para>
!         Pointer to the per-field properties.
!        </para>
!       </listitem>
!      </varlistentry>
! 
!      <varlistentry>
!      <term><literal>desc_name</></term>
!       <listitem>
!        <para>
!         Unused, filled with zerobytes.
!        </para>
!       </listitem>
!      </varlistentry>
! 
!      <varlistentry>
!      <term><literal>desc_occ</></term>
!       <listitem>
!        <para>
!         Size of the allocated structure.
!        </para>
!       </listitem>
!      </varlistentry>
! 
!      <varlistentry>
!      <term><literal>desc_next</></term>
!       <listitem>
!        <para>
!         Pointer to the next SQLDA structure if the resultset contains more than one records.
!        </para>
!       </listitem>
!      </varlistentry>
! 
!      <varlistentry>
!      <term><literal>reserved</></term>
!       <listitem>
!        <para>
!         Unused pointer, contains NULL. Kept for Informix-compatibility.
!        </para>
!       </listitem>
!      </varlistentry>
! 
!     </variablelist>
! 
!     The per-field properties are below, they are stored in the <literal>sqlvar</literal> array:
! 
!     <variablelist>
! 
!      <varlistentry>
!      <term><literal>sqltype</></term>
!       <listitem>
!        <para>
!         Type of the field. Constants are in <literal>sqltypes.h</literal>
!        </para>
!       </listitem>
!      </varlistentry>
! 
!      <varlistentry>
!      <term><literal>sqllen</></term>
!       <listitem>
!        <para>
!         Length of the field data.
!        </para>
!       </listitem>
!      </varlistentry>
! 
!      <varlistentry>
!      <term><literal>sqldata</></term>
!       <listitem>
!        <para>
!         Pointer to the field data. The pointer is of <literal>char *</literal> type,
!         the data pointed by it is in a binary format. Example:
! <programlisting>
!     int intval; 
! 
!     switch (sqldata->sqlvar[i].sqltype)
!     {
!       case SQLINTEGER:
!         intval = *(int *)sqldata->sqlvar[i].sqldata;
!         break;
!       ...
!     }
  </programlisting>
!        </para>
!       </listitem>
!      </varlistentry>
  
       <varlistentry>
!      <term><literal>sqlind</></term>
        <listitem>
         <para>
!         Pointer to the NULL indicator. If returned by DESCRIBE or FETCH then it's always a valid pointer.
!         If used as input for <literal>EXECUTE ... USING sqlda;</literal> then NULL-pointer value means   
!         that the value for this field is non-NULL. Otherwise a valid pointer and <literal>sqlitype</literal>
!         has to be properly set. Example:
  <programlisting>
!     if (*(int2 *)sqldata->sqlvar[i].sqlind != 0)
!       printf("value is NULL\n");
  </programlisting>
         </para>
        </listitem>
       </varlistentry>
+ 
+      <varlistentry>
+      <term><literal>sqlname</></term>
+       <listitem>
+        <para>
+         Name of the field. 0-terminated string.
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
+      <term><literal>sqlformat</></term>
+       <listitem>
+        <para>
+         Reserved in Informix, value of PQfformat() for the field.
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
+      <term><literal>sqlitype</></term>
+       <listitem>
+        <para>
+         Type of the NULL indicator data. It's always SQLSMINT when returning data from the server.
+         When the <literal>SQLDA</literal> is used for a parametrized query, the data is treated   
+         according to the set type.
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
+      <term><literal>sqlilen</></term>
+       <listitem>
+        <para>
+         Length of the NULL indicator data.
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
+      <term><literal>sqlxid</></term>
+       <listitem>
+        <para>
+         Extended type of the field, result of PQftype().
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
+      <term><literal>sqltypename</></term>
+      <term><literal>sqltypelen</></term> 
+      <term><literal>sqlownerlen</></term>
+      <term><literal>sqlsourcetype</></term>
+      <term><literal>sqlownername</></term> 
+      <term><literal>sqlsourceid</></term>  
+      <term><literal>sqlflags</></term>     
+      <term><literal>sqlreserved</></term>  
+       <listitem>
+        <para>
+         Unused.
+        </para>
+       </listitem>
+      </varlistentry>
+ 
+      <varlistentry>
+      <term><literal>sqlilongdata</></term>
+       <listitem>
+        <para>
+         It equals to <literal>sqldata</literal> if <literal>sqllen</literal> is larger than 32KB.
+        </para>
+       </listitem>
+      </varlistentry>
+ 
      </variablelist>
+ 
+     Example:
+ <programlisting>
+ EXEC SQL INCLUDE sqlda.h;
+ 
+     sqlda_t        *sqlda; /* This doesn't need to be under embedded DECLARE SECTION */
+ 
+     EXEC SQL BEGIN DECLARE SECTION;
+     char *prep_stmt = "select * from table1";
+     int i;
+     EXEC SQL END DECLARE SECTION;
+ 
+     ...
+ 
+     EXEC SQL PREPARE mystmt FROM :prep_stmt;
+ 
+     EXEC SQL DESCRIBE mystmt INTO sqlda;
+ 
+     printf("# of fields: %d\n", sqlda->sqld);
+     for (i = 0; i < sqlda->sqld; i++)
+       printf("field %d: \"%s\"\n", sqlda->sqlvar[i]->sqlname);
+ 
+     EXEC SQL DECLARE mycursor CURSOR FOR mystmt;
+     EXEC SQL OPEN mycursor;
+     EXEC SQL WHENEVER NOT FOUND GOTO out;
+ 
+     while (1)
+     {
+       EXEC SQL FETCH mycursor USING sqlda;
+     }
+ 
+     EXEC SQL CLOSE mycursor;
+ 
+     free(sqlda); /* The main structure is all to be free(),
+                   * sqlda and sqlda->sqlvar is in one allocated area */
+ </programlisting>
+     For more information, see the <literal>sqlda.h</> header and the
+     <literal>src/interfaces/ecpg/test/compat_informix/sqlda.pgc</literal> regression test.
     </para>
    </sect2>
  
***************
*** 3660,3867 ****
    </sect2>
   </sect1>
  
-  <sect1 id="ecpg-descriptors">
-   <title>Using SQL Descriptor Areas</title>
- 
-   <para>
-    An SQL descriptor area is a more sophisticated method for
-    processing the result of a <command>SELECT</command> or
-    <command>FETCH</command> statement.  An SQL descriptor area groups
-    the data of one row of data together with metadata items into one
-    data structure.  The metadata is particularly useful when executing
-    dynamic SQL statements, where the nature of the result columns might
-    not be known ahead of time.
-   </para>
- 
-   <para>
-    An SQL descriptor area consists of a header, which contains
-    information concerning the entire descriptor, and one or more item
-    descriptor areas, which basically each describe one column in the
-    result row.
-   </para>
- 
-   <para>
-    Before you can use an SQL descriptor area, you need to allocate one:
- <programlisting>
- EXEC SQL ALLOCATE DESCRIPTOR <replaceable>identifier</replaceable>;
- </programlisting>
-    The identifier serves as the <quote>variable name</quote> of the
-    descriptor area.  <remark>The scope of the allocated descriptor is WHAT?.</remark>
-    When you don't need the descriptor anymore, you should deallocate
-    it:
- <programlisting>
- EXEC SQL DEALLOCATE DESCRIPTOR <replaceable>identifier</replaceable>;
- </programlisting>
-   </para>
- 
-   <para>
-    To use a descriptor area, specify it as the storage target in an
-    <literal>INTO</literal> clause, instead of listing host variables:
- <programlisting>
- EXEC SQL FETCH NEXT FROM mycursor INTO DESCRIPTOR mydesc;
- </programlisting>
-   </para>
- 
-   <para>
-    Now how do you get the data out of the descriptor area?  You can
-    think of the descriptor area as a structure with named fields.  To
-    retrieve the value of a field from the header and store it into a
-    host variable, use the following command:
- <programlisting>
- EXEC SQL GET DESCRIPTOR <replaceable>name</replaceable> :<replaceable>hostvar</replaceable> = <replaceable>field</replaceable>;
- </programlisting>
-    Currently, there is only one header field defined:
-    <replaceable>COUNT</replaceable>, which tells how many item
-    descriptor areas exist (that is, how many columns are contained in
-    the result).  The host variable needs to be of an integer type.  To
-    get a field from the item descriptor area, use the following
-    command:
- <programlisting>
- EXEC SQL GET DESCRIPTOR <replaceable>name</replaceable> VALUE <replaceable>num</replaceable> :<replaceable>hostvar</replaceable> = <replaceable>field</replaceable>;
- </programlisting>
-    <replaceable>num</replaceable> can be a literal integer or a host
-    variable containing an integer. Possible fields are:
- 
-    <variablelist>
-     <varlistentry>
-      <term><literal>CARDINALITY</literal> (integer)</term>
-      <listitem>
-       <para>
-        number of rows in the result set
-       </para>
-      </listitem>
-     </varlistentry>
- 
-     <varlistentry>
-      <term><literal>DATA</literal></term>
-      <listitem>
-       <para>
-        actual data item (therefore, the data type of this field
-        depends on the query)
-       </para>
-      </listitem>
-     </varlistentry>
- 
-     <varlistentry>
-      <term><literal>DATETIME_INTERVAL_CODE</literal> (integer)</term>
-      <listitem>
-       <para>
-        ?
-       </para>
-      </listitem>
-     </varlistentry>
- 
-     <varlistentry>
-      <term><literal>DATETIME_INTERVAL_PRECISION</literal> (integer)</term>
-      <listitem>
-       <para>
-        not implemented
-       </para>
-      </listitem>
-     </varlistentry>
- 
-     <varlistentry>
-      <term><literal>INDICATOR</literal> (integer)</term>
-      <listitem>
-       <para>
-        the indicator (indicating a null value or a value truncation)
-       </para>
-      </listitem>
-     </varlistentry>
- 
-     <varlistentry>
-      <term><literal>KEY_MEMBER</literal> (integer)</term>
-      <listitem>
-       <para>
-        not implemented
-       </para>
-      </listitem>
-     </varlistentry>
- 
-     <varlistentry>
-      <term><literal>LENGTH</literal> (integer)</term>
-      <listitem>
-       <para>
-        length of the datum in characters
-       </para>
-      </listitem>
-     </varlistentry>
- 
-     <varlistentry>
-      <term><literal>NAME</literal> (string)</term>
-      <listitem>
-       <para>
-        name of the column
-       </para>
-      </listitem>
-     </varlistentry>
- 
-     <varlistentry>
-      <term><literal>NULLABLE</literal> (integer)</term>
-      <listitem>
-       <para>
-        not implemented
-       </para>
-      </listitem>
-     </varlistentry>
- 
-     <varlistentry>
-      <term><literal>OCTET_LENGTH</literal> (integer)</term>
-      <listitem>
-       <para>
-        length of the character representation of the datum in bytes
-       </para>
-      </listitem>
-     </varlistentry>
- 
-     <varlistentry>
-      <term><literal>PRECISION</literal> (integer)</term>
-      <listitem>
-       <para>
-        precision (for type <type>numeric</type>)
-       </para>
-      </listitem>
-     </varlistentry>
- 
-     <varlistentry>
-      <term><literal>RETURNED_LENGTH</literal> (integer)</term>
-      <listitem>
-       <para>
-        length of the datum in characters
-       </para>
-      </listitem>
-     </varlistentry>
- 
-     <varlistentry>
-      <term><literal>RETURNED_OCTET_LENGTH</literal> (integer)</term>
-      <listitem>
-       <para>
-        length of the character representation of the datum in bytes
-       </para>
-      </listitem>
-     </varlistentry>
- 
-     <varlistentry>
-      <term><literal>SCALE</literal> (integer)</term>
-      <listitem>
-       <para>
-        scale (for type <type>numeric</type>)
-       </para>
-      </listitem>
-     </varlistentry>
- 
-     <varlistentry>
-      <term><literal>TYPE</literal> (integer)</term>
-      <listitem>
-       <para>
-        numeric code of the data type of the column
-       </para>
-      </listitem>
-     </varlistentry>
-    </variablelist>
-   </para>
-  </sect1>
- 
   <sect1 id="ecpg-errors">
    <title>Error Handling</title>
  
--- 4447,4452 ----
#96Boszormenyi Zoltan
zb@cybertec.at
In reply to: Michael Meskes (#81)
1 attachment(s)
Fix auto-prepare #2

Hi,

we have found that auto-prepare causes a problem if the connection
is closed and re-opened and the previously prepared query is issued
again. The application gets back a error code -201 which seems bogus
and it turned out to be a missing
return (false);
after ecpg_raise(ECPG_SQLSTATE_INVALID_SQL_STATEMENT_NAME)
on line 1756 in execute.c, so the error handling later in the same function
masqueraded this error. But fixing this doesn't solve the main problem
that the query is in the auto-prepared query cache but not is not prepared
on the server if the connection is closed and re-opened.

The same problem may also arise if the same query is used over multiple
simultaneous connections.

This fix is that after looking up the query and having it found in the cache
we also have to check whether this query was prepared in the current
connection. The attached patch implements this fix and solves the problem
described above. Also, the missing "return false;" is also added to ECPGdo()
in execute.c.

Best regards,
Zolt�n B�sz�rm�nyi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

Attachments:

6-pg85-fix-auto-prepare-multiconn-2.patchtext/x-patch; name=6-pg85-fix-auto-prepare-multiconn-2.patchDownload
diff -dcrp pgsql.orig/src/interfaces/ecpg/ecpglib/execute.c pgsql.1/src/interfaces/ecpg/ecpglib/execute.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/execute.c	2010-01-05 18:02:03.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/ecpglib/execute.c	2010-01-18 11:49:17.000000000 +0100
*************** ECPGdo(const int lineno, const int compa
*** 1753,1759 ****
--- 1753,1762 ----
  			stmt->command = ecpg_strdup(command, lineno);
  		}
  		else
+ 		{
  			ecpg_raise(lineno, ECPG_INVALID_STMT, ECPG_SQLSTATE_INVALID_SQL_STATEMENT_NAME, stmt->command);
+ 			return (false);
+ 		}
  	}
  
  	stmt->connection = con;
diff -dcrp pgsql.orig/src/interfaces/ecpg/ecpglib/prepare.c pgsql.1/src/interfaces/ecpg/ecpglib/prepare.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/prepare.c	2010-01-15 12:55:24.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/ecpglib/prepare.c	2010-01-18 11:32:26.000000000 +0100
*************** ecpg_auto_prepare(int lineno, const char
*** 465,472 ****
--- 465,481 ----
  	/* if not found - add the statement to the cache	*/
  	if (entNo)
  	{
+ 		struct connection *con;
+ 		struct prepared_statement *prep;
+ 
  		ecpg_log("ecpg_auto_prepare on line %d: statement found in cache; entry %d\n", lineno, entNo);
  		*name = ecpg_strdup(stmtCacheEntries[entNo].stmtID, lineno);
+ 
+ 		con = ecpg_get_connection(connection_name);
+ 		prep = ecpg_find_prepared_statement(*name, con, NULL);
+ 		/* This prepared name doesn't exist on this connection. */
+ 		if (!prep && !ECPGprepare(lineno, connection_name, 0, ecpg_strdup(*name, lineno), query))
+ 			return (false);
  	}
  	else
  	{
#97Takahiro Itagaki
itagaki.takahiro@oss.ntt.co.jp
In reply to: Boszormenyi Zoltan (#96)
2 attachment(s)
Re: Fix auto-prepare #2

Hi, I'm reviewing your patch and have a couple of comments.

Boszormenyi Zoltan <zb@cybertec.at> wrote:

we have found that auto-prepare causes a problem if the connection
is closed and re-opened and the previously prepared query is issued
again.

You didn't attach actual test cases for the bug, so I verified it
by executing the routines twice in ecpg/test/preproc/autoprep.pgc.
The attached "6-pg85-fix-auto-prepare-multiconn-3-test.patch"
is an additional regression test for it. Is it enough for your case?

This fix is that after looking up the query and having it found in the cache
we also have to check whether this query was prepared in the current
connection. The attached patch implements this fix and solves the problem
described above. Also, the missing "return false;" is also added to ECPGdo()
in execute.c.

In addition to the two issues, I found memory leaks by careless calls
of ecpg_strdup() in ecpg_auto_prepare(). Prepared stetements also might
leak in a error path. I tryd to fix both of them in the attached
"6-pg85-fix-auto-prepare-multiconn-3.patch", but please recheck the issues.

Regards,
---
Takahiro Itagaki
NTT Open Source Software Center

Attachments:

6-pg85-fix-auto-prepare-multiconn-3.patchapplication/octet-stream; name=6-pg85-fix-auto-prepare-multiconn-3.patchDownload
diff -cprN head/src/interfaces/ecpg/ecpglib/execute.c work/src/interfaces/ecpg/ecpglib/execute.c
*** head/src/interfaces/ecpg/ecpglib/execute.c	Wed Jan  6 09:46:25 2010
--- work/src/interfaces/ecpg/ecpglib/execute.c	Tue Jan 19 13:39:40 2010
*************** ECPGdo(const int lineno, const int compa
*** 1753,1759 ****
--- 1753,1762 ----
  			stmt->command = ecpg_strdup(command, lineno);
  		}
  		else
+ 		{
  			ecpg_raise(lineno, ECPG_INVALID_STMT, ECPG_SQLSTATE_INVALID_SQL_STATEMENT_NAME, stmt->command);
+ 			return (false);
+ 		}
  	}
  
  	stmt->connection = con;
diff -cprN head/src/interfaces/ecpg/ecpglib/prepare.c work/src/interfaces/ecpg/ecpglib/prepare.c
*** head/src/interfaces/ecpg/ecpglib/prepare.c	Mon Jan 18 09:26:23 2010
--- work/src/interfaces/ecpg/ecpglib/prepare.c	Tue Jan 19 14:04:55 2010
*************** ecpg_freeStmtCacheEntry(int lineno, int 
*** 406,412 ****
   */
  static int
  AddStmtToCache(int lineno,		/* line # of statement		*/
! 			   char *stmtID,	/* statement ID				*/
  			   const char *connection,	/* connection				*/
  			   int compat,		/* compatibility level */
  			   const char *ecpgQuery)	/* query					*/
--- 406,412 ----
   */
  static int
  AddStmtToCache(int lineno,		/* line # of statement		*/
! 			   const char *stmtID,	/* statement ID				*/
  			   const char *connection,	/* connection				*/
  			   int compat,		/* compatibility level */
  			   const char *ecpgQuery)	/* query					*/
*************** ecpg_auto_prepare(int lineno, const char
*** 465,485 ****
  	/* if not found - add the statement to the cache	*/
  	if (entNo)
  	{
  		ecpg_log("ecpg_auto_prepare on line %d: statement found in cache; entry %d\n", lineno, entNo);
! 		*name = ecpg_strdup(stmtCacheEntries[entNo].stmtID, lineno);
  	}
  	else
  	{
  		ecpg_log("ecpg_auto_prepare on line %d: statement not in cache; inserting\n", lineno);
  
  		/* generate a statement ID */
! 		*name = (char *) ecpg_alloc(STMTID_SIZE, lineno);
! 		sprintf(*name, "ecpg%d", nextStmtID++);
  
! 		if (!ECPGprepare(lineno, connection_name, 0, ecpg_strdup(*name, lineno), query))
  			return (false);
! 		if (AddStmtToCache(lineno, *name, connection_name, compat, query) < 0)
  			return (false);
  	}
  
  	/* increase usage counter */
--- 465,503 ----
  	/* if not found - add the statement to the cache	*/
  	if (entNo)
  	{
+ 		struct connection *con;
+ 
  		ecpg_log("ecpg_auto_prepare on line %d: statement found in cache; entry %d\n", lineno, entNo);
! 		*name = stmtCacheEntries[entNo].stmtID;
! 
! 		if ((con = ecpg_get_connection(connection_name)) == NULL ||
! 			ecpg_find_prepared_statement(*name, con, NULL) == NULL)
! 		{
! 			/* The query is in cache, but not prepared on this connection. */
! 			if (!ECPGprepare(lineno, connection_name, 0, *name, query))
! 				return (false);
! 		}
! 
! 		*name = ecpg_strdup(*name, lineno);
  	}
  	else
  	{
+ 		char	stmtID[STMTID_SIZE];
+ 
  		ecpg_log("ecpg_auto_prepare on line %d: statement not in cache; inserting\n", lineno);
  
  		/* generate a statement ID */
! 		sprintf(stmtID, "ecpg%d", nextStmtID++);
  
! 		if (!ECPGprepare(lineno, connection_name, 0, stmtID, query))
  			return (false);
! 		if (AddStmtToCache(lineno, stmtID, connection_name, compat, query) < 0)
! 		{
! 			(void) ECPGdeallocate(lineno, compat, connection_name, stmtID);
  			return (false);
+ 		}
+ 
+ 		*name = ecpg_strdup(stmtID, lineno);
  	}
  
  	/* increase usage counter */
6-pg85-fix-auto-prepare-multiconn-3-test.patchapplication/octet-stream; name=6-pg85-fix-auto-prepare-multiconn-3-test.patchDownload
diff -cprN head/src/interfaces/ecpg/autoprep.c work/src/interfaces/ecpg/autoprep.c
*** head/src/interfaces/ecpg/autoprep.c	Thu Jan  1 09:00:00 1970
--- work/src/interfaces/ecpg/autoprep.c	Tue Jan 19 13:25:20 2010
***************
*** 0 ****
--- 1,299 ----
+ /* Processed by ecpg (4.6.0) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ 
+ #line 1 "autoprep.pgc"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ /* test automatic prepare for all statements */
+ 
+ #line 1 "./test/regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 6 "autoprep.pgc"
+ 
+ 
+ int main() {
+   /* exec sql begin declare section */
+   	     
+ 	  
+ 	   
+   
+ #line 10 "autoprep.pgc"
+  int item [ 4 ] , ind [ 4 ] , i = 1 ;
+  
+ #line 11 "autoprep.pgc"
+  int item1 , ind1 ;
+  
+ #line 12 "autoprep.pgc"
+  char sqlstr [ 64 ] = "SELECT item2 FROM T ORDER BY item2 NULLS LAST" ;
+ /* exec sql end declare section */
+ #line 13 "autoprep.pgc"
+ 
+ 
+   ECPGdebug(1, stderr);
+   { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); }
+ #line 16 "autoprep.pgc"
+ 
+ 
+   /* exec sql whenever sql_warning  sqlprint ; */
+ #line 18 "autoprep.pgc"
+ 
+   /* exec sql whenever sqlerror  sqlprint ; */
+ #line 19 "autoprep.pgc"
+ 
+ 
+   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table T ( Item1 int , Item2 int )", ECPGt_EOIT, ECPGt_EORT);
+ #line 21 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 21 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 21 "autoprep.pgc"
+ 
+ 
+   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , null )", ECPGt_EOIT, ECPGt_EORT);
+ #line 23 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 23 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 23 "autoprep.pgc"
+ 
+   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , $1  )", 
+ 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 24 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 24 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 24 "autoprep.pgc"
+ 
+   i++;
+   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "insert into T values ( 1 , $1  )", 
+ 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 26 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 26 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 26 "autoprep.pgc"
+ 
+   { ECPGprepare(__LINE__, NULL, 0, "i", " insert into T values ( 1 , 2 ) ");
+ #line 27 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 27 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 27 "autoprep.pgc"
+ 
+   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "i", ECPGt_EOIT, ECPGt_EORT);
+ #line 28 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 28 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 28 "autoprep.pgc"
+ 
+ 
+   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "select Item2 from T order by Item2 nulls last", ECPGt_EOIT, 
+ 	ECPGt_int,(item),(long)1,(long)4,sizeof(int), 
+ 	ECPGt_int,(ind),(long)1,(long)4,sizeof(int), ECPGt_EORT);
+ #line 30 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 30 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 30 "autoprep.pgc"
+ 
+ 
+   for (i=0; i<4; i++)
+   	printf("item[%d] = %d\n", i, ind[i] ? -1 : item[i]);
+ 
+   /* declare C cursor for select Item1 from T */
+ #line 35 "autoprep.pgc"
+ 
+ 
+   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select Item1 from T", ECPGt_EOIT, ECPGt_EORT);
+ #line 37 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 37 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 37 "autoprep.pgc"
+ 
+ 
+   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch 1 in C", ECPGt_EOIT, 
+ 	ECPGt_int,&(i),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
+ #line 39 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 39 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 39 "autoprep.pgc"
+ 
+   printf("i = %d\n", i);
+ 
+   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close C", ECPGt_EOIT, ECPGt_EORT);
+ #line 42 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 42 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 42 "autoprep.pgc"
+ 
+ 
+   { ECPGprepare(__LINE__, NULL, 0, "stmt1", sqlstr);
+ #line 44 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 44 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 44 "autoprep.pgc"
+ 
+ 
+   /* declare cur1 cursor for $1 */
+ #line 46 "autoprep.pgc"
+ 
+ 
+   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare cur1 cursor for $1", 
+ 	ECPGt_char_variable,(ECPGprepared_statement(NULL, "stmt1", __LINE__)),(long)1,(long)1,(1)*sizeof(char), 
+ 	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
+ #line 48 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 48 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 48 "autoprep.pgc"
+ 
+ 
+   /* exec sql whenever not found  break ; */
+ #line 50 "autoprep.pgc"
+ 
+ 
+   i = 0;
+   while (1)
+   {
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch cur1", ECPGt_EOIT, 
+ 	ECPGt_int,&(item1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&(ind1),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 55 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 55 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 55 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 55 "autoprep.pgc"
+ 
+ 	printf("item[%d] = %d\n", i, ind1 ? -1 : item1);
+ 	i++;
+   }
+ 
+   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close cur1", ECPGt_EOIT, ECPGt_EORT);
+ #line 60 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 60 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 60 "autoprep.pgc"
+ 
+ 
+   { ECPGdisconnect(__LINE__, "ALL");
+ #line 62 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 62 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 62 "autoprep.pgc"
+ 
+ 
+   /*
+    * tests for reconnection
+    */
+ 
+   { ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
+ #line 68 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 68 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 68 "autoprep.pgc"
+ 
+ 
+   /* exec sql whenever not found  stop ; */
+ #line 70 "autoprep.pgc"
+ 
+ 
+   memset(item, 0, sizeof(item));
+   memset(ind, 0, sizeof(ind));
+ 
+   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_prepnormal, "select Item2 from T order by Item2 nulls last", ECPGt_EOIT, 
+ 	ECPGt_int,(item),(long)1,(long)4,sizeof(int), 
+ 	ECPGt_int,(ind),(long)1,(long)4,sizeof(int), ECPGt_EORT);
+ #line 75 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) exit (1);
+ #line 75 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 75 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 75 "autoprep.pgc"
+ 
+ 
+   for (i=0; i<4; i++)
+     printf("item[%d] = %d\n", i, ind[i] ? -1 : item[i]);
+ 
+   { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table T", ECPGt_EOIT, ECPGt_EORT);
+ #line 80 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 80 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 80 "autoprep.pgc"
+ 
+ 
+   { ECPGdisconnect(__LINE__, "ALL");
+ #line 82 "autoprep.pgc"
+ 
+ if (sqlca.sqlwarn[0] == 'W') sqlprint();
+ #line 82 "autoprep.pgc"
+ 
+ if (sqlca.sqlcode < 0) sqlprint();}
+ #line 82 "autoprep.pgc"
+ 
+ 
+   return 0;
+ }
diff -cprN head/src/interfaces/ecpg/autoprep.pgc work/src/interfaces/ecpg/autoprep.pgc
*** head/src/interfaces/ecpg/autoprep.pgc	Thu Jan  1 09:00:00 1970
--- work/src/interfaces/ecpg/autoprep.pgc	Tue Jan 19 13:27:24 2010
***************
*** 0 ****
--- 1,83 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ /* test automatic prepare for all statements */
+ EXEC SQL INCLUDE test/regression;
+ 
+ int main() {
+   EXEC SQL BEGIN DECLARE SECTION;
+   	int item[4], ind[4], i = 1;
+ 	int item1, ind1;
+ 	char sqlstr[64] = "SELECT item2 FROM T ORDER BY item2 NULLS LAST";
+   EXEC SQL END DECLARE SECTION;
+ 
+   ECPGdebug(1, stderr);
+   EXEC SQL CONNECT TO REGRESSDB1;
+ 
+   EXEC SQL WHENEVER SQLWARNING SQLPRINT;
+   EXEC SQL WHENEVER SQLERROR SQLPRINT;
+ 
+   EXEC SQL CREATE TABLE T ( Item1 int, Item2 int );
+ 
+   EXEC SQL INSERT INTO T VALUES ( 1, null );
+   EXEC SQL INSERT INTO T VALUES ( 1, :i );
+   i++;
+   EXEC SQL INSERT INTO T VALUES ( 1, :i );
+   EXEC SQL PREPARE I AS INSERT INTO T VALUES ( 1, 2 );
+   EXEC SQL EXECUTE I;
+ 
+   EXEC SQL SELECT Item2 INTO :item:ind FROM T ORDER BY Item2 NULLS LAST;
+ 
+   for (i=0; i<4; i++)
+   	printf("item[%d] = %d\n", i, ind[i] ? -1 : item[i]);
+ 
+   EXEC SQL DECLARE C CURSOR FOR SELECT Item1 FROM T;
+ 
+   EXEC SQL OPEN C;
+ 
+   EXEC SQL FETCH 1 IN C INTO :i;
+   printf("i = %d\n", i);
+ 
+   EXEC SQL CLOSE C;
+ 
+   EXEC SQL PREPARE stmt1 FROM :sqlstr;
+ 
+   EXEC SQL DECLARE cur1 CURSOR FOR stmt1;
+ 
+   EXEC SQL OPEN cur1;
+ 
+   EXEC SQL WHENEVER NOT FOUND DO BREAK;
+ 
+   i = 0;
+   while (1)
+   {
+ 	EXEC SQL FETCH cur1 INTO :item1:ind1;
+ 	printf("item[%d] = %d\n", i, ind1 ? -1 : item1);
+ 	i++;
+   }
+ 
+   EXEC SQL CLOSE cur1;
+ 
+   EXEC SQL DISCONNECT ALL;
+ 
+   /* tests for reconnection */
+ 
+   EXEC SQL CONNECT TO REGRESSDB1;
+ 
+   EXEC SQL WHENEVER NOT FOUND STOP;
+ 
+   memset(item, 0, sizeof(item));
+   memset(ind, 0, sizeof(ind));
+ 
+   EXEC SQL SELECT Item2 INTO :item:ind FROM T ORDER BY Item2 NULLS LAST;
+ 
+   for (i=0; i<4; i++)
+     printf("item[%d] = %d\n", i, ind[i] ? -1 : item[i]);
+ 
+   EXEC SQL DROP TABLE T;
+ 
+   EXEC SQL DISCONNECT ALL;
+ 
+   return 0;
+ }
diff -cprN head/src/interfaces/ecpg/test/expected/preproc-autoprep.c work/src/interfaces/ecpg/test/expected/preproc-autoprep.c
*** head/src/interfaces/ecpg/test/expected/preproc-autoprep.c	Thu Dec 17 09:42:41 2009
--- work/src/interfaces/ecpg/test/expected/preproc-autoprep.c	Tue Jan 19 13:40:54 2010
***************
*** 23,29 ****
  #line 6 "autoprep.pgc"
  
  
! int main() {
    /* exec sql begin declare section */
    	     
  	  
--- 23,29 ----
  #line 6 "autoprep.pgc"
  
  
! void test(void) {
    /* exec sql begin declare section */
    	     
  	  
*************** if (sqlca.sqlwarn[0] == 'W') sqlprint();
*** 246,251 ****
--- 246,256 ----
  if (sqlca.sqlcode < 0) sqlprint();}
  #line 64 "autoprep.pgc"
  
+ }
+ 
+ int main() {
+   test();
+   test();	/* retry */
  
    return 0;
  }
diff -cprN head/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr work/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr
*** head/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr	Thu Dec 17 09:42:41 2009
--- work/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr	Tue Jan 19 14:05:14 2010
***************
*** 158,160 ****
--- 158,320 ----
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_finish: connection regress1 closed
  [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 21: query: create table T ( Item1 int , Item2 int ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 21: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 21: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_auto_prepare on line 23: statement found in cache; entry 15328
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 23: name ecpg1; query: "insert into T values ( 1 , null )"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 23: query: insert into T values ( 1 , null ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 23: using PQexecPrepared for "insert into T values ( 1 , null )"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 23: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_auto_prepare on line 24: statement found in cache; entry 1640
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 24: name ecpg2; query: "insert into T values ( 1 , $1  )"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 24: query: insert into T values ( 1 , $1  ); with 1 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 24: using PQexecPrepared for "insert into T values ( 1 , $1  )"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 24: parameter 1 = 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 24: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_auto_prepare on line 26: statement found in cache; entry 1640
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 26: query: insert into T values ( 1 , $1  ); with 1 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 26: using PQexecPrepared for "insert into T values ( 1 , $1  )"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 26: parameter 1 = 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 26: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 27: name i; query: " insert into T values ( 1 , 2 ) "
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 28: query:  insert into T values ( 1 , 2 ) ; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 28: using PQexecPrepared for " insert into T values ( 1 , 2 ) "
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 28: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_auto_prepare on line 30: statement found in cache; entry 13056
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 30: name ecpg3; query: "select Item2 from T order by Item2 nulls last"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: query: select Item2 from T order by Item2 nulls last; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: using PQexecPrepared for "select Item2 from T order by Item2 nulls last"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: correctly got 4 tuples with 1 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 30: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 30: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 30: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 30: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: declare C cursor for select Item1 from T; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: query: fetch 1 in C; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: correctly got 1 tuples with 1 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 39: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 42: query: close C; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 42: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 42: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 44: name stmt1; query: "SELECT item2 FROM T ORDER BY item2 NULLS LAST"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: query: declare cur1 cursor for SELECT item2 FROM T ORDER BY item2 NULLS LAST; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: correctly got 1 tuples with 1 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 55: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: correctly got 1 tuples with 1 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 55: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: correctly got 1 tuples with 1 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 55: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: correctly got 1 tuples with 1 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 55: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: correctly got 0 tuples with 1 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 55: no data found on line 55
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 60: query: close cur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 60: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 60: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: query: drop table T; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 0: name stmt1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 0: name ecpg3
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 0: name i
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 0: name ecpg2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 0: name ecpg1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -cprN head/src/interfaces/ecpg/test/expected/preproc-autoprep.stdout work/src/interfaces/ecpg/test/expected/preproc-autoprep.stdout
*** head/src/interfaces/ecpg/test/expected/preproc-autoprep.stdout	Thu Dec 17 09:42:41 2009
--- work/src/interfaces/ecpg/test/expected/preproc-autoprep.stdout	Tue Jan 19 13:42:37 2010
*************** item[0] = 1
*** 7,9 ****
--- 7,18 ----
  item[1] = 2
  item[2] = 2
  item[3] = -1
+ item[0] = 1
+ item[1] = 2
+ item[2] = 2
+ item[3] = -1
+ i = 1
+ item[0] = 1
+ item[1] = 2
+ item[2] = 2
+ item[3] = -1
diff -cprN head/src/interfaces/ecpg/test/preproc/autoprep.pgc work/src/interfaces/ecpg/test/preproc/autoprep.pgc
*** head/src/interfaces/ecpg/test/preproc/autoprep.pgc	Thu Dec 17 09:42:41 2009
--- work/src/interfaces/ecpg/test/preproc/autoprep.pgc	Tue Jan 19 13:35:21 2010
***************
*** 5,11 ****
  /* test automatic prepare for all statements */
  EXEC SQL INCLUDE ../regression;
  
! int main() {
    EXEC SQL BEGIN DECLARE SECTION;
    	int item[4], ind[4], i = 1;
  	int item1, ind1;
--- 5,11 ----
  /* test automatic prepare for all statements */
  EXEC SQL INCLUDE ../regression;
  
! void test(void) {
    EXEC SQL BEGIN DECLARE SECTION;
    	int item[4], ind[4], i = 1;
  	int item1, ind1;
*************** int main() {
*** 62,67 ****
--- 62,72 ----
    EXEC SQL DROP TABLE T;
  
    EXEC SQL DISCONNECT ALL;
+ }
+ 
+ int main() {
+   test();
+   test();	/* retry */
  
    return 0;
  }
#98Boszormenyi Zoltan
zb@cybertec.at
In reply to: Takahiro Itagaki (#97)
1 attachment(s)
Re: Fix auto-prepare #2

Hi,

Takahiro Itagaki �rta:

Hi, I'm reviewing your patch and have a couple of comments.

thanks for the review, comments below.

Boszormenyi Zoltan <zb@cybertec.at> wrote:

we have found that auto-prepare causes a problem if the connection
is closed and re-opened and the previously prepared query is issued
again.

You didn't attach actual test cases for the bug, so I verified it
by executing the routines twice in ecpg/test/preproc/autoprep.pgc.
The attached "6-pg85-fix-auto-prepare-multiconn-3-test.patch"
is an additional regression test for it. Is it enough for your case?

Yes, my bad that I didn't attach a test case.
The modification to the autoprep.pgc is enough to trigger it
because the INSERTs are auto-prepared.

This fix is that after looking up the query and having it found in the cache
we also have to check whether this query was prepared in the current
connection. The attached patch implements this fix and solves the problem
described above. Also, the missing "return false;" is also added to ECPGdo()
in execute.c.

In addition to the two issues, I found memory leaks by careless calls
of ecpg_strdup() in ecpg_auto_prepare().

Good catch, thanks. I didn't look in ECPGprepare(),
so I just copied the statement and the logic from the ELSE branch.

Prepared stetements also might
leak in a error path.

Yes, it is true as well, the statement name ("ecpgN") is not freed
in the error path in ECPGdo().

However, thinking a little more about this code:
con = ecpg_get_connection(connection_name);
prep = ecpg_find_prepared_statement(stmtID, con, NULL);
if (!prep && !ECPGprepare(...))

I only wanted to call ECPGprepare() in case it wasn't already prepared.
ECPGprepare() also checks for the statement being already prepared
with ecpg_find_prepared_statement() but in case it exists it
DEALLOCATEs the statement and PREPAREs again so there's
would be no saving for auto-prepare calling it unconditionally and
we are doing a little extra work by calling ecpg_find_prepared_statement()
twice. We need a common function shared by ECPGprepare() and
ecpg_auto_prepare() to not do extra work in the auto-prepare case.

The attached patch implements this and also your leak fixes
plus includes your change for the autoprep.pgc regression test.

Thanks and best regards,
Zolt�n B�sz�rm�nyi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zolt�n B�sz�rm�nyi
Cybertec Sch�nig & Sch�nig GmbH
http://www.postgresql.at/

Attachments:

6-pg85-fix-auto-prepare-multiconn-4.patchtext/x-patch; name=6-pg85-fix-auto-prepare-multiconn-4.patchDownload
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/execute.c pgsql.1/src/interfaces/ecpg/ecpglib/execute.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/execute.c	2010-01-05 18:02:03.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/ecpglib/execute.c	2010-01-18 11:49:17.000000000 +0100
*************** ECPGdo(const int lineno, const int compa
*** 1753,1759 ****
--- 1753,1762 ----
  			stmt->command = ecpg_strdup(command, lineno);
  		}
  		else
+ 		{
  			ecpg_raise(lineno, ECPG_INVALID_STMT, ECPG_SQLSTATE_INVALID_SQL_STATEMENT_NAME, stmt->command);
+ 			return (false);
+ 		}
  	}
  
  	stmt->connection = con;
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/prepare.c pgsql.1/src/interfaces/ecpg/ecpglib/prepare.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/prepare.c	2010-01-15 12:55:24.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/ecpglib/prepare.c	2010-01-19 11:53:42.000000000 +0100
*************** replace_variables(char **text, int linen
*** 99,125 ****
  	return true;
  }
  
! /* handle the EXEC SQL PREPARE statement */
! /* questionmarks is not needed but remians in there for the time being to not change the API */
! bool
! ECPGprepare(int lineno, const char *connection_name, const bool questionmarks, const char *name, const char *variable)
  {
- 	struct connection *con;
  	struct statement *stmt;
! 	struct prepared_statement *this,
! 			   *prev;
  	PGresult   *query;
  
- 	con = ecpg_get_connection(connection_name);
- 
- 	if (!ecpg_init(con, connection_name, lineno))
- 		return false;
- 
- 	/* check if we already have prepared this statement */
- 	this = ecpg_find_prepared_statement(name, con, &prev);
- 	if (this && !deallocate_one(lineno, ECPG_COMPAT_PGSQL, con, prev, this))
- 		return false;
- 
  	/* allocate new statement */
  	this = (struct prepared_statement *) ecpg_alloc(sizeof(struct prepared_statement), lineno);
  	if (!this)
--- 99,111 ----
  	return true;
  }
  
! static bool
! prepare_common(int lineno, struct connection *con, const bool questionmarks, const char *name, const char *variable)
  {
  	struct statement *stmt;
! 	struct prepared_statement *this;
  	PGresult   *query;
  
  	/* allocate new statement */
  	this = (struct prepared_statement *) ecpg_alloc(sizeof(struct prepared_statement), lineno);
  	if (!this)
*************** ECPGprepare(int lineno, const char *conn
*** 169,174 ****
--- 155,182 ----
  	return true;
  }
  
+ /* handle the EXEC SQL PREPARE statement */
+ /* questionmarks is not needed but remians in there for the time being to not change the API */
+ bool
+ ECPGprepare(int lineno, const char *connection_name, const bool questionmarks, const char *name, const char *variable)
+ {
+ 	struct connection *con;
+ 	struct prepared_statement *this,
+ 			   *prev;
+ 
+ 	con = ecpg_get_connection(connection_name);
+ 
+ 	if (!ecpg_init(con, connection_name, lineno))
+ 		return false;
+ 
+ 	/* check if we already have prepared this statement */
+ 	this = ecpg_find_prepared_statement(name, con, &prev);
+ 	if (this && !deallocate_one(lineno, ECPG_COMPAT_PGSQL, con, prev, this))
+ 		return false;
+ 
+ 	return prepare_common(lineno, con, questionmarks, name, variable);
+ }
+ 
  struct prepared_statement *
  ecpg_find_prepared_statement(const char *name,
  				 struct connection * con, struct prepared_statement ** prev_)
*************** ecpg_auto_prepare(int lineno, const char
*** 465,485 ****
  	/* if not found - add the statement to the cache	*/
  	if (entNo)
  	{
  		ecpg_log("ecpg_auto_prepare on line %d: statement found in cache; entry %d\n", lineno, entNo);
! 		*name = ecpg_strdup(stmtCacheEntries[entNo].stmtID, lineno);
  	}
  	else
  	{
  		ecpg_log("ecpg_auto_prepare on line %d: statement not in cache; inserting\n", lineno);
  
  		/* generate a statement ID */
! 		*name = (char *) ecpg_alloc(STMTID_SIZE, lineno);
! 		sprintf(*name, "ecpg%d", nextStmtID++);
  
! 		if (!ECPGprepare(lineno, connection_name, 0, ecpg_strdup(*name, lineno), query))
  			return (false);
! 		if (AddStmtToCache(lineno, *name, connection_name, compat, query) < 0)
  			return (false);
  	}
  
  	/* increase usage counter */
--- 473,509 ----
  	/* if not found - add the statement to the cache	*/
  	if (entNo)
  	{
+ 		char	   *stmtID;
+ 		struct connection *con;
+ 		struct prepared_statement *prep;
+ 
  		ecpg_log("ecpg_auto_prepare on line %d: statement found in cache; entry %d\n", lineno, entNo);
! 
! 		stmtID = stmtCacheEntries[entNo].stmtID;
! 
! 		con = ecpg_get_connection(connection_name);
! 		prep = ecpg_find_prepared_statement(stmtID, con, NULL);
! 		/* This prepared name doesn't exist on this connection. */
! 		if (!prep && !prepare_common(lineno, con, 0, stmtID, query))
! 			return (false);
! 
! 		*name = ecpg_strdup(stmtID, lineno);
  	}
  	else
  	{
+ 		char	stmtID[STMTID_SIZE];
+ 
  		ecpg_log("ecpg_auto_prepare on line %d: statement not in cache; inserting\n", lineno);
  
  		/* generate a statement ID */
! 		sprintf(stmtID, "ecpg%d", nextStmtID++);
  
! 		if (!ECPGprepare(lineno, connection_name, 0, stmtID, query))
  			return (false);
! 		if (AddStmtToCache(lineno, stmtID, connection_name, compat, query) < 0)
  			return (false);
+ 
+ 		*name = ecpg_strdup(stmtID, lineno);
  	}
  
  	/* increase usage counter */
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/preproc-autoprep.c pgsql.1/src/interfaces/ecpg/test/expected/preproc-autoprep.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/preproc-autoprep.c	2009-12-16 11:30:27.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/test/expected/preproc-autoprep.c	2010-01-19 11:54:32.000000000 +0100
***************
*** 23,29 ****
  #line 6 "autoprep.pgc"
  
  
! int main() {
    /* exec sql begin declare section */
    	     
  	  
--- 23,29 ----
  #line 6 "autoprep.pgc"
  
  
! static void test(void) {
    /* exec sql begin declare section */
    	     
  	  
*************** if (sqlca.sqlwarn[0] == 'W') sqlprint();
*** 246,251 ****
--- 246,256 ----
  if (sqlca.sqlcode < 0) sqlprint();}
  #line 64 "autoprep.pgc"
  
+ }
+ 
+ int main() {
+   test();
+   test();     /* retry */
  
    return 0;
  }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr pgsql.1/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr
*** pgsql.orig/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr	2009-12-16 11:30:27.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/test/expected/preproc-autoprep.stderr	2010-01-19 11:54:33.000000000 +0100
***************
*** 158,160 ****
--- 158,320 ----
  [NO_PID]: sqlca: code: 0, state: 00000
  [NO_PID]: ecpg_finish: connection regress1 closed
  [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 21: query: create table T ( Item1 int , Item2 int ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 21: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 21: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_auto_prepare on line 23: statement found in cache; entry 15328
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 23: name ecpg1; query: "insert into T values ( 1 , null )"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 23: query: insert into T values ( 1 , null ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 23: using PQexecPrepared for "insert into T values ( 1 , null )"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 23: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_auto_prepare on line 24: statement found in cache; entry 1640
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 24: name ecpg2; query: "insert into T values ( 1 , $1  )"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 24: query: insert into T values ( 1 , $1  ); with 1 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 24: using PQexecPrepared for "insert into T values ( 1 , $1  )"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 24: parameter 1 = 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 24: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_auto_prepare on line 26: statement found in cache; entry 1640
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 26: query: insert into T values ( 1 , $1  ); with 1 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 26: using PQexecPrepared for "insert into T values ( 1 , $1  )"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: free_params on line 26: parameter 1 = 2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 26: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 27: name i; query: " insert into T values ( 1 , 2 ) "
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 28: query:  insert into T values ( 1 , 2 ) ; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 28: using PQexecPrepared for " insert into T values ( 1 , 2 ) "
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 28: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_auto_prepare on line 30: statement found in cache; entry 13056
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 30: name ecpg3; query: "select Item2 from T order by Item2 nulls last"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: query: select Item2 from T order by Item2 nulls last; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: using PQexecPrepared for "select Item2 from T order by Item2 nulls last"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 30: correctly got 4 tuples with 1 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 30: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 30: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 30: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 30: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: declare C cursor for select Item1 from T; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: query: fetch 1 in C; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 39: correctly got 1 tuples with 1 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 39: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 42: query: close C; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 42: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 42: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGprepare on line 44: name stmt1; query: "SELECT item2 FROM T ORDER BY item2 NULLS LAST"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: query: declare cur1 cursor for SELECT item2 FROM T ORDER BY item2 NULLS LAST; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 48: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: correctly got 1 tuples with 1 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 55: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: correctly got 1 tuples with 1 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 55: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: correctly got 1 tuples with 1 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 55: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: correctly got 1 tuples with 1 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 55: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: query: fetch cur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 55: correctly got 0 tuples with 1 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 55: no data found on line 55
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 60: query: close cur1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 60: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 60: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: query: drop table T; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 0: name stmt1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 0: name ecpg3
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 0: name i
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 0: name ecpg2
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGdeallocate on line 0: name ecpg1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/preproc-autoprep.stdout pgsql.1/src/interfaces/ecpg/test/expected/preproc-autoprep.stdout
*** pgsql.orig/src/interfaces/ecpg/test/expected/preproc-autoprep.stdout	2009-12-16 11:30:27.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/test/expected/preproc-autoprep.stdout	2010-01-19 11:54:32.000000000 +0100
*************** item[0] = 1
*** 7,9 ****
--- 7,18 ----
  item[1] = 2
  item[2] = 2
  item[3] = -1
+ item[0] = 1
+ item[1] = 2
+ item[2] = 2
+ item[3] = -1
+ i = 1
+ item[0] = 1
+ item[1] = 2
+ item[2] = 2
+ item[3] = -1
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/preproc/autoprep.pgc pgsql.1/src/interfaces/ecpg/test/preproc/autoprep.pgc
*** pgsql.orig/src/interfaces/ecpg/test/preproc/autoprep.pgc	2009-12-16 11:30:27.000000000 +0100
--- pgsql.1/src/interfaces/ecpg/test/preproc/autoprep.pgc	2010-01-19 11:49:21.000000000 +0100
***************
*** 5,11 ****
  /* test automatic prepare for all statements */
  EXEC SQL INCLUDE ../regression;
  
! int main() {
    EXEC SQL BEGIN DECLARE SECTION;
    	int item[4], ind[4], i = 1;
  	int item1, ind1;
--- 5,11 ----
  /* test automatic prepare for all statements */
  EXEC SQL INCLUDE ../regression;
  
! static void test(void) {
    EXEC SQL BEGIN DECLARE SECTION;
    	int item[4], ind[4], i = 1;
  	int item1, ind1;
*************** int main() {
*** 62,67 ****
--- 62,72 ----
    EXEC SQL DROP TABLE T;
  
    EXEC SQL DISCONNECT ALL;
+ }
+ 
+ int main() {
+   test();
+   test();     /* retry */
  
    return 0;
  }
#99Michael Meskes
meskes@postgresql.org
In reply to: Boszormenyi Zoltan (#75)
Re: ECPG patch 4.1, out-of-scope cursor support in native mode

Zoltan,

while testing your patch I went through the test cases and found this in outofscope.pgc:

+ #include <inttypes.h>

As we know by now this won't work. :-)

Besides, would you mind simplifying the test case a little bit? There is no
need to have it test all the sqlda stuff, too. I don't mind having two cases
testing sqlda but this makes testing out of scope variable handling more
difficult especially with sqlda being a rather complex system with different
struct definitions and so on.

Also I wonder why you added struct.pgc. It seems to build and run without a
problem on a non-patched system. Is it an additional test that just happened to
be included here?

Michael

--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ 179140304, AIM/Yahoo/Skype michaelmeskes, Jabber meskes@jabber.org
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL

In reply to: Michael Meskes (#99)
Re: ECPG patch 4.1, out-of-scope cursor support in native mode

Michael Meskes írta:

Zoltan,

while testing your patch I went through the test cases and found this in outofscope.pgc:

+ #include <inttypes.h>

As we know by now this won't work. :-)

Okay, I will fix it. :-) I forgot it's in there as well.

Besides, would you mind simplifying the test case a little bit? There is no
need to have it test all the sqlda stuff, too. I don't mind having two cases
testing sqlda but this makes testing out of scope variable handling more
difficult especially with sqlda being a rather complex system with different
struct definitions and so on.

Okay.

Also I wonder why you added struct.pgc. It seems to build and run without a
problem on a non-patched system. Is it an additional test that just happened to
be included here?

It was included in there because the first symptom
that lead to this patch under Informix compat mode that
a simple struct variable wasn't properly unrolled because
adjust_informix() lost informiation about the type.
Did I accidentally move it to native mode? I'll move it back.

I will send an updated patch.

Thanks,
Zoltán Böszörményi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

In reply to: Boszormenyi Zoltan (#100)
1 attachment(s)
Re: ECPG patch 4.1, out-of-scope cursor support in native mode

Boszormenyi Zoltan írta:

I will send an updated patch.

Attached with the requested modifications.

Best regards,
Zoltán Böszörményi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

Attachments:

4.1-pg85-outofscopedeclare-11-ctxdiff.patchtext/x-patch; name=4.1-pg85-outofscopedeclare-11-ctxdiff.patchDownload
diff -dcrpN pgsql.orig/src/interfaces/ecpg/compatlib/informix.c pgsql.4.1/src/interfaces/ecpg/compatlib/informix.c
*** pgsql.orig/src/interfaces/ecpg/compatlib/informix.c	2009-10-01 20:37:18.000000000 +0200
--- pgsql.4.1/src/interfaces/ecpg/compatlib/informix.c	2010-01-19 19:13:35.000000000 +0100
*************** rtypwidth(int sqltype, int sqllen)
*** 1004,1060 ****
  	return 0;
  }
  
- static struct var_list
- {
- 	int			number;
- 	void	   *pointer;
- 	struct var_list *next;
- }	*ivlist = NULL;
- 
  void
  ECPG_informix_set_var(int number, void *pointer, int lineno)
  {
! 	struct var_list *ptr;
! 
! 	for (ptr = ivlist; ptr != NULL; ptr = ptr->next)
! 	{
! 		if (ptr->number == number)
! 		{
! 			/* already known => just change pointer value */
! 			ptr->pointer = pointer;
! 			return;
! 		}
! 	}
! 
! 	/* a new one has to be added */
! 	ptr = (struct var_list *) calloc(1L, sizeof(struct var_list));
! 	if (!ptr)
! 	{
! 		struct sqlca_t *sqlca = ECPGget_sqlca();
! 
! 		sqlca->sqlcode = ECPG_OUT_OF_MEMORY;
! 		strncpy(sqlca->sqlstate, "YE001", sizeof("YE001"));
! 		snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), "out of memory on line %d", lineno);
! 		sqlca->sqlerrm.sqlerrml = strlen(sqlca->sqlerrm.sqlerrmc);
! 		/* free all memory we have allocated for the user */
! 		ECPGfree_auto_mem();
! 	}
! 	else
! 	{
! 		ptr->number = number;
! 		ptr->pointer = pointer;
! 		ptr->next = ivlist;
! 		ivlist = ptr;
! 	}
  }
  
  void *
  ECPG_informix_get_var(int number)
  {
! 	struct var_list *ptr;
! 
! 	for (ptr = ivlist; ptr != NULL && ptr->number != number; ptr = ptr->next);
! 	return (ptr) ? ptr->pointer : NULL;
  }
  
  void
--- 1004,1019 ----
  	return 0;
  }
  
  void
  ECPG_informix_set_var(int number, void *pointer, int lineno)
  {
! 	ECPGset_var(number, pointer, lineno);
  }
  
  void *
  ECPG_informix_get_var(int number)
  {
! 	return ECPGget_var(number);
  }
  
  void
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/exports.txt pgsql.4.1/src/interfaces/ecpg/ecpglib/exports.txt
*** pgsql.orig/src/interfaces/ecpg/ecpglib/exports.txt	2009-09-21 15:19:11.000000000 +0200
--- pgsql.4.1/src/interfaces/ecpg/ecpglib/exports.txt	2010-01-19 19:13:35.000000000 +0100
*************** ECPGstatus                       23
*** 26,29 ****
  ECPGtrans                        24
  sqlprint                         25
  ECPGget_PGconn			 26
! ECPGtransactionStatus      27
--- 26,31 ----
  ECPGtrans                        24
  sqlprint                         25
  ECPGget_PGconn			 26
! ECPGtransactionStatus		 27
! ECPGset_var			 28
! ECPGget_var			 29
diff -dcrpN pgsql.orig/src/interfaces/ecpg/ecpglib/misc.c pgsql.4.1/src/interfaces/ecpg/ecpglib/misc.c
*** pgsql.orig/src/interfaces/ecpg/ecpglib/misc.c	2009-11-25 11:56:39.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/ecpglib/misc.c	2010-01-19 19:13:35.000000000 +0100
*************** ecpg_gettext(const char *msgid)
*** 505,507 ****
--- 505,559 ----
  }
  
  #endif   /* ENABLE_NLS */
+ 
+ static struct var_list
+ {
+ 	int		number;
+ 	void	   *pointer;
+ 	struct var_list *next;
+ } *ivlist = NULL;
+ 
+ void
+ ECPGset_var(int number, void *pointer, int lineno)
+ {
+ 	struct var_list *ptr;
+ 
+ 	for (ptr = ivlist; ptr != NULL; ptr = ptr->next)
+ 	{
+ 		if (ptr->number == number)
+ 		{
+ 			/* already known => just change pointer value */
+ 			ptr->pointer = pointer;
+ 			return;
+ 		}
+ 	}
+ 
+ 	/* a new one has to be added */
+ 	ptr = (struct var_list *) calloc(1L, sizeof(struct var_list));
+ 	if (!ptr)
+ 	{
+ 		struct sqlca_t *sqlca = ECPGget_sqlca();
+ 		sqlca->sqlcode = ECPG_OUT_OF_MEMORY;
+ 		strncpy(sqlca->sqlstate, "YE001", sizeof("YE001"));
+ 		snprintf(sqlca->sqlerrm.sqlerrmc, sizeof(sqlca->sqlerrm.sqlerrmc), "out of memory on line %d", lineno);
+ 		sqlca->sqlerrm.sqlerrml = strlen(sqlca->sqlerrm.sqlerrmc);
+ 		/* free all memory we have allocated for the user */
+ 		ECPGfree_auto_mem();
+ 	}
+ 	else
+ 	{
+ 		ptr->number = number;
+ 		ptr->pointer = pointer;
+ 		ptr->next = ivlist;
+ 		ivlist = ptr;
+ 	}
+ }
+ 
+ void *
+ ECPGget_var(int number)
+ {
+ 	struct var_list *ptr;
+ 
+ 	for (ptr = ivlist; ptr != NULL && ptr->number != number; ptr = ptr->next);
+ 		return (ptr) ? ptr->pointer : NULL;
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/include/ecpglib.h pgsql.4.1/src/interfaces/ecpg/include/ecpglib.h
*** pgsql.orig/src/interfaces/ecpg/include/ecpglib.h	2010-01-15 12:55:24.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/include/ecpglib.h	2010-01-19 19:13:35.000000000 +0100
*************** void		ECPGset_noind_null(enum ECPGttype,
*** 85,90 ****
--- 85,93 ----
  bool		ECPGis_noind_null(enum ECPGttype, void *);
  bool		ECPGdescribe(int, int, bool, const char *, const char *, ...);
  
+ void		ECPGset_var(int, void *, int);
+ void	   *ECPGget_var(int number);
+ 
  /* dynamic result allocation */
  void		ECPGfree_auto_mem(void);
  
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/descriptor.c pgsql.4.1/src/interfaces/ecpg/preproc/descriptor.c
*** pgsql.orig/src/interfaces/ecpg/preproc/descriptor.c	2010-01-05 18:02:03.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/descriptor.c	2010-01-19 19:13:35.000000000 +0100
*************** struct variable *
*** 317,323 ****
  descriptor_variable(const char *name, int input)
  {
  	static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN];
! 	static const struct ECPGtype descriptor_type = {ECPGt_descriptor, NULL, NULL, {NULL}, 0};
  	static const struct variable varspace[2] = {
  		{descriptor_names[0], (struct ECPGtype *) & descriptor_type, 0, NULL},
  		{descriptor_names[1], (struct ECPGtype *) & descriptor_type, 0, NULL}
--- 317,323 ----
  descriptor_variable(const char *name, int input)
  {
  	static char descriptor_names[2][MAX_DESCRIPTOR_NAMELEN];
! 	static const struct ECPGtype descriptor_type = {ECPGt_descriptor, NULL, NULL, NULL, {NULL}, 0};
  	static const struct variable varspace[2] = {
  		{descriptor_names[0], (struct ECPGtype *) & descriptor_type, 0, NULL},
  		{descriptor_names[1], (struct ECPGtype *) & descriptor_type, 0, NULL}
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.addons pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.addons
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.addons	2010-01-15 12:55:24.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.addons	2010-01-19 19:13:35.000000000 +0100
*************** ECPG: DeclareCursorStmtDECLAREcursor_nam
*** 310,320 ****
--- 310,323 ----
  
  		this->next = cur;
  		this->name = $2;
+ 		this->function = (current_function ? mm_strdup(current_function) : NULL);
  		this->connection = connection;
  		this->opened = false;
  		this->command =  cat_str(7, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for"), $7);
  		this->argsinsert = argsinsert;
+ 		this->argsinsert_oos = NULL;
  		this->argsresult = argsresult;
+ 		this->argsresult_oos = NULL;
  		argsinsert = argsresult = NULL;
  		cur = this;
  
*************** ECPG: DeclareCursorStmtDECLAREcursor_nam
*** 327,343 ****
  		}
  		comment = cat_str(3, make_str("/*"), c1, make_str("*/"));
  
! 		if (INFORMIX_MODE)
! 		{
! 			if (braces_open > 0) /* we're in a function */
! 			{
! 				$$ = cat_str(4, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), make_str("ECPG_informix_reset_sqlca();"), comment);
! 			}
! 			else
! 				$$ = cat_str(3, adjust_informix(this->argsinsert), adjust_informix(this->argsresult), comment);
! 		}
  		else
! 			$$ = comment;
  	}
  ECPG: ClosePortalStmtCLOSEcursor_name block
  	{
--- 330,346 ----
  		}
  		comment = cat_str(3, make_str("/*"), c1, make_str("*/"));
  
! 		if ((braces_open > 0) && INFORMIX_MODE) /* we're in a function */
! 			$$ = cat_str(4,
! 				adjust_outofscope_cursor_vars(this, true),
! 				adjust_outofscope_cursor_vars(this, false),
! 				make_str("ECPG_informix_reset_sqlca();"),
! 				comment);
  		else
! 			$$ = cat_str(3,
! 				adjust_outofscope_cursor_vars(this, true),
! 				adjust_outofscope_cursor_vars(this, false),
! 				comment);
  	}
  ECPG: ClosePortalStmtCLOSEcursor_name block
  	{
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.c pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.c
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.c	2010-01-03 12:54:40.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.c	2010-01-19 19:13:35.000000000 +0100
*************** main(int argc, char *const argv[])
*** 419,426 ****
  				/* and structure member lists */
  				memset(struct_member_list, 0, sizeof(struct_member_list));
  
! 				/* and our variable counter for Informix compatibility */
! 				ecpg_informix_var = 0;
  
  				/* finally the actual connection */
  				connection = NULL;
--- 419,426 ----
  				/* and structure member lists */
  				memset(struct_member_list, 0, sizeof(struct_member_list));
  
! 				/* and our variable counter for out of scope cursors' variables */
! 				ecpg_internal_var = 0;
  
  				/* finally the actual connection */
  				connection = NULL;
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.header pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.header
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.header	2009-11-06 11:06:24.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.header	2010-01-19 19:13:35.000000000 +0100
***************
*** 33,39 ****
   */
  int struct_level = 0;
  int braces_open; /* brace level counter */
! int ecpg_informix_var = 0;
  char	*connection = NULL;
  char	*input_filename = NULL;
  
--- 33,40 ----
   */
  int struct_level = 0;
  int braces_open; /* brace level counter */
! char *current_function;
! int ecpg_internal_var = 0;
  char	*connection = NULL;
  char	*input_filename = NULL;
  
*************** static char *ECPGstruct_sizeof = NULL;
*** 53,62 ****
  /* for forward declarations we have to store some data as well */
  static char *forward_name = NULL;
  
! struct ECPGtype ecpg_no_indicator = {ECPGt_NO_INDICATOR, NULL, NULL, {NULL}, 0};
  struct variable no_indicator = {"no_indicator", &ecpg_no_indicator, 0, NULL};
  
! struct ECPGtype ecpg_query = {ECPGt_char_variable, NULL, NULL, {NULL}, 0};
  
  /*
   * Handle parsing errors and warnings
--- 54,63 ----
  /* for forward declarations we have to store some data as well */
  static char *forward_name = NULL;
  
! struct ECPGtype ecpg_no_indicator = {ECPGt_NO_INDICATOR, NULL, NULL, NULL, {NULL}, 0};
  struct variable no_indicator = {"no_indicator", &ecpg_no_indicator, 0, NULL};
  
! struct ECPGtype ecpg_query = {ECPGt_char_variable, NULL, NULL, NULL, {NULL}, 0};
  
  /*
   * Handle parsing errors and warnings
*************** create_questionmarks(char *name, bool ar
*** 226,301 ****
  }
  
  static char *
! adjust_informix(struct arguments *list)
  {
  	/* Informix accepts DECLARE with variables that are out of scope when OPEN is called.
!  	 * for instance you can declare variables in a function, and then subsequently use them
! 	 * {
! 	 *      declare_vars();
! 	 *      exec sql ... which uses vars declared in the above function
  	 *
! 	 * This breaks standard and leads to some very dangerous programming.
! 	 * Since they do, we have to work around and accept their syntax as well.
! 	 * But we will do so ONLY in Informix mode.
! 	 * We have to change the variables to our own struct and just store the pointer instead of the variable
  	 */
  
! 	 struct arguments *ptr;
! 	 char *result = make_str("");
  
! 	 for (ptr = list; ptr != NULL; ptr = ptr->next)
! 	 {
! 	 	char temp[20]; /* this should be sufficient unless you have 8 byte integers */
  		char *original_var;
  
! 	 	/* change variable name to "ECPG_informix_get_var(<counter>)" */
  		original_var = ptr->variable->name;
! 		sprintf(temp, "%d))", ecpg_informix_var);
  
! 		if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char && ptr->variable->type->type != ECPGt_unsigned_char && ptr->variable->type->type != ECPGt_string) && atoi(ptr->variable->type->size) > 1)
  		{
! 			ptr->variable = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, make_str("1"), ptr->variable->type->u.element->lineno), ptr->variable->type->size), 0);
! 			sprintf(temp, "%d, (", ecpg_informix_var++);
  		}
  		else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char || ptr->variable->type->type == ECPGt_unsigned_char || ptr->variable->type->type == ECPGt_string) && atoi(ptr->variable->type->size) > 1)
  		{
! 			ptr->variable = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->lineno), 0);
! 			sprintf(temp, "%d, (", ecpg_informix_var++);
  		}
  		else
  		{
! 			ptr->variable = new_variable(cat_str(4, make_str("*("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->lineno), 0);
! 			sprintf(temp, "%d, &(", ecpg_informix_var++);
  		}
  
! 		/* create call to "ECPG_informix_set_var(<counter>, <pointer>. <linen number>)" */
! 		result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var), make_str("), __LINE__);\n"));
  
! 		/* now the indicator if there is one */
! 		if (ptr->indicator->type->type != ECPGt_NO_INDICATOR)
  		{
! 			/* change variable name to "ECPG_informix_get_var(<counter>)" */
  			original_var = ptr->indicator->name;
! 			sprintf(temp, "%d))", ecpg_informix_var);
  
! 			/* create call to "ECPG_informix_set_var(<counter>, <pointer>. <linen number>)" */
! 			if (atoi(ptr->indicator->type->size) > 1)
  			{
! 				ptr->indicator = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->lineno), 0);
! 				sprintf(temp, "%d, (", ecpg_informix_var++);
  			}
  			else
  			{
! 				ptr->indicator = new_variable(cat_str(4, make_str("*("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), make_str(" *)(ECPG_informix_get_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->lineno), 0);
! 				sprintf(temp, "%d, &(", ecpg_informix_var++);
  			}
! 			result = cat_str(5, result, make_str("ECPG_informix_set_var("), mm_strdup(temp), mm_strdup(original_var), make_str("), __LINE__);\n"));
  		}
- 	 }
  
! 	 return result;
  }
  
  static struct cursor *
  add_additional_variables(char *name, bool insert)
  {
--- 227,379 ----
  }
  
  static char *
! adjust_outofscope_cursor_vars(struct cursor *cur, bool insert)
  {
  	/* Informix accepts DECLARE with variables that are out of scope when OPEN is called.
! 	 * For instance you can DECLARE a cursor in one function, and OPEN/FETCH/CLOSE
! 	 * it in other functions. This is very useful for e.g. event-driver programming,
! 	 * but may also lead to dangerous programming. The limitation when this is allowed
! 	 * and doesn's cause problems have to be documented, like the allocated variables
! 	 * must not be realloc()'ed.
  	 *
! 	 * We have to change the variables to our own struct and just store the pointer
! 	 * instead of the variable. Do it only for local variables, not for globals.
  	 */
  
! 	struct arguments *list;
! 	struct arguments *ptr;
! 	struct arguments *newlist = NULL;
! 	struct variable *newvar, *newind;
! 	char *result = make_str("");
  
! 	list = (insert ? cur->argsinsert : cur->argsresult);
! 
! 	for (ptr = list; ptr != NULL; ptr = ptr->next)
! 	{
! 		char temp[20]; /* this should be sufficient unless you have 8 byte integers */
  		char *original_var;
+ 		bool skip_set_var = false;
  
! 		/* change variable name to "ECPGget_var(<counter>)" */
  		original_var = ptr->variable->name;
! 		sprintf(temp, "%d))", ecpg_internal_var);
  
! 		/* Don't emit ECPGset_var() calls for global variables */
! 		if (ptr->variable->brace_level == 0)
  		{
! 			newvar = ptr->variable;
! 			skip_set_var = true;
! 		}
! 		else if ((ptr->variable->type->type == ECPGt_char_variable) && (!strncmp(ptr->variable->name, "ECPGprepared_statement", strlen("ECPGprepared_statement"))))
! 		{
! 			newvar = ptr->variable;
! 			skip_set_var = true;
! 		}
! 		else if ((ptr->variable->type->type != ECPGt_varchar && ptr->variable->type->type != ECPGt_char && ptr->variable->type->type != ECPGt_unsigned_char && ptr->variable->type->type != ECPGt_string) && atoi(ptr->variable->type->size) > 1)
! 		{
! 			newvar = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->u.element->type)), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, make_str("1"), ptr->variable->type->u.element->lineno), ptr->variable->type->size), 0);
! 			sprintf(temp, "%d, (", ecpg_internal_var++);
  		}
  		else if ((ptr->variable->type->type == ECPGt_varchar || ptr->variable->type->type == ECPGt_char || ptr->variable->type->type == ECPGt_unsigned_char || ptr->variable->type->type == ECPGt_string) && atoi(ptr->variable->type->size) > 1)
  		{
! 			newvar = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->lineno), 0);
! 			if (ptr->variable->type->type == ECPGt_varchar)
! 				sprintf(temp, "%d, &(", ecpg_internal_var++);
! 			else
! 				sprintf(temp, "%d, (", ecpg_internal_var++);
! 		}
! 		else if (ptr->variable->type->type == ECPGt_struct || ptr->variable->type->type == ECPGt_union)
! 		{
! 			sprintf(temp, "%d)))", ecpg_internal_var);
! 			newvar = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->variable->type->type_name), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->variable->type->u.members, ptr->variable->type->type, ptr->variable->type->type_name, ptr->variable->type->struct_sizeof), 0);
! 			sprintf(temp, "%d, &(", ecpg_internal_var++);
! 		}
! 		else if (ptr->variable->type->type == ECPGt_array)
! 		{
! 			if (ptr->variable->type->u.element->type == ECPGt_struct || ptr->variable->type->u.element->type == ECPGt_union)
! 			{
! 				sprintf(temp, "%d)))", ecpg_internal_var);
! 				newvar = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->variable->type->u.element->type_name), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->variable->type->u.element->u.members, ptr->variable->type->u.element->type, ptr->variable->type->u.element->type_name, ptr->variable->type->u.element->struct_sizeof), 0);
! 				sprintf(temp, "%d, (", ecpg_internal_var++);
! 			}
! 			else
! 			{
! 				newvar = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->variable->type->u.element->type, ptr->variable->type->u.element->size, ptr->variable->type->u.element->lineno), ptr->variable->type->size), 0);
! 				sprintf(temp, "%d, &(", ecpg_internal_var++);
! 			}
  		}
  		else
  		{
! 			newvar = new_variable(cat_str(4, make_str("*("), mm_strdup(ecpg_type_name(ptr->variable->type->type)), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->variable->type->type, ptr->variable->type->size, ptr->variable->type->lineno), 0);
! 			sprintf(temp, "%d, &(", ecpg_internal_var++);
  		}
  
! 		/* create call to "ECPGset_var(<counter>, <pointer>. <linen number>)" */
! 		if (!skip_set_var)
! 			result = cat_str(5, result, make_str("ECPGset_var("), mm_strdup(temp), mm_strdup(original_var), make_str("), __LINE__);\n"));
  
! 		/* now the indicator if there is one and it's not a global variable */
! 		if ((ptr->indicator->type->type == ECPGt_NO_INDICATOR) || (ptr->indicator->brace_level == 0))
  		{
! 			newind = ptr->indicator;
! 		}
! 		else
! 		{
! 			/* change variable name to "ECPGget_var(<counter>)" */
  			original_var = ptr->indicator->name;
! 			sprintf(temp, "%d))", ecpg_internal_var);
  
! 			if (ptr->indicator->type->type == ECPGt_struct || ptr->indicator->type->type == ECPGt_union)
  			{
! 				sprintf(temp, "%d)))", ecpg_internal_var);
! 				newind = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->indicator->type->type_name), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->indicator->type->u.members, ptr->indicator->type->type, ptr->indicator->type->type_name, ptr->indicator->type->struct_sizeof), 0);
! 				sprintf(temp, "%d, &(", ecpg_internal_var++);
! 			}
! 			else if (ptr->indicator->type->type == ECPGt_array)
! 			{
! 				if (ptr->indicator->type->u.element->type == ECPGt_struct || ptr->indicator->type->u.element->type == ECPGt_union)
! 				{
! 					sprintf(temp, "%d)))", ecpg_internal_var);
! 					newind = new_variable(cat_str(4, make_str("(*("), mm_strdup(ptr->indicator->type->u.element->type_name), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_struct_type(ptr->indicator->type->u.element->u.members, ptr->indicator->type->u.element->type, ptr->indicator->type->u.element->type_name, ptr->indicator->type->u.element->struct_sizeof), 0);
! 					sprintf(temp, "%d, (", ecpg_internal_var++);
! 				}
! 				else
! 				{
! 					newind = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->indicator->type->u.element->type)), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_array_type(ECPGmake_simple_type(ptr->indicator->type->u.element->type, ptr->indicator->type->u.element->size, ptr->indicator->type->u.element->lineno), ptr->indicator->type->size), 0);
! 					sprintf(temp, "%d, &(", ecpg_internal_var++);
! 				}
! 			}
! 			else if (atoi(ptr->indicator->type->size) > 1)
! 			{
! 				newind = new_variable(cat_str(4, make_str("("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->lineno), 0);
! 				sprintf(temp, "%d, (", ecpg_internal_var++);
  			}
  			else
  			{
! 				newind = new_variable(cat_str(4, make_str("*("), mm_strdup(ecpg_type_name(ptr->indicator->type->type)), make_str(" *)(ECPGget_var("), mm_strdup(temp)), ECPGmake_simple_type(ptr->indicator->type->type, ptr->indicator->type->size, ptr->variable->type->lineno), 0);
! 				sprintf(temp, "%d, &(", ecpg_internal_var++);
  			}
! 
! 			/* create call to "ECPGset_var(<counter>, <pointer>. <linen number>)" */
! 			result = cat_str(5, result, make_str("ECPGset_var("), mm_strdup(temp), mm_strdup(original_var), make_str("), __LINE__);\n"));
  		}
  
! 		add_variable_to_tail(&newlist, newvar, newind);
! 	}
! 
! 	if (insert)
! 		cur->argsinsert_oos = newlist;
! 	else
! 		cur->argsresult_oos = newlist;
! 
! 	return result;
  }
  
+ /* This tests whether the cursor was declared and opened in the same function. */
+ #define SAMEFUNC(cur)	\
+ 	((cur->function == NULL) ||		\
+ 	 (cur->function != NULL && !strcmp(cur->function, current_function)))
+ 
  static struct cursor *
  add_additional_variables(char *name, bool insert)
  {
*************** add_additional_variables(char *name, boo
*** 318,329 ****
  	{
  		/* add all those input variables that were given earlier
  		 * note that we have to append here but have to keep the existing order */
! 		for (p = ptr->argsinsert; p; p = p->next)
  			add_variable_to_tail(&argsinsert, p->variable, p->indicator);
  	}
  
  	/* add all those output variables that were given earlier */
! 	for (p = ptr->argsresult; p; p = p->next)
  		add_variable_to_tail(&argsresult, p->variable, p->indicator);
  
  	return ptr;
--- 396,407 ----
  	{
  		/* add all those input variables that were given earlier
  		 * note that we have to append here but have to keep the existing order */
! 		for (p = (SAMEFUNC(ptr) ? ptr->argsinsert : ptr->argsinsert_oos); p; p = p->next)
  			add_variable_to_tail(&argsinsert, p->variable, p->indicator);
  	}
  
  	/* add all those output variables that were given earlier */
! 	for (p = (SAMEFUNC(ptr) ? ptr->argsresult : ptr->argsresult_oos); p; p = p->next)
  		add_variable_to_tail(&argsresult, p->variable, p->indicator);
  
  	return ptr;
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/ecpg.trailer pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.trailer
*** pgsql.orig/src/interfaces/ecpg/preproc/ecpg.trailer	2010-01-15 12:55:25.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/ecpg.trailer	2010-01-19 19:13:35.000000000 +0100
*************** statement: ecpgstart at stmt ';'        
*** 16,22 ****
                  | c_thing               { fprintf(yyout, "%s", $1); free($1); }
                  | CPP_LINE              { fprintf(yyout, "%s", $1); free($1); }
                  | '{'                   { braces_open++; fputs("{", yyout); }
!                 | '}'                   { remove_typedefs(braces_open); remove_variables(braces_open--); fputs("}", yyout); }
                  ;
  
  CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
--- 16,32 ----
                  | c_thing               { fprintf(yyout, "%s", $1); free($1); }
                  | CPP_LINE              { fprintf(yyout, "%s", $1); free($1); }
                  | '{'                   { braces_open++; fputs("{", yyout); }
!                 | '}'
! 		{
! 			remove_typedefs(braces_open);
! 			remove_variables(braces_open--);
! 			if (braces_open == 0)
! 			{
! 				free(current_function);
! 				current_function = NULL;
! 			}
! 			fputs("}", yyout);
! 		}
                  ;
  
  CreateAsStmt: CREATE OptTemp TABLE create_as_target AS {FoundInto = 0;} SelectStmt opt_with_data
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 281,286 ****
--- 291,297 ----
  			char *cursor_marker = $2[0] == ':' ? make_str("$0") : mm_strdup($2);
  			struct variable *thisquery = (struct variable *)mm_alloc(sizeof(struct variable));
  			const char *con = connection ? connection : "NULL";
+ 			char *comment;
  
  			for (ptr = cur; ptr != NULL; ptr = ptr->next)
  			{
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 294,302 ****
--- 305,315 ----
  			/* initial definition */
  			this->next = cur;
  			this->name = $2;
+ 			this->function = (current_function ? mm_strdup(current_function) : NULL);
  			this->connection = connection;
  			this->command =  cat_str(6, make_str("declare"), cursor_marker, $3, make_str("cursor"), $5, make_str("for $1"));
  			this->argsresult = NULL;
+ 			this->argsresult_oos = NULL;
  
  			thisquery->type = &ecpg_query;
  			thisquery->brace_level = 0;
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 305,310 ****
--- 318,324 ----
  			sprintf(thisquery->name, "ECPGprepared_statement(%s, %s, __LINE__)", con, $7);
  
  			this->argsinsert = NULL;
+ 			this->argsinsert_oos = NULL;
  			if ($2[0] == ':')
  			{
  				struct variable *var = find_variable($2 + 1);
*************** ECPGCursorStmt:  DECLARE cursor_name cur
*** 315,324 ****
  
  			cur = this;
  
! 			if (INFORMIX_MODE && braces_open > 0) /* we're in a function */
! 				$$ = cat_str(4, make_str("ECPG_informix_reset_sqlca();"), make_str("/*"), mm_strdup(this->command), make_str("*/"));
  			else
! 				$$ = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/"));
  		}
  		;
  
--- 329,347 ----
  
  			cur = this;
  
! 			comment = cat_str(3, make_str("/*"), mm_strdup(this->command), make_str("*/"));
! 
! 			if ((braces_open > 0) && INFORMIX_MODE) /* we're in a function */
! 				$$ = cat_str(4,
! 					adjust_outofscope_cursor_vars(this, true),
! 					adjust_outofscope_cursor_vars(this, false),
! 					make_str("ECPG_informix_reset_sqlca();"),
! 					comment);
  			else
! 				$$ = cat_str(3,
! 					adjust_outofscope_cursor_vars(this, true),
! 					adjust_outofscope_cursor_vars(this, false),
! 					comment);
  		}
  		;
  
*************** var_declaration: storage_declaration
*** 402,407 ****
--- 425,431 ----
  		var_type
  		{
  			actual_type[struct_level].type_enum = $2.type_enum;
+ 			actual_type[struct_level].type_str = $2.type_str;
  			actual_type[struct_level].type_dimension = $2.type_dimension;
  			actual_type[struct_level].type_index = $2.type_index;
  			actual_type[struct_level].type_sizeof = $2.type_sizeof;
*************** var_declaration: storage_declaration
*** 415,420 ****
--- 439,445 ----
  		| var_type
  		{
  			actual_type[struct_level].type_enum = $1.type_enum;
+ 			actual_type[struct_level].type_str = $1.type_str;
  			actual_type[struct_level].type_dimension = $1.type_dimension;
  			actual_type[struct_level].type_index = $1.type_index;
  			actual_type[struct_level].type_sizeof = $1.type_sizeof;
*************** variable: opt_pointer ECPGColLabel opt_a
*** 826,834 ****
  				case ECPGt_struct:
  				case ECPGt_union:
  					if (atoi(dimension) < 0)
! 						type = ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_sizeof);
  					else
! 						type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_sizeof), dimension);
  
  					$$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
  					break;
--- 851,859 ----
  				case ECPGt_struct:
  				case ECPGt_union:
  					if (atoi(dimension) < 0)
! 						type = ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_str, actual_type[struct_level].type_sizeof);
  					else
! 						type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], actual_type[struct_level].type_enum, actual_type[struct_level].type_str, actual_type[struct_level].type_sizeof), dimension);
  
  					$$ = cat_str(5, $1, mm_strdup($2), $3.str, $4, $5);
  					break;
*************** ECPGVar: SQL_VAR
*** 1303,1311 ****
  					case ECPGt_struct:
  					case ECPGt_union:
  						if (atoi(dimension) < 0)
! 							type = ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_sizeof);
  						else
! 							type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum,$5.type_sizeof), dimension);
  						break;
  
  					case ECPGt_varchar:
--- 1328,1336 ----
  					case ECPGt_struct:
  					case ECPGt_union:
  						if (atoi(dimension) < 0)
! 							type = ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_str, $5.type_sizeof);
  						else
! 							type = ECPGmake_array_type(ECPGmake_struct_type(struct_member_list[struct_level], $5.type_enum, $5.type_str, $5.type_sizeof), dimension);
  						break;
  
  					case ECPGt_varchar:
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/extern.h pgsql.4.1/src/interfaces/ecpg/preproc/extern.h
*** pgsql.orig/src/interfaces/ecpg/preproc/extern.h	2010-01-05 18:02:03.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/extern.h	2010-01-19 19:13:35.000000000 +0100
*************** extern int	braces_open,
*** 26,34 ****
  			questionmarks,
  			ret_value,
  			struct_level,
! 			ecpg_informix_var,
  			regression_mode,
  			auto_prepare;
  extern char *descriptor_index;
  extern char *descriptor_name;
  extern char *connection;
--- 26,35 ----
  			questionmarks,
  			ret_value,
  			struct_level,
! 			ecpg_internal_var,
  			regression_mode,
  			auto_prepare;
+ extern char *current_function;
  extern char *descriptor_index;
  extern char *descriptor_name;
  extern char *connection;
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/pgc.l pgsql.4.1/src/interfaces/ecpg/preproc/pgc.l
*** pgsql.orig/src/interfaces/ecpg/preproc/pgc.l	2010-01-03 12:54:40.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/pgc.l	2010-01-19 19:13:35.000000000 +0100
*************** static char    *literalbuf = NULL;		/* e
*** 41,46 ****
--- 41,49 ----
  static int		literallen;				/* actual current length */
  static int		literalalloc;			/* current allocated buffer size */
  
+ /* Used for detecting global state together with braces_open */
+ static int		parenths_open;
+ 
  #define startlit()	(literalbuf[0] = '\0', literallen = 0)
  static void addlit(char *ytext, int yleng);
  static void addlitchar (unsigned char);
*************** cppline			{space}*#(.*\\{space})*.*{newl
*** 788,794 ****
  					}
  <C>{identifier} 	{
  						const ScanKeyword		*keyword;
! 							
  						/* Informix uses SQL defines only in SQL space */
  						/* however, some defines have to be taken care of for compatibility */
  						if ((!INFORMIX_MODE || !isinformixdefine()) && !isdefine())
--- 791,807 ----
  					}
  <C>{identifier} 	{
  						const ScanKeyword		*keyword;
! 
! 						/*
! 						 * Try to detect a function name:
! 						 * look for identifiers at the global scope
! 						 * keep the last identifier before the first '(' and '{' */
! 						if (braces_open == 0 && parenths_open == 0)
! 						{
! 							if (current_function)
! 								free(current_function);
! 							current_function = mm_strdup(yytext);
! 						}
  						/* Informix uses SQL defines only in SQL space */
  						/* however, some defines have to be taken care of for compatibility */
  						if ((!INFORMIX_MODE || !isinformixdefine()) && !isdefine())
*************** cppline			{space}*#(.*\\{space})*.*{newl
*** 811,818 ****
  <C>"/"				{ return('/'); }
  <C>"+"				{ return('+'); }
  <C>"-"				{ return('-'); }
! <C>"("				{ return('('); }
! <C>")"				{ return(')'); }
  <C,xskip>{space}		{ ECHO; }
  <C>\{				{ return('{'); }
  <C>\}				{ return('}'); }
--- 824,831 ----
  <C>"/"				{ return('/'); }
  <C>"+"				{ return('+'); }
  <C>"-"				{ return('-'); }
! <C>"("				{ parenths_open++; return('('); }
! <C>")"				{ parenths_open--; return(')'); }
  <C,xskip>{space}		{ ECHO; }
  <C>\{				{ return('{'); }
  <C>\}				{ return('}'); }
*************** void
*** 1178,1183 ****
--- 1191,1198 ----
  lex_init(void)
  {
  	braces_open = 0;
+ 	parenths_open = 0;
+ 	current_function = NULL;
  
  	preproc_tos = 0;
  	yylineno = 1;
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/type.c pgsql.4.1/src/interfaces/ecpg/preproc/type.c
*** pgsql.orig/src/interfaces/ecpg/preproc/type.c	2010-01-05 18:02:03.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/type.c	2010-01-19 19:13:35.000000000 +0100
*************** ECPGstruct_member_dup(struct ECPGstruct_
*** 46,52 ****
  		{
  			case ECPGt_struct:
  			case ECPGt_union:
! 				type = ECPGmake_struct_type(rm->type->u.members, rm->type->type, rm->type->struct_sizeof);
  				break;
  			case ECPGt_array:
  
--- 46,52 ----
  		{
  			case ECPGt_struct:
  			case ECPGt_union:
! 				type = ECPGmake_struct_type(rm->type->u.members, rm->type->type, rm->type->type_name, rm->type->struct_sizeof);
  				break;
  			case ECPGt_array:
  
*************** ECPGstruct_member_dup(struct ECPGstruct_
*** 55,61 ****
  				 * create the struct too
  				 */
  				if (rm->type->u.element->type == ECPGt_struct)
! 					type = ECPGmake_struct_type(rm->type->u.element->u.members, rm->type->u.element->type, rm->type->u.element->struct_sizeof);
  				else
  					type = ECPGmake_array_type(ECPGmake_simple_type(rm->type->u.element->type, rm->type->u.element->size, rm->type->u.element->lineno), rm->type->size);
  				break;
--- 55,61 ----
  				 * create the struct too
  				 */
  				if (rm->type->u.element->type == ECPGt_struct)
! 					type = ECPGmake_struct_type(rm->type->u.element->u.members, rm->type->u.element->type, rm->type->u.element->type_name, rm->type->u.element->struct_sizeof);
  				else
  					type = ECPGmake_array_type(ECPGmake_simple_type(rm->type->u.element->type, rm->type->u.element->size, rm->type->u.element->lineno), rm->type->size);
  				break;
*************** ECPGmake_simple_type(enum ECPGttype type
*** 98,103 ****
--- 98,104 ----
  	struct ECPGtype *ne = (struct ECPGtype *) mm_alloc(sizeof(struct ECPGtype));
  
  	ne->type = type;
+ 	ne->type_name = NULL;
  	ne->size = size;
  	ne->u.element = NULL;
  	ne->struct_sizeof = NULL;
*************** ECPGmake_array_type(struct ECPGtype * ty
*** 117,126 ****
  }
  
  struct ECPGtype *
! ECPGmake_struct_type(struct ECPGstruct_member * rm, enum ECPGttype type, char *struct_sizeof)
  {
  	struct ECPGtype *ne = ECPGmake_simple_type(type, make_str("1"), 0);
  
  	ne->u.members = ECPGstruct_member_dup(rm);
  	ne->struct_sizeof = struct_sizeof;
  
--- 118,128 ----
  }
  
  struct ECPGtype *
! ECPGmake_struct_type(struct ECPGstruct_member * rm, enum ECPGttype type, char *type_name, char *struct_sizeof)
  {
  	struct ECPGtype *ne = ECPGmake_simple_type(type, make_str("1"), 0);
  
+ 	ne->type_name = mm_strdup(type_name);
  	ne->u.members = ECPGstruct_member_dup(rm);
  	ne->struct_sizeof = struct_sizeof;
  
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/type.h pgsql.4.1/src/interfaces/ecpg/preproc/type.h
*** pgsql.orig/src/interfaces/ecpg/preproc/type.h	2009-06-13 18:25:05.000000000 +0200
--- pgsql.4.1/src/interfaces/ecpg/preproc/type.h	2010-01-19 19:13:35.000000000 +0100
*************** struct ECPGstruct_member
*** 17,22 ****
--- 17,23 ----
  struct ECPGtype
  {
  	enum ECPGttype type;
+ 	char	   *type_name;			/* For struct and union types it is the struct name */
  	char	   *size;			/* For array it is the number of elements. For
  								 * varchar it is the maxsize of the area. */
  	char	   *struct_sizeof;	/* For a struct this is the sizeof() type as
*************** void		ECPGmake_struct_member(char *, str
*** 36,42 ****
  struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, char *, int);
  struct ECPGtype *ECPGmake_varchar_type(enum ECPGttype, long);
  struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, char *);
! struct ECPGtype *ECPGmake_struct_type(struct ECPGstruct_member *, enum ECPGttype, char *);
  struct ECPGstruct_member *ECPGstruct_member_dup(struct ECPGstruct_member *);
  
  /* Frees a type. */
--- 37,43 ----
  struct ECPGtype *ECPGmake_simple_type(enum ECPGttype, char *, int);
  struct ECPGtype *ECPGmake_varchar_type(enum ECPGttype, long);
  struct ECPGtype *ECPGmake_array_type(struct ECPGtype *, char *);
! struct ECPGtype *ECPGmake_struct_type(struct ECPGstruct_member *, enum ECPGttype, char *, char *);
  struct ECPGstruct_member *ECPGstruct_member_dup(struct ECPGstruct_member *);
  
  /* Frees a type. */
*************** struct _include_path
*** 123,133 ****
--- 124,137 ----
  struct cursor
  {
  	char	   *name;
+ 	char	   *function;
  	char	   *command;
  	char	   *connection;
  	bool		opened;
  	struct arguments *argsinsert;
+ 	struct arguments *argsinsert_oos;
  	struct arguments *argsresult;
+ 	struct arguments *argsresult_oos;
  	struct cursor *next;
  };
  
diff -dcrpN pgsql.orig/src/interfaces/ecpg/preproc/variable.c pgsql.4.1/src/interfaces/ecpg/preproc/variable.c
*** pgsql.orig/src/interfaces/ecpg/preproc/variable.c	2009-11-26 18:57:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/preproc/variable.c	2010-01-19 19:13:35.000000000 +0100
*************** find_struct_member(char *name, char *str
*** 47,53 ****
  						return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->type, members->type->u.element->size, members->type->u.element->lineno), members->type->size), brace_level));
  					case ECPGt_struct:
  					case ECPGt_union:
! 						return (new_variable(name, ECPGmake_struct_type(members->type->u.members, members->type->type, members->type->struct_sizeof), brace_level));
  					default:
  						return (new_variable(name, ECPGmake_simple_type(members->type->type, members->type->size, members->type->lineno), brace_level));
  				}
--- 47,53 ----
  						return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->type, members->type->u.element->size, members->type->u.element->lineno), members->type->size), brace_level));
  					case ECPGt_struct:
  					case ECPGt_union:
! 						return (new_variable(name, ECPGmake_struct_type(members->type->u.members, members->type->type, members->type->type_name, members->type->struct_sizeof), brace_level));
  					default:
  						return (new_variable(name, ECPGmake_simple_type(members->type->type, members->type->size, members->type->lineno), brace_level));
  				}
*************** find_struct_member(char *name, char *str
*** 94,100 ****
  								return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->u.element->type, members->type->u.element->u.element->size, members->type->u.element->u.element->lineno), members->type->u.element->size), brace_level));
  							case ECPGt_struct:
  							case ECPGt_union:
! 								return (new_variable(name, ECPGmake_struct_type(members->type->u.element->u.members, members->type->u.element->type, members->type->u.element->struct_sizeof), brace_level));
  							default:
  								return (new_variable(name, ECPGmake_simple_type(members->type->u.element->type, members->type->u.element->size, members->type->u.element->lineno), brace_level));
  						}
--- 94,100 ----
  								return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(members->type->u.element->u.element->type, members->type->u.element->u.element->size, members->type->u.element->u.element->lineno), members->type->u.element->size), brace_level));
  							case ECPGt_struct:
  							case ECPGt_union:
! 								return (new_variable(name, ECPGmake_struct_type(members->type->u.element->u.members, members->type->u.element->type, members->type->u.element->type_name, members->type->u.element->struct_sizeof), brace_level));
  							default:
  								return (new_variable(name, ECPGmake_simple_type(members->type->u.element->type, members->type->u.element->size, members->type->u.element->lineno), brace_level));
  						}
*************** find_variable(char *name)
*** 235,241 ****
  						return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(p->type->u.element->u.element->type, p->type->u.element->u.element->size, p->type->u.element->u.element->lineno), p->type->u.element->size), p->brace_level));
  					case ECPGt_struct:
  					case ECPGt_union:
! 						return (new_variable(name, ECPGmake_struct_type(p->type->u.element->u.members, p->type->u.element->type, p->type->u.element->struct_sizeof), p->brace_level));
  					default:
  						return (new_variable(name, ECPGmake_simple_type(p->type->u.element->type, p->type->u.element->size, p->type->u.element->lineno), p->brace_level));
  				}
--- 235,241 ----
  						return (new_variable(name, ECPGmake_array_type(ECPGmake_simple_type(p->type->u.element->u.element->type, p->type->u.element->u.element->size, p->type->u.element->u.element->lineno), p->type->u.element->size), p->brace_level));
  					case ECPGt_struct:
  					case ECPGt_union:
! 						return (new_variable(name, ECPGmake_struct_type(p->type->u.element->u.members, p->type->u.element->type, p->type->u.element->type_name, p->type->u.element->struct_sizeof), p->brace_level));
  					default:
  						return (new_variable(name, ECPGmake_simple_type(p->type->u.element->type, p->type->u.element->size, p->type->u.element->lineno), p->brace_level));
  				}
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/compat_informix/Makefile pgsql.4.1/src/interfaces/ecpg/test/compat_informix/Makefile
*** pgsql.orig/src/interfaces/ecpg/test/compat_informix/Makefile	2010-01-15 12:55:25.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/compat_informix/Makefile	2010-01-19 19:20:05.000000000 +0100
*************** TESTS = test_informix test_informix.c \
*** 17,22 ****
--- 17,23 ----
          rfmtlong rfmtlong.c \
          rnull rnull.c \
          sqlda sqlda.c \
+         struct struct.c \
          describe describe.c \
          charfuncs charfuncs.c
  
*************** test_informix2.c: test_informix2.pgc ../
*** 31,36 ****
--- 32,40 ----
  sqlda.c: sqlda.pgc ../regression.h
  	$(ECPG) -o $@ -I$(srcdir) $<
  
+ struct.c: struct.pgc ../regression.h
+ 	$(ECPG) -o $@ -I$(srcdir) $<
+ 
  dec_test.c: dec_test.pgc ../regression.h
  	$(ECPG) -o $@ -I$(srcdir) $<
  
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/compat_informix/struct.h pgsql.4.1/src/interfaces/ecpg/test/compat_informix/struct.h
*** pgsql.orig/src/interfaces/ecpg/test/compat_informix/struct.h	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/compat_informix/struct.h	2010-01-19 19:18:56.000000000 +0100
***************
*** 0 ****
--- 1,18 ----
+ 
+ struct mytype {
+ 	int	id;
+ 	char	t[64];
+ 	double	d1; /* dec_t */
+ 	double	d2;
+ 	char	c[30];
+ };
+ typedef struct mytype MYTYPE;
+ 
+ struct mynulltype {
+ 	int	id;
+ 	int	t;
+ 	int	d1;
+ 	int	d2;
+ 	int	c;
+ };
+ typedef struct mynulltype MYNULLTYPE;
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/compat_informix/struct.pgc pgsql.4.1/src/interfaces/ecpg/test/compat_informix/struct.pgc
*** pgsql.orig/src/interfaces/ecpg/test/compat_informix/struct.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/compat_informix/struct.pgc	2010-01-19 19:18:56.000000000 +0100
***************
*** 0 ****
--- 1,76 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql begin declare section;
+ exec sql include struct.h;
+ exec sql end declare section;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ int
+ main (void)
+ {
+ 	exec sql begin declare section;
+ 	MYTYPE		myvar;
+ 	MYNULLTYPE	mynullvar;
+ 	exec sql end declare section;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table a1(id serial primary key, t text, d1 numeric, d2 float8, c character(10));
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, 'a', 1.0, 2, 'a');
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, null, null, null, null);
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, '"a"', -1.0, 'nan'::float8, 'a');
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, 'b', 2.0, 3, 'b');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* Test DECLARE ... SELECT ... INTO with struct type */
+ 
+ 	exec sql declare mycur cursor for select * into :myvar :mynullvar from a1;
+ 	exec sql open mycur;
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	while (1)
+ 	{
+ 		memset(&myvar, 0, sizeof(myvar));
+ 		exec sql fetch mycur;
+ 		printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+ 			myvar.id, mynullvar.id ? " (NULL)" : "",
+ 			myvar.t, mynullvar.t ? " (NULL)" : "",
+ 			myvar.d1, mynullvar.d1 ? " (NULL)" : "",
+ 			myvar.d2, mynullvar.d2 ? " (NULL)" : "",
+ 			myvar.c, mynullvar.c ? " (NULL)" : "");
+ 	}
+ 
+ 	exec sql close mycur;
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table a1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule pgsql.4.1/src/interfaces/ecpg/test/ecpg_schedule
*** pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule	2010-01-15 12:55:25.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/ecpg_schedule	2010-01-19 19:21:55.000000000 +0100
*************** test: compat_informix/rfmtlong
*** 5,10 ****
--- 5,11 ----
  test: compat_informix/rnull
  test: compat_informix/sqlda
  test: compat_informix/describe
+ test: compat_informix/struct
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: preproc/init
*** 24,29 ****
--- 25,31 ----
  test: preproc/strings
  test: preproc/type
  test: preproc/variable
+ test: preproc/outofscope
  test: preproc/whenever
  test: sql/array
  test: sql/binary
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule_tcp pgsql.4.1/src/interfaces/ecpg/test/ecpg_schedule_tcp
*** pgsql.orig/src/interfaces/ecpg/test/ecpg_schedule_tcp	2010-01-15 12:55:25.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/ecpg_schedule_tcp	2010-01-19 19:20:51.000000000 +0100
*************** test: compat_informix/rfmtlong
*** 5,10 ****
--- 5,11 ----
  test: compat_informix/rnull
  test: compat_informix/sqlda
  test: compat_informix/describe
+ test: compat_informix/struct
  test: compat_informix/test_informix
  test: compat_informix/test_informix2
  test: connect/test2
*************** test: preproc/init
*** 24,29 ****
--- 25,31 ----
  test: preproc/strings
  test: preproc/type
  test: preproc/variable
+ test: preproc/outofscope
  test: preproc/whenever
  test: sql/array
  test: sql/binary
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-struct.c pgsql.4.1/src/interfaces/ecpg/test/expected/compat_informix-struct.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-struct.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/compat_informix-struct.c	2010-01-19 19:24:09.000000000 +0100
***************
*** 0 ****
--- 1,265 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* Needed for informix compatibility */
+ #include <ecpg_informix.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "struct.pgc"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 5 "struct.pgc"
+ 
+ 
+ /* exec sql begin declare section */
+ 
+ #line 1 "struct.h"
+ 
+   
+ 		
+ 		
+ 		 /* dec_t */
+ 		
+ 		
+ 
+    typedef struct mytype  MYTYPE ;
+ 
+ #line 9 "struct.h"
+ 
+ 
+   
+ 		
+ 		
+ 		
+ 		
+ 		
+ 
+    typedef struct mynulltype  MYNULLTYPE ;
+ 
+ #line 18 "struct.h"
+ 
+ 
+ #line 8 "struct.pgc"
+ 
+ struct mytype { 
+ #line 3 "struct.h"
+  int id ;
+  
+ #line 4 "struct.h"
+  char t [ 64 ] ;
+  
+ #line 5 "struct.h"
+  double d1 ;
+  
+ #line 6 "struct.h"
+  double d2 ;
+  
+ #line 7 "struct.h"
+  char c [ 30 ] ;
+  } ; struct mynulltype { 
+ #line 12 "struct.h"
+  int id ;
+  
+ #line 13 "struct.h"
+  int t ;
+  
+ #line 14 "struct.h"
+  int d1 ;
+  
+ #line 15 "struct.h"
+  int d2 ;
+  
+ #line 16 "struct.h"
+  int c ;
+  } ;/* exec sql end declare section */
+ #line 9 "struct.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 11 "struct.pgc"
+ 
+ 
+ int
+ main (void)
+ {
+ 	/* exec sql begin declare section */
+ 			
+ 		
+ 	
+ #line 17 "struct.pgc"
+  MYTYPE myvar ;
+  
+ #line 18 "struct.pgc"
+  MYNULLTYPE mynullvar ;
+ /* exec sql end declare section */
+ #line 19 "struct.pgc"
+ 
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 1, "regress1" , NULL, NULL , NULL, 0); 
+ #line 26 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 26 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 29 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 29 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
+ #line 32 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 32 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 35 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 35 "struct.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null )", ECPGt_EOIT, ECPGt_EORT);
+ #line 36 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 36 "struct.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , '\"a\"' , - 1.0 , 'nan' :: float8 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 37 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 37 "struct.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 38 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 38 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 41 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 41 "struct.pgc"
+ 
+ 
+ 	/* Test DECLARE ... SELECT ... INTO with struct type */
+ 
+ 	ECPGset_var( 0, &( myvar ), __LINE__);\
+  ECPGset_var( 1, &( mynullvar ), __LINE__);\
+  ECPG_informix_reset_sqlca(); /* declare mycur cursor for select * from a1 */
+ #line 45 "struct.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT, 
+ 	ECPGt_int,&(myvar.id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&(mynullvar.id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&(myvar.t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_int,&(mynullvar.t),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&(myvar.d1),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&(mynullvar.d1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&(myvar.d2),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&(mynullvar.d2),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&(myvar.c),(long)30,(long)1,(30)*sizeof(char), 
+ 	ECPGt_int,&(mynullvar.c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 46 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 46 "struct.pgc"
+ 
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 48 "struct.pgc"
+ 
+ 
+ 	while (1)
+ 	{
+ 		memset(&myvar, 0, sizeof(myvar));
+ 		{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "fetch mycur", ECPGt_EOIT, 
+ 	ECPGt_int,&(myvar.id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&(mynullvar.id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&(myvar.t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_int,&(mynullvar.t),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&(myvar.d1),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&(mynullvar.d1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&(myvar.d2),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&(mynullvar.d2),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&(myvar.c),(long)30,(long)1,(30)*sizeof(char), 
+ 	ECPGt_int,&(mynullvar.c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 53 "struct.pgc"
+ 
+ if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
+ #line 53 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 53 "struct.pgc"
+ 
+ 		printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+ 			myvar.id, mynullvar.id ? " (NULL)" : "",
+ 			myvar.t, mynullvar.t ? " (NULL)" : "",
+ 			myvar.d1, mynullvar.d1 ? " (NULL)" : "",
+ 			myvar.d2, mynullvar.d2 ? " (NULL)" : "",
+ 			myvar.c, mynullvar.c ? " (NULL)" : "");
+ 	}
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "close mycur", ECPGt_EOIT, ECPGt_EORT);
+ #line 62 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 62 "struct.pgc"
+ 
+ 
+ 	/* End test */
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "drop table a1", ECPGt_EOIT, ECPGt_EORT);
+ #line 67 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 67 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 70 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 70 "struct.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 73 "struct.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 73 "struct.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-struct.stderr pgsql.4.1/src/interfaces/ecpg/test/expected/compat_informix-struct.stderr
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-struct.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/compat_informix-struct.stderr	2010-01-19 19:24:09.000000000 +0100
***************
*** 0 ****
--- 1,136 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 29: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: query: create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 32: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 35: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 36: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , '"a"' , - 1.0 , 'nan' :: float8 , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 37: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 38: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 41: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 46: query: declare mycur cursor for select * from a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 46: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 46: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: "a" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: -1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 2.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 53: RESULT: b          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 53: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 53: no data found on line 53
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 62: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 62: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 67: query: drop table a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 67: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 67: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 70: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-struct.stdout pgsql.4.1/src/interfaces/ecpg/test/expected/compat_informix-struct.stdout
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-struct.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/compat_informix-struct.stdout	2010-01-19 19:24:09.000000000 +0100
***************
*** 0 ****
--- 1,4 ----
+ id=1 t='a' d1=1.000000 d2=2.000000 c = 'a         '
+ id=2 t='' (NULL) d1=0.000000 (NULL) d2=0.000000 (NULL) c = '' (NULL)
+ id=3 t='"a"' d1=-1.000000 d2=nan c = 'a         '
+ id=4 t='b' d1=2.000000 d2=3.000000 c = 'b         '
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c pgsql.4.1/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c	2009-11-11 20:47:12.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/compat_informix-test_informix.c	2010-01-19 19:13:35.000000000 +0100
*************** if (sqlca.sqlcode < 0) dosqlprint ( );}
*** 147,153 ****
  
  
  	sqlca.sqlcode = 100;
! 	ECPG_informix_set_var( 0, &( i ), __LINE__);\
   ECPG_informix_reset_sqlca(); /* declare c cursor for select * from test where i <= $1  */
  #line 49 "test_informix.pgc"
  
--- 147,153 ----
  
  
  	sqlca.sqlcode = 100;
! 	ECPGset_var( 0, &( i ), __LINE__);\
   ECPG_informix_reset_sqlca(); /* declare c cursor for select * from test where i <= $1  */
  #line 49 "test_informix.pgc"
  
*************** if (sqlca.sqlcode < 0) dosqlprint ( );}
*** 245,251 ****
  static void openit(void)
  {
  	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare c cursor for select * from test where i <= $1 ", 
! 	ECPGt_int,&(*( int  *)(ECPG_informix_get_var( 0))),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 95 "test_informix.pgc"
  
--- 245,251 ----
  static void openit(void)
  {
  	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare c cursor for select * from test where i <= $1 ", 
! 	ECPGt_int,&(*( int  *)(ECPGget_var( 0))),(long)1,(long)1,sizeof(int), 
  	ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
  #line 95 "test_informix.pgc"
  
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/preproc-cursor.c pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-cursor.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/preproc-cursor.c	2009-11-26 16:55:57.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-cursor.c	2010-01-19 19:13:35.000000000 +0100
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 153,159 ****
  	/* Dynamic cursorname test with INTO list in FETCH stmts */
  
  	strcpy(msg, "declare");
! 	/* declare $0 cursor for select id , t from t1 */
  #line 59 "cursor.pgc"
  
  
--- 153,160 ----
  	/* Dynamic cursorname test with INTO list in FETCH stmts */
  
  	strcpy(msg, "declare");
! 	ECPGset_var( 0, &( curname1 ), __LINE__);\
!  /* declare $0 cursor for select id , t from t1 */
  #line 59 "cursor.pgc"
  
  
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 286,292 ****
  	/* Dynamic cursorname test with INTO list in DECLARE stmt */
  
  	strcpy(msg, "declare");
! 	/* declare $0 cursor for select id , t from t1 */
  #line 100 "cursor.pgc"
  
  
--- 287,296 ----
  	/* Dynamic cursorname test with INTO list in DECLARE stmt */
  
  	strcpy(msg, "declare");
! 	ECPGset_var( 3, &( curname2 ), __LINE__);\
!  ECPGset_var( 1, ( t ), __LINE__);\
!  ECPGset_var( 2, &( id ), __LINE__);\
!  /* declare $0 cursor for select id , t from t1 */
  #line 100 "cursor.pgc"
  
  
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 435,441 ****
  
  
  	strcpy(msg, "declare");
! 	/* declare $0 cursor for $1 */
  #line 143 "cursor.pgc"
  
  
--- 439,446 ----
  
  
  	strcpy(msg, "declare");
! 	ECPGset_var( 4, &( curname3 ), __LINE__);\
!  /* declare $0 cursor for $1 */
  #line 143 "cursor.pgc"
  
  
*************** if (sqlca.sqlcode < 0) exit (1);}
*** 590,596 ****
  
  
  	strcpy(msg, "declare");
! 	/* declare $0 cursor for $1 */
  #line 193 "cursor.pgc"
  
  
--- 595,602 ----
  
  
  	strcpy(msg, "declare");
! 	ECPGset_var( 5, &( curname4 ), __LINE__);\
!  /* declare $0 cursor for $1 */
  #line 193 "cursor.pgc"
  
  
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/preproc-outofscope.c pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-outofscope.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/preproc-outofscope.c	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-outofscope.c	2010-01-19 19:28:31.000000000 +0100
***************
*** 0 ****
--- 1,379 ----
+ /* Processed by ecpg (regression mode) */
+ /* These include files are added by the preprocessor */
+ #include <ecpglib.h>
+ #include <ecpgerrno.h>
+ #include <sqlca.h>
+ /* End of automatic include section */
+ #define ECPGdebug(X,Y) ECPGdebug((X)+100,(Y))
+ 
+ #line 1 "outofscope.pgc"
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <limits.h>
+ 
+ 
+ #line 1 "regression.h"
+ 
+ 
+ 
+ 
+ 
+ 
+ #line 6 "outofscope.pgc"
+ 
+ 
+ 
+ #line 1 "pgtypes_numeric.h"
+ #ifndef PGTYPES_NUMERIC
+ #define PGTYPES_NUMERIC
+ 
+ #define NUMERIC_POS						0x0000
+ #define NUMERIC_NEG						0x4000
+ #define NUMERIC_NAN						0xC000
+ #define NUMERIC_MAX_PRECISION			1000
+ #define NUMERIC_MAX_DISPLAY_SCALE		NUMERIC_MAX_PRECISION
+ #define NUMERIC_MIN_DISPLAY_SCALE		0
+ #define NUMERIC_MIN_SIG_DIGITS			16
+ 
+ #define DECSIZE 30
+ 
+ typedef unsigned char NumericDigit;
+ typedef struct
+ {
+ 	int			ndigits;		/* number of digits in digits[] - can be 0! */
+ 	int			weight;			/* weight of first digit */
+ 	int			rscale;			/* result scale */
+ 	int			dscale;			/* display scale */
+ 	int			sign;			/* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
+ 	NumericDigit *buf;			/* start of alloc'd space for digits[] */
+ 	NumericDigit *digits;		/* decimal digits */
+ } numeric;
+ 
+ typedef struct
+ {
+ 	int			ndigits;		/* number of digits in digits[] - can be 0! */
+ 	int			weight;			/* weight of first digit */
+ 	int			rscale;			/* result scale */
+ 	int			dscale;			/* display scale */
+ 	int			sign;			/* NUMERIC_POS, NUMERIC_NEG, or NUMERIC_NAN */
+ 	NumericDigit digits[DECSIZE];		/* decimal digits */
+ } decimal;
+ 
+ #ifdef __cplusplus
+ extern		"C"
+ {
+ #endif
+ 
+ numeric    *PGTYPESnumeric_new(void);
+ decimal    *PGTYPESdecimal_new(void);
+ void		PGTYPESnumeric_free(numeric *);
+ void		PGTYPESdecimal_free(decimal *);
+ numeric    *PGTYPESnumeric_from_asc(char *, char **);
+ char	   *PGTYPESnumeric_to_asc(numeric *, int);
+ int			PGTYPESnumeric_add(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_sub(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_mul(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_div(numeric *, numeric *, numeric *);
+ int			PGTYPESnumeric_cmp(numeric *, numeric *);
+ int			PGTYPESnumeric_from_int(signed int, numeric *);
+ int			PGTYPESnumeric_from_long(signed long int, numeric *);
+ int			PGTYPESnumeric_copy(numeric *, numeric *);
+ int			PGTYPESnumeric_from_double(double, numeric *);
+ int			PGTYPESnumeric_to_double(numeric *, double *);
+ int			PGTYPESnumeric_to_int(numeric *, int *);
+ int			PGTYPESnumeric_to_long(numeric *, long *);
+ int			PGTYPESnumeric_to_decimal(numeric *, decimal *);
+ int			PGTYPESnumeric_from_decimal(decimal *, numeric *);
+ 
+ #ifdef __cplusplus
+ }
+ #endif
+ 
+ #endif   /* PGTYPES_NUMERIC */
+ 
+ #line 8 "outofscope.pgc"
+ 
+ 
+ /* exec sql begin declare section */
+ 
+ #line 1 "struct.h"
+ 
+   
+ 		
+ 		
+ 		 /* dec_t */
+ 		
+ 		
+ 
+    typedef struct mytype  MYTYPE ;
+ 
+ #line 9 "struct.h"
+ 
+ 
+   
+ 		
+ 		
+ 		
+ 		
+ 		
+ 
+    typedef struct mynulltype  MYNULLTYPE ;
+ 
+ #line 18 "struct.h"
+ 
+ 
+ #line 11 "outofscope.pgc"
+ 
+ struct mytype { 
+ #line 3 "struct.h"
+  int id ;
+  
+ #line 4 "struct.h"
+  char t [ 64 ] ;
+  
+ #line 5 "struct.h"
+  double d1 ;
+  
+ #line 6 "struct.h"
+  double d2 ;
+  
+ #line 7 "struct.h"
+  char c [ 30 ] ;
+  } ; struct mynulltype { 
+ #line 12 "struct.h"
+  int id ;
+  
+ #line 13 "struct.h"
+  int t ;
+  
+ #line 14 "struct.h"
+  int d1 ;
+  
+ #line 15 "struct.h"
+  int d2 ;
+  
+ #line 16 "struct.h"
+  int c ;
+  } ;/* exec sql end declare section */
+ #line 12 "outofscope.pgc"
+ 
+ 
+ /* exec sql whenever sqlerror  stop ; */
+ #line 14 "outofscope.pgc"
+ 
+ 
+ /* Functions for test 1 */
+ 
+ static void
+ get_var1(MYTYPE **myvar0, MYNULLTYPE **mynullvar0)
+ {
+ 	/* exec sql begin declare section */
+ 			  
+ 		  
+ 	
+ #line 22 "outofscope.pgc"
+  MYTYPE * myvar = malloc ( sizeof ( MYTYPE ) ) ;
+  
+ #line 23 "outofscope.pgc"
+  MYNULLTYPE * mynullvar = malloc ( sizeof ( MYNULLTYPE ) ) ;
+ /* exec sql end declare section */
+ #line 24 "outofscope.pgc"
+ 
+ 
+ 	/* Test DECLARE ... SELECT ... INTO with pointers */
+ 
+ 	ECPGset_var( 0, ( myvar ), __LINE__);\
+  ECPGset_var( 1, ( mynullvar ), __LINE__);\
+  /* declare mycur cursor for select * from a1 */
+ #line 28 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ 
+ 	*myvar0 = myvar;
+ 	*mynullvar0 = mynullvar;
+ }
+ 
+ static void
+ open_cur1(void)
+ {
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT, 
+ 	ECPGt_int,&((*( MYTYPE  *)(ECPGget_var( 0))).id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&((*( MYTYPE  *)(ECPGget_var( 0))).t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).t),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&((*( MYTYPE  *)(ECPGget_var( 0))).d1),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).d1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&((*( MYTYPE  *)(ECPGget_var( 0))).d2),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).d2),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&((*( MYTYPE  *)(ECPGget_var( 0))).c),(long)30,(long)1,(30)*sizeof(char), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 40 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 40 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ get_record1(void)
+ {
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "fetch mycur", ECPGt_EOIT, 
+ 	ECPGt_int,&((*( MYTYPE  *)(ECPGget_var( 0))).id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).id),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&((*( MYTYPE  *)(ECPGget_var( 0))).t),(long)64,(long)1,(64)*sizeof(char), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).t),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&((*( MYTYPE  *)(ECPGget_var( 0))).d1),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).d1),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_double,&((*( MYTYPE  *)(ECPGget_var( 0))).d2),(long)1,(long)1,sizeof(double), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).d2),(long)1,(long)1,sizeof(int), 
+ 	ECPGt_char,&((*( MYTYPE  *)(ECPGget_var( 0))).c),(long)30,(long)1,(30)*sizeof(char), 
+ 	ECPGt_int,&((*( MYNULLTYPE  *)(ECPGget_var( 1))).c),(long)1,(long)1,sizeof(int), ECPGt_EORT);
+ #line 49 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 49 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0 && sqlca.sqlcode != ECPG_NOT_FOUND)
+ 		exit(1);
+ }
+ 
+ static void
+ close_cur1(void)
+ {
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "close mycur", ECPGt_EOIT, ECPGt_EORT);
+ #line 58 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 58 "outofscope.pgc"
+ 
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ int
+ main (void)
+ {
+ 	MYTYPE		*myvar;
+ 	MYNULLTYPE	*mynullvar;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	{ ECPGconnect(__LINE__, 0, "regress1" , NULL, NULL , NULL, 0); 
+ #line 75 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 75 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "set");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
+ #line 78 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 78 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "create");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) )", ECPGt_EOIT, ECPGt_EORT);
+ #line 81 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 81 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "insert");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 84 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 84 "outofscope.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null )", ECPGt_EOIT, ECPGt_EORT);
+ #line 85 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 85 "outofscope.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , '\"a\"' , - 1.0 , 'nan' :: float8 , 'a' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 86 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 86 "outofscope.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' )", ECPGt_EOIT, ECPGt_EORT);
+ #line 87 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 87 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 90 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 90 "outofscope.pgc"
+ 
+ 
+ 	/* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE */
+ 
+ 	get_var1(&myvar, &mynullvar);
+ 	open_cur1();
+ 
+ 	/* exec sql whenever not found  break ; */
+ #line 97 "outofscope.pgc"
+ 
+ 
+ 	while (1)
+ 	{
+ 		memset(myvar, 0, sizeof(MYTYPE));
+ 		get_record1();
+ 		if (sqlca.sqlcode == ECPG_NOT_FOUND)
+ 			break;
+ 		printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+ 			myvar->id, mynullvar->id ? " (NULL)" : "",
+ 			myvar->t, mynullvar->t ? " (NULL)" : "",
+ 			myvar->d1, mynullvar->d1 ? " (NULL)" : "",
+ 			myvar->d2, mynullvar->d2 ? " (NULL)" : "",
+ 			myvar->c, mynullvar->c ? " (NULL)" : "");
+ 	}
+ 
+ 	close_cur1();
+ 
+ 	strcpy(msg, "drop");
+ 	{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "drop table a1", ECPGt_EOIT, ECPGt_EORT);
+ #line 116 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 116 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "commit");
+ 	{ ECPGtrans(__LINE__, NULL, "commit");
+ #line 119 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 119 "outofscope.pgc"
+ 
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	{ ECPGdisconnect(__LINE__, "CURRENT");
+ #line 122 "outofscope.pgc"
+ 
+ if (sqlca.sqlcode < 0) exit (1);}
+ #line 122 "outofscope.pgc"
+ 
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr
*** pgsql.orig/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-outofscope.stderr	2010-01-19 19:28:31.000000000 +0100
***************
*** 0 ****
--- 1,136 ----
+ [NO_PID]: ECPGdebug: set to 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>  
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 78: query: set datestyle to iso; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 78: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 78: OK: SET
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 81: query: create table a1 ( id serial primary key , t text , d1 numeric , d2 float8 , c character ( 10 ) ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 81: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 81: OK: CREATE TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 84: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'a' , 1.0 , 2 , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 84: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 84: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , null , null , null , null ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 85: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 86: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , '"a"' , - 1.0 , 'nan' :: float8 , 'a' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 86: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 86: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 87: query: insert into a1 ( id , t , d1 , d2 , c ) values ( default , 'b' , 2.0 , 3 , 'b' ); with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 87: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 87: OK: INSERT 0 1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 90: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 40: query: declare mycur cursor for select * from a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 40: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 40: OK: DECLARE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 49: RESULT: 1 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 49: RESULT: a offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 49: RESULT: 1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 49: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 49: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 49: RESULT: 2 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 49: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 49: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 49: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 49: RESULT:  offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 49: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 49: RESULT: "a" offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 49: RESULT: -1.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 49: RESULT: NaN offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 49: RESULT: a          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: correctly got 1 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 49: RESULT: 4 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 49: RESULT: b offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 49: RESULT: 2.0 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 49: RESULT: 3 offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_get_data on line 49: RESULT: b          offset: -1; array: yes
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: query: fetch mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 49: correctly got 0 tuples with 5 fields
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: raising sqlcode 100 on line 49: no data found on line 49
+ [NO_PID]: sqlca: code: 100, state: 02000
+ [NO_PID]: ecpg_execute on line 58: query: close mycur; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 58: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 58: OK: CLOSE CURSOR
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: query: drop table a1; with 0 parameter(s) on connection regress1
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: using PQexec
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_execute on line 116: OK: DROP TABLE
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ECPGtrans on line 119: action "commit"; connection "regress1"
+ [NO_PID]: sqlca: code: 0, state: 00000
+ [NO_PID]: ecpg_finish: connection regress1 closed
+ [NO_PID]: sqlca: code: 0, state: 00000
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/preproc-outofscope.stdout pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-outofscope.stdout
*** pgsql.orig/src/interfaces/ecpg/test/expected/preproc-outofscope.stdout	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/expected/preproc-outofscope.stdout	2010-01-19 19:28:31.000000000 +0100
***************
*** 0 ****
--- 1,4 ----
+ id=1 t='a' d1=1.000000 d2=2.000000 c = 'a         '
+ id=2 t='' (NULL) d1=0.000000 (NULL) d2=0.000000 (NULL) c = '' (NULL)
+ id=3 t='"a"' d1=-1.000000 d2=nan c = 'a         '
+ id=4 t='b' d1=2.000000 d2=3.000000 c = 'b         '
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/sql-binary.c pgsql.4.1/src/interfaces/ecpg/test/expected/sql-binary.c
*** pgsql.orig/src/interfaces/ecpg/test/expected/sql-binary.c	2009-08-07 13:06:28.000000000 +0200
--- pgsql.4.1/src/interfaces/ecpg/test/expected/sql-binary.c	2010-01-19 19:13:35.000000000 +0100
*************** main (void)
*** 107,113 ****
        exit (sqlca.sqlcode);
      }
  
!   /* declare C cursor for select name , accs , byte from empl where idnum = $1  */
  #line 58 "binary.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select name , accs , byte from empl where idnum = $1 ", 
--- 107,114 ----
        exit (sqlca.sqlcode);
      }
  
!   ECPGset_var( 0, &( empl.idnum ), __LINE__);\
!  /* declare C cursor for select name , accs , byte from empl where idnum = $1  */
  #line 58 "binary.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare C cursor for select name , accs , byte from empl where idnum = $1 ", 
*************** main (void)
*** 133,139 ****
    printf ("name=%s, accs=%d byte=%s\n", empl.name, empl.accs, empl.byte);
  
    memset(empl.name, 0, 21L);
!   /* declare B binary cursor for select name , accs , byte from empl where idnum = $1  */
  #line 70 "binary.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare B binary cursor for select name , accs , byte from empl where idnum = $1 ", 
--- 134,141 ----
    printf ("name=%s, accs=%d byte=%s\n", empl.name, empl.accs, empl.byte);
  
    memset(empl.name, 0, 21L);
!   ECPGset_var( 1, &( empl.idnum ), __LINE__);\
!  /* declare B binary cursor for select name , accs , byte from empl where idnum = $1  */
  #line 70 "binary.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare B binary cursor for select name , accs , byte from empl where idnum = $1 ", 
*************** main (void)
*** 166,172 ****
  	printf("(%o)", (unsigned char)empl.byte[i]);
    printf("\n");
  
!   /* declare A binary cursor for select byte from empl where idnum = $1  */
  #line 87 "binary.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare A binary cursor for select byte from empl where idnum = $1 ", 
--- 168,175 ----
  	printf("(%o)", (unsigned char)empl.byte[i]);
    printf("\n");
  
!   ECPGset_var( 2, &( empl.idnum ), __LINE__);\
!  /* declare A binary cursor for select byte from empl where idnum = $1  */
  #line 87 "binary.pgc"
  
    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare A binary cursor for select byte from empl where idnum = $1 ", 
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/preproc/Makefile pgsql.4.1/src/interfaces/ecpg/test/preproc/Makefile
*** pgsql.orig/src/interfaces/ecpg/test/preproc/Makefile	2009-11-26 18:57:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/preproc/Makefile	2010-01-19 19:20:16.000000000 +0100
*************** TESTS = array_of_struct array_of_struct.
*** 11,16 ****
--- 11,17 ----
  	define define.c \
  	init init.c \
  	strings strings.c \
+ 	outofscope outofscope.c \
  	type type.c \
  	variable variable.c \
  	whenever whenever.c
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/preproc/outofscope.pgc pgsql.4.1/src/interfaces/ecpg/test/preproc/outofscope.pgc
*** pgsql.orig/src/interfaces/ecpg/test/preproc/outofscope.pgc	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/preproc/outofscope.pgc	2010-01-19 19:27:29.000000000 +0100
***************
*** 0 ****
--- 1,125 ----
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <limits.h>
+ 
+ exec sql include ../regression;
+ 
+ exec sql include pgtypes_numeric.h;
+ 
+ exec sql begin declare section;
+ exec sql include struct.h;
+ exec sql end declare section;
+ 
+ exec sql whenever sqlerror stop;
+ 
+ /* Functions for test 1 */
+ 
+ static void
+ get_var1(MYTYPE **myvar0, MYNULLTYPE **mynullvar0)
+ {
+ 	exec sql begin declare section;
+ 	MYTYPE		*myvar = malloc(sizeof(MYTYPE));
+ 	MYNULLTYPE	*mynullvar = malloc(sizeof(MYNULLTYPE));
+ 	exec sql end declare section;
+ 
+ 	/* Test DECLARE ... SELECT ... INTO with pointers */
+ 
+ 	exec sql declare mycur cursor for select * INTO :myvar :mynullvar from a1;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ 
+ 	*myvar0 = myvar;
+ 	*mynullvar0 = mynullvar;
+ }
+ 
+ static void
+ open_cur1(void)
+ {
+ 	exec sql open mycur;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ static void
+ get_record1(void)
+ {
+ 	exec sql fetch mycur;
+ 
+ 	if (sqlca.sqlcode != 0 && sqlca.sqlcode != ECPG_NOT_FOUND)
+ 		exit(1);
+ }
+ 
+ static void
+ close_cur1(void)
+ {
+ 	exec sql close mycur;
+ 
+ 	if (sqlca.sqlcode != 0)
+ 		exit(1);
+ }
+ 
+ int
+ main (void)
+ {
+ 	MYTYPE		*myvar;
+ 	MYNULLTYPE	*mynullvar;
+ 
+ 	char msg[128];
+ 
+ 	ECPGdebug(1, stderr);
+ 
+ 	strcpy(msg, "connect");
+ 	exec sql connect to REGRESSDB1;
+ 
+ 	strcpy(msg, "set");
+ 	exec sql set datestyle to iso;
+ 
+ 	strcpy(msg, "create");
+ 	exec sql create table a1(id serial primary key, t text, d1 numeric, d2 float8, c character(10));
+ 
+ 	strcpy(msg, "insert");
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, 'a', 1.0, 2, 'a');
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, null, null, null, null);
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, '"a"', -1.0, 'nan'::float8, 'a');
+ 	exec sql insert into a1(id, t, d1, d2, c) values (default, 'b', 2.0, 3, 'b');
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	/* Test out-of-scope DECLARE/OPEN/FETCH/CLOSE */
+ 
+ 	get_var1(&myvar, &mynullvar);
+ 	open_cur1();
+ 
+ 	exec sql whenever not found do break;
+ 
+ 	while (1)
+ 	{
+ 		memset(myvar, 0, sizeof(MYTYPE));
+ 		get_record1();
+ 		if (sqlca.sqlcode == ECPG_NOT_FOUND)
+ 			break;
+ 		printf("id=%d%s t='%s'%s d1=%lf%s d2=%lf%s c = '%s'%s\n",
+ 			myvar->id, mynullvar->id ? " (NULL)" : "",
+ 			myvar->t, mynullvar->t ? " (NULL)" : "",
+ 			myvar->d1, mynullvar->d1 ? " (NULL)" : "",
+ 			myvar->d2, mynullvar->d2 ? " (NULL)" : "",
+ 			myvar->c, mynullvar->c ? " (NULL)" : "");
+ 	}
+ 
+ 	close_cur1();
+ 
+ 	strcpy(msg, "drop");
+ 	exec sql drop table a1;
+ 
+ 	strcpy(msg, "commit");
+ 	exec sql commit;
+ 
+ 	strcpy(msg, "disconnect"); 
+ 	exec sql disconnect;
+ 
+ 	return (0);
+ }
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/preproc/struct.h pgsql.4.1/src/interfaces/ecpg/test/preproc/struct.h
*** pgsql.orig/src/interfaces/ecpg/test/preproc/struct.h	1970-01-01 01:00:00.000000000 +0100
--- pgsql.4.1/src/interfaces/ecpg/test/preproc/struct.h	2010-01-19 19:13:35.000000000 +0100
***************
*** 0 ****
--- 1,18 ----
+ 
+ struct mytype {
+ 	int	id;
+ 	char	t[64];
+ 	double	d1; /* dec_t */
+ 	double	d2;
+ 	char	c[30];
+ };
+ typedef struct mytype MYTYPE;
+ 
+ struct mynulltype {
+ 	int	id;
+ 	int	t;
+ 	int	d1;
+ 	int	d2;
+ 	int	c;
+ };
+ typedef struct mynulltype MYNULLTYPE;
#102Takahiro Itagaki
itagaki.takahiro@oss.ntt.co.jp
In reply to: Boszormenyi Zoltan (#98)
Re: Fix auto-prepare #2

Boszormenyi Zoltan <zb@cybertec.at> wrote:

I only wanted to call ECPGprepare() in case it wasn't already prepared.
ECPGprepare() also checks for the statement being already prepared
with ecpg_find_prepared_statement() but in case it exists it
DEALLOCATEs the statement and PREPAREs again so there's
would be no saving for auto-prepare calling it unconditionally and
we are doing a little extra work by calling ecpg_find_prepared_statement()
twice. We need a common function shared by ECPGprepare() and
ecpg_auto_prepare() to not do extra work in the auto-prepare case.

The attached patch implements this and also your leak fixes
plus includes your change for the autoprep.pgc regression test.

Good. I think the patch is ready to commit.

A comment for committer (Michael?) :
I was cofused by the AddStmtToCache's 2nd argument "char *stmtID"
because it doesn't have a const. Should it be "const char *" ?
If the argument has a const, callers assume that they can pass
a not-strdup'ed string as the argument.

Regards,
---
Takahiro Itagaki
NTT Open Source Software Center

#103Michael Meskes
meskes@postgresql.org
In reply to: Takahiro Itagaki (#102)
Re: Fix auto-prepare #2

Takahiro-san,

Good. I think the patch is ready to commit.

Thanks for reviewing it. I just committed the patch.

A comment for committer (Michael?) :
I was cofused by the AddStmtToCache's 2nd argument "char *stmtID"
because it doesn't have a const. Should it be "const char *" ?
If the argument has a const, callers assume that they can pass
a not-strdup'ed string as the argument.

Valid point, I can see no reason for not making this a "const char *". So let's
try.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ 179140304, AIM/Yahoo/Skype michaelmeskes, Jabber meskes@jabber.org
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL

#104Michael Meskes
meskes@postgresql.org
In reply to: Boszormenyi Zoltan (#101)
Re: ECPG patch 4.1, out-of-scope cursor support in native mode
diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-struct.c pgsql.4.1/src/interfaces/ecpg/test/expected/compat_informix-struct.c
...
+ 	/* Test DECLARE ... SELECT ... INTO with struct type */
+ 
+ 	ECPGset_var( 0, &( myvar ), __LINE__);\
+  ECPGset_var( 1, &( mynullvar ), __LINE__);\
+  ECPG_informix_reset_sqlca(); /* declare mycur cursor for select * from a1 */
+ #line 45 "struct.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT, 
+ 	ECPGt_int,&(myvar.id),(long)1,(long)1,sizeof(int), 
...

Why does the preproc spit out ECPGset_var's but no ECPGget_var's in this test case?

Michael

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ 179140304, AIM/Yahoo/Skype michaelmeskes, Jabber meskes@jabber.org
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL

In reply to: Michael Meskes (#104)
Re: ECPG patch 4.1, out-of-scope cursor support in native mode

Michael Meskes írta:

diff -dcrpN pgsql.orig/src/interfaces/ecpg/test/expected/compat_informix-struct.c pgsql.4.1/src/interfaces/ecpg/test/expected/compat_informix-struct.c
...
+ 	/* Test DECLARE ... SELECT ... INTO with struct type */
+ 
+ 	ECPGset_var( 0, &( myvar ), __LINE__);\
+  ECPGset_var( 1, &( mynullvar ), __LINE__);\
+  ECPG_informix_reset_sqlca(); /* declare mycur cursor for select * from a1 */
+ #line 45 "struct.pgc"
+ 
+ 	{ ECPGdo(__LINE__, 1, 1, NULL, 0, ECPGst_normal, "declare mycur cursor for select * from a1", ECPGt_EOIT, 
+ 	ECPGt_int,&(myvar.id),(long)1,(long)1,sizeof(int), 
...

Why does the preproc spit out ECPGset_var's but no ECPGget_var's in this test case?

Because there's no ECPGget_var()s emitted for
- global variables
- variables in the same function

ECPGget_var() is only used in case the cursor declaration
used INTO/USING and it's in a different function from
the one where OPEN/FETCH/CLOSE reside. But this
cannot be determined easily, e.g. short of making ECPG
a two-pass precompiler, so ECPGset_var() is always used.

Best regards,
Zoltán Böszörményi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

#106Michael Meskes
meskes@postgresql.org
In reply to: Boszormenyi Zoltan (#105)
Re: ECPG patch 4.1, out-of-scope cursor support in native mode

On Fri, Jan 22, 2010 at 06:11:51PM +0100, Boszormenyi Zoltan wrote:

Why does the preproc spit out ECPGset_var's but no ECPGget_var's in this test case?

Because there's no ECPGget_var()s emitted for
- global variables
- variables in the same function

ECPGget_var() is only used in case the cursor declaration
used INTO/USING and it's in a different function from
the one where OPEN/FETCH/CLOSE reside. But this
cannot be determined easily, e.g. short of making ECPG
a two-pass precompiler, so ECPGset_var() is always used.

This shows some well thought implementation. But what I was wondering about was
why this is used as test case. While I see the need to test this part of ecpg I
thought this test case was added because it showed a problem without your
changes.

Michael

--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ 179140304, AIM/Yahoo/Skype michaelmeskes, Jabber meskes@jabber.org
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL

In reply to: Michael Meskes (#106)
Re: ECPG patch 4.1, out-of-scope cursor support in native mode

Michael Meskes írta:

On Fri, Jan 22, 2010 at 06:11:51PM +0100, Boszormenyi Zoltan wrote:

Why does the preproc spit out ECPGset_var's but no ECPGget_var's in this test case?

Because there's no ECPGget_var()s emitted for
- global variables
- variables in the same function

ECPGget_var() is only used in case the cursor declaration
used INTO/USING and it's in a different function from
the one where OPEN/FETCH/CLOSE reside. But this
cannot be determined easily, e.g. short of making ECPG
a two-pass precompiler, so ECPGset_var() is always used.

This shows some well thought implementation.

Thanks. But the truth is that your comment about "this
adjust_informix() hack goes into native mode only over
my dead body" made me come up with this change and
the reasoning. :-) Thus if some code with cursors does
everything in one function then only some useless
ECPGset_var() calls are added by the preprocessor,
making the change the least intrusive for old regression tests.

But what I was wondering about was
why this is used as test case. While I see the need to test this part of ecpg I
thought this test case was added because it showed a problem without your
changes.

The problem that popped up first was that adjust_informix()
didn't properly deal with structs, remember? I tried some
small changes to fix that but they turned out to be improper
ones. The small changes worked for the initial problem,
i.e. IIRC in some cases adjust_informix() was bypassed
and the struct/union members were unrolled properly
for Informix compat mode, too. The regression test
"compat_informix/struct.pgc" shows this case. Then our
client showed a much larger programme which actually
used cursors in an event driver way. E.g. PgUp/PgDn
called different functions that contained only FETCH NEXT
or FETCH PRIOR. This was a curses based terminal programme
and my first little patch that solved only the struct unrolling case
failed in this case, because either ECPG segfaulted in
adjust_informix() or the code that ECPG produced for the
FETCH statements didn't have the proper output variables.
This is lead to the changes in the patch, which can be
summarized as:
1. track function names via the lexer (to minimize the impact
of ECPGget_var(), now we can compare the function name
where the cursor was DECLAREd and is used)
2. track type names for structs/unions to be able to emit
(* ( typename *) &var) in adjust_informix(), and
3. rewriting adjust_informix() to handle struct/union

The result is that cursors handling statements (OPEN/FETCH/MOVE)
can now be safely put into a different function from where
it was DECLAREd. And this makes possible to use ECPG
in event driven code, which is a feature that I think worth
considering making available in native mode, too. This is
why adjust_informix() was also renamed. And while I agree
with your comment about that "this can lead to dangerous
programming", I think the only thing needed is to document
the safety borders, not to prevent crossing them. C is about
"living la vida loca". ;-)

The regression test introduced (preproc/outofscope.pgc) tries
to show this functionality. Currently (without the patch) this
test makes ECPG abort in ecpg_type_name().

Best regards,
Zoltán Böszörményi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

#108Michael Meskes
meskes@postgresql.org
In reply to: Boszormenyi Zoltan (#107)
Re: ECPG patch 4.1, out-of-scope cursor support in native mode

On Sun, Jan 24, 2010 at 07:25:24PM +0100, Boszormenyi Zoltan wrote:

The problem that popped up first was that adjust_informix()
didn't properly deal with structs, remember? I tried some

Yes, that's what made me wondering.

i.e. IIRC in some cases adjust_informix() was bypassed
and the struct/union members were unrolled properly
for Informix compat mode, too. The regression test
"compat_informix/struct.pgc" shows this case. Then our

Now this is what I don't get. Shouldn't this test use different functions to
really show this problem? Isn't it hidden now by the new functionality of not
spitting out ECPGget_var's?

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ 179140304, AIM/Yahoo/Skype michaelmeskes, Jabber meskes@jabber.org
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL

In reply to: Michael Meskes (#108)
Re: ECPG patch 4.1, out-of-scope cursor support in native mode

Michael Meskes írta:

On Sun, Jan 24, 2010 at 07:25:24PM +0100, Boszormenyi Zoltan wrote:

The problem that popped up first was that adjust_informix()
didn't properly deal with structs, remember? I tried some

Yes, that's what made me wondering.

i.e. IIRC in some cases adjust_informix() was bypassed
and the struct/union members were unrolled properly
for Informix compat mode, too. The regression test
"compat_informix/struct.pgc" shows this case. Then our

Now this is what I don't get.

I may have been unclear. My first attempts at solving it
either basically bypassed adjust_informix() or tried to
unroll the structs *before* calling adjust_informix().
IIRC, your comment about that solution was something
like "unrolling should be done at only one place centrally".
Which I agreed after learning what dump_variables() and
ECPGdump_a_type() do.

Shouldn't this test use different functions to
really show this problem?

I don't think so. The problem only happened in case of
cursors because this was the only case when adjust_informix()
was called and the lack of handling struct/union there
was the problem. The final "else" branch used ecpg_type_name()
which calls abort() in case of unknown types.

Isn't it hidden now by the new functionality of not
spitting out ECPGget_var's?

No. This problem is hidden by the fact the adjust_informix()
(now adjust_outofscope_cursor_vars()) now handles structs/unions
properly and the struct members are properly unrolled by
ECPGdump_a_type().

The "not spitting out ECPGget_var()" part is about tidying
the preprocessed C source. As I wrote previously, globals
don't need transformation and nor the locals in case the
OPEN/FETCH statements are in the same function as DECLARE.

But considering all the above, we might not need the new
compat_informix/struct.pgc regression test. I think it was tested
already in e.g. preproc/array_of_struct.pgc and preproc/type.pgc
and the new feature (if accepted) is a unified one, it would show
the problem for native mode as well.

Best regards,
Zoltán Böszörményi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

#110Michael Meskes
meskes@postgresql.org
In reply to: Boszormenyi Zoltan (#109)
Re: ECPG patch 4.1, out-of-scope cursor support in native mode

On Mon, Jan 25, 2010 at 07:52:05PM +0100, Boszormenyi Zoltan wrote:

But considering all the above, we might not need the new
compat_informix/struct.pgc regression test. I think it was tested
already in e.g. preproc/array_of_struct.pgc and preproc/type.pgc
and the new feature (if accepted) is a unified one, it would show
the problem for native mode as well.

That was my feeling too and the reason for these questions. Again, this has
nothing to do with the feature you implemented, it was just about this special
test.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ 179140304, AIM/Yahoo/Skype michaelmeskes, Jabber meskes@jabber.org
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL

In reply to: Michael Meskes (#110)
Re: ECPG patch 4.1, out-of-scope cursor support in native mode

Michael Meskes írta:

On Mon, Jan 25, 2010 at 07:52:05PM +0100, Boszormenyi Zoltan wrote:

But considering all the above, we might not need the new
compat_informix/struct.pgc regression test. I think it was tested
already in e.g. preproc/array_of_struct.pgc and preproc/type.pgc
and the new feature (if accepted) is a unified one, it would show
the problem for native mode as well.

That was my feeling too and the reason for these questions. Again, this has
nothing to do with the feature you implemented, it was just about this special
test.

Should I send you a new patch without this regression test
or do you delete it before applying the patch?

BTW, thank you very much for the review.

Best regards,
Zoltán Böszörményi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

#112Michael Meskes
meskes@postgresql.org
In reply to: Boszormenyi Zoltan (#111)
Re: ECPG patch 4.1, out-of-scope cursor support in native mode

Should I send you a new patch without this regression test
or do you delete it before applying the patch?

Na, I will just remove it, no need to worry.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ 179140304, AIM/Yahoo/Skype michaelmeskes, Jabber meskes@jabber.org
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL

In reply to: Michael Meskes (#112)
Re: ECPG patch 4.1, out-of-scope cursor support in native mode

Michael Meskes írta:

Should I send you a new patch without this regression test
or do you delete it before applying the patch?

Na, I will just remove it, no need to worry.

Michael

Thanks for applying it. You seem to have accidentally
removed the outofscope.pgc test, too. The test results are there
and the test is wired up in Makefile and in ecpg_schedule[_tcp]
but the actual regression test code is missing:

make[2]: *** No rule to make target `outofscope', needed by `all'. Stop.
make[2]: Leaving directory
`/home/zozo/Schönig-számlák/leoni/2/new/new/new/8/pgsql/src/interfaces/ecpg/test/preproc'
make[1]: *** [all] Error 2
make[1]: Leaving directory
`/home/zozo/Schönig-számlák/leoni/2/new/new/new/8/pgsql/src/interfaces/ecpg/test'
make: *** [check] Error 2

Best regards,
Zoltán Böszörményi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

#114Michael Meskes
meskes@postgresql.org
In reply to: Boszormenyi Zoltan (#113)
Re: ECPG patch 4.1, out-of-scope cursor support in native mode

On Tue, Jan 26, 2010 at 10:56:52AM +0100, Boszormenyi Zoltan wrote:

Thanks for applying it. You seem to have accidentally
removed the outofscope.pgc test, too. The test results are there

Yup, my bad. I'm already trying to recover and testing. Apparently the files
weren't added but I didn't notice.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ 179140304, AIM/Yahoo/Skype michaelmeskes, Jabber meskes@jabber.org
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL