Skip to content
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

Setup with postgres DBMS #8

Open
Shushandr opened this issue Oct 30, 2023 · 4 comments
Open

Setup with postgres DBMS #8

Shushandr opened this issue Oct 30, 2023 · 4 comments

Comments

@Shushandr
Copy link

Shushandr commented Oct 30, 2023

I think that SQL script doesn't conform to SQL standards:

# PGPASSWORD="password" psql -U user -d beyondpaste <./config/structure.sql
ERROR:  syntax error at or near "("
LINE 2:     id INT(6) UNSIGNED NOT NULL AUTO_INCREMENT,
                  ^
ERROR:  syntax error at or near "("
LINE 2:     id INT(6) UNSIGNED NOT NULL AUTO_INCREMENT,
@Shushandr
Copy link
Author

Shushandr commented Oct 31, 2023

DROP TABLE IF EXISTS paste;
DROP SEQUENCE IF EXISTS paste_id_seq;
DROP TABLE IF EXISTS access;
DROP SEQUENCE IF EXISTS access_id_seq;

CREATE SEQUENCE access_id_seq;

CREATE TABLE access (
 id INTEGER NOT NULL DEFAULT nextval('access_id_seq'),
 type SMALLINT NOT NULL DEFAULT 0,
 parameter VARCHAR(120),
 PRIMARY KEY(id)
);

CREATE SEQUENCE paste_id_seq;

CREATE TABLE paste ( 
 id INTEGER NOT NULL DEFAULT nextval('paste_id_seq'),
 owner_ip INTEGER,
 title VARCHAR(50),
 creation_epoch INTEGER,
 expiration_epoch INTEGER,
 autodestroy SMALLINT NOT NULL DEFAULT 0,
 syntax_highlighting VARCHAR(32),
 content TEXT NOT NULL,
 access_id INTEGER,
 views INTEGER NOT NULL DEFAULT 0,
 deleted SMALLINT NOT NULL DEFAULT 0,
 PRIMARY KEY(id)
);

It's impossible to have one script for both MySQL and PostgreSQL (without additional macro tool)

@RaJiska
Copy link
Owner

RaJiska commented Oct 31, 2023

Yes, it's not about being standard, it's that all the SQL code was designed to work with MariaDB. You can sort the code from the structure file, but you might or might not have issues with the requests issued by the application itself.

@Shushandr
Copy link
Author

php have PDO (PHP Data Objects) technology to have the same application code for different DBMS.

@RaJiska
Copy link
Owner

RaJiska commented Nov 1, 2023

Indeed, PDO is what I used for this project. You should however note that PDO only offers an abstraction over the database it connects to, and not over the queries that are passed to this database. Since queries are "hand-crafted", some of them may or may not work on other database engines than MariaDB for which they were initially designed for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants