Hi, Mark!

On Tue, May 30, 2017 at 2:18 AM, Mark Rofail <markm.rof...@gmail.com> wrote:

> rhaas=# select oid, * from pg_opfamily where opfmethod = 2742;
>>  oid  | opfmethod |    opfname     | opfnamespace | opfowner
>> ------+-----------+----------------+--------------+----------
>>  2745 |      2742 | array_ops      |           11 |       10
>>  3659 |      2742 | tsvector_ops   |           11 |       10
>>  4036 |      2742 | jsonb_ops      |           11 |       10
>>  4037 |      2742 | jsonb_path_ops |           11 |       10
>> (4 rows)
>
> I am particulary intrested in array_ops but I have failed in locating the
> code behind it. Where is it reflected in the source code
>

Let's look what particular opclass is consisting of.  Besides records in
pg_opfamily, it also contains records in pg_opclass, pg_amproc and pg_amop.

=# select * from pg_opclass where opcfamily = 2745;
 opcmethod |  opcname  | opcnamespace | opcowner | opcfamily | opcintype |
opcdefault | opckeytype
-----------+-----------+--------------+----------+-----------+-----------+------------+------------
      2742 | array_ops |           11 |       10 |      2745 |      2277 |
t          |       2283
(1 row)

=# select * from pg_amproc where amprocfamily = 2745;
 amprocfamily | amproclefttype | amprocrighttype | amprocnum |
amproc
--------------+----------------+-----------------+-----------+----------------------------
         2745 |           2277 |            2277 |         2 |
pg_catalog.ginarrayextract
         2745 |           2277 |            2277 |         3 |
ginqueryarrayextract
         2745 |           2277 |            2277 |         4 |
ginarrayconsistent
         2745 |           2277 |            2277 |         6 |
ginarraytriconsistent
(4 rows)

=# select * from pg_amop where amopfamily = 2745;
 amopfamily | amoplefttype | amoprighttype | amopstrategy | amoppurpose |
amopopr | amopmethod | amopsortfamily
------------+--------------+---------------+--------------+-------------+---------+------------+----------------
       2745 |         2277 |          2277 |            1 | s           |
 2750 |       2742 |              0
       2745 |         2277 |          2277 |            2 | s           |
 2751 |       2742 |              0
       2745 |         2277 |          2277 |            3 | s           |
 2752 |       2742 |              0
       2745 |         2277 |          2277 |            4 | s           |
 1070 |       2742 |              0
(4 rows)

These records of system catalog are defined in special headers the source
code:
src/include/catalog/pg_amop.h
src/include/catalog/pg_amproc.h
src/include/catalog/pg_opclass.h
src/include/catalog/pg_opfamily.h
These records are written to system catalog during bootstrap process (see
src/backend/catalog/README).

As you can see pg_amproc records refer some procedures.  Those procedures
are actually the majority of source code behind of opclass.  Those
procedures are defined in src/backend/access/gin/ginarrayproc.c.

------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Reply via email to