User does not have authority/permission despite being db2 dba admin user - db2

On Db2 v11.1 Enterprise Edition on Linux/x86-64 I checked authorities for my current connected user:
select
granteetype,
dbadmauth,
securityadmauth,
dataaccessauth,
accessctrlauth
from syscat.dbauth
where grantee = 'ADM1'
and from output I see this user is super user on database:
GRANTEETYPE DBADMAUTH SECURITYADMAUTH DATAACCESSAUTH ACCESSCTRLAUTH
----------- --------- --------------- -------------- --------------
U Y Y Y Y
When I try to do one of the following three tasks I always get permission errors.
db2 "select * from sysibmadm.snaptab_reorg"
SQL1092N The requested command or operation failed because the user
ID does not have the authority to perform the requested command or
operation. User ID: "ADM1".
db2 "CREATE REGULAR TABLESPACE tbs1"
SQL0552N "ADM1" does not have the privilege to perform
operation "CREATE TABLESPACE". SQLSTATE=42502
db2 "CREATE bufferpool bp1"
SQL0552N "ADM1" does not have the privilege to perform operation
"CREATE BUFFERPOOL". SQLSTATE=42502
Why does 'ADM1' user get permission errors?
Regards

I checked documentation create tablespace, create bufferpool and snaptab_org table and all of them require one of the SYSxxx authority, but user "ADM1" does not have one of SYSxxx authorities.
select * from table
(sysproc.auth_list_authorities_for_authid ('ADM1', 'U')) as t
where authority like 'SYS%'
AUTHORITY D_USER D_GROUP D_PUBLIC ROLE_USER ROLE_GROUP ROLE_PUBLIC D_ROLE
--------- ------ ------- -------- --------- ---------- ----------- ------
SYSADM * N * * * * *
SYSCTRL * N * * * * *
SYSMAINT * N * * * * *
SYSMON * N * * * * *
P.S. I wrongly assumed that DBA authority is sufficient for those actions.

Related

What is the seq_name column in the ag_label table?

I'm working on a new feature that involves labels for Apache AGE and I'm looking for tools with which I can work with.
In psql interface, when you input the command SELECT * FROM ag_catalog.ag_label; the following output is shown:
name | graph | id | kind | relation | seq_name
------------------+--------+----+------+-----------------------+-------------------------
_ag_label_vertex | 495486 | 1 | v | test._ag_label_vertex | _ag_label_vertex_id_seq
_ag_label_edge | 495486 | 2 | e | test._ag_label_edge | _ag_label_edge_id_seq
vtx_label | 495486 | 3 | v | test.vtx_label | vtx_label_id_seq
elabel | 495486 | 4 | e | test.elabel | elabel_id_seq
I came across this and wasn't able to figure out what kind of data I can retrieve from it, what is it used for or how can it help me.
Can you explain the seq_name column?
Seq_name refers to sequences. Sequences are single-row tables that can be thought of as 'number generators' that start at some minimum integer value and then increment as they are 'consumed'.
A sequence that is associated with a column can be used to assign values to it. For example, 'mytable_seq_id' associated with column 'id' in a particular table 'mytable' might start at 1. Then as you add more entries to mytable, the 'id' column begins to increment to 2,3 and so on.
Postgres docs on creating sequences:
https://www.postgresql.org/docs/current/sql-createsequence.html
As for AGE, here's a comment taken directly out of the 'graph_commands.c' source file. It describes how sequences are used to generate labels ids.
static Oid create_schema_for_graph(const Name graph_name)
{
char *graph_name_str = NameStr(*graph_name);
CreateSchemaStmt *schema_stmt;
CreateSeqStmt *seq_stmt;
TypeName *integer;
DefElem *data_type;
DefElem *maxvalue;
DefElem *cycle;
Oid nsp_id;
/*
* This is the same with running the following SQL statement.
*
* CREATE SCHEMA `graph_name`
* CREATE SEQUENCE `LABEL_ID_SEQ_NAME`
* AS integer
* MAXVALUE `LABEL_ID_MAX`
* CYCLE
*
* The sequence will be used to assign a unique id to a label in the graph.
*
* schemaname doesn't have to be graph_name but the same name is used so
* that users can find the backed schema for a graph only by its name.
*
* ProcessUtilityContext of this command is PROCESS_UTILITY_SUBCOMMAND
* so the event trigger will not be fired.
*/
Note that sequences are used in other functions in the AGE internals as well, and the above function is just one example.

Postgres FTS Priority Field

I am using Postgres FTS to search a field in a table. The only issue is for some reason the below issue is happening.
store=# select name from service where to_tsvector(name) ## to_tsquery('find:*') = true;
name
--------------
Finding Nora
(1 row)
store=# select name from service where to_tsvector(name) ## to_tsquery('findi:*') = true;
name
------
(0 rows)
store=# select name from service where to_tsvector(name) ## to_tsquery('findi:*') = true;
How come when searching using the query findi:*,the result doesnt show?
In my PG 12.2 with default text search configuration I have:
# select to_tsvector('Finding Nora');
to_tsvector
-------------------
'find':1 'nora':2
(1 row)
# select to_tsquery('findi:*');
to_tsquery
------------
'findi':*
(1 row)
I understand that because there is no lexeme findi in the default dictionary, the query does not find any match.

PostgreSQL full text search yielding weird results

I have a schema like this (simplified):
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name NOT NULL
);
CREATE INDEX users_idx
ON users
USING GIN (to_tsvector('finnish', name));
But I'm getting completely invalid results with my queries:
# select name from users where to_tsvector('finnish', name) ## to_tsquery('lemmin');
name
------
(0 rows)
# select name from users where to_tsvector('finnish', name) ## to_tsquery('lemmink');
name
--------------------
Riitta ja Lemminki
Riitta ja Lemminki
(2 rows)
# select name from users where name ilike 'lemmink%';
name
----------------------
Lemminkäinen Matilda
Lemminkäinen Matias
Lemminkäinen Kyösti
Lemminkäinen Tuomas
(4 rows)
Another example:
# select name from users where to_tsvector('finnish', name) ## to_tsquery('partu');
name
----------
Partuuna
(1 row)
# select name from users where to_tsvector('finnish', name) ## to_tsquery('partur');
name
------------------------
Parturi-Kampaamo Raija
Parturi-Kampaamo Siema
(2 rows)
I was expecting to get the bottom two results on both queries...
Using the following version:
psql (9.4.6, server 9.5.2)
WARNING: psql major version 9.4, server major version 9.5.
Some psql features might not work.
I don't speak Finnish, but it seems expected result. FTS looks for lexemes, not for parts of words, Eg, do is not a lexemme for dog, but dog is for dogs:
t=# select to_tsvector('english', 'Dogs eats bone') ## to_tsquery('do');
NOTICE: text-search query contains only stop words or doesn't contain lexemes, ignored
?column?
----------
f
(1 row)
t=# select to_tsvector('english', 'Dogs eats bone') ## to_tsquery('dog');
?column?
----------
t
(1 row)
So I believe in Parturi last i is optional ending - right?..
Update:
from https://en.wiktionary.org/wiki/parturi :
partur[i], partur[eita] => lexeme will be partur

