Skip to content
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

Transaction parameters tpShared/tpProtected unusable #2

Open
Alekcvp opened this issue Jun 15, 2017 · 5 comments
Open

Transaction parameters tpShared/tpProtected unusable #2

Alekcvp opened this issue Jun 15, 2017 · 5 comments

Comments

@Alekcvp
Copy link

Alekcvp commented Jun 15, 2017

When transaction options tpShared or tpProtected enabled, StartTransaction raises an exception with error:

Table reservation lock type isc_tpb_shared requires tablename before in TPB

This is because the option syntax is like:

...
lock_write TABLE
shared / protected
....

but the actual TPB from CreateTRParams produced in the natural order of parameters like:

....
shared / protected
....
lock_write TABLE
....

Update:
UIB Compiled with {$DEFINE FB30} set in uib.inc.
These options shouldn't be there at all but they are due to #3.

@the-Arioch
Copy link
Owner

the-Arioch commented Jun 23, 2017

so, is this basically a duplicate of #3 ? Are them the same issue or different ones ?

Did you tried with FB3 if those options work there ?

@the-Arioch
Copy link
Owner

This is because the option syntax is like:

...
lock_write TABLE
shared / protected

Where is it specified how exactly those options should be ordered ?

@Alekcvp
Copy link
Author

Alekcvp commented Jun 23, 2017

Where is it specified how exactly those options should be ordered ?

Firebird 3.0, see attached screenshots for options and error:

//----------
// FIREBIRD
//----------
{.$DEFINE FB102}
{.$DEFINE FB103}
{.$DEFINE FB15}
{.$DEFINE FB20}
{.$DEFINE FB21}
{.$DEFINE FB25}
{$DEFINE FB30}
{.$DEFINE FBEMBED}

transaction
exception

I've made a quick and dirty workaround, but at least it's worked now:

function CreateTRParams(Options: TTransParams; const LockRead, LockWrite: string{$IFDEF FB20_UP}; LockTimeout: Word{$ENDIF}): RawByteString;
  var
    tp: TTransParam;
    procedure ParseStrOption(const code: AnsiChar; const Value: AnsiString);
    var
      P, Start: PAnsiChar;
      S, T: AnsiString;
    begin
      P := Pointer(Value);
      if P <> nil then
        while (P^ <> #0) do
        begin
          Start := P;
        {$IFDEF FB21_UP}
          case P^ of
            '~': T := isc_tpb_shared;
            '!': T := isc_tpb_protected;
          else
        {$ENDIF}
            T := '';
        {$IFDEF FB21_UP}
          end;
          Inc(Start, Length(T));
        {$ENDIF}
          while not (P^ in [#0, ';']) do Inc(P);
          if (P - Start) > 0 then
          begin
            SetString(S, Start, P - Start);
            Result := Result + code + AnsiChar(P - Start) + S + T;
          end;
          if P^ =';' then inc(P);
        end;
    end;

The table names in lock_xxx property should now start with '~' or '!' if you need shared or protected lock.

@Alekcvp
Copy link
Author

Alekcvp commented Jun 23, 2017

so, is thsi basicalyl a dub of #3 ? Are them the same issue or different ones ?

#3 is the reason why the 'tpShared' and 'tpProtected' parameters is shown for Firebird 2.1 and up.

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

No branches or pull requests

2 participants