gin--a rule for function parameter

Started by hx.lialmost 17 years ago4 messageshackers
Jump to latest
#1hx.li
fly2nn@126.com

version: PG8.2.2

MY Question:
Why must "take the same number of parameters" ?

" We can check that all the referenced instances of the same support routine
number take the same number of parameters" ?

1 there is no results by running regress test as follow:
plsql/src/test/regress/sql/opr_sanity.sql
......
-- Unfortunately, we can't check the amproc link very well because the
-- signature of the function may be different for different support routines
-- or different base data types.
-- We can check that all the referenced instances of the same support
-- routine number take the same number of parameters, but that's about it
-- for a general check...
SELECT p1.amopclaid, p1.amprocnum,
p2.oid, p2.proname,
p3.opcname,
p4.amopclaid, p4.amprocnum,
p5.oid, p5.proname,
p6.opcname
FROM sys_amproc AS p1, sys_proc AS p2, sys_opclass AS p3,
sys_amproc AS p4, sys_proc AS p5, sys_opclass AS p6
WHERE p1.amopclaid = p3.oid AND p4.amopclaid = p6.oid AND
p3.opcamid = p6.opcamid AND p1.amprocnum = p4.amprocnum AND
p1.amproc = p2.oid AND p4.amproc = p5.oid AND
(p2.proretset OR p5.proretset OR p2.pronargs != p5.pronargs);

But,
contrib\tsearch2\tsearch.sql.in:
...
CREATE OPERATOR CLASS gin_tsvector_ops
DEFAULT FOR TYPE tsvector USING gin
AS
OPERATOR 1 @@ (tsvector, tsquery),
OPERATOR 2 @@@ (tsvector, tsquery) RECHECK,
FUNCTION 1 bttextcmp(text, text),
FUNCTION 2 gin_extract_tsvector(tsvector,internal),
FUNCTION 3
gin_extract_tsquery(tsquery,internal,internal),
FUNCTION 4
gin_ts_consistent(internal,internal,tsquery),
STORAGE text;

When I use tsearch2, I found that gin_extract_tsquery() has 3 parameters, it
break the rule "take the same number of parameters".
So, who can tell me whether the rule is right?

Grateful,
Fly.Li

for example, "ginarrayextract" function has two parameters
----------------------
amopclaid | amprocnum | oid | proname | opcname |
amopclaid | amprocnum | oid | proname | opcname
-----------+-----------+------+---------------------+------------------+-----------+-----------+------+---------------------+------------------
2771 | 3 | 2743 | ginarrayextract | _oidvector_ops

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: hx.li (#1)
Re: gin--a rule for function parameter

"Fly.Li" <fly2nn@126.com> writes:

version: PG8.2.2
MY Question:
Why must "take the same number of parameters" ?

Because the GIN code will call it with a particular number of arguments.

When I use tsearch2, I found that gin_extract_tsquery() has 3 parameters, it
break the rule "take the same number of parameters".

3 is the correct number of parameters for an extractQuery function
(before 8.4 anyway), so I'm not clear what you are complaining about.

regards, tom lane

#3hx.li
fly2nn@126.com
In reply to: hx.li (#1)
Re: gin--a rule for function parameter

1 ginarrayextract() has 2 parameters
2 gin_extract_tsquery() has 3 parameters
3 run sql(from plsql/src/test/regress/sql/opr_sanity.sql), it expect no
results:
-------------
SELECT p1.amopclaid, p1.amprocnum,
p2.oid, p2.proname,
p3.opcname,
p4.amopclaid, p4.amprocnum,
p5.oid, p5.proname,
p6.opcname
FROM pg_amproc AS p1, pg_proc AS p2, pg_opclass AS p3,
pg_amproc AS p4, pg_proc AS p5, pg_opclass AS p6
WHERE p1.amopclaid = p3.oid AND p4.amopclaid = p6.oid AND
p3.opcamid = p6.opcamid AND p1.amprocnum = p4.amprocnum AND
p1.amproc = p2.oid AND p4.amproc = p5.oid AND
(p2.proretset OR p5.proretset OR p2.pronargs != p5.pronargs);
--------------
We can get results as follow:
amopclaid | amprocnum | oid | proname | opcname |
amopclaid | amprocnum | oid | proname | opcname
-----------+-----------+------+---------------------+------------------+-----------+-----------+------+---------------------+------------------
2771 | 3 | 2743 | ginarrayextract | _oidvector_ops |
3659 | 3 | 3657 | gin_extract_tsquery | tsvector_ops
2759 | 3 | 2743 | ginarrayextract | _cidr_ops |
3659 | 3 | 3657 | gin_extract_tsquery | tsvector_ops
2768 | 3 | 2743 | ginarrayextract | _name_ops |
3659 | 3 | 3657 | gin_extract_tsquery | tsvector_ops
......
4 But, reading "plsql/src/test/regress/sql/opr_sanity.sql", there is a
sentence said:
" We can check that all the referenced instances of the same support routine
number take the same number of parameters" ?

5 So, ginarrayextract() and gin_extract_tsquery() should take the same
number of parameters?
Or, " We can check that all the referenced instances of the same support
routine number take the same number of parameters" is not a right?

6 Actually, pgsql allow all the referenced instances of the same support
routine number do not take the same number of parameters.

Thanks.
Fly.Li

"Tom Lane" <tgl@sss.pgh.pa.us> д���ʼ�����:<10550.1246457758@sss.pgh.pa.us>...

Show quoted text

"Fly.Li" <fly2nn@126.com> writes:

version: PG8.2.2
MY Question:
Why must "take the same number of parameters" ?

Because the GIN code will call it with a particular number of arguments.

When I use tsearch2, I found that gin_extract_tsquery() has 3
parameters, it
break the rule "take the same number of parameters".

3 is the correct number of parameters for an extractQuery function
(before 8.4 anyway), so I'm not clear what you are complaining about.

regards, tom lane

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: hx.li (#3)
Re: gin--a rule for function parameter

"Fly.Li" <fly2nn@126.com> writes:

1 ginarrayextract() has 2 parameters
2 gin_extract_tsquery() has 3 parameters
3 run sql(from plsql/src/test/regress/sql/opr_sanity.sql), it expect no
results:

Well, actually what's cheating here is ginarrayextract, not tsearch2.
That was fixed as of 8.3.

regards, tom lane