pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Failed to parse new syntax
2+ messages / 2 participants
[nested] [flat]

* Failed to parse new syntax
@ 2023-08-05 15:56  jacktby jacktby <jacktby@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: jacktby jacktby @ 2023-08-05 15:56 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

/*
*	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.




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Failed to parse new syntax
@ 2023-08-05 18:18  Jan Wieck <jan@wi3ck.info>
  parent: jacktby jacktby <jacktby@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Jan Wieck @ 2023-08-05 18:18 UTC (permalink / raw)
  To: jacktby jacktby <jacktby@gmail.com>; pgsql-general@lists.postgresql.org

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.
> 






^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2023-08-05 18:18 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-08-05 15:56 Failed to parse new syntax jacktby jacktby <jacktby@gmail.com>
2023-08-05 18:18 ` Jan Wieck <jan@wi3ck.info>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox