Re: cuando creo una tabla quiero añadir un campo int4 nombrado cflavia "al vuelo"

From: "Jaime Casanova" <systemguards(at)gmail(dot)com>
To: "lein gutierrez" <leing2002(at)gmail(dot)com>
Cc: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: cuando creo una tabla quiero añadir un campo int4 nombrado cflavia "al vuelo"
Date: 2006-06-04 04:16:08
Message-ID: c2d9e70e0606032116k725565fk3b5cd56816366894@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

On 6/2/06, lein gutierrez <leing2002(at)gmail(dot)com> wrote:
> Te entendi la idea introduje en el parsenodes.h esto:
>
> typedef struct CreateStmt
> {
> NodeTag type;
> RangeVar *relation; /* relation to create */
> List *tableElts; /* column definitions (list of ColumnDef)
> */
> List *inhRelations; /* relations to inherit from (list of
> * inhRelation) */
> List *constraints; /* constraints (list of Constraint nodes) */
> ContainsOids hasoids; /* should it have OIDs? */
> OnCommitAction oncommit; /* what do we do at COMMIT? */
> char *tablespacename; /* table space to use, or NULL */
>
> /* nuevo lein */
> char *colname; /* name of column */
> TypeName *typename; /* type of column */
> } CreateStmt;
>
> En el gram.y:
>
>
> CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')' AS VALID
> EVENT
> OptInherit OptWithOids OnCommitOption OptTableSpace
> {
> CreateStmt *n = makeNode(CreateStmt);
> $4->istemp = $2;
> n->relation = $4;
> n->tableElts = $6;
> n->inhRelations = $11;
> n->constraints = NIL;
> n->hasoids = $12;
> n->oncommit = $13;
> n->tablespacename = $14;
> n->colname = "cflavia";
> n->typename = "int4";
> $$ = (Node *)n;
> }
>
> estA bien me crea la tabla asi
> postgres=# CREATE TABLE mitabla4 (mientero int) AS VALID EVENT ;
> CREATE TABLE
>
> Al consultarla espero dos campos, pero sale:
>
> postgres=# SELECT * FROM mitabla4 ;
> mientero
> ----------
> (0 rows)
>
> Alguna sugerencia ?
>

y porque supones que por añadir 2 campos en CreateStmt se van a añadir
en la tabla? no deberias estar modificando la funcion que crea la
tabla?

src/backend/commands/tablecmds.c

--
Atentamente,
Jaime Casanova

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs and the universe trying
to produce bigger and better idiots.
So far, the universe is winning."
Richard Cook

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Mariano Lauría 2006-06-04 12:31:18 Experiencia de PostgreSQL
Previous Message Jaime Casanova 2006-06-04 03:16:13 Re: consulta Por mese y dias