Play 2.4 / Slick 3.1: database evolution connection leak

I have a default setup of Play 2.4 and Slick 3.1 and I'm using database evolutions (my db is PostgreSQL). It seems that evolutions create a connection leak.
I'm connecting to two databases (prod and test):
slick.dbs.default.driver = "slick.driver.PostgresDriver$"
slick.dbs.default.db.driver = "org.postgresql.Driver"
slick.dbs.default.db.url = "jdbc:postgresql://localhost:5432/et"
slick.dbs.default.db.user = "postgres"
slick.dbs.default.db.password = "postgres"
slick.dbs.test.driver = "slick.driver.PostgresDriver$"
slick.dbs.test.db.driver = "org.postgresql.Driver"
slick.dbs.test.db.url = "jdbc:postgresql://localhost:5432/et_test"
slick.dbs.test.db.user = "postgres"
slick.dbs.test.db.password = "postgres"
This is the connection count before the application is started:
et=# select count(*) from pg_stat_activity;
count
-------
3
(1 row)
This is the connection count after the application is started:
et=# select count(*) from pg_stat_activity;
count
-------
45
(1 row)
It would seem each database allocates 21 connections - 42 in total, fair enough.
This is the connection count after the "apply evolutions" is clicked:
et=# select count(*) from pg_stat_activity;
count
-------
87
(1 row)
It seems evolutions allocate 21 more connections per database, so another 42.
After 10 minutes of application running idle:
et=# select count(*) from pg_stat_activity;
count
-------
87
(1 row)
This looks like an obvious connection leak created by evolutions, doesn't it? Correct me if I'm wrong. Any ideas on how to fix this?

SQL Server 2008 R2 database size

How to find the default size of database in SQL Server 2008 R2?
I can try this
select * from sys.dm_db_file_space_usage
but it should not give the result.
SELECT
database_name = DB_NAME(database_id)
, log_size_mb = CAST(SUM(CASE WHEN type_desc = 'LOG' THEN size END) * 8. / 1024 AS DECIMAL(8,2))
, row_size_mb = CAST(SUM(CASE WHEN type_desc = 'ROWS' THEN size END) * 8. / 1024 AS DECIMAL(8,2))
, total_size_mb = CAST(SUM(size) * 8. / 1024 AS DECIMAL(8,2))
FROM sys.master_files WITH(NOWAIT)
WHERE database_id = DB_ID()
GROUP BY database_id
Choose your database in query panel or you can use USE DATABASE_NAME GO at top of this code.
--EDIT--
I found built-in stored procedure for this :
EXEC sp_helpdb #dbname= 'your_database_name'