sequel_pg 1.13.0 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +6 -0
- data/README.rdoc +1 -6
- data/ext/sequel_pg/sequel_pg.c +83 -46
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 277c659f136e9d34a715ccd94bab948b776d903f72b0f679fd919bedacef9cf7
|
4
|
+
data.tar.gz: 031cd967776330ecc1c999c8597c49eb5a96f376dfcc88c51ab9d9bdbda52190
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b722922bf49095005ad19bc7bb1ba41d358d851f367df6f51bd5fbf0202784244cee83293919ee27fb1ff7accb3fb10ddbbc7745455cf545f2b1a7a7e301bdd
|
7
|
+
data.tar.gz: 2b3933ab84065cdd81b5c544523ba4c50192acbc912b449d4d4f03d5650873a5ad125fc3f339a435cbcc514d350bbf6e98d49d10f39349faa9cb8b2c7236fa61
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
=== 1.14.0 (2020-09-22)
|
2
|
+
|
3
|
+
* Reduce stack memory usage for result sets with 64 or fewer columns (jeremyevans)
|
4
|
+
|
5
|
+
* Support result sets with more than 256 columns by default (jeremyevans) (#39)
|
6
|
+
|
1
7
|
=== 1.13.0 (2020-04-13)
|
2
8
|
|
3
9
|
* Allow overriding of inet/cidr type conversion using conversion procs (beanieboi, jeremyevans) (#36, #37)
|
data/README.rdoc
CHANGED
@@ -70,12 +70,6 @@ can do the following:
|
|
70
70
|
|
71
71
|
gem install sequel_pg
|
72
72
|
|
73
|
-
Note that by default sequel_pg only supports result sets with up to
|
74
|
-
256 columns. If you will have a result set with more than 256 columns,
|
75
|
-
you should modify the maximum supported number of columns via:
|
76
|
-
|
77
|
-
gem install sequel_pg -- --with-cflags=\"-DSPG_MAX_FIELDS=512\"
|
78
|
-
|
79
73
|
Make sure the pg_config binary is in your PATH so the installation
|
80
74
|
can find the PostgreSQL shared library and header files. Alternatively,
|
81
75
|
you can use the POSTGRES_LIB and POSTGRES_INCLUDE environment
|
@@ -130,6 +124,7 @@ sequel_pg has been tested on the following:
|
|
130
124
|
* ruby 2.4
|
131
125
|
* ruby 2.5
|
132
126
|
* ruby 2.6
|
127
|
+
* ruby 2.7
|
133
128
|
|
134
129
|
== Known Issues
|
135
130
|
|
data/ext/sequel_pg/sequel_pg.c
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#define SEQUEL_PG_VERSION_INTEGER
|
1
|
+
#define SEQUEL_PG_VERSION_INTEGER 11400
|
2
2
|
|
3
3
|
#include <string.h>
|
4
4
|
#include <stdio.h>
|
@@ -15,9 +15,6 @@
|
|
15
15
|
#include <ruby/version.h>
|
16
16
|
#include <ruby/encoding.h>
|
17
17
|
|
18
|
-
#ifndef SPG_MAX_FIELDS
|
19
|
-
#define SPG_MAX_FIELDS 256
|
20
|
-
#endif
|
21
18
|
#define SPG_MINUTES_PER_DAY 1440.0
|
22
19
|
#define SPG_SECONDS_PER_DAY 86400.0
|
23
20
|
|
@@ -1380,10 +1377,7 @@ static void spg_set_column_info(VALUE self, PGresult *res, VALUE *colsyms, VALUE
|
|
1380
1377
|
rb_funcall(self, spg_id_columns_equal, 1, rb_ary_new4(nfields, colsyms));
|
1381
1378
|
}
|
1382
1379
|
|
1383
|
-
static VALUE
|
1384
|
-
PGresult *res;
|
1385
|
-
VALUE colsyms[SPG_MAX_FIELDS];
|
1386
|
-
VALUE colconvert[SPG_MAX_FIELDS];
|
1380
|
+
static VALUE spg_yield_hash_rows_internal(VALUE self, PGresult *res, int enc_index, VALUE* colsyms, VALUE* colconvert) {
|
1387
1381
|
long ntuples;
|
1388
1382
|
long nfields;
|
1389
1383
|
long i;
|
@@ -1393,21 +1387,9 @@ static VALUE spg_yield_hash_rows(VALUE self, VALUE rres, VALUE ignore) {
|
|
1393
1387
|
VALUE pg_type;
|
1394
1388
|
VALUE pg_value;
|
1395
1389
|
char type = SPG_YIELD_NORMAL;
|
1396
|
-
int enc_index;
|
1397
|
-
|
1398
|
-
if (!RTEST(rres)) {
|
1399
|
-
return self;
|
1400
|
-
}
|
1401
|
-
res = pgresult_get(rres);
|
1402
|
-
|
1403
|
-
enc_index = spg_use_pg_get_result_enc_idx ? pg_get_result_enc_idx(rres) : enc_get_index(rres);
|
1404
1390
|
|
1405
1391
|
ntuples = PQntuples(res);
|
1406
1392
|
nfields = PQnfields(res);
|
1407
|
-
if (nfields > SPG_MAX_FIELDS) {
|
1408
|
-
rb_raise(rb_eRangeError, "more than %d columns in query (%ld columns detected)", SPG_MAX_FIELDS, nfields);
|
1409
|
-
}
|
1410
|
-
|
1411
1393
|
spg_set_column_info(self, res, colsyms, colconvert, enc_index);
|
1412
1394
|
|
1413
1395
|
opts = rb_funcall(self, spg_id_opts, 0);
|
@@ -1624,6 +1606,40 @@ static VALUE spg_yield_hash_rows(VALUE self, VALUE rres, VALUE ignore) {
|
|
1624
1606
|
return self;
|
1625
1607
|
}
|
1626
1608
|
|
1609
|
+
#define def_spg_yield_hash_rows(max_fields) static VALUE spg_yield_hash_rows_ ## max_fields(VALUE self, PGresult *res, int enc_index) { \
|
1610
|
+
VALUE colsyms[max_fields]; \
|
1611
|
+
VALUE colconvert[max_fields]; \
|
1612
|
+
return spg_yield_hash_rows_internal(self, res, enc_index, colsyms, colconvert); \
|
1613
|
+
}
|
1614
|
+
|
1615
|
+
def_spg_yield_hash_rows(16)
|
1616
|
+
def_spg_yield_hash_rows(64)
|
1617
|
+
def_spg_yield_hash_rows(256)
|
1618
|
+
def_spg_yield_hash_rows(1664)
|
1619
|
+
|
1620
|
+
static VALUE spg_yield_hash_rows(VALUE self, VALUE rres, VALUE ignore) {
|
1621
|
+
PGresult *res;
|
1622
|
+
long nfields;
|
1623
|
+
int enc_index;
|
1624
|
+
|
1625
|
+
if (!RTEST(rres)) {
|
1626
|
+
return self;
|
1627
|
+
}
|
1628
|
+
res = pgresult_get(rres);
|
1629
|
+
|
1630
|
+
enc_index = spg_use_pg_get_result_enc_idx ? pg_get_result_enc_idx(rres) : enc_get_index(rres);
|
1631
|
+
|
1632
|
+
nfields = PQnfields(res);
|
1633
|
+
if (nfields <= 16) return spg_yield_hash_rows_16(self, res, enc_index);
|
1634
|
+
else if (nfields <= 64) return spg_yield_hash_rows_64(self, res, enc_index);
|
1635
|
+
else if (nfields <= 256) return spg_yield_hash_rows_256(self, res, enc_index);
|
1636
|
+
else if (nfields <= 1664) return spg_yield_hash_rows_1664(self, res, enc_index);
|
1637
|
+
else rb_raise(rb_eRangeError, "more than 1664 columns in query (%ld columns detected)", nfields);
|
1638
|
+
|
1639
|
+
/* UNREACHABLE */
|
1640
|
+
return self;
|
1641
|
+
}
|
1642
|
+
|
1627
1643
|
static VALUE spg_supports_streaming_p(VALUE self) {
|
1628
1644
|
return
|
1629
1645
|
#if HAVE_PQSETSINGLEROWMODE
|
@@ -1643,12 +1659,7 @@ static VALUE spg_set_single_row_mode(VALUE self) {
|
|
1643
1659
|
return Qnil;
|
1644
1660
|
}
|
1645
1661
|
|
1646
|
-
static VALUE
|
1647
|
-
PGresult *res;
|
1648
|
-
VALUE rres;
|
1649
|
-
VALUE rconn;
|
1650
|
-
VALUE colsyms[SPG_MAX_FIELDS];
|
1651
|
-
VALUE colconvert[SPG_MAX_FIELDS];
|
1662
|
+
static VALUE spg__yield_each_row_internal(VALUE self, VALUE rconn, VALUE rres, PGresult *res, int enc_index, VALUE *colsyms, VALUE *colconvert) {
|
1652
1663
|
long nfields;
|
1653
1664
|
long j;
|
1654
1665
|
VALUE h;
|
@@ -1656,19 +1667,8 @@ static VALUE spg__yield_each_row(VALUE self) {
|
|
1656
1667
|
VALUE pg_type;
|
1657
1668
|
VALUE pg_value = Qnil;
|
1658
1669
|
char type = SPG_YIELD_NORMAL;
|
1659
|
-
int enc_index;
|
1660
|
-
|
1661
|
-
rconn = rb_ary_entry(self, 1);
|
1662
|
-
self = rb_ary_entry(self, 0);
|
1663
1670
|
|
1664
|
-
|
1665
|
-
if (rres == Qnil) {
|
1666
|
-
goto end_yield_each_row;
|
1667
|
-
}
|
1668
|
-
rb_funcall(rres, spg_id_check, 0);
|
1669
|
-
res = pgresult_get(rres);
|
1670
|
-
|
1671
|
-
enc_index = spg_use_pg_get_result_enc_idx ? pg_get_result_enc_idx(rres) : enc_get_index(rres);
|
1671
|
+
nfields = PQnfields(res);
|
1672
1672
|
|
1673
1673
|
/* Only handle regular and model types. All other types require compiling all
|
1674
1674
|
* of the results at once, which is not a use case for streaming. The streaming
|
@@ -1682,12 +1682,6 @@ static VALUE spg__yield_each_row(VALUE self) {
|
|
1682
1682
|
}
|
1683
1683
|
}
|
1684
1684
|
|
1685
|
-
nfields = PQnfields(res);
|
1686
|
-
if (nfields > SPG_MAX_FIELDS) {
|
1687
|
-
rb_funcall(rres, spg_id_clear, 0);
|
1688
|
-
rb_raise(rb_eRangeError, "more than %d columns in query", SPG_MAX_FIELDS);
|
1689
|
-
}
|
1690
|
-
|
1691
1685
|
spg_set_column_info(self, res, colsyms, colconvert, enc_index);
|
1692
1686
|
|
1693
1687
|
while (PQntuples(res) != 0) {
|
@@ -1709,14 +1703,57 @@ static VALUE spg__yield_each_row(VALUE self) {
|
|
1709
1703
|
|
1710
1704
|
rres = rb_funcall(rconn, spg_id_get_result, 0);
|
1711
1705
|
if (rres == Qnil) {
|
1712
|
-
|
1706
|
+
return self;
|
1713
1707
|
}
|
1714
1708
|
rb_funcall(rres, spg_id_check, 0);
|
1715
1709
|
res = pgresult_get(rres);
|
1716
1710
|
}
|
1717
1711
|
rb_funcall(rres, spg_id_clear, 0);
|
1718
1712
|
|
1719
|
-
|
1713
|
+
return self;
|
1714
|
+
}
|
1715
|
+
|
1716
|
+
#define def_spg__yield_each_row(max_fields) static VALUE spg__yield_each_row_ ## max_fields(VALUE self, VALUE rconn, VALUE rres, PGresult *res, int enc_index) { \
|
1717
|
+
VALUE colsyms[max_fields]; \
|
1718
|
+
VALUE colconvert[max_fields]; \
|
1719
|
+
return spg__yield_each_row_internal(self, rconn, rres, res, enc_index, colsyms, colconvert); \
|
1720
|
+
}
|
1721
|
+
|
1722
|
+
def_spg__yield_each_row(16)
|
1723
|
+
def_spg__yield_each_row(64)
|
1724
|
+
def_spg__yield_each_row(256)
|
1725
|
+
def_spg__yield_each_row(1664)
|
1726
|
+
|
1727
|
+
static VALUE spg__yield_each_row(VALUE self) {
|
1728
|
+
PGresult *res;
|
1729
|
+
VALUE rres;
|
1730
|
+
VALUE rconn;
|
1731
|
+
int enc_index;
|
1732
|
+
long nfields;
|
1733
|
+
|
1734
|
+
rconn = rb_ary_entry(self, 1);
|
1735
|
+
self = rb_ary_entry(self, 0);
|
1736
|
+
|
1737
|
+
rres = rb_funcall(rconn, spg_id_get_result, 0);
|
1738
|
+
if (rres == Qnil) {
|
1739
|
+
return self;
|
1740
|
+
}
|
1741
|
+
rb_funcall(rres, spg_id_check, 0);
|
1742
|
+
res = pgresult_get(rres);
|
1743
|
+
|
1744
|
+
enc_index = spg_use_pg_get_result_enc_idx ? pg_get_result_enc_idx(rres) : enc_get_index(rres);
|
1745
|
+
|
1746
|
+
nfields = PQnfields(res);
|
1747
|
+
if (nfields <= 16) return spg__yield_each_row_16(self, rconn, rres, res, enc_index);
|
1748
|
+
else if (nfields <= 64) return spg__yield_each_row_64(self, rconn, rres, res, enc_index);
|
1749
|
+
else if (nfields <= 256) return spg__yield_each_row_256(self, rconn, rres, res, enc_index);
|
1750
|
+
else if (nfields <= 1664) return spg__yield_each_row_1664(self, rconn, rres, res, enc_index);
|
1751
|
+
else {
|
1752
|
+
rb_funcall(rres, spg_id_clear, 0);
|
1753
|
+
rb_raise(rb_eRangeError, "more than 1664 columns in query (%ld columns detected)", nfields);
|
1754
|
+
}
|
1755
|
+
|
1756
|
+
/* UNREACHABLE */
|
1720
1757
|
return self;
|
1721
1758
|
}
|
1722
1759
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel_pg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|