IP Library › Granted Patent US 12,475,100
Granted Patent B2
US 12,475,100 · App. 17/478,233 · Granted Nov 18, 2025

Using ad-hoc stored procedures for online transaction processing

Inventors: Mayank Lahiri (San Francisco, CA); Jayakrishnan Balakrishnan Nair (San Ramon, CA); Padmaja U. Mantravadi (Cupertino, CA)
Assignee: Twilio Inc.
G06F16/2343G06F16/2358G06F16/2365G06F16/2379G06F16/2443G06F16/252
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,475,100
App. No.
17/478,233
Granted
Nov 18, 2025
Kind
B2
Abstract

An example method of using ad-hoc stored procedures for OLTP operations includes: identifying, by a processing device, one or more values for updating a dataset stored in a database; creating an ad-hoc stored procedure comprising a sequence of commands specifying atomically-executable database update operations with respect to the dataset, wherein the atomically-executable database update operations utilize the one or more values that are encoded into the sequence of commands by respective inline constant values; executing the ad-hoc stored procedure, wherein the executing comprises acquiring a temporary lock of at least part of the dataset; and dropping the ad-hoc stored procedure.

Claims (46)

1 . A method, comprising:

generating, by a processing device, based on one or more templates, a create procedure command for updating a dataset stored in a database, wherein each template of the one or more templates comprises a text of a database update command, the text comprising one or more placeholders for respective data values;

creating, by executing the create procedure command, an ad-hoc stored procedure comprising a sequence of database access commands specifying atomically-executable database update operations with respect to the dataset, wherein the atomically-executable database update operations utilize one or more values that are encoded into the sequence of database access commands by respective inline constant values substituting the one or more placeholders, wherein a procedure name of the ad-hoc stored procedure comprises a digest of the one or more values that are encoded into the sequence of commands by respective inline constant values; and

executing the ad-hoc stored procedure, wherein the executing comprises:

acquiring a temporary lock of at least part of the dataset,

transforming a loop within the ad-hoc stored procedure into a linear sequence of operations,

performing the atomically-executable database update operations with respect to the dataset, and

releasing the temporary lock, with no intervening transfers of execution control to a client between acquiring and releasing the temporary lock.

2 . The method of claim 1 , wherein the ad-hoc stored procedure accepts no parameters.

3 . The method of claim 1 , wherein the dataset comprises one or more records of a table of the database.

4 . The method of claim 1 , wherein the atomically-executable database update operations update, using the one or more values, one or more records of one or more tables of the database.

5 . The method of claim 1 , wherein the ad-hoc stored procedure comprises: a transaction start command, one or more database update commands referencing the one or more values, and a transaction commit command.

6 . The method of claim 1 , further comprising:

responsive to detecting a failure of an operation of the atomically-executable database update operations, rolling back database updates that have been performed by preceding operations of the atomically-executable database update operations.

7 . The method of claim 1 , wherein the procedure name of the ad-hoc stored procedure further comprises at least one of: a predefined prefix including one or more alphanumeric characters or a predefined suffix including one or more alphanumeric characters.

8 . The method of claim 1 , further comprising:

keeping the ad-hoc stored procedure in the database; and

re-using the ad-hoc stored procedure.

9 . A system, comprising:

a memory; and

a processing device, coupled to the memory, the processing device to:

generate, based on one or more templates, a create procedure command for updating a dataset stored in a database, wherein each template of the one or more templates comprises a text of a database update command, the text comprising one or more placeholders for respective data values;

create, by executing the create procedure command, an ad-hoc stored procedure comprising a sequence of database access commands specifying atomically-executable database update operations with respect to the dataset, wherein the atomically-executable database update operations utilize one or more values that are encoded into the sequence of database access commands by respective inline constant values substituting the one or more placeholders, wherein a procedure name of the ad-hoc stored procedure comprises a digest of the one or more values that are encoded into the sequence of commands by respective inline constant values; and

execute the ad-hoc stored procedure, wherein the executing comprises:

acquiring a temporary lock of at least part of the dataset,

transforming a loop within the ad-hoc stored procedure into a linear sequence of operations,

performing the atomically-executable database update operations with respect to the dataset, and

releasing the temporary lock, with no intervening transfers of execution control to a client between acquiring and releasing the temporary lock.

10 . The system of claim 9 , wherein the ad-hoc stored procedure accepts no parameters.

11 . The system of claim 9 , wherein the atomically-executable database update operations update, using the one or more values, one or more records of one or more tables of the database.

12 . The system of claim 9 , wherein the ad-hoc stored procedure comprises: a transaction start command, one or more database update commands referencing the one or more values, and a transaction commit command.

13 . The system of claim 9 , wherein the processing device is further to: responsive to detecting a failure of an operation of the atomically-executable database update operations, roll back database updates that have been performed by preceding operations of the atomically-executable database update operations.

14 . A non-transitory computer-readable storage medium comprising executable instructions that, when executed by a computer system, cause the computer system to:

generate, based on one or more templates, a create procedure command for updating a dataset stored in a database, wherein each template of the one or more templates comprises a text of a database update command, the text comprising one or more placeholders for respective data values;

