Re: ECPG patchset

Lists: pgsql-hackers
From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: pgsql-hackers(at)postgresql(dot)org, Michael Meskes <meskes(at)postgresql(dot)org>
Cc: Hans-Juergen Schoenig <hs(at)cybertec(dot)at>
Subject: ECPG patchset
Date: 2009-09-03 13:20:42
Message-ID: 4A9FC2AA.1080603@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

we have updated our patchset to current 8.5 CVS.
The actual patches will be in emails coming as
answers to this one. As two patches were already included,
the remaining patches are as follows:

1. dynamic cursorname
2. sqlda support
3. describe support
4. proper out-of-scope declare/open/fetch for cursors in compat mode

Changes (the numbers indicate the patch it was made in):

1. ECPG auto-generated grammar couldn't deal with
grammar objects having both an "addon" and a "rule"
extension, emitting an extra '{' between the "addon"
and the original rule code blocks. Fix was needed for parse.pl
and now the grammar looks nicer, my previous question was
solved by it.

2. No more ecpg_compare_sqlda_with_PGresult() function, it triggered
most of the time anyway, it's cheaper to unconditionally free() and
malloc().
No more realloc(), it ruined the internal pointers inside the sqlda
structure.
A small leak fix for FETCH when a decimal or numeric was used:

> diff -durpN pgsql.dyncursor/src/interfaces/ecpg/ecpglib/data.c
> pgsql.sqlda/src/interfaces/ecpg/ecpglib/data.c
> --- pgsql.dyncursor/src/interfaces/ecpg/ecpglib/data.c 2009-08-08
> 17:19:45.000000000 +0200
> +++ pgsql.sqlda/src/interfaces/ecpg/ecpglib/data.c 2009-09-03
> 12:56:36.000000000 +0200
> @@ -554,7 +554,7 @@ ecpg_get_data(const PGresult *results, i
> else
>
> PGTYPESnumeric_to_decimal(nres, (decimal *) (var + offset * act_tuple));
>
> - free(nres);
> + PGTYPESnumeric_free(nres);
> break;
>
> case ECPGt_interval:

Now sqlda usage is valgrind-clean.
We added the possibility to extend SQLDA for multi-row FETCH,
using the ->desc_next pointer, but not implemented. Multi-row
FETCH is not available in Informix.

3. Only updated to current CVS.

4. Fixed uninitialized pointers that were discovered by valgrind and
were causing problems on HP-UX. (Small malloc()s seem to be
zeroed out by Fedora 9's glibc, but not on HP-UX.)

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/


From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: pgsql-hackers(at)postgresql(dot)org, Michael Meskes <meskes(at)postgresql(dot)org>
Cc: Hans-Juergen Schoenig <hs(at)cybertec(dot)at>
Subject: Re: ECPG patchset
Date: 2009-09-03 13:21:38
Message-ID: 4A9FC2E2.70002@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Dynamic cursorname

--
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/

Attachment Content-Type Size
1-pg85-dyncursor-8-ctxdiff.patch text/x-patch 140.4 KB

From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: pgsql-hackers(at)postgresql(dot)org, Michael Meskes <meskes(at)postgresql(dot)org>
Cc: Hans-Juergen Schoenig <hs(at)cybertec(dot)at>
Subject: Re: ECPG patchset
Date: 2009-09-03 13:22:49
Message-ID: 4A9FC329.5030400@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

SQLDA support

--
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/

Attachment Content-Type Size
2-pg85-sqlda-9-ctxdiff.patch text/x-patch 65.2 KB

From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: pgsql-hackers(at)postgresql(dot)org, Michael Meskes <meskes(at)postgresql(dot)org>
Cc: Hans-Juergen Schoenig <hs(at)cybertec(dot)at>
Subject: Re: ECPG patchset
Date: 2009-09-03 13:23:23
Message-ID: 4A9FC34B.5080709@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

DESCRIBE [OUTPUT] support

--
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/

Attachment Content-Type Size
3-pg85-describe-6-ctxdiff.patch text/x-patch 61.9 KB

From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: pgsql-hackers(at)postgresql(dot)org, Michael Meskes <meskes(at)postgresql(dot)org>
Cc: Hans-Juergen Schoenig <hs(at)cybertec(dot)at>
Subject: Re: ECPG patchset
Date: 2009-09-03 13:24:05
Message-ID: 4A9FC375.8050403@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Out of scope cursor usage

--
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/

Attachment Content-Type Size
4-pg85-outofscopedeclare-3-ctxdiff.patch text/x-patch 84.2 KB

From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: pgsql-hackers(at)postgresql(dot)org, Michael Meskes <meskes(at)postgresql(dot)org>
Cc: Hans-Juergen Schoenig <hs(at)cybertec(dot)at>
Subject: Re: ECPG patchset
Date: 2009-09-05 12:20:05
Message-ID: 4AA25775.2020006@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Boszormenyi Zoltan írta:
> Out of scope cursor usage
>

New version of this, changes:
- DECLARE cursor FOR prepared_stmt is also handled properly
- ECPG_informix_set_var() calls are not emitted for global statements
- regression test "outofscope.pgc" is updated

I think it's now at the point where we can reconsider your argument
about making this feature generic and not an Informix-only feature:

> Yeah, right, and you also add this hack to all applications. No.

I don't think it's hackish at all now. Read the outofscope.pgc
regression test and its generated source.
- ECPG_informix_set_var() calls are only generated for variables
in function scope, not for globals.
- ECPG_informix_get_var() calls are generated only when
OPEN and FETCH are in a function different from the one
where DECLARE was.

In the common case the generated source would only contain
some *_set_var() calls but the function references wouldn't change.

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/

Attachment Content-Type Size
4-pg85-outofscopedeclare-4-ctxdiff.patch text/x-patch 100.6 KB

From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: pgsql-hackers(at)postgresql(dot)org, Michael Meskes <meskes(at)postgresql(dot)org>
Cc: Hans-Juergen Schoenig <hs(at)cybertec(dot)at>
Subject: Re: ECPG patchset
Date: 2009-09-08 10:01:45
Message-ID: 4AA62B89.2020706@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

New patch, typo fix in pgc.l.

According to our customer who is porting their application
to PostgreSQL, this causes an error currently in ECPG:

========================================

1. within included structures the use of "$else;" is causing an
precompiler error (tested several times in different programs)
/home/progs/fors_neu/share/include/bwltrec.h:124: ERROR: syntax error at
or near ";"

Example:

mainprog.ec:
EXEC SQL BEGIN DECLARE SECTION;
EXEC SQL INCLUDE share/include/bwltrec.h; /* record bwlt */
EXEC SQL END DECLARE SECTION;

bwltrec.h:
struct record_type_bwlt
{ int firmnr; /* Firmennummer (2,0) */
int liwerk; /* Werk - Lieferant (2,0) */
...
$ifdef FORS3;
string besktr[7]; /* Kostentraeger */
$else;
string besktr[13]; /* Kostentraeger */
$endif;
} bwlt;

========================================

It looks to me that "EXEC SQL else;" is expected in the native
syntax, but "$else" (without ";" at the end of the line) is expected
in compat mode. Considering that the ";" seems to be expected
by esql, this must be a typo in ecpg/preproc/pgc.l

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/

Attachment Content-Type Size
6-pg85-dollar-else-1-ctxdiff.patch text/x-patch 710 bytes

From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: pgsql-hackers(at)postgresql(dot)org, Michael Meskes <meskes(at)postgresql(dot)org>
Cc: Hans-Juergen Schoenig <hs(at)cybertec(dot)at>
Subject: Re: ECPG patchset
Date: 2009-09-18 07:12:33
Message-ID: 4AB332E1.7090805@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

New version of the SQLDA support
Changes:
- removed a decimal-related leak fix (to be posted separately)
- free(sqlda->sqlvar) as well if it's not in the same allocation area
as the main sqlda

--
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/

Attachment Content-Type Size
2-pg85-sqlda-10-ctxdiff.patch text/x-patch 69.4 KB

From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: pgsql-hackers(at)postgresql(dot)org, Michael Meskes <meskes(at)postgresql(dot)org>
Cc: Hans-Juergen Schoenig <hs(at)cybertec(dot)at>
Subject: Re: ECPG patchset
Date: 2009-09-18 07:15:36
Message-ID: 4AB33398.6030109@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

New version of the DESCRIBE patch
Changes:
- free(sqlda->sqlvar) as well if it's not in the same
allocation area as teh main sqlda
- allow variable name for the prepared stmt in DESCRIBE

--
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/

Attachment Content-Type Size
3-pg85-describe-9-ctxdiff.patch text/x-patch 61.8 KB

From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: pgsql-hackers(at)postgresql(dot)org, Michael Meskes <meskes(at)postgresql(dot)org>
Cc: Hans-Juergen Schoenig <hs(at)cybertec(dot)at>
Subject: Re: ECPG patchset
Date: 2009-09-18 07:19:25
Message-ID: 4AB3347D.1090306@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

New patch - two decimal-related memory leak fixes.
Happens on 8.4 and 8.5, maybe on older trees as well.
One of the two chunks was in the SQLDA patch originally.
This is independent from any other patches.

--
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/

Attachment Content-Type Size
7-pg85-decimal-leak-1-ctxdiff.patch text/x-patch 1.4 KB

From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: pgsql-hackers(at)postgresql(dot)org, Michael Meskes <meskes(at)postgresql(dot)org>
Cc: Hans-Juergen Schoenig <hs(at)cybertec(dot)at>
Subject: Re: ECPG patchset
Date: 2009-09-18 07:55:29
Message-ID: 4AB33CF1.7020300@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Disregard the previous one, correct one is attached.

Boszormenyi Zoltan írta:
> New version of the DESCRIBE patch
> Changes:
> - free(sqlda->sqlvar) as well if it's not in the same
> allocation area as teh main sqlda
> - allow variable name for the prepared stmt in DESCRIBE
>
>
> ------------------------------------------------------------------------
>
>

--
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/

Attachment Content-Type Size
3-pg85-describe-10-ctxdiff.patch text/x-patch 61.7 KB