Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Spanner DB Functions and Triggers

I am in the process of evaluating Cloud Spanner to determine if its the proper fit.  We currently are running a PostgreSQL database and am planning to build in some functions and triggers so we can centralize some of the queries and have them as standards.  

When looking into Spanner, I do not see any means of creating stored procs, functions or triggers.  Seems like these options may not be available, so I am trying to figure out how to do this in the cloud?  Do I use Could Functions or something?  

Hopefully what I am trying to say makes sense and thank you in advance for any help.  

 

Thank you.

1 1 4,380
1 REPLY 1

As you mentioned in the public documentation the functionality should be created in the application logic [1]:

  • Views
  • Triggers
  • Stored procedures
  • User-defined functions (UDFs)
  • Columns that use serial data types as sequence generators

I found this Stackoverflow article that suggested using App engine for small scripts and Dataflow for large jobs [2].

As for the triggers I believe you can use Cloud Functions as mentioned in the documentation [3].

Hopefully this answered your questions.

[1]https://cloud.google.com/spanner/docs/migrating-postgres-spanner#other-database-objects  [2]https://stackoverflow.com/questions/42278193/does-google-cloud-spanner-support-stored-procedures

[3]https://cloud.google.com/spanner/docs/use-cloud-functions