create, by executing the create procedure command, an ad-hoc stored procedure comprising a sequence of database access commands specifying atomically-executable database update operations with respect to the dataset, wherein the atomically-executable database update operations utilize one or more values that are encoded into the sequence of database access commands by respective inline constant values substituting the one or more placeholders, wherein a procedure name of the ad-hoc stored procedure comprises a digest of the one or more values that are encoded into the sequence of commands by respective inline constant values; and

execute the ad-hoc stored procedure, wherein the executing comprises:

acquiring a temporary lock of at least part of the dataset,

transforming a loop within the ad-hoc stored procedure into a linear sequence of operations,

performing the atomically-executable database update operations with respect to the dataset,

and releasing the temporary lock, with no intervening transfers of execution control to a client between acquiring and releasing the temporary lock.

15 . The non-transitory computer-readable storage medium of claim 14 , wherein the atomically-executable database update operations update, using the one or more values, one or more records of one or more tables of the database.

16 . The non-transitory computer-readable storage medium of claim 14 , wherein the ad-hoc stored procedure comprises: a transaction start command, one or more database update commands referencing the one or more values, and a transaction commit command.

17 . The non-transitory computer-readable storage medium of claim 14 , further comprising executable instructions that, when executed by the computer system, cause the computer system to:

responsive to detecting a failure of an operation of the atomically-executable database update operations, rolling back database updates that have been performed by preceding operations of the atomically-executable database update operations.

18 . The non-transitory computer-readable storage medium of claim 14 , wherein the ad-hoc stored procedure accepts no parameters.

19 . The non-transitory computer-readable storage medium of claim 14 , wherein the dataset comprises one or more records of a table of the database.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Sep 17, 2021
From: LAHIRI, MAYANK; NAIR, JAYAKRISHNAN BALAKRISHNAN; MANTRAVADI, PADMAJA U.
To: TWILIO INC.
Reel/Frame 057518/0332 →
Continuity (2)
Provisional Application 63235049 · Aug 19, 2021
Related Publication 20230054501A1 · Feb 23, 2023
References Cited (35)
US 5553234A · Cotner · 1996 [cited by examiner]
US 5835755A · Stellwagen, Jr. · 1998 [cited by examiner]
US 6725213B1 · Chiocca · 2004 [cited by examiner]
US 7058620B1 · Mandel, III · 2006 [cited by examiner]
US 7720884B1 · Gandhi · 2010 [cited by examiner]
US 9734222B1 · Milne · 2017 [cited by examiner]
US 10545957B1 · Winiarski · 2020 [cited by examiner]
US 11061965B1 · Heisz · 2021 [cited by examiner]
US 11256684B1 · Papakonstantinou · 2022 [cited by examiner]
US 20030028498A1 · Hayes-Roth · 2003 [cited by examiner]
US 20030066053A1 · Al-Azzawe · 2003 [cited by examiner]
US 20030159089A1 · DiJoseph · 2003 [cited by examiner]
US 20040162822A1 · Papanyan · 2004 [cited by examiner]
US 20070208695A1 · Burger · 2007 [cited by examiner]
US 20080034014A1 · Beck · 2008 [cited by examiner]
US 20090287737A1 · Hammerly · 2009 [cited by examiner]
US 20130151491A1 · Gislason · 2013 [cited by examiner]
US 20130151591A1 · Lee · 2013 [cited by examiner]
US 20130198218A1 · Wu · 2013 [cited by examiner]
US 20140280324A1 · Teletia · 2014 [cited by examiner]
US 20160196295A1 · Bhattacharjee · 2016 [cited by examiner]
US 20180082043A1 · Witchey · 2018 [cited by examiner]
US 20180260196A1 · Andrews · 2018 [cited by examiner]
US 20190324952A1 · Ying · 2019 [cited by examiner]
US 20190354620A1 · Eluri · 2019 [cited by examiner]
US 20200320069A1 · Jeong · 2020 [cited by examiner]
US 20210240854A1 · Krafcik · 2021 [cited by examiner]
US 20210264420A1 · Tammana · 2021 [cited by examiner]
WO WO2014150098A1 · 2014 [cited by examiner]
Manish Sharma, “How To Create PL/SQL Stored Procedures Without Parameters In Oracle Database”, Jan. 11, 2019, pp. 1-3 (Year: 2019). [cited by examiner]
Hannah Vernon, “Database Administrators: Transaction in a stored procedure”, Apr. 1, 2016, Database Administrators, pp. 5 (Year: 2016). [cited by examiner]
Solomon Rutzky and Frosty840, “How can I set a lock inside a stored procedure?”, Nov. 20, 2014, 3 pages. (Year: 2014). [cited by examiner]
WG, “Loop unrolling”, Feb. 9, 2012, https://forums.ni.com/t5/LabVIEW-Idea-Exchange/Loop-unrolling/idi-p/1870107, Labview Idea Exchange, pp. 1-11. (Year: 2012). [cited by examiner]
Tarang, “Using digest in a stored procedure #1096”, Apr. 7, 2021, Supabase, pp. 2. (Year: 2021). [cited by examiner]
“14.22.4 InnoDB Error Handling”, https://docs.oracle.com/cd/E17952_01/mysql-5.7-en/innodb-error-handling.html, 1 page, [retrieved from the internet on May 25, 2022]. [cited by applicant]