Search

Monday 26 November 2018

Skoda Fabia (mk1) Fuse Layout

image

Power consumer

A

1

Instrument cluster, ESP

5

2

Brake lights

10

3

Power supply for the diagnostics, air-conditioning system

5

4

Interior lighting

10

5

Not assigned

-

6

Lights and Visibility

5

7

Engine electronics, power-assisted steering

5

8

Not assigned

-

9

Lambda probe

10

10

S-contacta)

5

11

Electrically adjustable rear mirrorb)

5

12

Ventilation system, air-conditioning system, Xenon headlight

5

13

Reversing light

10

14

Diesel engine control unit

10

15

Headlight cleaning system, window wiper

10

16

Instrument cluster

5

17

Petrol engine - control unitc)

5

18

Phone

5

19

Automatic gearbox

10

20

Control unit for lamp failure

5

21

Heated windscreen washer nozzles

5

22

Not assigned

-

23

Right main beam

10

24

Engine electronics

10

25

Control unit for ABS, TCS control unit for ESP

5 10

26

Not assigned

-

27

Not assigned

-

28

Cruise control, switch for the brake and clutch pedal

5

29

Not assigned

-

30

Main beam on the left and indicator light

10

31

Central locking system - door lock for the boot lid

10

32

Rear window wiper

10

33

Parking light on the right

5

34

Parking light on the left

5

35

Injector - petrol engine

10

36

Licence plate light

5

37

Rear fog light and indicator light

5

38

Heating of the external mirror

5

39

Rear window heater

20

40

Horn

20

41

Front window wiper

20

42

Cigarette lighter, power socket

15

43

Central control unit, selector lever lock for the automatic gearbox

20

44

Turn signals

15

45

Radio, navigation system

20

46

Electrical power window (at the front on the right)

25

47

Not assigned

-

48

Diesel engine - control unit, injector

30

49

Central locking system

15

50

Low beam on the right

15

51

Power socket in the luggage compartment

15

52

Ignition

15

53

Electrical power window (at the rear on the right)

25

54

Low beam on the left

15

56

Control unit - petrol engine

20

57

Towing device

25

58

Electrical power window (at the front on the left)

25

59

Not assigned

-

60

Horn for the anti-theft alarm system

15

61

Fuel pump - petrol engine

15

62

Electric sliding/tilting roof

25

63

Seat heaters

15

64

Headlight cleaning system

20

65

Fog lights

15

66

Electrical power window (at the rear on the left)

25

67

Not assigned

-

68

Fresh air blower

25


Wednesday 21 November 2018

SQL SERVER IDENTITY vs POSTGRES SERIAL

What’s the POSTGRES equivalent of SQL SERVER’s IDENTITY column property?

SQL SERVER’s IDENTITY column property is often found when creating a table, and defining a column as int datatype (or biigint), with the IDENTITY property.

Create table dbo.some_table
(
  my_primary_key int IDENTITY as primary key
, some_field varchar(10)
);

The IDENTITY property helps auto-increment the field in SQL SERVER.

More details: MS link.


In POSTGRES, we follow a 2-step strategy.

1) Create (or alter) the table, and define the datatype as SERIAL.
Create table public.some_table
(
  my_primary_key SERIAL primary key
, some_field varchar(10)
);

In the background, POSTGRES then creates a SEQUENCE that is used for this SERIAL column
public.some_table_my_primary_key_seq

2) Grant USAGE and SELECT to the users (or roles) that will insert into the table.
The owner of the table has all privileges on the table, and the sequence.
Other users do not.
Make sure the other users (or roles) have select and insert on the table
GRANT SELECT, INSERT on public.some_table to <other_users>;

To correct this, execute the psql:
GRANT USAGE, SELECT on public.some_table_my_primary_key_seq to  <other_users>;
(replace <other_users> with the users/roles as needed)


If step (2) isn’t followed,  you are presented with an error message:

Query execution failed

Reason:
SQL Error [42501]: ERROR: permission denied for sequence some_table_my_primary_key_seq

(

in DBeaver, the error message looks like

image

)

Summary

In SQL SERVER, there’s the IDENTITY field property.

In POSTGRES, use SERIAL, and grant USAGE, and SELECT on the associated sequence.


Bonus tip

It may be easier to grant all privileges in a schema to the user.

grant all privileges on all sequences in schema public to some_user;


Script

--connect to postgres as user2
grant user2 to user1; –this is needed so that user1 can execute as user2

--reconnect to postgres as user1
select session_user, current_user, current_database();

Create table public.some_table --user1 owns this table
(
   my_primary_key SERIAL primary key
, some_field varchar(10)
);
grant select, insert on public.some_table to user2;

set role user2;
     select session_user, current_user, current_database();
     select * from public.some_table;
     insert into public.some_table (some_field) values ('hello'); --this should error
     reset role; --reset the local user to user1;
     select session_user, current_user, current_database(); --confirm that we're back as user1

grant usage, select on public.some_table_my_primary_key_seq to user2;
set role user2;
     select session_user, current_user, current_database();
     select * from public.some_table;
     insert into public.some_table (some_field) values ('hello'); --this should now pass
     reset role; --reset the local user to user1;
     select session_user, current_user, current_database(); --confirm that we're back as user1

drop table public.some_table; --can only drop the table as the owner user1