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

Support dm8 database #630

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Support dm8 database #630

wants to merge 5 commits into from

Conversation

feiniks
Copy link
Contributor

@feiniks feiniks commented Oct 11, 2023

No description provided.

@@ -267,7 +310,7 @@ create_group_common (CcnetGroupManager *mgr,

char *user_name_l = g_ascii_strdown (user_name, -1);

if (seaf_db_type(db) == SEAF_DB_TYPE_PGSQL)
if (seaf_db_type(db) == SEAF_DB_TYPE_PGSQL || seaf_db_type(db) == SEAF_DB_TYPE_DM)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PG 的支持已经很久不维护了,所以新写的 SQL 语句并没有考虑对 PG 的支持。因此不能仅通过查找针对 PG 写的语句来替代 REPLACE,要把所有 REPLACE 语句搜索出来检查一下。

#include <sql.h>
#include <sqltypes.h>
#include <sqlext.h>
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

把 sqlite, mysql, dm 三个数据库的实现分为三个文件吧,现在有3个数据库,放在一个文件里面代码就显得臃肿了。

可以把 DBOperations 这个结构声明在一个 seaf-db-impl.h 的头文件里面,作为一个接口结构体,和对外提供接口的 seaf-db.h 分开。seaf-db.c 的公共代码,从每个数据库的实现文件里面调用一个函数获取相应的 DBOperations 对象。

while (1) {
rc = SQLFetch(stmt);
if (!SUCCESS(rc)) {
if (rc != SQL_ERROR || dm_get_error_state(SQL_HANDLE_STMT, stmt) != BUFFER_NOT_ENOUGH) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的错误处理逻辑看不太懂。你这里的意思应该是,当 buffer 的大小比返回的数据小,则标记一下 over_buffer。如果是这样的话,你的逻辑应该是 if (出现 buffer 不足的情况) 而不是反过来写,这样不太好理解。

另外,我看了一下微软 ODBC 的文档。里面说的应该是某一列的数据超出长度之后,会把实际长度保存到 length 缓冲区里面,你应该在获取具体的列数据的时候,判断一下这个长度是否大于指定的缓冲区长度。(这个逻辑和 mysql 是类似的。)文档并没有说此时会有一个 BUFFER_NOT_ENOUGH 的错误状态。

Copy link
Contributor Author

@feiniks feiniks Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ODBC通过BindCol方式获取多个列的情况下,如果某一列的长度超出缓存,是会返回缓存不足的错误,并且长度会设置为0。所以SQLFetch需要判断缓存不足的错误。SQLGetData获取单个列的数据时,如果缓存不足是会设置单个列的数据长度的。这里应该可以重新分配相应的缓存。

if (!passwd) {
seaf_warning ("DB passwd not set in config.\n");
return -1;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用 ODBC 为什么不用指定服务器地址呢?只能访问本地的 DM 服务器吗?需要在文档中说明一下,如何安装配置 ODBC,尤其针对不是本地服务器的情况。

@@ -1,3 +1,6 @@
//go:build !dm
// +build !dm

// Main package for Seafile file server.
package main
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么有一个 fileserver_dm.go 呢?

@@ -95,9 +97,15 @@ func getUserGroups(sqlStr string, args ...interface{}) ([]group, error) {
}

func getGroupsByUser(userName string, returnAncestors bool) ([]group, error) {
tableName := ""
if strings.EqualFold(dbType, "mysql") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go fileserver 实际上是不支持 sqlite 的吧。那么在代码里面把 sqlite 的支持都删掉吧,避免造成混淆。

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

Successfully merging this pull request may close these issues.

2 participants