Google Cloud SQL中的用户定义函数的替代方案 [英] Alternative to user defined functions in Google's Cloud SQL

查看:123
本文介绍了Google Cloud SQL中的用户定义函数的替代方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚将我的数据库转移到Google的Cloud SQL,但正如 Google Cloud上的常见问题解答SQL ,它表示用户定义的函数不受支持。我正在使用一个名为Levenshtein的函数,它取自这篇 stackoverflow文章,对我在数据库中创建的字典执行搜索。这是一个功能,可以找到类似的单词(包括拼写错误),并返回给定单词的距离。

Google是否提供了用户定义函数的替代方法,允许我使用此功能执行搜索?

解决方案

您对术语感到困惑:


  • 用户定义函数 =在真实代码中定义的函数,编译为DLL / SO,并在MySQL中创建 CREATE FUNCTION ... SONAME 。这在Cloud SQL中是不可能的。

  • 存储过程 =在SQL语句中定义的函数, href =https://dev.mysql.com/doc/refman/5.6/en/create-procedure.html =nofollow noreferrer> CREATE FUNCTION routine_body CREATE PROCEDURE 。这在Cloud SQL中是允许的。 我刚刚通过复制并粘贴定义从这个SO帖子到我的云SQL实例,它完美运行。


    I just transferred my database to Google's Cloud SQL, but as stated in the FAQ on Google Cloud SQL, it says user defined functions are not supported. I am using a function called Levenshtein, taken from this stackoverflow article, to perform a search on a dictionary that I created in my database. It is a function that can find words that look similar (including misspellings) and returns the distance from a given word.

    Does Google offer any alternatives to user defined functions that would allow me to use this functionality to perform search?

    解决方案

    You are confused about terminology:

    • User Defined Function = A function defined in real code, compiled into a DLL/SO, and created in MySQL with CREATE FUNCTION ... SONAME. This is not possible in Cloud SQL.

    • Stored Procedure = A function defined in SQL statements, and created in MySQL with CREATE FUNCTION routine_body or CREATE PROCEDURE. This is allowed in Cloud SQL.

    I just tested this out by copying and pasting the definition from that SO post into my Cloud SQL instance and it worked perfectly.

    这篇关于Google Cloud SQL中的用户定义函数的替代方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