Re: Failed to parse new syntax

From: Jan Wieck <jan(at)wi3ck(dot)info>
To: jacktby jacktby <jacktby(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Failed to parse new syntax
Date: 2023-08-05 18:18:58
Message-ID: 19b7d441-b1a4-1455-1fd2-703244004808@wi3ck.info
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Are you aware that PostgreSQL has a built in '~' operator for regular
expressions?

Regards, Jan

On 8/5/23 11:56, jacktby jacktby wrote:
> /*
> * similarity_search_expr is used for our multi-mode
> * similarity_search, and we just use this for multi
> * cols search.
> */
> similarity_search_expr:
> sub_search_expr '<' AexprConst {
> $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "<", $1, $3, @2);
> }
> ;
> sub_search_expr:
> '[' col_tuple_expr '~' AexprConst ']' {
> $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~", $2, $4, @3);
> }
> ;
> col_tuple_expr:
> columnref { $$ = $1;}
> | '(' col_list_expr ')' { $$ = $2;}
> ;
> col_list_expr:
> columnref {
> ResTarget* target = makeNode(ResTarget);
> target->name = NULL;
> target->indirection = NIL;
> target->val = (Node *) $1;
> target->location = @1;
> $$ = list_make1(target);
> }
> | col_list_expr ',' columnref { $$ = lappend($1,$3);}
> ;
> This is my new grammer.
> But I get below:
> postgres=# select * from t2 where [a ~ 1] < 0;
> ERROR: syntax error at or near "~"
> LINE 1: select * from t2 where [a ~ 1] < 0;
> It’s strange that it can’t parse ‘~’, I add it in the parser.
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Wen Yi 2023-08-06 02:50:15 Re:How to solve the warning?
Previous Message jacktby jacktby 2023-08-05 15:56:18 Failed to parse new syntax