Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

BIT_OR(), BIT_AND() and BIT_XOR() aggregates are not supported

Aperta
#526 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
php, sqlite
Ambito
database

Direzione di ricerca

Start by reading the SQLite function translation and registration code, especially the existing UDFs and any aggregate translations; the issue does not name specific files or tests. Then check how the project tests SQL compatibility and the pdo_sqlite integer limits described here. Done means BIT_OR(), BIT_AND(), and BIT_XOR() produce MySQL-compatible results, including NULLs, empty sets, and unsigned 64-bit values.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Reproduction

CREATE TABLE b (x INT);
INSERT INTO b (x) VALUES (1), (4), (NULL);
SELECT BIT_OR(x), BIT_AND(x), BIT_XOR(x) FROM b;
-- SQLSTATE[HY000]: General error: 1 no such function: BIT_OR

Expected (MySQL 8): 5, 0, 5. Over an empty set, MySQL returns 0 for BIT_OR and BIT_XOR, and 18446744073709551615 for BIT_AND. NULLs are ignored, and the result type is BIGINT UNSIGNED.

Reproduced on trunk (3.1.0) with PHP 8.3 and SQLite 3.45.1.

Implementation question

Registering PHP aggregates through createAggregate() / sqliteCreateAggregate() looks natural next to the existing UDFs, but one constraint makes the design a maintainers' call: pdo_sqlite passes integers into and out of PHP callbacks as 32 bits (verified on PHP 8.3: an argument of 4294967297 arrives as 1, and a returned 4294967297 comes back as 1). Correct 64-bit results would need either:

  • a translation that passes the argument as text (CAST(expr AS TEXT)) and returns the result as text, plus a decision on how values above 2^63 (for example the empty-set BIT_AND) should surface; or
  • a pure-SQL translation per bit (for example COALESCE(MAX((expr >> n) & 1), 0) << n summed over the 64 bits for BIT_OR), which is exact but large.

A PHP aggregate limited to 32-bit values would cover common flag columns, but would silently return wrong results for wider ones, so I haven't proposed one. Happy to contribute a PR for whichever direction you prefer.

Found while running WooCommerce on WordPress Playground.

Use of AI

This report was prepared with Claude Code.

Lingua principale
PHP
Stelle
363
Fork
72
Merge medio
3g 7h
PR unite (30g)
13

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

  • Nessun Dockerfile né file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di WordPress/sqlite-database-integration

Tutte le issue di WordPress/sqlite-database-integration

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.