Skip site navigation (1) Skip section navigation (2)

Still "Stalled"? ECPG - varchar in struct?

From: "William West" <wwest(at)csc(dot)com>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Still "Stalled"? ECPG - varchar in struct?
Date: 2002-07-29 14:06:16
Message-ID: OFF9D5DF25.8F847163-ON85256C05.004CD4D5@com (view raw, whole thread or download thread mbox)
Lists: pgsql-interfaces
Note: This is a re-send of a question that was
'stalled' due lack of author first establishing
list membership. Apologies for the duplication,
but it is unclear what has happened to/ will
happen to the 'stalled' original.
I looked at comp.databases.postgresql.questions
and posted a brief form of this question there.

I am porting an existing Oracle/ PRO-C Application
over to PostgreSQL 7.2.1 (ecpg 2.9.0).

This application takes advantage of the fact that
PRO-C lets you use 'varchar' as part of 'struct'
definitions by re-writing 'varchar' during INCLUDE
or DECLARE processing either one. This application
can (and presently does) make a lot of use of:

struct rowdef {
  ... /* Column */
  varchar nameOFcolumn[maxlen] ;
  ... /* Column */

to define an interface buffer. PRO-C will re-write
this, during EXEC SQL INCLUDE processing, as:

struct rowdef {
... /* Column */
struct {int len;  char arr[maxlen];} nameOFcolumn;
... /* Column */

This makes it possible to easily declare an I/O buffer
that can hold many rows:

    struct rowdef ManyRows[25];

and code can easily refer to members of this buffer:

/* Length column instance 7 */
ManyRows [7].nameOFcolumn.len;

/* Address of column instance 7 */
ManyRows [7].nameOFcolumn.arr;

or send them to other compile units:

 foo (ManyRows + 7);

can run 'foo' on row 7 without 'foo' needing to be
able to see the ManyRows DECLARE. The 'foo' compile
unit only needs the INCLUDE to provide the 'rowdef'
struct layout, since INCLUDE processing takes care
of the C re-write that a varchar always needs.


It would appear that ecpg will only re-write a
varchar if it is found in a DECLARE statement,
because the varchar gets past the ecpg preprocessor's
INCLUDE as-is ... and, of course, the real C compiler
does not know what a 'varchar' is, so it complains.

As a PostgreSQL 'newbie', I am not sure if it is more
work to fix ecpg or to re-write how the application
does things. I see it is a 'yacc' unit that handles the
re-writing that ecpg now does, but I do not know
'yacc-ese' and do not know what else would be involved
to fix ecpg to work like PRO-C?

- Did I miss something here?
- Any insights/ advice from the gurus?
- Would it be a really big deal to support
  varchar re-writes during INCLUDE and not
  just during DECLARE?

pgsql-interfaces by date

Next:From: Preston LordDate: 2002-07-29 17:05:13
Subject: PGACCESS connection failure?
Previous:From: MaksimRomanovDate: 2002-07-29 13:47:59
Subject: How to get binary data from pgsql function

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group