ekuiper icon indicating copy to clipboard operation
ekuiper copied to clipboard

Can't load sql source plugin while debugging in VSCode

Open fufel88 opened this issue 8 months ago • 4 comments

I have got a mqtt stream (beacon_stream) and table in PostgresQL (beacon_table), which was added to eKuiper as lookup table. So i created a rule via SQL to query from stream and table (inner join beacon_stream.id = beacon_table.id) which sinks to log file. The rule works but every other time i get error :

sql source meet column id unknown columnType:INT4" file="sql/source.go:278" rule=test_rule

The rule queries data from the same table in PostgresQL... So i wanted to try to debug app in VSCode and i stumbled across the fact i can't load sql source plugin (i get error when i try to create lookup table "lookup source type sql not found") while debugging. If i build eKuiper via existing Makefile and run /bin/kuiperd sql plugin is loaded fine and lookup sql table can ve created. But when i run the code in VSCode i get error in file /usr/local/go/src/runtime/plugin.go (function plugin_lastmoduleinit(), line 54):

for _, pkghash := range md.pkghashes { if pkghash.linktimehash != *pkghash.runtimehash { md.bad = true return "", nil, nil, "plugin was built with a different version of package " + pkghash.modulename } }

The sql plugin was built as described in docs: go build -trimpath --buildmode=plugin -o plugins/sources/Sql.so extensions/sources/sql/*.go

The launch.json is:

{ "name": "Launch file", "type": "go", "request": "launch", "mode": "debug", "program": "${file}", "env": { "GO111MODULE": "on", "CGO_ENABLED": "1" } }

Maybe i should apply different launch options to run the app properly?

fufel88 avatar Apr 02 '25 16:04 fufel88

If i chage launch.json as follows: { "name": "Launch Package", "type": "go", "request": "launch", "mode": "debug", "program": "${relativeFileDirname}", "buildFlags": "-trimpath -ldflags='-X github.com/lf-edge/ekuiper/v2/cmd.LoadFileType=relative -X github.com/lf-edge/ekuiper/v2/cmd.Version=123'", "console": "integratedTerminal", "env": { "GO111MODULE": "on", "CGO_ENABLED": "1" } }

i still can't load sql plugin

fufel88 avatar Apr 02 '25 16:04 fufel88

Use build tag full, the plugins are included. -tags "full". Check the makefile for detail.

ngjaying avatar Apr 03 '25 06:04 ngjaying

i added -gcflags="all=-N -l" for both ekuiper and plugin and removed -trimpath and it worked. Problem with getting data from PostgreQL is not a bug actually, in file extension/impl/sql/source.go method buildScanValueByColumnType can't find columnt type INT4 which is returned by Postgres. But the actual value moves forward afterwards successfully despite the fact error messages are being written in log constantly. It looks like something is wrong while everything is fine

fufel88 avatar Apr 03 '25 09:04 fufel88

Looks like the INT4 type is not handled correctly. You can try to fix it and create a PR. Thanks in advance.

ngjaying avatar Apr 03 '25 10:04 ngjaying