Issue Details (XML | Word | Printable)

Key: CORE-4716
Type: Improvement Improvement
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Nick
Votes: 2
Watchers: 6
Operations

If you were logged in you would be able to see more operations.
Firebird Core

user-friendly DPB-string in new api

Created: 21/Mar/15 08:35 PM   Updated: 22/Jan/17 12:19 PM
Component/s: API / Client Library
Affects Version/s: None
Fix Version/s: None


 Description  « Hide
Now DPB looks like this: #1'?'#1#3'0'#7'WIN1251'#$1C#6'SYSDBA'#$1D#9'masterkey' (in Delphi).
It is not so easy to generate it correctly.
Something like 'ConnectionSqlDialect=[3], ConnectionCharSet=[WIN1251], UserName=[SYSDBA], Password=[masterkey]' seems more friendly.

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Dimitry Sibiryakov added a comment - 22/Mar/15 03:45 PM
Should it be case-sensitive?
Comma-separated, zero-separated or semicolon separated?
Why use square braces instead of ODBC-standard braces?
Encoding? wchar_t?..
How to handle mistyped/unknown parameter names?

Doug Chamberlin added a comment - 22/Mar/15 05:16 PM
Please pick an established standard for this syntax, such as JSON, rather than using something new! That would answer all the questions from Dimitry, I think.

Also, avoid XML as the point is to make the options more readable.

Dimitry Sibiryakov added a comment - 22/Mar/15 05:26 PM - edited
Is ODBC standard established enough?..

Nick added a comment - 22/Mar/15 05:42 PM
I think...
>Should it be case-sensitive?
as in DPB

>Comma-separated, zero-separated or semicolon separated?
something human-printable and human-readable

>Why use square braces instead of ODBC-standard braces?
symbols ' and " are used for strings in many languages.
Now I think it will be useful if developer can use any of them, and maybe square braces too.
In C#: string dpb = "ConnectionSqlDialect='3', ConnectionCharSet='WIN1251', UserName='SYSDBA', Password='masterkey'";
In Delphi: DPB: string = 'ConnectionSqlDialect="3", ConnectionCharSet="WIN1251", UserName="SYSDBA", Password="masterkey"';

>Encoding? wchar_t?..
binary, with utf-8 encoded values if needed (username, path to database, etc. ), with doubling quote symbol if it is in param value (like UserName='it''s user').

>How to handle mistyped/unknown parameter names?
with smart skiping and error if parameter does not exists and not defined in skipped list for current version.
something like this:

with error for NoDbTriggers and ProcessName params for FB < 2.1 (they not exists there):
'EngineParams(ConnectionSqlDialect="3", ConnectionCharSet="WIN1251", UserName="SYSDBA", Password="masterkey", NoDbTriggers, ProcessName="D:\App.exe")'

with skip NoDbTriggers and ProcessName for FB < 2.1, and skipping SomeFB3Param for FB3:
'EngineParams(ConnectionSqlDialect="3", ConnectionCharSet="WIN1251", UserName="SYSDBA", Password="masterkey", NoDbTriggers, ProcessName="D:\App.exe", SomeFB3Param="ParamValue" ,SkipParamsForVersionsLowerThan("2.1.0")="NoDbTriggers, ProcessName"), SkipParamsForVersionsLowerThan("3")="SomeFB3Param")'


and with plugin params:
'EngineParams(ConnectionSqlDialect="3", ConnectionCharSet="WIN1251", UserName="SYSDBA", Password="masterkey"), PluginParams(PluginName="DS_Replication", Timeout="30"), PluginParams(PluginName="SmartLogging", LogLevel="12")'

with skip:
'EngineParams(ConnectionSqlDialect="3", ConnectionCharSet="WIN1251", UserName="SYSDBA", Password="masterkey"), PluginParams(PluginName="DS_Replication", Timeout="30"), PluginParams(PluginName="SmartLogging", LogLevel="12", SkipParamsForVersionsLowerThan("0.1")="LogLevel")'

Nick added a comment - 22/Mar/15 06:09 PM
JSON is good too.
{
    "Engine": {
        "ConnectionSqlDialect": 3,
        "ConnectionCharSet": "WIN1251",
        "UserName": "SYSDBA",
        "Password": "masterkey",
        "VersionParams": {
            "2.1": {
                "NoDbTriggers": True,
                "ProcessName": "D:\App.exe"
            },
            "3": {
                "SomeFB3Param": "ParamValue"
            }
        }
    },
    "Plugin": {
       "Name": "DS_Replication",
       "Timeout": 30
    },
    "Plugin": {
       "Name": "SmartLogging",
        "PluginVersionParams": {
            "0.1": {
                "LogLevel": 12
            }
        }
    }
}

PizzaProgram Ltd. added a comment - 22/Jan/17 12:19 PM
While this seems to be a great feature at first sight, please consider following aspects too:
1.) SPEED:
 - it is obvious that parsing a JSON gives much more overhead than analysing a simple #1 char
 - The ideal DB connection is, if you: <Connect><do things><Disconnect> ... as quickly as possible.
 - param-parsing + encrypting + compressing should happen at the client side BEFORE a connection attempt is made

2.) Encryption / safety / password protection:
 - it is very hard to protect something encrypted, if there are always standard keywords at standard places.
(Think about how they decrypted the enigma machine ... )
Think about if YOUR personal data would be hacked from a DB.

3.) Separating:
 - maybe if there would be a feature to send more specific (JSON formed) parameters AFTER a connection has been established with minimum params.

4.) Enhancements:
 - it would be nice to be able to disable showing DB-PATHs in the 'firebird.log' file.
 (Currently you can easily find a database hidden on a PC or server by simply looking at this log file and search for errors when connection broke. It reveals the full path. :(( )
 - or turn OFF logging completely during a specific connection.
 - overwriting connection/command/idle timeouts (See: CORE-985)