Thread: FATAL: operator class "xxxx" does not exist for access method "btree"
Dear pgsql:
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Asia/Shanghai
creating configuration files ... ok
running bootstrap script ... 2023-07-19 09:40:47.083 CST [2808392] FATAL: operator class "key_ops" does not exist for access method "btree"
2023-07-19 09:40:47.083 CST [2808392] PANIC: cannot abort transaction 1, it was already committed
Aborted (core dumped)
child process exited with exit code 134
initdb: removing contents of data directory "/usr/local/pgsql/data"
When we adding a custom system table and defining an index for it at the same time, the code compilation is possible, but the following errors may occur when starting the database:
----------------------------------------------------------------------------------------------------------
fixing permissions on existing directory /usr/local/pgsql/data ... ok
creating subdirectories ... okselecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Asia/Shanghai
creating configuration files ... ok
running bootstrap script ... 2023-07-19 09:40:47.083 CST [2808392] FATAL: operator class "key_ops" does not exist for access method "btree"
2023-07-19 09:40:47.083 CST [2808392] PANIC: cannot abort transaction 1, it was already committed
Aborted (core dumped)
child process exited with exit code 134
initdb: removing contents of data directory "/usr/local/pgsql/data"
---------------------------------------------------------------------------------------------------------------
There are my steps as follows:
- add a new header file (pg_bm_client_global_keys_args.h) for the custom system table, the file path is : src/include/catalog/pg_bm_client_global_keys_args.h;
- the modified Makefile is: src/backend/catalog/Makefile, add the new header file at the label CATALOG_HEADERS of the file;
- make; make install
- when run the cmd : /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data, the error will occur.
Best Wishes.
Attachment
mao zhang <mzhang2048@gmail.com> writes: > running bootstrap script ... 2023-07-19 09:40:47.083 CST [2808392] FATAL: > operator class "key_ops" does not exist for access method "btree" I'm not sure what you find so mysterious about that error message. > Oid global_key_id; > ... > DECLARE_UNIQUE_INDEX(pg_bm_client_global_keys_args_oid_index,8063,BmClientGlobalKeysArgsOidIndexId,on pg_bm_client_global_keys_argsusing btree(global_key_id key_ops)); If global_key_id is an OID, why aren't you declaring its index with opclass oid_ops, rather than the quite nonexistent "key_ops"? regards, tom lane
Fixed!
Tom Lane <tgl@sss.pgh.pa.us> 于2023年7月19日周三 11:10写道:
mao zhang <mzhang2048@gmail.com> writes:
> running bootstrap script ... 2023-07-19 09:40:47.083 CST [2808392] FATAL:
> operator class "key_ops" does not exist for access method "btree"
I'm not sure what you find so mysterious about that error message.
> Oid global_key_id;
> ...
> DECLARE_UNIQUE_INDEX(pg_bm_client_global_keys_args_oid_index,8063,BmClientGlobalKeysArgsOidIndexId,on pg_bm_client_global_keys_args using btree(global_key_id key_ops));
If global_key_id is an OID, why aren't you declaring its index
with opclass oid_ops, rather than the quite nonexistent "key_ops"?
regards, tom lane