Re: Call flow of btinsert(PG_FUNCTION_ARGS)

From: Amit Langote <amitlangote09(at)gmail(dot)com>
To: Rohit Goyal <rhtgyl(dot)87(at)gmail(dot)com>
Cc: Peter Geoghegan <pg(at)heroku(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Call flow of btinsert(PG_FUNCTION_ARGS)
Date: 2013-11-19 10:45:12
Message-ID: CA+HiwqEBF-EPB5Tzm4_8kuTW4sV=YY_v4ZciV0DTGgp8Q6LshA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Nov 19, 2013 at 7:31 PM, Rohit Goyal <rhtgyl(dot)87(at)gmail(dot)com> wrote:
>
>
>
> On Tue, Nov 19, 2013 at 11:26 AM, Peter Geoghegan <pg(at)heroku(dot)com> wrote:
>>
>> On Tue, Nov 19, 2013 at 2:22 AM, Rohit Goyal <rhtgyl(dot)87(at)gmail(dot)com> wrote:
>> >
>> > I was reading b tree index code and I wanted to the know the calling
>> > function which calls btinsert(PG_FUNCTION_ARGS) function in nbtree.c
>> > file.
>> > Moreover, my goal behind reading this function was to check how tuple is
>> > inserted in btree.
>> > I want to understand the code flow for b tree index
>>
>> Take a look at this:
>>
>> http://www.postgresql.org/docs/9.3/static/index-functions.html
>>
>>
>> --
>> Peter Geoghegan
>
> thanks for reply. :) Moreover, I am so confused about reading the nbtree
> folder c files or the file which you gave.
>
> For example, If I want to read how the data is inserted in B tree index.
> Should I read your link or the btinsert(PG_FUNCTION_ARGS) in nbtree.c file
> in nbtree folder.
>
> In future, if i want to modify btree indexing approach, then which files to
> look for.?

You could use gdb to debug a simple INSERT.

Take a look at the following also:

[http://www.postgresql.org/docs/devel/static/catalog-pg-am.html]

"The catalog pg_am stores information about index access methods.
There is one row for each index access method supported by the
system."

For example,

postgres=# \x
Expanded display (expanded) is on.
postgres=# select * from pg_am;
-[ RECORD 1 ]---+------------------
amname | btree
amstrategies | 5
amsupport | 2
amcanorder | t
amcanorderbyop | f
amcanbackward | t
amcanunique | t
amcanmulticol | t
amoptionalkey | t
amsearcharray | t
amsearchnulls | t
amstorage | f
amclusterable | t
ampredlocks | t
amkeytype | 0
aminsert | btinsert
ambeginscan | btbeginscan
amgettuple | btgettuple
amgetbitmap | btgetbitmap
amrescan | btrescan
amendscan | btendscan
ammarkpos | btmarkpos
amrestrpos | btrestrpos
ambuild | btbuild
ambuildempty | btbuildempty
ambulkdelete | btbulkdelete
amvacuumcleanup | btvacuumcleanup
amcanreturn | btcanreturn
amcostestimate | btcostestimate
amoptions | btoptions
...
...

Likewise you could find access method (am) details for other index types.

So, if you want to study the flow for a btree insert you could set a
gdb breakpoint in btinsert (listed as 'aminsert' for btree above) to
begin with.

--
Amit

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Craig Ringer 2013-11-19 10:52:47 Re: Call flow of btinsert(PG_FUNCTION_ARGS)
Previous Message David Rowley 2013-11-19 10:35:55 Re: CLUSTER FREEZE