pg_sql_parser icon indicating copy to clipboard operation
pg_sql_parser copied to clipboard

Distinction between SelectStmt-Rule in SELECT (INTO) and VALUES clauses in others

Open Tornadotuan opened this issue 9 years ago • 0 comments

@valgog I noticed that your grammar fires the SelectStmt Rule during normal SELECT-Statements alright, but unfortunately it fires on VALUES-clauses after INSERT statements as well. Therefore I believe, there could be more cases of this occurrence. Anyway, here is is an example statement where it occured. This is the PostgreSQL-Code:

CREATE TABLE public.result (
    id      int,
    personname  character varying(10),
    age         integer,
    division    integer,
    projectid   character varying(10) NOT NULL,

    CONSTRAINT pk_personid  PRIMARY KEY (id)
)

WITH (
    OIDS=FALSE
);
ALTER TABLE public.result
  OWNER TO postgres;

 INSERT INTO result(
            id,personname, age, division, projectid)
    VALUES
    (1,'Max',   12,  5,   'AB11001'),
    (2,'Felix', 37,  8,   'XX78474'),
    (3,'Hanna', 22, 10,  'TET747'),
    (4,'Erik',  42,  1,  'HL4745');

And if I try to output SelectStmtContext´s childnode text it gives me:

VALUES(1,'Max',12,5,'AB11001'),(2,'Felix',37,8,'XX78474'),(3,'Hanna',22,10,'TET747'),(4,'Erik',42,1,'HL4745')

as return value. Is there a workaround or is it intended to work that way?

Kind regards Tornado

Tornadotuan avatar Mar 30 '16 15:03 Tornadotuan