[asterisk-bugs] [JIRA] (ASTERISK-25938) MySQL/MariaDB statement LAST_INSERT_ID() always returns zero.

Edwin Vandamme (JIRA) noreply at issues.asterisk.org
Tue Apr 19 07:53:56 CDT 2016


     [ https://issues.asterisk.org/jira/browse/ASTERISK-25938?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Edwin Vandamme updated ASTERISK-25938:
--------------------------------------

    Description: 
After upgrading to Asterisk 13.8.0 the MySQL/MariaDB statement LAST_INSERT_ID() always returns zero.
To double check that it is related to Asterisk, I recompiled and installed 13.7.0 without any other modifications and the LAST_INSERT_ID() was returned correctly.
To be sure, I recompiled and installed 13.8.0 and the problem returned.
So back to 13.7.0 and no problem whatsoever.
I checked the latest version which at time of writing is 13.8.1 and the problem returned.
So back to 13.7.0 and no problem whatsoever.


In my extensions.conf I do the following : 
{quote}
; Lock MySQL/MariaDB access.
same = n,While($[${L} <= 0])
same = n,Set(L=${LOCK(MySQL)})
same = n,EndWhile()

; Mark start of a call attempt.
same = n,Set(history_h1(${nIServer},${IProject},${ANI})=)

; Get unique call id
same = n,Set(CallId=${history_h2()})

; Unlock MySQL access as the correct CallId was found.
same = n,Set(L=${UNLOCK(MySQL)})
{quote}

In my func_odbc.conf I do the following : 
{quote}
[h1]
prefix=history
dsn=asterisk
writesql=INSERT INTO callsystem.history SET IServer=${ARG1},IProject='${ARG2}',CallerId='${ARG3}',Status='ONLINE';

[h2]
prefix=history
dsn=asterisk
readsql=SELECT LAST_INSERT_ID() FROM callsystem.history LIMIT 1;
{quote}

I also tried
{quote}
readsql=SELECT LAST_INSERT_ID(); to no avail.
{quote}

  was:
After upgrading to Asterisk 13.8.0 the MySQL/MariaDB statement LAST_INSERT_ID() always returns zero.
To double check that it is related to Asterisk, I recompiled and installed 13.7.0 without any other modifications and the LAST_INSERT_ID() was returned correctly.
To be sure, I recompiled and installed 13.8.0 and the problem returned.
So back to 13.7.0 and no problem whatsoever.
I checked the latest version which at time of writing is 13.8.1 and the problem returned.
So back to 13.7.0 and no problem whatsoever.


In my extensions.conf I do the following : 
<blockquote>
; Lock MySQL/MariaDB access.
same = n,While($[${L} <= 0])
same = n,Set(L=${LOCK(MySQL)})
same = n,EndWhile()

; Mark start of a call attempt.
same = n,Set(history_h1(${nIServer},${IProject},${ANI})=)

; Get unique call id
same = n,Set(CallId=${history_h2()})

; Unlock MySQL access as the correct CallId was found.
same = n,Set(L=${UNLOCK(MySQL)})
</blockquote>
In my func_odbc.conf I do the following : 
<blockquote>
[h1]
prefix=history
dsn=asterisk
writesql=INSERT INTO callsystem.history SET IServer=${ARG1},IProject='${ARG2}',CallerId='${ARG3}',Status='ONLINE';

[h2]
prefix=history
dsn=asterisk
readsql=SELECT LAST_INSERT_ID() FROM callsystem.history LIMIT 1;
</blockquote>

I also tried
<blockquote>
readsql=SELECT LAST_INSERT_ID(); to no avail.
</blockquote>


> MySQL/MariaDB statement LAST_INSERT_ID() always returns zero.
> -------------------------------------------------------------
>
>                 Key: ASTERISK-25938
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-25938
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>    Affects Versions: 13.8.0, 13.8.1
>         Environment: CentOS	  	  	7.2		  	2015-11
> Asterisk	  		13.8.0/13.8.1
> MariaDB			5.5.44
> unixODBC		2.3.1
> jansson  	  		2.7	  		2014-10-02
> PJSIP (pjproject)	2.4.5		2015-08-12
>            Reporter: Edwin Vandamme
>
> After upgrading to Asterisk 13.8.0 the MySQL/MariaDB statement LAST_INSERT_ID() always returns zero.
> To double check that it is related to Asterisk, I recompiled and installed 13.7.0 without any other modifications and the LAST_INSERT_ID() was returned correctly.
> To be sure, I recompiled and installed 13.8.0 and the problem returned.
> So back to 13.7.0 and no problem whatsoever.
> I checked the latest version which at time of writing is 13.8.1 and the problem returned.
> So back to 13.7.0 and no problem whatsoever.
> In my extensions.conf I do the following : 
> {quote}
> ; Lock MySQL/MariaDB access.
> same = n,While($[${L} <= 0])
> same = n,Set(L=${LOCK(MySQL)})
> same = n,EndWhile()
> ; Mark start of a call attempt.
> same = n,Set(history_h1(${nIServer},${IProject},${ANI})=)
> ; Get unique call id
> same = n,Set(CallId=${history_h2()})
> ; Unlock MySQL access as the correct CallId was found.
> same = n,Set(L=${UNLOCK(MySQL)})
> {quote}
> In my func_odbc.conf I do the following : 
> {quote}
> [h1]
> prefix=history
> dsn=asterisk
> writesql=INSERT INTO callsystem.history SET IServer=${ARG1},IProject='${ARG2}',CallerId='${ARG3}',Status='ONLINE';
> [h2]
> prefix=history
> dsn=asterisk
> readsql=SELECT LAST_INSERT_ID() FROM callsystem.history LIMIT 1;
> {quote}
> I also tried
> {quote}
> readsql=SELECT LAST_INSERT_ID(); to no avail.
> {quote}



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list