-
Notifications
You must be signed in to change notification settings - Fork 9
Upgrade to pg13 & mruby 3.0 (w/ load_avg script) #15
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
#include "mruby/array.h" | ||
#include "mruby/proc.h" | ||
#include "mruby/compile.h" | ||
#include "mruby/numeric.h" | ||
#include "mruby/string.h" | ||
#include "mruby/range.h" | ||
#include "mruby/hash.h" | ||
|
@@ -28,7 +29,15 @@ | |
#include "optimizer/pathnode.h" | ||
#include "optimizer/planmain.h" | ||
#include "optimizer/restrictinfo.h" | ||
|
||
#if PG_VERSION_NUM < 120000 | ||
#include "optimizer/var.h" | ||
#endif | ||
|
||
#if PG_VERSION_NUM >= 120000 | ||
#include "optimizer/optimizer.h" | ||
#endif | ||
|
||
#include "utils/memutils.h" | ||
#include "utils/rel.h" | ||
#include "utils/builtins.h" | ||
|
@@ -155,10 +164,10 @@ static void rbGetOptions(Oid foreigntableid, HolycornPlanState *state, List **ot | |
|
||
if (strcmp(def->defname, "wrapper_path") == 0) { /* Extract the wrapper_path */ | ||
state->wrapper_path = defGetString(def); | ||
options = list_delete_cell(options, lc, prev); | ||
options = list_delete_cell(options, lc); | ||
} else if (strcmp(def->defname, "wrapper_class") == 0) { /* Extract the wrapper_class */ | ||
state->wrapper_class = defGetString(def); | ||
options = list_delete_cell(options, lc, prev); | ||
options = list_delete_cell(options, lc); | ||
} | ||
|
||
prev = lc; | ||
|
@@ -327,12 +336,12 @@ static TupleTableSlot * rbIterateForeignScan(ForeignScanState *node) { | |
} else { | ||
slot->tts_nvalid = RARRAY_LEN(output); | ||
|
||
slot->tts_isempty = false; | ||
// slot->tts_isempty = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any particular reason for this commenting? |
||
slot->tts_isnull = (bool *)palloc(sizeof(bool) * slot->tts_nvalid); | ||
slot->tts_values = (Datum *)palloc(sizeof(Datum) * slot->tts_nvalid); | ||
|
||
if (slot->tts_nvalid <= 0) { //TODO: the size can't be < 0 but being defensive is OK :-) | ||
slot->tts_isempty = true; | ||
// slot->tts_isempty = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
} else { | ||
Datum outputDatum; | ||
for(int i = 0; i < slot->tts_nvalid; i++) { | ||
|
@@ -366,7 +375,7 @@ static TupleTableSlot * rbIterateForeignScan(ForeignScanState *node) { | |
elog(ERROR,"MRB_TT_UNDEF not supported (yet?)"); | ||
break; | ||
case MRB_TT_FLOAT: | ||
outputDatum = Float8GetDatum(mrb_flo_to_fixnum(column)); | ||
outputDatum = Float8GetDatum(mrb_to_flo(exec_state->mrb_state, column)); | ||
slot->tts_isnull[i] = false; | ||
slot->tts_values[i] = outputDatum; | ||
break; | ||
|
@@ -424,9 +433,6 @@ static TupleTableSlot * rbIterateForeignScan(ForeignScanState *node) { | |
case MRB_TT_EXCEPTION: | ||
elog(ERROR, "MRB_TT_EXCEPTION not supported (yet?)"); | ||
break; | ||
case MRB_TT_FILE: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What has motivated that change? |
||
elog(ERROR, "MRB_TT_FILE not supported (yet?)"); | ||
break; | ||
case MRB_TT_ENV: | ||
elog(ERROR, "MRB_TT_ENV not supported (yet?)"); | ||
break; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# DROP EXTENSION holycorn CASCADE; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we move this to the |
||
# CREATE EXTENSION holycorn; | ||
# CREATE SERVER holycorn_server FOREIGN DATA WRAPPER holycorn; | ||
# CREATE FOREIGN TABLE holytable (load1 Float8, load2 Float8, load3 Float8) | ||
# SERVER holycorn_server | ||
# OPTIONS (wrapper_path '/tmp/loadavg.rb'); | ||
# /tmp/loadavg.rb | ||
class LoadAverage | ||
def initialize(env = {}) # env contains informations provided by Holycorn | ||
end | ||
|
||
def each | ||
@enum ||= ::Enumerator.new do |row| | ||
load_averages = [] | ||
w_output = ::IO.popen("w").read | ||
string_values = w_output.lines.first.split(":").last.strip.split | ||
string_values.each do |string_value| | ||
load_averages << string_value.to_f | ||
end | ||
|
||
row.yield load_averages | ||
end | ||
|
||
@enum.next | ||
end | ||
|
||
def import_schema(args = {}) | ||
# Keys are: | ||
# * local_schema: the target schema | ||
# * server_name: name of the foreign data server in-use | ||
# * wrapper_class: name of the current class | ||
# * any other OPTIONS passed to IMPORT FOREIGN SCHEMA | ||
end | ||
|
||
self | ||
end |
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we removing support for
mruby-redis
?