Обсуждение: IDL :)

Поиск
Список
Период
Сортировка

IDL :)

От
"Taral"
Дата:
Well... SOMEONE comment on this! It's what I've got so far:

Taral

--- cut here ---

module PostgreSQL {
    enum celltype {
        int2,
        int4,
        int8

        // more types
    };

    typedef short int2type;
    typedef sequence<int2type> int2col;
    typedef long int4type;
    typedef sequence<int4type> int4col;
    struct int8type {
        long lsw;
        long msw;
    };
    typedef sequence<int8type> int8col;

    union Column switch (celltype) {
      case int2:
        int2col int2var;
      case int4:
        int4col int4var;
      case int8:
        int8col int8var;

      // more types
    };

    union Cell switch (celltype) {
      case int2:
        int2type int2var;
      case int4:
        int4type int4var;
      case int8:
        int8type int8var;

      // more types
    };

    interface Row {
        typedef sequence<Cell> type;
        attribute type data; // throws system exception on set until BE
supports this
    };

    interface QueryResult {
        typedef sequence<Column> type;
        typedef sequence<string> headerType;

        readonly attribute headerType header;
        attribute type data; // throws system exception on set until
implemented

        Row fetch(in long rownum); // returns nil until implemented
    };

    interface Database {
        QueryResult exec(in string query);
    };
};


Re: [INTERFACES] IDL :)

От
Tom Lane
Дата:
"Taral" <taral@cyberjunkie.com> writes:
> Well... SOMEONE comment on this! It's what I've got so far:

This sort of thing would be workable (barely) for the Postgres built-in
types, but I think it falls down badly as soon as you think about
user-defined types, which are after all one of Postgres' strengths.

We need some way of not having to enumerate all the possible field
datatypes in advance.

Bearing in mind that I don't know anything about IDL, here is one
way to attack it:

1. Go ahead and provide explicit representations for the half-dozen
most common datatypes, ie, ints, floats, char strings.  (Don't forget
arrays of these.)

2. Allow any datatype to be transported as a character string, with
necessary conversions happening at the backend (and probably in the
calling application as now).  This corresponds to "ASCII" queries
in the current FE/BE protocol.

3. Allow any datatype to be transported as an uninterpreted binary
byte string, with the calling app responsible for making sense of the
backend's representation.  This corresponds to "binary" queries
in the current protocol.

With an approach like this you don't need direct IDL representation
of anything except ints, floats, and strings.  However, untranslated
binary representations are pretty ugly and untransportable.  So I wonder
whether CORBA doesn't provide some more intelligent way to deal with the
problem of run-time type description.  Surely there's got to be an
explicit run-time representation of type knowledge in CORBA?  The wire
protocol, at least, must have it...

            regards, tom lane

RE: [INTERFACES] IDL :)

От
"Taral"
Дата:
> We need some way of not having to enumerate all the possible field
> datatypes in advance.

[ suggestions snipped ]

d) none of the above

CORBA provides the "any" type, and it turns out that those discriminated
unions are TERRIBLE memory hogs in C++. So see attached.

There are now two files because some ORBs require a special switch to enable
a type to be extracted from/represented by an "any".

So now our user-defined types will have to work via the dynamic
interfaces... someone explain to me how those types work!

Taral

--- cut here: pgsql.idl ---

module PostgreSQL {
    // Discriminated unions removed due to inefficiency in C++
implementation

    typedef any Cell;
    typedef sequence<Cell> Column;

    interface Row {
        typedef sequence<Cell> type;
        attribute type data; // throws BAD_OPERATION on set until BE
supports this
    };

    interface QueryResult {
        typedef sequence<Column> type;
        typedef sequence<string> headerType;

        readonly attribute headerType header;
        attribute type data; // throws BAD_OPERATION on set until
implemented

        Row fetch(in long rownum); // returns nil or BAD_OPERATION until
implemented
        // zero based numbering of rows
    };

    interface Database {
        QueryResult exec(in string query);
        oneway void disconnect();
    };

    interface Server {
        Database connect(in string db, in string user, in string password);
    };
};

--- cut here: pgsql_types.idl ---

// This file compiled for support of any for new types

module PostgreSQL {
    enum celltype {
        int2,
        int4,
        int8

        // more types
    };

    typedef short int2type;
    typedef long int4type;
    struct int8type {
        long lsw;
        long msw;
    };
};