Re: integer square root function proposed

2022-12-17 Thread Tom Lane
"Martin L. Buchanan" writes: > Reading the documentation I found no built-in function for integer square > root, requiring a sequence of: > floor(sqrt(foo))::integer > to go from an integer to the integer square root as an integer. I'm a little down on this idea, mainly because I doubt there is a

Re: integer square root function proposed

2022-12-17 Thread Rob Sargent
On 12/17/22 20:40, Martin L. Buchanan wrote: Dear Rob and all readers: Generating prime numbers is one example where you use integer square root in the inner loop, going from integer to integer. Calculating an integer square root from an integer input may have a more efficient algorithm than

Re: integer square root function proposed

2022-12-17 Thread Martin L. Buchanan
Dear Rob and all readers: Generating prime numbers is one example where you use integer square root in the inner loop, going from integer to integer. Calculating an integer square root from an integer input may have a more efficient algorithm than doing so in floating-point, with the caveat that

Re: integer square root function proposed

2022-12-17 Thread Rob Sargent
On 12/17/22 19:39, Martin L. Buchanan wrote: Dear PostgreSQL colleagues: I have just joined this, my first PG mailing list. Reading the documentation I found no built-in function for integer square root, requiring a sequence of: floor(sqrt(foo))::integer to go from an integer to the integer

integer square root function proposed

2022-12-17 Thread Martin L. Buchanan
Dear PostgreSQL colleagues: I have just joined this, my first PG mailing list. Reading the documentation I found no built-in function for integer square root, requiring a sequence of: floor(sqrt(foo))::integer to go from an integer to the integer square root as an integer. If PG leaders smile

Re: Postgres Date Type Value

2022-12-17 Thread Michael Arnold
My bad - was referencing the wrong column with PQgetvalue(). With that corrected, get 8332 for 2022-10-25. So date is an integer day count from POSTGRES_EPOCH_JDATE (2000-01-01). Thanks for the help! --- On Sun, Dec 18, 2022 at 8:24 AM David G. Johnston < david.g.johns...@gmail.com>

Re: Postgres Date Type Value

2022-12-17 Thread David G. Johnston
On Sat, Dec 17, 2022 at 4:55 PM Michael Arnold wrote: > How do I interpret the 4 bytes of postgresql 'date' value? > See date2j and j2date in datetime.c timestamp.h has the relevant constant Tom refers to (POSTGRES_EPOCH_JDATE) David J.

Re: Postgres Date Type Value

2022-12-17 Thread Tom Lane
Michael Arnold writes: > Something like this: > int32_t date_val = be32toh(*((uint32_t *) PQgetvalue(res, 0, 17))); > Gives date_val=1,466,004,328 for 2022-10-25. The origin is 2000-01-01 (I'm pretty sure that's documented somewhere), so the correct integer value for that date is 8333 by my m

Postgres Date Type Value

2022-12-17 Thread Michael Arnold
Want to retrieve a date type from a postgres table using libpq PQexecParams() in binary mode (please humor me). https://www.postgresql.org/docs/14/datatype-datetime.html says that a date is 4 bytes (4713 BC to 5874897 AD). src/include/utils/date.h defines: typedef int32 DateADT; Something like

Re: tsvector not giving expected results on one host

2022-12-17 Thread Dan Langille
On Sat, Dec 17, 2022, at 3:22 PM, Dan Langille wrote: > On Sat, Dec 17, 2022, at 3:14 PM, Dan Langille wrote: >> On Sat, Dec 17, 2022, at 2:55 PM, Tom Lane wrote: >>> "Dan Langille" writes: pkgmessage_textsearchable2 | tsvector | | | generated always

Re: tsvector not giving expected results on one host

2022-12-17 Thread Dan Langille
On Sat, Dec 17, 2022, at 3:14 PM, Dan Langille wrote: > On Sat, Dec 17, 2022, at 2:55 PM, Tom Lane wrote: >> "Dan Langille" writes: >>> pkgmessage_textsearchable2 | tsvector | | >>> | generated always as (to_tsvector('english'::regconfig, >>> translate(pkgmess

Re: tsvector not giving expected results on one host

2022-12-17 Thread Dan Langille
On Sat, Dec 17, 2022, at 2:55 PM, Tom Lane wrote: > "Dan Langille" writes: >> pkgmessage_textsearchable2 | tsvector | | >> | generated always as (to_tsvector('english'::regconfig, >> translate(pkgmessage, '/'::text, ' '::text))) stored > > That is not likely t

Re: tsvector not giving expected results on one host

2022-12-17 Thread Tom Lane
"Dan Langille" writes: > pkgmessage_textsearchable2 | tsvector | | > | generated always as (to_tsvector('english'::regconfig, > translate(pkgmessage, '/'::text, ' '::text))) stored That is not likely to play well with this: > freshports.org=> show default_t

Re: tsvector not giving expected results on one host

2022-12-17 Thread Dan Langille
On Sat, Dec 17, 2022, at 1:53 PM, Dan Langille wrote: > Under PostgreSQL 12, I have a table using tsvector to search the column > pkgmessage. > > It looks like this (not all columns are shown). > > > Table "public

tsvector not giving expected results on one host

2022-12-17 Thread Dan Langille
Under PostgreSQL 12, I have a table using tsvector to search the column pkgmessage. It looks like this (not all columns are shown). Table "public.ports" Column | Type | C