Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5ac462e

Browse files
committed
Add support for custom_query_jumble as a node field attribute
This option gives the possibility for query jumble to define a customroutine for the field of a Node, extending support forcustom_query_jumble as a node field attribute. When dealing withcomplex node structures, this can be simpler than having to enforce acustom function across a full node.Custom functions need to be defined in queryjumblefuncs.c, named as_jumble${node}_${field}(), and use in input the JumbleState, the nodeand its field. The field is not really required if we have the Node,but it makes custom implementations somewhat easier to think about. Thecode generated by gen_node_support.pl uses a macro calledJUMBLE_CUSTOM(), hiding the internals of the logic insidequeryjumblefuncs.c.This will be used by an upcoming patch manipulating adding a customroutine into a field of RangeTblEntry, but this facility can becomeuseful in more cases.Reviewed-by: Christoph Berg <myon@debian.org>Discussion:https://postgr.es/m/Z9y43-dRvb4EtxQ0@paquier.xyz
1 parent626df47 commit5ac462e

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

‎src/backend/nodes/gen_node_support.pl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ sub elem
471471
&&$attr !~/^read_as\(\w+\)$/
472472
&& !elem$attr,
473473
qw(copy_as_scalar
474+
custom_query_jumble
474475
equal_as_scalar
475476
equal_ignore
476477
equal_ignore_if_zero
@@ -1283,12 +1284,17 @@ sub elem
12831284
my$t =$node_type_info{$n}->{field_types}{$f};
12841285
my@a = @{$node_type_info{$n}->{field_attrs}{$f} };
12851286
my$query_jumble_ignore =$struct_no_query_jumble;
1287+
my$query_jumble_custom = 0;
12861288
my$query_jumble_location = 0;
12871289
my$query_jumble_squash = 0;
12881290

12891291
# extract per-field attributes
12901292
foreachmy$a (@a)
12911293
{
1294+
if ($aeq'custom_query_jumble')
1295+
{
1296+
$query_jumble_custom = 1;
1297+
}
12921298
if ($aeq'query_jumble_ignore')
12931299
{
12941300
$query_jumble_ignore = 1;
@@ -1304,7 +1310,12 @@ sub elem
13041310
}
13051311

13061312
# node type
1307-
if (($t =~/^(\w+)\*$/or$t =~/^struct\s+(\w+)\*$/)
1313+
if ($query_jumble_custom)
1314+
{
1315+
# Custom function that applies to one field of a node.
1316+
print$jff"\tJUMBLE_CUSTOM($n,$f);\n";
1317+
}
1318+
elsif (($t =~/^(\w+)\*$/or$t =~/^struct\s+(\w+)\*$/)
13081319
and elem$1,@node_types)
13091320
{
13101321
# Squash constants if requested.

‎src/backend/nodes/queryjumblefuncs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,9 @@ do { \
333333
if (expr->str) \
334334
AppendJumble(jstate, (const unsigned char *) (expr->str), strlen(expr->str) + 1); \
335335
} while(0)
336+
/* Function name used for the node field attribute custom_query_jumble. */
337+
#defineJUMBLE_CUSTOM(nodetype,item) \
338+
_jumble##nodetype##_##item(jstate, expr, expr->item)
336339

337340
#include"queryjumblefuncs.funcs.c"
338341

‎src/include/nodes/nodes.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ typedef enum NodeTag
5454
* readfuncs.c.
5555
*
5656
* - custom_query_jumble: Has custom implementation in queryjumblefuncs.c.
57+
* Also available as a node field attribute.
5758
*
5859
* - no_copy: Does not support copyObject() at all.
5960
*
@@ -101,6 +102,9 @@ typedef enum NodeTag
101102
* - equal_ignore_if_zero: Ignore the field for equality if it is zero.
102103
* (Otherwise, compare normally.)
103104
*
105+
* - custom_query_jumble: Has custom implementation in queryjumblefuncs.c
106+
* for the field of a node. Also available as a node attribute.
107+
*
104108
* - query_jumble_ignore: Ignore the field for the query jumbling. Note
105109
* that typmod and collation information are usually irrelevant for the
106110
* query jumbling.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp