sql-language-server icon indicating copy to clipboard operation
sql-language-server copied to clipboard

Failure to parse valid PostgreSQL statements

Open bennieswart opened this issue 1 year ago • 4 comments

This is probably a very similar issue to https://github.com/joe-re/sql-language-server/issues/129 in that it simply requires extension of the parser.

The code I'm hacking on:

CREATE OR REPLACE FUNCTION api._cuidin(cstring) RETURNS api._cuid AS 'textin' LANGUAGE internal STABLE PARALLEL SAFE;
CREATE OR REPLACE FUNCTION api._cuidout(api._cuid) RETURNS cstring AS 'textout' LANGUAGE internal STABLE PARALLEL SAFE;
CREATE OR REPLACE FUNCTION api._cuidrecv(internal) RETURNS api._cuid AS 'textrecv' LANGUAGE internal STABLE PARALLEL SAFE;
CREATE OR REPLACE FUNCTION api._cuidsend(api._cuid) RETURNS bytea AS 'textsend' LANGUAGE internal STABLE PARALLEL SAFE;
CREATE TYPE api._cuid (
    INPUT = api._cuidin,
    OUTPUT = api._cuidout,
    RECEIVE = api._cuidrecv,
    SEND = api._cuidsend
);

CREATE OR REPLACE FUNCTION api._cuid_text_eq(uid1 api._cuid, uid2 text) RETURNS bool AS $$
BEGIN
    RAISE NOTICE 'custom equals';
    RETURN uid1::text = uid2;
END;
$$ LANGUAGE plpgsql;

CREATE OPERATOR = (
    FUNCTION = api._cuid_text_eq,
    LEFTARG = api._cuid,
    RIGHTARG = text
);

bennieswart avatar Apr 17 '23 21:04 bennieswart