Skip to content

Allow specifying exactly what type of database string is expected in the database section for trace configuration #8427

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 2, 2025

Conversation

Noremos
Copy link
Contributor

@Noremos Noremos commented Feb 3, 2025

The new syntax:

database = name /var/primary-db.fdb  
{  
enabled = true  
log_errors = true  
}  

database = name /var/secondary.fdb  
{  
enabled = true  
log_connections = true  
}  

database = regex (%[\\/](e[[:DIGIT:]]{{2}}).fdb)  
{  
enabled = true  
}  

# Default behavior for backward compatibility  
database = %[\\/]my_database.fdb  
{  
enabled = true  
}  

I chose database = name path.fdb over database name = path.fdb because it is easier to implement and parse, but it doesn't look as great, so it can be reimplemented.

Copy link
Member

@hvlad hvlad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, avoid massive not related changes such as end space trimming.
It makes harder to read the patch looking for valuable changes.

@hvlad
Copy link
Member

hvlad commented Feb 3, 2025

I chose database = name path.fdb over database name = path.fdb because it is easier to implement and parse, but it doesn't look as great, so it can be reimplemented.

Consider databaseName = path or databaseByName = path.

Note, in proposed syntax database name path.fdb also accepted, as = is not required by config code.

Also, your sample is wrong as default section must be the first one.

@Noremos
Copy link
Contributor Author

Noremos commented Feb 3, 2025

Please, avoid massive not related changes such as end space trimming. It makes harder to read the patch looking for valuable changes.

Sorry, my IDE automatically trimmed the spaces and didn't display them in the DIFF editor

@Noremos
Copy link
Contributor Author

Noremos commented Feb 3, 2025

I chose database = name path.fdb over database name = path.fdb because it is easier to implement and parse, but it doesn't look as great, so it can be reimplemented.

Consider databaseName = path or databaseByName = path.

Now databaseName and databaseRegex are used

database
{
	enabled = false
}

databaseName = /var/primary-db.fdb
{
	enabled = true
	log_errors = true
}

databaseRegex = (%[\\/](e[[:DIGIT:]]{{2}}).fdb)
{
	enabled = true
}

database = employee
{
	enabled = true
}

@dyemanov dyemanov merged commit f54cd06 into FirebirdSQL:master Apr 2, 2025
24 checks passed
@pavel-zotov
Copy link

If we try to run trace with following config:

database =
{
	enabled = true
	log_initfini = false

	time_threshold = 0
    log_statement_finish = true
    print_perf = true
}

services 
{
	#enabled = true
	log_initfini = false
	log_services = true
	log_errors = true
}

-- then on 6.0.0.710-f54cd06 we will get:

Error creating trace session for service manager attachment:
error while parsing trace configuration
line 11: wrong section header, "database", "databaseName", "databaseRegex" or "service" is expected

But in fbtrace.conf there is comment:
# - there is two kind of sections allowed : "database" and "services"

So, what is the proper name of section related to services - should it be specified in the singular or plural form ?

@Noremos
Copy link
Contributor Author

Noremos commented Apr 2, 2025

The correct term is "services." I misspelled it, but I'll prepare a PR to fix it.

@Noremos
Copy link
Contributor Author

Noremos commented Apr 2, 2025

#8500

@pavel-zotov
Copy link

#	database = (%[\\/](e[[:DIGIT:]]{{2}}).fdb)
vs
#	databaseRegex = (%[\\/](e[[:DIGIT:]]{{2}}).fdb)

What's the difference between them ? (i.e. for what one more section was introduced - just for ease of perception when read trace config ?)

@Noremos
Copy link
Contributor Author

Noremos commented Apr 3, 2025

#	database = (%[\\/](e[[:DIGIT:]]{{2}}).fdb)
vs
#	databaseRegex = (%[\\/](e[[:DIGIT:]]{{2}}).fdb)

What's the difference between them ? (i.e. for what one more section was introduced - just for ease of perception when read trace config ?)

This change is a solution to a problem when there is a database that has a correct path but the path is an incorrect regex: #8426

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants